File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
compiler/rustc_mir/src/transform Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,9 @@ struct CallSite<'tcx> {
3939
4040impl < ' 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 }
Original file line number Diff line number Diff 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) ;
You can’t perform that action at this time.
0 commit comments