Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Leave some notes for future changes to the MIR opt level of mir inlining
  • Loading branch information
oli-obk committed Jan 23, 2021
commit 209889ddc1d51c125c7fded26e51cd259129b699
3 changes: 3 additions & 0 deletions compiler/rustc_mir/src/transform/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ struct CallSite<'tcx> {

impl<'tcx> MirPass<'tcx> for Inline {
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
// If you change this optimization level, also change the level in
// `mir_drops_elaborated_and_const_checked` for the call to `mir_inliner_callees`.
// Otherwise you will get an ICE about stolen MIR.
if tcx.sess.opts.debugging_opts.mir_opt_level < 2 {
return;
}
Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_mir/src/transform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,12 @@ fn mir_drops_elaborated_and_const_checked<'tcx>(
if is_fn_like {
let did = def.did.to_def_id();
let def = ty::WithOptConstParam::unknown(did);
let _ = tcx.mir_inliner_callees(ty::InstanceDef::Item(def));

// Do not compute the mir call graph without said call graph actually being used.
// Keep this in sync with the mir inliner's optimization level.
if tcx.sess.opts.debugging_opts.mir_opt_level >= 2 {
let _ = tcx.mir_inliner_callees(ty::InstanceDef::Item(def));
}
}

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