@@ -90,7 +90,10 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
90
90
/// string, to hold the function name passed to LLVM intrinsic
91
91
/// `instrprof.increment()`. The `Value` is only created once per instance.
92
92
/// 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 {
94
97
debug ! ( "getting pgo_func_name_var for instance={:?}" , instance) ;
95
98
let mut pgo_func_name_var_map = self . coverage_cx ( ) . pgo_func_name_var_map . borrow_mut ( ) ;
96
99
pgo_func_name_var_map. entry ( instance) . or_insert_with ( || {
@@ -114,7 +117,7 @@ impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
114
117
return ;
115
118
}
116
119
117
- let fn_name = self . get_pgo_func_name_var ( instance) ;
120
+ let fn_name = self . ensure_pgo_func_name_var ( instance) ;
118
121
let hash = self . const_u64 ( function_coverage_info. function_source_hash ) ;
119
122
let bitmap_bits = self . const_u32 ( function_coverage_info. mcdc_bitmap_bits as u32 ) ;
120
123
self . mcdc_parameters ( fn_name, hash, bitmap_bits) ;
@@ -170,7 +173,7 @@ impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
170
173
CoverageKind :: VirtualCounter { bcb }
171
174
if let Some ( & id) = ids_info. phys_counter_for_node . get ( & bcb) =>
172
175
{
173
- let fn_name = bx. get_pgo_func_name_var ( instance) ;
176
+ let fn_name = bx. ensure_pgo_func_name_var ( instance) ;
174
177
let hash = bx. const_u64 ( function_coverage_info. function_source_hash ) ;
175
178
let num_counters = bx. const_u32 ( ids_info. num_counters ) ;
176
179
let index = bx. const_u32 ( id. as_u32 ( ) ) ;
@@ -200,7 +203,7 @@ impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
200
203
"bitmap index of the decision out of range"
201
204
) ;
202
205
203
- let fn_name = bx. get_pgo_func_name_var ( instance) ;
206
+ let fn_name = bx. ensure_pgo_func_name_var ( instance) ;
204
207
let hash = bx. const_u64 ( function_coverage_info. function_source_hash ) ;
205
208
let bitmap_index = bx. const_u32 ( bitmap_idx) ;
206
209
bx. mcdc_tvbitmap_update ( fn_name, hash, bitmap_index, cond_bitmap) ;
0 commit comments