Skip to content

Commit d0b2c4f

Browse files
committed
Revert "Use the same DISubprogram for each instance of the same inlined function within the caller"
This reverts commit 687bffa. Reverting to resolve ICEs reported on nightly.
1 parent a8b905c commit d0b2c4f

File tree

7 files changed

+51
-106
lines changed

7 files changed

+51
-106
lines changed

compiler/rustc_codegen_gcc/src/debuginfo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl<'gcc, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
5555
_fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
5656
_llfn: RValue<'gcc>,
5757
_mir: &mir::Body<'tcx>,
58-
) -> Option<FunctionDebugContext<'tcx, Self::DIScope, Self::DILocation>> {
58+
) -> Option<FunctionDebugContext<Self::DIScope, Self::DILocation>> {
5959
// TODO(antoyo)
6060
None
6161
}

compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs

+14-21
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub fn compute_mir_scopes<'ll, 'tcx>(
2020
cx: &CodegenCx<'ll, 'tcx>,
2121
instance: Instance<'tcx>,
2222
mir: &Body<'tcx>,
23-
debug_context: &mut FunctionDebugContext<'tcx, &'ll DIScope, &'ll DILocation>,
23+
debug_context: &mut FunctionDebugContext<&'ll DIScope, &'ll DILocation>,
2424
) {
2525
// Find all scopes with variables defined in them.
2626
let variables = if cx.sess().opts.debuginfo == DebugInfo::Full {
@@ -51,7 +51,7 @@ fn make_mir_scope<'ll, 'tcx>(
5151
instance: Instance<'tcx>,
5252
mir: &Body<'tcx>,
5353
variables: &Option<BitSet<SourceScope>>,
54-
debug_context: &mut FunctionDebugContext<'tcx, &'ll DIScope, &'ll DILocation>,
54+
debug_context: &mut FunctionDebugContext<&'ll DIScope, &'ll DILocation>,
5555
instantiated: &mut BitSet<SourceScope>,
5656
scope: SourceScope,
5757
) {
@@ -84,6 +84,7 @@ fn make_mir_scope<'ll, 'tcx>(
8484
}
8585

8686
let loc = cx.lookup_debug_loc(scope_data.span.lo());
87+
let file_metadata = file_metadata(cx, &loc.file);
8788

8889
let dbg_scope = match scope_data.inlined {
8990
Some((callee, _)) => {
@@ -94,26 +95,18 @@ fn make_mir_scope<'ll, 'tcx>(
9495
ty::ParamEnv::reveal_all(),
9596
ty::EarlyBinder::bind(callee),
9697
);
97-
debug_context.inlined_function_scopes.entry(callee).or_insert_with(|| {
98-
let callee_fn_abi = cx.fn_abi_of_instance(callee, ty::List::empty());
99-
cx.dbg_scope_fn(callee, callee_fn_abi, None)
100-
})
101-
}
102-
None => {
103-
let file_metadata = file_metadata(cx, &loc.file);
104-
debug_context
105-
.lexical_blocks
106-
.entry((parent_scope.dbg_scope, loc.line, loc.col, file_metadata))
107-
.or_insert_with(|| unsafe {
108-
llvm::LLVMRustDIBuilderCreateLexicalBlock(
109-
DIB(cx),
110-
parent_scope.dbg_scope,
111-
file_metadata,
112-
loc.line,
113-
loc.col,
114-
)
115-
})
98+
let callee_fn_abi = cx.fn_abi_of_instance(callee, ty::List::empty());
99+
cx.dbg_scope_fn(callee, callee_fn_abi, None)
116100
}
101+
None => unsafe {
102+
llvm::LLVMRustDIBuilderCreateLexicalBlock(
103+
DIB(cx),
104+
parent_scope.dbg_scope,
105+
file_metadata,
106+
loc.line,
107+
loc.col,
108+
)
109+
},
117110
};
118111

119112
let inlined_at = scope_data.inlined.map(|(_, callsite_span)| {

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

+32-44
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_codegen_ssa::mir::debuginfo::VariableKind::*;
55
use self::metadata::{file_metadata, type_di_node};
66
use self::metadata::{UNKNOWN_COLUMN_NUMBER, UNKNOWN_LINE_NUMBER};
77
use self::namespace::mangled_name_of_instance;
8-
use self::utils::{create_DIArray, debug_context, is_node_local_to_unit, DIB};
8+
use self::utils::{create_DIArray, is_node_local_to_unit, DIB};
99

1010
use crate::abi::FnAbi;
1111
use crate::builder::Builder;
@@ -67,8 +67,6 @@ pub struct CodegenUnitDebugContext<'ll, 'tcx> {
6767
type_map: metadata::TypeMap<'ll, 'tcx>,
6868
namespace_map: RefCell<DefIdMap<&'ll DIScope>>,
6969
recursion_marker_type: OnceCell<&'ll DIType>,
70-
/// Maps a variable (name, scope, kind (argument or local), span) to its debug information.
71-
variables: RefCell<FxHashMap<(Symbol, &'ll DIScope, VariableKind, Span), &'ll DIVariable>>,
7270
}
7371

7472
impl Drop for CodegenUnitDebugContext<'_, '_> {
@@ -93,7 +91,6 @@ impl<'ll, 'tcx> CodegenUnitDebugContext<'ll, 'tcx> {
9391
type_map: Default::default(),
9492
namespace_map: RefCell::new(Default::default()),
9593
recursion_marker_type: OnceCell::new(),
96-
variables: RefCell::new(Default::default()),
9794
}
9895
}
9996

@@ -295,7 +292,7 @@ impl<'ll, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
295292
fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
296293
llfn: &'ll Value,
297294
mir: &mir::Body<'tcx>,
298-
) -> Option<FunctionDebugContext<'tcx, &'ll DIScope, &'ll DILocation>> {
295+
) -> Option<FunctionDebugContext<&'ll DIScope, &'ll DILocation>> {
299296
if self.sess().opts.debuginfo == DebugInfo::None {
300297
return None;
301298
}
@@ -307,11 +304,8 @@ impl<'ll, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
307304
file_start_pos: BytePos(0),
308305
file_end_pos: BytePos(0),
309306
};
310-
let mut fn_debug_context = FunctionDebugContext {
311-
scopes: IndexVec::from_elem(empty_scope, &mir.source_scopes),
312-
inlined_function_scopes: Default::default(),
313-
lexical_blocks: Default::default(),
314-
};
307+
let mut fn_debug_context =
308+
FunctionDebugContext { scopes: IndexVec::from_elem(empty_scope, &mir.source_scopes) };
315309

316310
// Fill in all the scopes, with the information from the MIR body.
317311
compute_mir_scopes(self, instance, mir, &mut fn_debug_context);
@@ -612,39 +606,33 @@ impl<'ll, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
612606
variable_kind: VariableKind,
613607
span: Span,
614608
) -> &'ll DIVariable {
615-
debug_context(self)
616-
.variables
617-
.borrow_mut()
618-
.entry((variable_name, scope_metadata, variable_kind, span))
619-
.or_insert_with(|| {
620-
let loc = self.lookup_debug_loc(span.lo());
621-
let file_metadata = file_metadata(self, &loc.file);
622-
623-
let type_metadata = type_di_node(self, variable_type);
624-
625-
let (argument_index, dwarf_tag) = match variable_kind {
626-
ArgumentVariable(index) => (index as c_uint, DW_TAG_arg_variable),
627-
LocalVariable => (0, DW_TAG_auto_variable),
628-
};
629-
let align = self.align_of(variable_type);
630-
631-
let name = variable_name.as_str();
632-
unsafe {
633-
llvm::LLVMRustDIBuilderCreateVariable(
634-
DIB(self),
635-
dwarf_tag,
636-
scope_metadata,
637-
name.as_ptr().cast(),
638-
name.len(),
639-
file_metadata,
640-
loc.line,
641-
type_metadata,
642-
true,
643-
DIFlags::FlagZero,
644-
argument_index,
645-
align.bytes() as u32,
646-
)
647-
}
648-
})
609+
let loc = self.lookup_debug_loc(span.lo());
610+
let file_metadata = file_metadata(self, &loc.file);
611+
612+
let type_metadata = type_di_node(self, variable_type);
613+
614+
let (argument_index, dwarf_tag) = match variable_kind {
615+
ArgumentVariable(index) => (index as c_uint, DW_TAG_arg_variable),
616+
LocalVariable => (0, DW_TAG_auto_variable),
617+
};
618+
let align = self.align_of(variable_type);
619+
620+
let name = variable_name.as_str();
621+
unsafe {
622+
llvm::LLVMRustDIBuilderCreateVariable(
623+
DIB(self),
624+
dwarf_tag,
625+
scope_metadata,
626+
name.as_ptr().cast(),
627+
name.len(),
628+
file_metadata,
629+
loc.line,
630+
type_metadata,
631+
true,
632+
DIFlags::FlagZero,
633+
argument_index,
634+
align.bytes() as u32,
635+
)
636+
}
649637
}
650638
}

compiler/rustc_codegen_ssa/src/mir/debuginfo.rs

+2-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
use crate::traits::*;
2-
use rustc_data_structures::fx::FxHashMap;
32
use rustc_index::IndexVec;
43
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
54
use rustc_middle::mir;
65
use rustc_middle::ty;
76
use rustc_middle::ty::layout::TyAndLayout;
87
use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf};
9-
use rustc_middle::ty::Instance;
108
use rustc_middle::ty::Ty;
119
use rustc_session::config::DebugInfo;
1210
use rustc_span::symbol::{kw, Symbol};
@@ -19,19 +17,11 @@ use super::{FunctionCx, LocalRef};
1917

2018
use std::ops::Range;
2119

22-
pub struct FunctionDebugContext<'tcx, S, L> {
23-
/// Maps from source code to the corresponding debug info scope.
20+
pub struct FunctionDebugContext<S, L> {
2421
pub scopes: IndexVec<mir::SourceScope, DebugScope<S, L>>,
25-
26-
/// Maps from a given inlined function to its debug info declaration.
27-
pub inlined_function_scopes: FxHashMap<Instance<'tcx>, S>,
28-
29-
/// Maps from a lexical block (parent scope, line, column, file) to its debug info declaration.
30-
/// This is particularily useful if the parent scope is an inlined function.
31-
pub lexical_blocks: FxHashMap<(S, u32, u32, S), S>,
3222
}
3323

34-
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
24+
#[derive(Copy, Clone)]
3525
pub enum VariableKind {
3626
ArgumentVariable(usize /*index*/),
3727
LocalVariable,

compiler/rustc_codegen_ssa/src/mir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub struct FunctionCx<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> {
4646

4747
mir: &'tcx mir::Body<'tcx>,
4848

49-
debug_context: Option<FunctionDebugContext<'tcx, Bx::DIScope, Bx::DILocation>>,
49+
debug_context: Option<FunctionDebugContext<Bx::DIScope, Bx::DILocation>>,
5050

5151
llfn: Bx::Function,
5252

compiler/rustc_codegen_ssa/src/traits/debuginfo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub trait DebugInfoMethods<'tcx>: BackendTypes {
2626
fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
2727
llfn: Self::Function,
2828
mir: &mir::Body<'tcx>,
29-
) -> Option<FunctionDebugContext<'tcx, Self::DIScope, Self::DILocation>>;
29+
) -> Option<FunctionDebugContext<Self::DIScope, Self::DILocation>>;
3030

3131
// FIXME(eddyb) find a common convention for all of the debuginfo-related
3232
// names (choose between `dbg`, `debug`, `debuginfo`, `debug_info` etc.).

tests/codegen/debuginfo-inline-callsite-location.rs

-26
This file was deleted.

0 commit comments

Comments
 (0)