@@ -11,7 +11,7 @@ use self::metadata::{type_metadata, file_metadata, TypeMap};
11
11
use self :: source_loc:: InternalDebugLocation :: { self , UnknownLocation } ;
12
12
13
13
use crate :: llvm;
14
- use crate :: llvm:: debuginfo:: { DIFile , DIType , DIScope , DIBuilder , DISubprogram , DIArray , DIFlags ,
14
+ use crate :: llvm:: debuginfo:: { DIFile , DIType , DIScope , DIBuilder , DIArray , DIFlags ,
15
15
DISPFlags , DILexicalBlock } ;
16
16
use rustc:: hir:: CodegenFnAttrFlags ;
17
17
use rustc:: hir:: def_id:: { DefId , CrateNum , LOCAL_CRATE } ;
@@ -29,13 +29,13 @@ use rustc_data_structures::small_c_str::SmallCStr;
29
29
use rustc_index:: vec:: IndexVec ;
30
30
use rustc_codegen_ssa:: debuginfo:: type_names;
31
31
use rustc_codegen_ssa:: mir:: debuginfo:: { FunctionDebugContext , DebugScope , VariableAccess ,
32
- VariableKind , FunctionDebugContextData } ;
32
+ VariableKind } ;
33
33
34
34
use libc:: c_uint;
35
35
use std:: cell:: RefCell ;
36
36
use std:: ffi:: { CStr , CString } ;
37
37
38
- use syntax_pos:: { self , Span , Pos } ;
38
+ use syntax_pos:: { self , BytePos , Span , Pos } ;
39
39
use syntax:: ast;
40
40
use syntax:: symbol:: Symbol ;
41
41
use rustc:: ty:: layout:: { self , LayoutOf , HasTyCtxt } ;
@@ -48,7 +48,7 @@ pub mod metadata;
48
48
mod create_scope_map;
49
49
mod source_loc;
50
50
51
- pub use self :: create_scope_map:: { create_mir_scopes } ;
51
+ pub use self :: create_scope_map:: compute_mir_scopes ;
52
52
pub use self :: metadata:: create_global_var_metadata;
53
53
pub use self :: metadata:: extend_scope_to_file;
54
54
pub use self :: source_loc:: set_source_location;
@@ -149,21 +149,21 @@ pub fn finalize(cx: &CodegenCx<'_, '_>) {
149
149
impl DebugInfoBuilderMethods < ' tcx > for Builder < ' a , ' ll , ' tcx > {
150
150
fn declare_local (
151
151
& mut self ,
152
- dbg_context : & FunctionDebugContext < & ' ll DISubprogram > ,
152
+ dbg_context : & FunctionDebugContext < & ' ll DIScope > ,
153
153
variable_name : ast:: Name ,
154
154
variable_type : Ty < ' tcx > ,
155
155
scope_metadata : & ' ll DIScope ,
156
156
variable_access : VariableAccess < ' _ , & ' ll Value > ,
157
157
variable_kind : VariableKind ,
158
158
span : Span ,
159
159
) {
160
- assert ! ( !dbg_context. get_ref ( span ) . source_locations_enabled) ;
160
+ assert ! ( !dbg_context. source_locations_enabled) ;
161
161
let cx = self . cx ( ) ;
162
162
163
163
let file = span_start ( cx, span) . file ;
164
164
let file_metadata = file_metadata ( cx,
165
165
& file. name ,
166
- dbg_context. get_ref ( span ) . defining_crate ) ;
166
+ dbg_context. defining_crate ) ;
167
167
168
168
let loc = span_start ( cx, span) ;
169
169
let type_metadata = type_metadata ( cx, variable_type, span) ;
@@ -215,8 +215,8 @@ impl DebugInfoBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
215
215
216
216
fn set_source_location (
217
217
& mut self ,
218
- debug_context : & mut FunctionDebugContext < & ' ll DISubprogram > ,
219
- scope : Option < & ' ll DIScope > ,
218
+ debug_context : & mut FunctionDebugContext < & ' ll DIScope > ,
219
+ scope : & ' ll DIScope ,
220
220
span : Span ,
221
221
) {
222
222
set_source_location ( debug_context, & self , scope, span)
@@ -269,14 +269,14 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
269
269
sig : ty:: FnSig < ' tcx > ,
270
270
llfn : & ' ll Value ,
271
271
mir : & mir:: Body < ' _ > ,
272
- ) -> FunctionDebugContext < & ' ll DISubprogram > {
272
+ ) -> Option < FunctionDebugContext < & ' ll DIScope > > {
273
273
if self . sess ( ) . opts . debuginfo == DebugInfo :: None {
274
- return FunctionDebugContext :: DebugInfoDisabled ;
274
+ return None ;
275
275
}
276
276
277
277
if let InstanceDef :: Item ( def_id) = instance. def {
278
278
if self . tcx ( ) . codegen_fn_attrs ( def_id) . flags . contains ( CodegenFnAttrFlags :: NO_DEBUG ) {
279
- return FunctionDebugContext :: FunctionWithoutDebugInfo ;
279
+ return None ;
280
280
}
281
281
}
282
282
@@ -285,7 +285,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
285
285
// This can be the case for functions inlined from another crate
286
286
if span. is_dummy ( ) {
287
287
// FIXME(simulacrum): Probably can't happen; remove.
288
- return FunctionDebugContext :: FunctionWithoutDebugInfo ;
288
+ return None ;
289
289
}
290
290
291
291
let def_id = instance. def_id ( ) ;
@@ -358,14 +358,23 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
358
358
None )
359
359
} ;
360
360
361
- // Initialize fn debug context (including scope map and namespace map)
362
- let fn_debug_context = FunctionDebugContextData {
363
- fn_metadata,
361
+ // Initialize fn debug context (including scopes).
362
+ // FIXME(eddyb) figure out a way to not need `Option` for `scope_metadata`.
363
+ let null_scope = DebugScope {
364
+ scope_metadata : None ,
365
+ file_start_pos : BytePos ( 0 ) ,
366
+ file_end_pos : BytePos ( 0 )
367
+ } ;
368
+ let mut fn_debug_context = FunctionDebugContext {
369
+ scopes : IndexVec :: from_elem ( null_scope, & mir. source_scopes ) ,
364
370
source_locations_enabled : false ,
365
371
defining_crate : def_id. krate ,
366
372
} ;
367
373
368
- return FunctionDebugContext :: RegularContext ( fn_debug_context) ;
374
+ // Fill in all the scopes, with the information from the MIR body.
375
+ compute_mir_scopes ( self , mir, fn_metadata, & mut fn_debug_context) ;
376
+
377
+ return Some ( fn_debug_context) ;
369
378
370
379
fn get_function_signature < ' ll , ' tcx > (
371
380
cx : & CodegenCx < ' ll , ' tcx > ,
@@ -550,14 +559,6 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
550
559
metadata:: create_vtable_metadata ( self , ty, vtable)
551
560
}
552
561
553
- fn create_mir_scopes (
554
- & self ,
555
- mir : & mir:: Body < ' _ > ,
556
- debug_context : & mut FunctionDebugContext < & ' ll DISubprogram > ,
557
- ) -> IndexVec < mir:: SourceScope , DebugScope < & ' ll DIScope > > {
558
- create_scope_map:: create_mir_scopes ( self , mir, debug_context)
559
- }
560
-
561
562
fn extend_scope_to_file (
562
563
& self ,
563
564
scope_metadata : & ' ll DIScope ,
0 commit comments