Leave some notes for future changes to the MIR opt level of mir inlining

This commit is contained in:
oli 2021-01-11 11:21:24 +00:00
parent f238148214
commit 209889ddc1
2 changed files with 9 additions and 1 deletions

View File

@ -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;
}

View File

@ -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);