Skip to content

Commit 7023948

Browse files
committed
rustc_codegen_llvm: don't generate "lexical block" scopes for -Cdebuginfo=1.
1 parent d1e81ef commit 7023948

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/librustc_codegen_llvm/debuginfo/create_scope_map.rs

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
use super::metadata::{file_metadata, UNKNOWN_COLUMN_NUMBER, UNKNOWN_LINE_NUMBER};
22
use super::utils::DIB;
33
use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext};
4+
use rustc_codegen_ssa::traits::*;
45

56
use crate::common::CodegenCx;
67
use crate::llvm;
78
use crate::llvm::debuginfo::{DIScope, DISubprogram};
89
use rustc::mir::{Body, SourceScope};
10+
use rustc_session::config::DebugInfo;
911

1012
use rustc_index::bit_set::BitSet;
1113
use rustc_index::vec::Idx;
@@ -19,10 +21,17 @@ pub fn compute_mir_scopes(
1921
) {
2022
// Find all the scopes with variables defined in them.
2123
let mut has_variables = BitSet::new_empty(mir.source_scopes.len());
22-
// FIXME(eddyb) take into account that arguments always have debuginfo,
23-
// irrespective of their name (assuming full debuginfo is enabled).
24-
for var_debug_info in &mir.var_debug_info {
25-
has_variables.insert(var_debug_info.source_info.scope);
24+
25+
// Only consider variables when they're going to be emitted.
26+
// FIXME(eddyb) don't even allocate `has_variables` otherwise.
27+
if cx.sess().opts.debuginfo == DebugInfo::Full {
28+
// FIXME(eddyb) take into account that arguments always have debuginfo,
29+
// irrespective of their name (assuming full debuginfo is enabled).
30+
// NOTE(eddyb) actually, on second thought, those are always in the
31+
// function scope, which always exists.
32+
for var_debug_info in &mir.var_debug_info {
33+
has_variables.insert(var_debug_info.source_info.scope);
34+
}
2635
}
2736

2837
// Instantiate all scopes.

0 commit comments

Comments
 (0)