From 4ae354213c71cb0032f93534f88c49b69c704aaf Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Wed, 23 Oct 2024 22:44:53 -0400 Subject: [PATCH] Use worse MIR for incr comp --- compiler/rustc_codegen_ssa/src/base.rs | 2 +- compiler/rustc_codegen_ssa/src/mir/mod.rs | 2 +- compiler/rustc_middle/src/ty/mod.rs | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index f3d9a7d37e6cc..406f78cf15d6a 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -416,7 +416,7 @@ pub(crate) fn codegen_instance<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( // release builds. info!("codegen_instance({})", instance); - mir::codegen_mir::(cx, instance); + mir::lower_mir::(cx, instance); } /// Creates the `main` function which will initialize the rust runtime and call diff --git a/compiler/rustc_codegen_ssa/src/mir/mod.rs b/compiler/rustc_codegen_ssa/src/mir/mod.rs index 15bb733f26d8d..a30c0da804c95 100644 --- a/compiler/rustc_codegen_ssa/src/mir/mod.rs +++ b/compiler/rustc_codegen_ssa/src/mir/mod.rs @@ -159,7 +159,7 @@ impl<'tcx, V: CodegenObject> LocalRef<'tcx, V> { /////////////////////////////////////////////////////////////////////////// #[instrument(level = "debug", skip(cx))] -pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( +pub fn lower_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( cx: &'a Bx::CodegenCx, instance: Instance<'tcx>, ) { diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index ed24fcc7eb88a..763d048a46f94 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -1718,6 +1718,14 @@ impl<'tcx> TyCtxt<'tcx> { } } + pub fn codegen_mir(self, instance: ty::Instance<'tcx>) -> &'tcx Body<'tcx> { + if self.sess.opts.incremental == None { + self.build_codegen_mir(instance) + } else { + self.instance_mir(instance.def) + } + } + /// Returns the possibly-auto-generated MIR of a [`ty::InstanceKind`]. #[instrument(skip(self), level = "debug")] pub fn instance_mir(self, instance: ty::InstanceKind<'tcx>) -> &'tcx Body<'tcx> {