@@ -10,6 +10,7 @@ use rustc_middle::ty::SymbolName;
10
10
use indexmap:: IndexSet ;
11
11
12
12
use crate :: constant:: ConstantCx ;
13
+ use crate :: debuginfo:: FunctionDebugContext ;
13
14
use crate :: prelude:: * ;
14
15
use crate :: pretty_clif:: CommentWriter ;
15
16
@@ -18,6 +19,7 @@ struct CodegenedFunction<'tcx> {
18
19
func_id : FuncId ,
19
20
func : Function ,
20
21
clif_comments : CommentWriter ,
22
+ func_debug_cx : Option < FunctionDebugContext > ,
21
23
function_span : Span ,
22
24
source_info_set : IndexSet < SourceInfo > ,
23
25
}
@@ -82,13 +84,20 @@ fn codegen_fn<'tcx>(
82
84
let pointer_type = target_config. pointer_type ( ) ;
83
85
let clif_comments = crate :: pretty_clif:: CommentWriter :: new ( tcx, instance) ;
84
86
87
+ let func_debug_cx = if let Some ( debug_context) = & mut cx. debug_context {
88
+ Some ( debug_context. define_function ( symbol_name. name ) )
89
+ } else {
90
+ None
91
+ } ;
92
+
85
93
let mut fx = FunctionCx {
86
94
cx,
87
95
module,
88
96
tcx,
89
97
target_config,
90
98
pointer_type,
91
99
constants_cx : ConstantCx :: new ( ) ,
100
+ func_debug_cx,
92
101
93
102
instance,
94
103
symbol_name,
@@ -109,6 +118,7 @@ fn codegen_fn<'tcx>(
109
118
110
119
// Recover all necessary data from fx, before accessing func will prevent future access to it.
111
120
let clif_comments = fx. clif_comments ;
121
+ let func_debug_cx = fx. func_debug_cx ;
112
122
let function_span = fx. mir . span ;
113
123
let source_info_set = fx. source_info_set ;
114
124
@@ -128,7 +138,15 @@ fn codegen_fn<'tcx>(
128
138
// Verify function
129
139
verify_func ( tcx, & clif_comments, & func) ;
130
140
131
- CodegenedFunction { symbol_name, func_id, func, clif_comments, function_span, source_info_set }
141
+ CodegenedFunction {
142
+ symbol_name,
143
+ func_id,
144
+ func,
145
+ clif_comments,
146
+ func_debug_cx,
147
+ function_span,
148
+ source_info_set,
149
+ }
132
150
}
133
151
134
152
fn compile_fn < ' tcx > (
@@ -214,7 +232,7 @@ fn compile_fn<'tcx>(
214
232
let unwind_context = & mut cx. unwind_context ;
215
233
cx. profiler . verbose_generic_activity ( "generate debug info" ) . run ( || {
216
234
if let Some ( debug_context) = debug_context {
217
- debug_context . define_function ( codegened_func. symbol_name . name ) . finalize (
235
+ codegened_func. func_debug_cx . unwrap ( ) . finalize (
218
236
debug_context,
219
237
tcx,
220
238
codegened_func. func_id ,
0 commit comments