Skip to content

Commit 209889d

Browse files
committed
Leave some notes for future changes to the MIR opt level of mir inlining
1 parent f238148 commit 209889d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

compiler/rustc_mir/src/transform/inline.rs

+3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ struct CallSite<'tcx> {
3939

4040
impl<'tcx> MirPass<'tcx> for Inline {
4141
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
42+
// If you change this optimization level, also change the level in
43+
// `mir_drops_elaborated_and_const_checked` for the call to `mir_inliner_callees`.
44+
// Otherwise you will get an ICE about stolen MIR.
4245
if tcx.sess.opts.debugging_opts.mir_opt_level < 2 {
4346
return;
4447
}

compiler/rustc_mir/src/transform/mod.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,12 @@ fn mir_drops_elaborated_and_const_checked<'tcx>(
425425
if is_fn_like {
426426
let did = def.did.to_def_id();
427427
let def = ty::WithOptConstParam::unknown(did);
428-
let _ = tcx.mir_inliner_callees(ty::InstanceDef::Item(def));
428+
429+
// Do not compute the mir call graph without said call graph actually being used.
430+
// Keep this in sync with the mir inliner's optimization level.
431+
if tcx.sess.opts.debugging_opts.mir_opt_level >= 2 {
432+
let _ = tcx.mir_inliner_callees(ty::InstanceDef::Item(def));
433+
}
429434
}
430435

431436
let (body, _) = tcx.mir_promoted(def);

0 commit comments

Comments
 (0)