diff options
| author | Jubilee Young <workingjubilee@gmail.com> | 2022-03-25 03:50:41 -0700 |
|---|---|---|
| committer | Jubilee Young <workingjubilee@gmail.com> | 2022-03-25 03:55:18 -0700 |
| commit | f5f0e6d551041ac15db0d27ecbcac1b5f0ec5665 (patch) | |
| tree | 17bcf6dc525fc5423815d8bb223c101edfecb5af /compiler/rustc_codegen_llvm/src/debuginfo | |
| parent | 7941b3f1473331d2abb2b8796046adc0105c8f94 (diff) | |
| download | rust-f5f0e6d551041ac15db0d27ecbcac1b5f0ec5665.tar.gz rust-f5f0e6d551041ac15db0d27ecbcac1b5f0ec5665.zip | |
Skip needless bitset for debuginfo
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/debuginfo')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs b/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs index 39f53235e2c..76caa3ceaaf 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs @@ -23,25 +23,26 @@ pub fn compute_mir_scopes<'ll, 'tcx>( fn_dbg_scope: &'ll DIScope, debug_context: &mut FunctionDebugContext<&'ll DIScope, &'ll DILocation>, ) { - // Find all the scopes with variables defined in them. - let mut has_variables = BitSet::new_empty(mir.source_scopes.len()); - - // Only consider variables when they're going to be emitted. - // FIXME(eddyb) don't even allocate `has_variables` otherwise. - if cx.sess().opts.debuginfo == DebugInfo::Full { + // Find all scopes with variables defined in them. + let variables = if cx.sess().opts.debuginfo == DebugInfo::Full { + let mut vars = BitSet::new_empty(mir.source_scopes.len()); // FIXME(eddyb) take into account that arguments always have debuginfo, // irrespective of their name (assuming full debuginfo is enabled). // NOTE(eddyb) actually, on second thought, those are always in the // function scope, which always exists. for var_debug_info in &mir.var_debug_info { - has_variables.insert(var_debug_info.source_info.scope); + vars.insert(var_debug_info.source_info.scope); } - } + Some(vars) + } else { + // Nothing to emit, of course. + None + }; // Instantiate all scopes. for idx in 0..mir.source_scopes.len() { let scope = SourceScope::new(idx); - make_mir_scope(cx, instance, mir, fn_dbg_scope, &has_variables, debug_context, scope); + make_mir_scope(cx, instance, mir, fn_dbg_scope, &variables, debug_context, scope); } } @@ -50,7 +51,7 @@ fn make_mir_scope<'ll, 'tcx>( instance: Instance<'tcx>, mir: &Body<'tcx>, fn_dbg_scope: &'ll DIScope, - has_variables: &BitSet<SourceScope>, + variables: &Option<BitSet<SourceScope>>, debug_context: &mut FunctionDebugContext<&'ll DIScope, &'ll DILocation>, scope: SourceScope, ) { @@ -60,7 +61,7 @@ fn make_mir_scope<'ll, 'tcx>( let scope_data = &mir.source_scopes[scope]; let parent_scope = if let Some(parent) = scope_data.parent_scope { - make_mir_scope(cx, instance, mir, fn_dbg_scope, has_variables, debug_context, parent); + make_mir_scope(cx, instance, mir, fn_dbg_scope, variables, debug_context, parent); debug_context.scopes[parent] } else { // The root is the function itself. @@ -74,7 +75,7 @@ fn make_mir_scope<'ll, 'tcx>( return; }; - if !has_variables.contains(scope) && scope_data.inlined.is_none() { + if let Some(vars) = variables && !vars.contains(scope) && scope_data.inlined.is_none() { // Do not create a DIScope if there are no variables defined in this // MIR `SourceScope`, and it's not `inlined`, to avoid debuginfo bloat. debug_context.scopes[scope] = parent_scope; |
