@@ -7,7 +7,6 @@ use rustc_codegen_ssa::traits::{
7
7
} ;
8
8
use rustc_data_structures:: fx:: { FxHashMap , FxIndexMap } ;
9
9
use rustc_llvm:: RustString ;
10
- use rustc_middle:: bug;
11
10
use rustc_middle:: mir:: coverage:: CoverageKind ;
12
11
use rustc_middle:: ty:: Instance ;
13
12
use rustc_middle:: ty:: layout:: HasTyCtxt ;
@@ -76,15 +75,11 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
76
75
/// `instrprof.increment()`. The `Value` is only created once per instance.
77
76
/// Multiple invocations with the same instance return the same `Value`.
78
77
fn get_pgo_func_name_var ( & self , instance : Instance < ' tcx > ) -> & ' ll llvm:: Value {
79
- if let Some ( coverage_context) = self . coverage_context ( ) {
80
- debug ! ( "getting pgo_func_name_var for instance={:?}" , instance) ;
81
- let mut pgo_func_name_var_map = coverage_context. pgo_func_name_var_map . borrow_mut ( ) ;
82
- pgo_func_name_var_map
83
- . entry ( instance)
84
- . or_insert_with ( || create_pgo_func_name_var ( self , instance) )
85
- } else {
86
- bug ! ( "Could not get the `coverage_context`" ) ;
87
- }
78
+ debug ! ( "getting pgo_func_name_var for instance={:?}" , instance) ;
79
+ let mut pgo_func_name_var_map = self . coverage_cx ( ) . pgo_func_name_var_map . borrow_mut ( ) ;
80
+ pgo_func_name_var_map
81
+ . entry ( instance)
82
+ . or_insert_with ( || create_pgo_func_name_var ( self , instance) )
88
83
}
89
84
}
90
85
@@ -118,11 +113,7 @@ impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
118
113
cond_bitmaps. push ( cond_bitmap) ;
119
114
}
120
115
121
- self . coverage_context ( )
122
- . expect ( "always present when coverage is enabled" )
123
- . mcdc_condition_bitmap_map
124
- . borrow_mut ( )
125
- . insert ( instance, cond_bitmaps) ;
116
+ self . coverage_cx ( ) . mcdc_condition_bitmap_map . borrow_mut ( ) . insert ( instance, cond_bitmaps) ;
126
117
}
127
118
128
119
#[ instrument( level = "debug" , skip( self ) ) ]
@@ -143,8 +134,7 @@ impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
143
134
return ;
144
135
} ;
145
136
146
- let Some ( coverage_context) = bx. coverage_context ( ) else { return } ;
147
- let mut coverage_map = coverage_context. function_coverage_map . borrow_mut ( ) ;
137
+ let mut coverage_map = bx. coverage_cx ( ) . function_coverage_map . borrow_mut ( ) ;
148
138
let func_coverage = coverage_map
149
139
. entry ( instance)
150
140
. or_insert_with ( || FunctionCoverageCollector :: new ( instance, function_coverage_info) ) ;
@@ -186,15 +176,16 @@ impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
186
176
}
187
177
CoverageKind :: CondBitmapUpdate { index, decision_depth } => {
188
178
drop ( coverage_map) ;
189
- let cond_bitmap = coverage_context
179
+ let cond_bitmap = bx
180
+ . coverage_cx ( )
190
181
. try_get_mcdc_condition_bitmap ( & instance, decision_depth)
191
182
. expect ( "mcdc cond bitmap should have been allocated for updating" ) ;
192
183
let cond_index = bx. const_i32 ( index as i32 ) ;
193
184
bx. mcdc_condbitmap_update ( cond_index, cond_bitmap) ;
194
185
}
195
186
CoverageKind :: TestVectorBitmapUpdate { bitmap_idx, decision_depth } => {
196
187
drop ( coverage_map) ;
197
- let cond_bitmap = coverage_context
188
+ let cond_bitmap = bx . coverage_cx ( )
198
189
. try_get_mcdc_condition_bitmap ( & instance, decision_depth)
199
190
. expect ( "mcdc cond bitmap should have been allocated for merging into the global bitmap" ) ;
200
191
assert ! (
0 commit comments