@@ -90,7 +90,10 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
9090 /// string, to hold the function name passed to LLVM intrinsic
9191 /// `instrprof.increment()`. The `Value` is only created once per instance.
9292 /// Multiple invocations with the same instance return the same `Value`.
93- fn get_pgo_func_name_var ( & self , instance : Instance < ' tcx > ) -> & ' ll llvm:: Value {
93+ ///
94+ /// This has the side-effect of causing coverage codegen to consider this
95+ /// function "used", making it eligible to emit an associated covfun record.
96+ fn ensure_pgo_func_name_var ( & self , instance : Instance < ' tcx > ) -> & ' ll llvm:: Value {
9497 debug ! ( "getting pgo_func_name_var for instance={:?}" , instance) ;
9598 let mut pgo_func_name_var_map = self . coverage_cx ( ) . pgo_func_name_var_map . borrow_mut ( ) ;
9699 pgo_func_name_var_map. entry ( instance) . or_insert_with ( || {
@@ -114,7 +117,7 @@ impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
114117 return ;
115118 }
116119
117- let fn_name = self . get_pgo_func_name_var ( instance) ;
120+ let fn_name = self . ensure_pgo_func_name_var ( instance) ;
118121 let hash = self . const_u64 ( function_coverage_info. function_source_hash ) ;
119122 let bitmap_bits = self . const_u32 ( function_coverage_info. mcdc_bitmap_bits as u32 ) ;
120123 self . mcdc_parameters ( fn_name, hash, bitmap_bits) ;
@@ -170,7 +173,7 @@ impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
170173 CoverageKind :: VirtualCounter { bcb }
171174 if let Some ( & id) = ids_info. phys_counter_for_node . get ( & bcb) =>
172175 {
173- let fn_name = bx. get_pgo_func_name_var ( instance) ;
176+ let fn_name = bx. ensure_pgo_func_name_var ( instance) ;
174177 let hash = bx. const_u64 ( function_coverage_info. function_source_hash ) ;
175178 let num_counters = bx. const_u32 ( ids_info. num_counters ) ;
176179 let index = bx. const_u32 ( id. as_u32 ( ) ) ;
@@ -200,7 +203,7 @@ impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
200203 "bitmap index of the decision out of range"
201204 ) ;
202205
203- let fn_name = bx. get_pgo_func_name_var ( instance) ;
206+ let fn_name = bx. ensure_pgo_func_name_var ( instance) ;
204207 let hash = bx. const_u64 ( function_coverage_info. function_source_hash ) ;
205208 let bitmap_index = bx. const_u32 ( bitmap_idx) ;
206209 bx. mcdc_tvbitmap_update ( fn_name, hash, bitmap_index, cond_bitmap) ;
0 commit comments