@@ -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 < & ' ll DIScope , & ' ll DILocation > ,
23+ debug_context : & mut FunctionDebugContext < ' tcx , & ' 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 < & ' ll DIScope , & ' ll DILocation > ,
54+ debug_context : & mut FunctionDebugContext < ' tcx , & ' ll DIScope , & ' ll DILocation > ,
5555 instantiated : & mut BitSet < SourceScope > ,
5656 scope : SourceScope ,
5757) {
@@ -86,7 +86,7 @@ fn make_mir_scope<'ll, 'tcx>(
8686 let loc = cx. lookup_debug_loc ( scope_data. span . lo ( ) ) ;
8787 let file_metadata = file_metadata ( cx, & loc. file ) ;
8888
89- let dbg_scope = match scope_data. inlined {
89+ let parent_dbg_scope = match scope_data. inlined {
9090 Some ( ( callee, _) ) => {
9191 // FIXME(eddyb) this would be `self.monomorphize(&callee)`
9292 // if this is moved to `rustc_codegen_ssa::mir::debuginfo`.
@@ -95,18 +95,22 @@ fn make_mir_scope<'ll, 'tcx>(
9595 ty:: ParamEnv :: reveal_all ( ) ,
9696 ty:: EarlyBinder :: bind ( callee) ,
9797 ) ;
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+ } )
100102 }
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+ )
110114 } ;
111115
112116 let inlined_at = scope_data. inlined . map ( |( _, callsite_span) | {
0 commit comments