Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3412f01

Browse files
committedApr 18, 2024
Auto merge of #123949 - scottmcm:debug-no-means-no-debug-info-when-inlined, r=oli-obk,onur-ozkan
At debuginfo=0, don't inline debuginfo when inlining See #123949 (comment) for info.
2 parents 0e15f5e + 20cf595 commit 3412f01

File tree

108 files changed

+825
-1192
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+825
-1192
lines changed
 

‎compiler/rustc_mir_transform/src/inline.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_middle::mir::visit::*;
1111
use rustc_middle::mir::*;
1212
use rustc_middle::ty::TypeVisitableExt;
1313
use rustc_middle::ty::{self, Instance, InstanceDef, ParamEnv, Ty, TyCtxt};
14-
use rustc_session::config::OptLevel;
14+
use rustc_session::config::{DebugInfo, OptLevel};
1515
use rustc_span::source_map::Spanned;
1616
use rustc_span::sym;
1717
use rustc_target::abi::FieldIdx;
@@ -699,7 +699,19 @@ impl<'tcx> Inliner<'tcx> {
699699
// Insert all of the (mapped) parts of the callee body into the caller.
700700
caller_body.local_decls.extend(callee_body.drain_vars_and_temps());
701701
caller_body.source_scopes.extend(&mut callee_body.source_scopes.drain(..));
702-
caller_body.var_debug_info.append(&mut callee_body.var_debug_info);
702+
if self
703+
.tcx
704+
.sess
705+
.opts
706+
.unstable_opts
707+
.inline_mir_preserve_debug
708+
.unwrap_or(self.tcx.sess.opts.debuginfo != DebugInfo::None)
709+
{
710+
// Note that we need to preserve these in the standard library so that
711+
// people working on rust can build with or without debuginfo while
712+
// still getting consistent results from the mir-opt tests.
713+
caller_body.var_debug_info.append(&mut callee_body.var_debug_info);
714+
}
703715
caller_body.basic_blocks_mut().extend(callee_body.basic_blocks_mut().drain(..));
704716

705717
caller_body[callsite.block].terminator = Some(Terminator {

‎compiler/rustc_session/src/options.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,6 +1717,9 @@ options! {
17171717
"enable MIR inlining (default: no)"),
17181718
inline_mir_hint_threshold: Option<usize> = (None, parse_opt_number, [TRACKED],
17191719
"inlining threshold for functions with inline hint (default: 100)"),
1720+
inline_mir_preserve_debug: Option<bool> = (None, parse_opt_bool, [TRACKED],
1721+
"when MIR inlining, whether to preserve debug info for callee variables \
1722+
(default: preserve for debuginfo != None, otherwise remove)"),
17201723
inline_mir_threshold: Option<usize> = (None, parse_opt_number, [TRACKED],
17211724
"a default MIR inlining threshold (default: 50)"),
17221725
input_stats: bool = (false, parse_bool, [UNTRACKED],

0 commit comments

Comments
 (0)