diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 24e532660d05f..bac0955d7c5a4 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -567,7 +567,6 @@ rustc_queries! { /// and with extra transforms applied. query build_codegen_mir(key: ty::Instance<'tcx>) -> &'tcx mir::Body<'tcx> { desc { |tcx| "finalizing codegen MIR for `{}`", tcx.def_path_str_with_args(key.def_id(), key.args) } - cache_on_disk_if { true } arena_cache } diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index 0f8003d454662..084a9e72c3ca4 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -690,12 +690,27 @@ fn inner_optimized_mir(tcx: TyCtxt<'_>, did: LocalDefId) -> Body<'_> { } pub fn build_codegen_mir<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> Body<'tcx> { + #[inline(never)] + fn clone_mir<'tcx>(body: &Body<'tcx>) -> Body<'tcx> { + body.clone() + } + #[inline(never)] + fn monomorphize_mir<'tcx>( + tcx: TyCtxt<'tcx>, + instance: Instance<'tcx>, + body: Body<'tcx>, + ) -> Body<'tcx> { + instance.instantiate_mir_and_normalize_erasing_regions( + tcx, + ty::ParamEnv::reveal_all(), + ty::EarlyBinder::bind(body), + ) + } + let body = tcx.instance_mir(instance.def); - let mut body = instance.instantiate_mir_and_normalize_erasing_regions( - tcx, - ty::ParamEnv::reveal_all(), - ty::EarlyBinder::bind(body.clone()), - ); + let body = clone_mir(body); + let mut body = monomorphize_mir(tcx, instance, body); + pm::run_passes( tcx, &mut body,