Skip to content

Commit 13c9fc3

Browse files
committed
Auto merge of #95300 - workingjubilee:less-bitsets, r=eddyb
Skip needless bitset for debuginfo Found this while digging around looking at the inlining logic. Seemed obvious enough so I decided to try to take care of it. Is this what you had in mind, `@eddyb?`
2 parents 93313d1 + f5f0e6d commit 13c9fc3

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs

+13-12
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,26 @@ pub fn compute_mir_scopes<'ll, 'tcx>(
2323
fn_dbg_scope: &'ll DIScope,
2424
debug_context: &mut FunctionDebugContext<&'ll DIScope, &'ll DILocation>,
2525
) {
26-
// Find all the scopes with variables defined in them.
27-
let mut has_variables = BitSet::new_empty(mir.source_scopes.len());
28-
29-
// Only consider variables when they're going to be emitted.
30-
// FIXME(eddyb) don't even allocate `has_variables` otherwise.
31-
if cx.sess().opts.debuginfo == DebugInfo::Full {
26+
// Find all scopes with variables defined in them.
27+
let variables = if cx.sess().opts.debuginfo == DebugInfo::Full {
28+
let mut vars = BitSet::new_empty(mir.source_scopes.len());
3229
// FIXME(eddyb) take into account that arguments always have debuginfo,
3330
// irrespective of their name (assuming full debuginfo is enabled).
3431
// NOTE(eddyb) actually, on second thought, those are always in the
3532
// function scope, which always exists.
3633
for var_debug_info in &mir.var_debug_info {
37-
has_variables.insert(var_debug_info.source_info.scope);
34+
vars.insert(var_debug_info.source_info.scope);
3835
}
39-
}
36+
Some(vars)
37+
} else {
38+
// Nothing to emit, of course.
39+
None
40+
};
4041

4142
// Instantiate all scopes.
4243
for idx in 0..mir.source_scopes.len() {
4344
let scope = SourceScope::new(idx);
44-
make_mir_scope(cx, instance, mir, fn_dbg_scope, &has_variables, debug_context, scope);
45+
make_mir_scope(cx, instance, mir, fn_dbg_scope, &variables, debug_context, scope);
4546
}
4647
}
4748

@@ -50,7 +51,7 @@ fn make_mir_scope<'ll, 'tcx>(
5051
instance: Instance<'tcx>,
5152
mir: &Body<'tcx>,
5253
fn_dbg_scope: &'ll DIScope,
53-
has_variables: &BitSet<SourceScope>,
54+
variables: &Option<BitSet<SourceScope>>,
5455
debug_context: &mut FunctionDebugContext<&'ll DIScope, &'ll DILocation>,
5556
scope: SourceScope,
5657
) {
@@ -60,7 +61,7 @@ fn make_mir_scope<'ll, 'tcx>(
6061

6162
let scope_data = &mir.source_scopes[scope];
6263
let parent_scope = if let Some(parent) = scope_data.parent_scope {
63-
make_mir_scope(cx, instance, mir, fn_dbg_scope, has_variables, debug_context, parent);
64+
make_mir_scope(cx, instance, mir, fn_dbg_scope, variables, debug_context, parent);
6465
debug_context.scopes[parent]
6566
} else {
6667
// The root is the function itself.
@@ -74,7 +75,7 @@ fn make_mir_scope<'ll, 'tcx>(
7475
return;
7576
};
7677

77-
if !has_variables.contains(scope) && scope_data.inlined.is_none() {
78+
if let Some(vars) = variables && !vars.contains(scope) && scope_data.inlined.is_none() {
7879
// Do not create a DIScope if there are no variables defined in this
7980
// MIR `SourceScope`, and it's not `inlined`, to avoid debuginfo bloat.
8081
debug_context.scopes[scope] = parent_scope;

compiler/rustc_codegen_llvm/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
88
#![feature(bool_to_option)]
99
#![feature(crate_visibility_modifier)]
10+
#![feature(let_chains)]
1011
#![feature(let_else)]
1112
#![feature(extern_types)]
1213
#![feature(once_cell)]

0 commit comments

Comments
 (0)