@@ -10,6 +10,7 @@ use rustc_middle::ty::SymbolName;
1010use indexmap:: IndexSet ;
1111
1212use crate :: constant:: ConstantCx ;
13+ use crate :: debuginfo:: FunctionDebugContext ;
1314use crate :: prelude:: * ;
1415use crate :: pretty_clif:: CommentWriter ;
1516
@@ -18,6 +19,7 @@ struct CodegenedFunction<'tcx> {
1819 func_id : FuncId ,
1920 func : Function ,
2021 clif_comments : CommentWriter ,
22+ func_debug_cx : Option < FunctionDebugContext > ,
2123 function_span : Span ,
2224 source_info_set : IndexSet < SourceInfo > ,
2325}
@@ -82,13 +84,20 @@ fn codegen_fn<'tcx>(
8284 let pointer_type = target_config. pointer_type ( ) ;
8385 let clif_comments = crate :: pretty_clif:: CommentWriter :: new ( tcx, instance) ;
8486
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+
8593 let mut fx = FunctionCx {
8694 cx,
8795 module,
8896 tcx,
8997 target_config,
9098 pointer_type,
9199 constants_cx : ConstantCx :: new ( ) ,
100+ func_debug_cx,
92101
93102 instance,
94103 symbol_name,
@@ -109,6 +118,7 @@ fn codegen_fn<'tcx>(
109118
110119 // Recover all necessary data from fx, before accessing func will prevent future access to it.
111120 let clif_comments = fx. clif_comments ;
121+ let func_debug_cx = fx. func_debug_cx ;
112122 let function_span = fx. mir . span ;
113123 let source_info_set = fx. source_info_set ;
114124
@@ -128,7 +138,15 @@ fn codegen_fn<'tcx>(
128138 // Verify function
129139 verify_func ( tcx, & clif_comments, & func) ;
130140
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+ }
132150}
133151
134152fn compile_fn < ' tcx > (
@@ -214,7 +232,7 @@ fn compile_fn<'tcx>(
214232 let unwind_context = & mut cx. unwind_context ;
215233 cx. profiler . verbose_generic_activity ( "generate debug info" ) . run ( || {
216234 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 (
218236 debug_context,
219237 tcx,
220238 codegened_func. func_id ,
0 commit comments