diff options
| author | Deadbeef <ent3rm4n@gmail.com> | 2022-08-31 13:28:55 +0000 |
|---|---|---|
| committer | Deadbeef <ent3rm4n@gmail.com> | 2022-09-04 20:35:23 +0800 |
| commit | 58c8823e3183611160207a47c9914bcbf84f9eb1 (patch) | |
| tree | c74776b1fd73735121dac3019eccb6eef5e5142d /compiler/rustc_mir_transform/src | |
| parent | bd61b8fb3ff04de61f40ea62043b17dc1e418c4c (diff) | |
| download | rust-58c8823e3183611160207a47c9914bcbf84f9eb1.tar.gz rust-58c8823e3183611160207a47c9914bcbf84f9eb1.zip | |
remap mir before running optimization passes
Diffstat (limited to 'compiler/rustc_mir_transform/src')
| -rw-r--r-- | compiler/rustc_mir_transform/src/lib.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index 69b49604250..162f7d969b1 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -387,7 +387,9 @@ fn inner_mir_for_ctfe(tcx: TyCtxt<'_>, def: ty::WithOptConstParam<LocalDefId>) - .body_const_context(def.did) .expect("mir_for_ctfe should not be used for runtime functions"); - let mut body = tcx.mir_drops_elaborated_and_const_checked(def).borrow().clone(); + let body = tcx.mir_drops_elaborated_and_const_checked(def).borrow().clone(); + + let mut body = remap_mir_for_const_eval_select(tcx, body, hir::Constness::Const); match context { // Do not const prop functions, either they get executed at runtime or exported to metadata, @@ -416,7 +418,7 @@ fn inner_mir_for_ctfe(tcx: TyCtxt<'_>, def: ty::WithOptConstParam<LocalDefId>) - debug_assert!(!body.has_free_regions(), "Free regions in MIR for CTFE"); - remap_mir_for_const_eval_select(tcx, body, hir::Constness::Const) + body } /// Obtain just the main MIR (no promoteds) and run some cleanups on it. This also runs @@ -620,14 +622,15 @@ fn inner_optimized_mir(tcx: TyCtxt<'_>, did: LocalDefId) -> Body<'_> { Some(other) => panic!("do not use `optimized_mir` for constants: {:?}", other), } debug!("about to call mir_drops_elaborated..."); - let mut body = + let body = tcx.mir_drops_elaborated_and_const_checked(ty::WithOptConstParam::unknown(did)).steal(); + let mut body = remap_mir_for_const_eval_select(tcx, body, hir::Constness::NotConst); debug!("body: {:#?}", body); run_optimization_passes(tcx, &mut body); debug_assert!(!body.has_free_regions(), "Free regions in optimized MIR"); - remap_mir_for_const_eval_select(tcx, body, hir::Constness::NotConst) + body } /// Fetch all the promoteds of an item and prepare their MIR bodies to be ready for |
