Skip to content

Commit 0b425d4

Browse files
Rollup merge of #158560 - bjorn3:ssa_refactor_debuginfo, r=Kivooeo
Move per-function debuginfo methods from codegen to builder methods In cg_clif the debuginfo for the function we are currently codegening is stored in `FunctionDebugContext`, which is stored in the `FunctionCx`, not in the per-cgu `DebugContext`.
2 parents d0314ca + 78410ba commit 0b425d4

2 files changed

Lines changed: 64 additions & 65 deletions

File tree

src/base.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use gccjit::{CType, Context, FunctionType, GlobalKind};
77
use rustc_codegen_ssa::ModuleCodegen;
88
use rustc_codegen_ssa::base::maybe_create_entry_wrapper;
99
use rustc_codegen_ssa::mono_item::MonoItemExt;
10-
use rustc_codegen_ssa::traits::DebugInfoCodegenMethods;
1110
use rustc_hir::attrs::{AttributeKind, Linkage};
1211
use rustc_hir::find_attr;
1312
use rustc_middle::dep_graph;

src/debuginfo.rs

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,66 @@ pub(super) const UNKNOWN_LINE_NUMBER: u32 = 0;
1616
pub(super) const UNKNOWN_COLUMN_NUMBER: u32 = 0;
1717

1818
impl<'a, 'gcc, 'tcx> DebugInfoBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
19+
fn dbg_scope_fn(
20+
&mut self,
21+
_instance: Instance<'tcx>,
22+
_fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
23+
_maybe_definition_llfn: Option<Function<'gcc>>,
24+
) -> Self::DIScope {
25+
// FIXME(antoyo): implement.
26+
}
27+
28+
fn dbg_create_lexical_block(
29+
&mut self,
30+
_pos: BytePos,
31+
_parent_scope: Self::DIScope,
32+
) -> Self::DIScope {
33+
}
34+
35+
fn dbg_location_clone_with_discriminator(
36+
&mut self,
37+
loc: Self::DILocation,
38+
_discriminator: u32,
39+
) -> Option<Self::DILocation> {
40+
Some(loc)
41+
}
42+
43+
fn extend_scope_to_file(
44+
&mut self,
45+
_scope_metadata: Self::DIScope,
46+
_file: &SourceFile,
47+
) -> Self::DIScope {
48+
// FIXME(antoyo): implement.
49+
}
50+
51+
fn dbg_loc(
52+
&mut self,
53+
_scope: Self::DIScope,
54+
_inlined_at: Option<Self::DILocation>,
55+
span: Span,
56+
) -> Self::DILocation {
57+
let pos = span.lo();
58+
let DebugLoc { file, line, col } = self.lookup_debug_loc(pos);
59+
match file.name {
60+
rustc_span::FileName::Real(ref name) => self.context.new_location(
61+
name.path(rustc_span::RemapPathScopeComponents::DEBUGINFO).to_string_lossy(),
62+
line as i32,
63+
col as i32,
64+
),
65+
_ => Location::null(),
66+
}
67+
}
68+
69+
fn create_dbg_var(
70+
&mut self,
71+
_variable_name: Symbol,
72+
_variable_type: Ty<'tcx>,
73+
_scope_metadata: Self::DIScope,
74+
_variable_kind: VariableKind,
75+
_span: Span,
76+
) -> Self::DIVariable {
77+
}
78+
1979
// FIXME(eddyb) find a common convention for all of the debuginfo-related
2080
// names (choose between `dbg`, `debug`, `debuginfo`, `debug_info` etc.).
2181
fn dbg_var_addr(
@@ -103,6 +163,10 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
103163
DebugLoc { file, line, col }
104164
}
105165
}
166+
167+
pub(crate) fn debuginfo_finalize(&self) {
168+
self.context.set_debug_info(true)
169+
}
106170
}
107171

108172
impl<'gcc, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
@@ -114,68 +178,4 @@ impl<'gcc, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
114178
) {
115179
// FIXME(antoyo)
116180
}
117-
118-
fn dbg_create_lexical_block(
119-
&self,
120-
_pos: BytePos,
121-
_parent_scope: Self::DIScope,
122-
) -> Self::DIScope {
123-
}
124-
125-
fn dbg_location_clone_with_discriminator(
126-
&self,
127-
loc: Self::DILocation,
128-
_discriminator: u32,
129-
) -> Option<Self::DILocation> {
130-
Some(loc)
131-
}
132-
133-
fn extend_scope_to_file(
134-
&self,
135-
_scope_metadata: Self::DIScope,
136-
_file: &SourceFile,
137-
) -> Self::DIScope {
138-
// FIXME(antoyo): implement.
139-
}
140-
141-
fn debuginfo_finalize(&self) {
142-
self.context.set_debug_info(true)
143-
}
144-
145-
fn create_dbg_var(
146-
&self,
147-
_variable_name: Symbol,
148-
_variable_type: Ty<'tcx>,
149-
_scope_metadata: Self::DIScope,
150-
_variable_kind: VariableKind,
151-
_span: Span,
152-
) -> Self::DIVariable {
153-
}
154-
155-
fn dbg_scope_fn(
156-
&self,
157-
_instance: Instance<'tcx>,
158-
_fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
159-
_maybe_definition_llfn: Option<Function<'gcc>>,
160-
) -> Self::DIScope {
161-
// FIXME(antoyo): implement.
162-
}
163-
164-
fn dbg_loc(
165-
&self,
166-
_scope: Self::DIScope,
167-
_inlined_at: Option<Self::DILocation>,
168-
span: Span,
169-
) -> Self::DILocation {
170-
let pos = span.lo();
171-
let DebugLoc { file, line, col } = self.lookup_debug_loc(pos);
172-
match file.name {
173-
rustc_span::FileName::Real(ref name) => self.context.new_location(
174-
name.path(rustc_span::RemapPathScopeComponents::DEBUGINFO).to_string_lossy(),
175-
line as i32,
176-
col as i32,
177-
),
178-
_ => Location::null(),
179-
}
180-
}
181181
}

0 commit comments

Comments
 (0)