@@ -20,7 +20,7 @@ pub fn compute_mir_scopes<'ll, 'tcx>(
20
20
cx : & CodegenCx < ' ll , ' tcx > ,
21
21
instance : Instance < ' tcx > ,
22
22
mir : & Body < ' tcx > ,
23
- debug_context : & mut FunctionDebugContext < & ' ll DIScope , & ' ll DILocation > ,
23
+ debug_context : & mut FunctionDebugContext < ' tcx , & ' ll DIScope , & ' ll DILocation > ,
24
24
) {
25
25
// Find all scopes with variables defined in them.
26
26
let variables = if cx. sess ( ) . opts . debuginfo == DebugInfo :: Full {
@@ -51,7 +51,7 @@ fn make_mir_scope<'ll, 'tcx>(
51
51
instance : Instance < ' tcx > ,
52
52
mir : & Body < ' tcx > ,
53
53
variables : & Option < BitSet < SourceScope > > ,
54
- debug_context : & mut FunctionDebugContext < & ' ll DIScope , & ' ll DILocation > ,
54
+ debug_context : & mut FunctionDebugContext < ' tcx , & ' ll DIScope , & ' ll DILocation > ,
55
55
instantiated : & mut BitSet < SourceScope > ,
56
56
scope : SourceScope ,
57
57
) {
@@ -86,7 +86,7 @@ fn make_mir_scope<'ll, 'tcx>(
86
86
let loc = cx. lookup_debug_loc ( scope_data. span . lo ( ) ) ;
87
87
let file_metadata = file_metadata ( cx, & loc. file ) ;
88
88
89
- let dbg_scope = match scope_data. inlined {
89
+ let parent_dbg_scope = match scope_data. inlined {
90
90
Some ( ( callee, _) ) => {
91
91
// FIXME(eddyb) this would be `self.monomorphize(&callee)`
92
92
// if this is moved to `rustc_codegen_ssa::mir::debuginfo`.
@@ -95,18 +95,22 @@ fn make_mir_scope<'ll, 'tcx>(
95
95
ty:: ParamEnv :: reveal_all ( ) ,
96
96
ty:: EarlyBinder :: bind ( callee) ,
97
97
) ;
98
- let callee_fn_abi = cx. fn_abi_of_instance ( callee, ty:: List :: empty ( ) ) ;
99
- cx. dbg_scope_fn ( callee, callee_fn_abi, None )
98
+ debug_context. inlined_function_scopes . entry ( callee) . or_insert_with ( || {
99
+ let callee_fn_abi = cx. fn_abi_of_instance ( callee, ty:: List :: empty ( ) ) ;
100
+ cx. dbg_scope_fn ( callee, callee_fn_abi, None )
101
+ } )
100
102
}
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
- } ,
103
+ None => parent_scope. dbg_scope ,
104
+ } ;
105
+
106
+ let dbg_scope = unsafe {
107
+ llvm:: LLVMRustDIBuilderCreateLexicalBlock (
108
+ DIB ( cx) ,
109
+ parent_dbg_scope,
110
+ file_metadata,
111
+ loc. line ,
112
+ loc. col ,
113
+ )
110
114
} ;
111
115
112
116
let inlined_at = scope_data. inlined . map ( |( _, callsite_span) | {
0 commit comments