File tree 2 files changed +9
-1
lines changed
compiler/rustc_mir/src/transform
2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,9 @@ struct CallSite<'tcx> {
39
39
40
40
impl < ' tcx > MirPass < ' tcx > for Inline {
41
41
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.
42
45
if tcx. sess . opts . debugging_opts . mir_opt_level < 2 {
43
46
return ;
44
47
}
Original file line number Diff line number Diff line change @@ -425,7 +425,12 @@ fn mir_drops_elaborated_and_const_checked<'tcx>(
425
425
if is_fn_like {
426
426
let did = def. did . to_def_id ( ) ;
427
427
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
+ }
429
434
}
430
435
431
436
let ( body, _) = tcx. mir_promoted ( def) ;
You can’t perform that action at this time.
0 commit comments