@@ -3,13 +3,9 @@ use std::sync::Arc;
33
44use gccjit:: { Function , Location , RValue } ;
55use rustc_abi:: Size ;
6- use rustc_codegen_ssa:: mir:: debuginfo:: { DebugScope , FunctionDebugContext , VariableKind } ;
6+ use rustc_codegen_ssa:: mir:: debuginfo:: VariableKind ;
77use rustc_codegen_ssa:: traits:: { DebugInfoBuilderMethods , DebugInfoCodegenMethods } ;
8- use rustc_index:: bit_set:: DenseBitSet ;
9- use rustc_index:: { Idx , IndexVec } ;
10- use rustc_middle:: mir:: { self , Body , SourceScope } ;
118use rustc_middle:: ty:: { ExistentialTraitRef , Instance , Ty } ;
12- use rustc_session:: config:: DebugInfo ;
139use rustc_span:: { BytePos , Pos , SourceFile , SourceFileAndLine , Span , Symbol } ;
1410use rustc_target:: callconv:: FnAbi ;
1511
@@ -65,115 +61,6 @@ impl<'a, 'gcc, 'tcx> DebugInfoBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
6561 }
6662}
6763
68- /// Generate the `debug_context` in an MIR Body.
69- /// # Source of Origin
70- /// Copied from `create_scope_map.rs` of rustc_codegen_llvm
71- fn compute_mir_scopes < ' gcc , ' tcx > (
72- cx : & CodegenCx < ' gcc , ' tcx > ,
73- instance : Instance < ' tcx > ,
74- mir : & Body < ' tcx > ,
75- debug_context : & mut FunctionDebugContext < ' tcx , ( ) , Location < ' gcc > > ,
76- ) {
77- // Find all scopes with variables defined in them.
78- let variables = if cx. sess ( ) . opts . debuginfo == DebugInfo :: Full {
79- let mut vars = DenseBitSet :: new_empty ( mir. source_scopes . len ( ) ) ;
80- // FIXME(eddyb) take into account that arguments always have debuginfo,
81- // irrespective of their name (assuming full debuginfo is enabled).
82- // NOTE(eddyb) actually, on second thought, those are always in the
83- // function scope, which always exists.
84- for var_debug_info in & mir. var_debug_info {
85- vars. insert ( var_debug_info. source_info . scope ) ;
86- }
87- Some ( vars)
88- } else {
89- // Nothing to emit, of course.
90- None
91- } ;
92- let mut instantiated = DenseBitSet :: new_empty ( mir. source_scopes . len ( ) ) ;
93- // Instantiate all scopes.
94- for idx in 0 ..mir. source_scopes . len ( ) {
95- let scope = SourceScope :: new ( idx) ;
96- make_mir_scope ( cx, instance, mir, & variables, debug_context, & mut instantiated, scope) ;
97- }
98- assert ! ( instantiated. count( ) == mir. source_scopes. len( ) ) ;
99- }
100-
101- /// Update the `debug_context`, adding new scope to it,
102- /// if it's not added as is denoted in `instantiated`.
103- ///
104- /// # Source of Origin
105- /// Copied from `create_scope_map.rs` of rustc_codegen_llvm
106- /// FIXME(tempdragon/?): Add Scope Support Here.
107- fn make_mir_scope < ' gcc , ' tcx > (
108- cx : & CodegenCx < ' gcc , ' tcx > ,
109- _instance : Instance < ' tcx > ,
110- mir : & Body < ' tcx > ,
111- variables : & Option < DenseBitSet < SourceScope > > ,
112- debug_context : & mut FunctionDebugContext < ' tcx , ( ) , Location < ' gcc > > ,
113- instantiated : & mut DenseBitSet < SourceScope > ,
114- scope : SourceScope ,
115- ) {
116- if instantiated. contains ( scope) {
117- return ;
118- }
119-
120- let scope_data = & mir. source_scopes [ scope] ;
121- let parent_scope = if let Some ( parent) = scope_data. parent_scope {
122- make_mir_scope ( cx, _instance, mir, variables, debug_context, instantiated, parent) ;
123- debug_context. scopes [ parent]
124- } else {
125- // The root is the function itself.
126- let file = cx. sess ( ) . source_map ( ) . lookup_source_file ( mir. span . lo ( ) ) ;
127- debug_context. scopes [ scope] = DebugScope {
128- file_start_pos : file. start_pos ,
129- file_end_pos : file. end_position ( ) ,
130- ..debug_context. scopes [ scope]
131- } ;
132- instantiated. insert ( scope) ;
133- return ;
134- } ;
135-
136- if let Some ( ref vars) = * variables
137- && !vars. contains ( scope)
138- && scope_data. inlined . is_none ( )
139- {
140- // Do not create a DIScope if there are no variables defined in this
141- // MIR `SourceScope`, and it's not `inlined`, to avoid debuginfo bloat.
142- debug_context. scopes [ scope] = parent_scope;
143- instantiated. insert ( scope) ;
144- return ;
145- }
146-
147- let loc = cx. lookup_debug_loc ( scope_data. span . lo ( ) ) ;
148-
149- // FIXME(tempdragon): Add the scope related code here if the scope is supported.
150- let dbg_scope = ( ) ;
151-
152- let inlined_at = scope_data. inlined . map ( |( _, callsite_span) | {
153- // FIXME(eddyb) this doesn't account for the macro-related
154- // `Span` fixups that `rustc_codegen_ssa::mir::debuginfo` does.
155-
156- // FIXME(tempdragon): Add scope support and then revert to cg_llvm version of this closure
157- // NOTE: These variables passed () here.
158- // Changed to comply to clippy.
159-
160- /* let callsite_scope = */
161- parent_scope. adjust_dbg_scope_for_span ( cx, callsite_span) ;
162- cx. dbg_loc ( /* callsite_scope */ ( ) , parent_scope. inlined_at , callsite_span)
163- } ) ;
164- let p_inlined_at = parent_scope. inlined_at ;
165- // FIXME(tempdragon): dbg_scope: Add support for scope extension here.
166- inlined_at. or ( p_inlined_at) ;
167-
168- debug_context. scopes [ scope] = DebugScope {
169- dbg_scope,
170- inlined_at,
171- file_start_pos : loc. file . start_pos ,
172- file_end_pos : loc. file . end_position ( ) ,
173- } ;
174- instantiated. insert ( scope) ;
175- }
176-
17764/// A source code location used to generate debug information.
17865// FIXME(eddyb) rename this to better indicate it's a duplicate of
17966// `rustc_span::Loc` rather than `DILocation`, perhaps by making
@@ -228,33 +115,19 @@ impl<'gcc, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
228115 // FIXME(antoyo)
229116 }
230117
231- fn create_function_debug_context (
118+ fn dbg_create_lexical_block (
232119 & self ,
233- instance : Instance < ' tcx > ,
234- fn_abi : & FnAbi < ' tcx , Ty < ' tcx > > ,
235- llfn : Function < ' gcc > ,
236- mir : & mir:: Body < ' tcx > ,
237- ) -> Option < FunctionDebugContext < ' tcx , Self :: DIScope , Self :: DILocation > > {
238- if self . sess ( ) . opts . debuginfo == DebugInfo :: None {
239- return None ;
240- }
241-
242- // Initialize fn debug context (including scopes).
243- let empty_scope = DebugScope {
244- dbg_scope : self . dbg_scope_fn ( instance, fn_abi, Some ( llfn) ) ,
245- inlined_at : None ,
246- file_start_pos : BytePos ( 0 ) ,
247- file_end_pos : BytePos ( 0 ) ,
248- } ;
249- let mut fn_debug_context = FunctionDebugContext {
250- scopes : IndexVec :: from_elem ( empty_scope, mir. source_scopes . as_slice ( ) ) ,
251- inlined_function_scopes : Default :: default ( ) ,
252- } ;
253-
254- // Fill in all the scopes, with the information from the MIR body.
255- compute_mir_scopes ( self , instance, mir, & mut fn_debug_context) ;
120+ _pos : BytePos ,
121+ _parent_scope : Self :: DIScope ,
122+ ) -> Self :: DIScope {
123+ }
256124
257- Some ( fn_debug_context)
125+ fn dbg_location_clone_with_discriminator (
126+ & self ,
127+ loc : Self :: DILocation ,
128+ _discriminator : u32 ,
129+ ) -> Option < Self :: DILocation > {
130+ Some ( loc)
258131 }
259132
260133 fn extend_scope_to_file (
0 commit comments