about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorScott McMurray <scottmcm@users.noreply.github.com>2024-04-17 18:14:16 -0700
committerScott McMurray <scottmcm@users.noreply.github.com>2024-04-18 09:35:36 -0700
commit90b4c86335f625f64e6238614d4c7cfd0dbbb37a (patch)
tree416c7ef4a7886e4d4da85bc084bacc0ba750508a /compiler
parent6094063c35d3b3f7c07b6c069ebeb27797ddadc1 (diff)
downloadrust-90b4c86335f625f64e6238614d4c7cfd0dbbb37a.tar.gz
rust-90b4c86335f625f64e6238614d4c7cfd0dbbb37a.zip
Ensure `[rust] debuginfo-level-std` doesn't change core's MIR
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_mir_transform/src/inline.rs12
-rw-r--r--compiler/rustc_session/src/options.rs3
2 files changed, 14 insertions, 1 deletions
diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs
index 1182a738402..625d8f53939 100644
--- a/compiler/rustc_mir_transform/src/inline.rs
+++ b/compiler/rustc_mir_transform/src/inline.rs
@@ -699,7 +699,17 @@ impl<'tcx> Inliner<'tcx> {
         // Insert all of the (mapped) parts of the callee body into the caller.
         caller_body.local_decls.extend(callee_body.drain_vars_and_temps());
         caller_body.source_scopes.extend(&mut callee_body.source_scopes.drain(..));
-        if self.tcx.sess.opts.debuginfo != DebugInfo::None {
+        if self
+            .tcx
+            .sess
+            .opts
+            .unstable_opts
+            .inline_mir_preserve_debug
+            .unwrap_or(self.tcx.sess.opts.debuginfo != DebugInfo::None)
+        {
+            // Note that we need to preserve these in the standard library so that
+            // people working on rust can build with or without debuginfo while
+            // still getting consistent results from the mir-opt tests.
             caller_body.var_debug_info.append(&mut callee_body.var_debug_info);
         }
         caller_body.basic_blocks_mut().extend(callee_body.basic_blocks_mut().drain(..));
diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs
index c4d802a222b..6a2975263cf 100644
--- a/compiler/rustc_session/src/options.rs
+++ b/compiler/rustc_session/src/options.rs
@@ -1717,6 +1717,9 @@ options! {
         "enable MIR inlining (default: no)"),
     inline_mir_hint_threshold: Option<usize> = (None, parse_opt_number, [TRACKED],
         "inlining threshold for functions with inline hint (default: 100)"),
+    inline_mir_preserve_debug: Option<bool> = (None, parse_opt_bool, [TRACKED],
+        "when MIR inlining, whether to preserve debug info for callee variables \
+        (default: preserve for debuginfo != None, otherwise remove)"),
     inline_mir_threshold: Option<usize> = (None, parse_opt_number, [TRACKED],
         "a default MIR inlining threshold (default: 50)"),
     input_stats: bool = (false, parse_bool, [UNTRACKED],