@@ -7,7 +7,6 @@ use rustc_codegen_ssa::traits::{
77} ;
88use rustc_data_structures:: fx:: { FxHashMap , FxIndexMap } ;
99use rustc_llvm:: RustString ;
10- use rustc_middle:: bug;
1110use rustc_middle:: mir:: coverage:: CoverageKind ;
1211use rustc_middle:: ty:: Instance ;
1312use rustc_middle:: ty:: layout:: HasTyCtxt ;
@@ -76,15 +75,11 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
7675 /// `instrprof.increment()`. The `Value` is only created once per instance.
7776 /// Multiple invocations with the same instance return the same `Value`.
7877 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) )
8883 }
8984}
9085
@@ -118,11 +113,7 @@ impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
118113 cond_bitmaps. push ( cond_bitmap) ;
119114 }
120115
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) ;
126117 }
127118
128119 #[ instrument( level = "debug" , skip( self ) ) ]
@@ -143,8 +134,7 @@ impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
143134 return ;
144135 } ;
145136
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 ( ) ;
148138 let func_coverage = coverage_map
149139 . entry ( instance)
150140 . or_insert_with ( || FunctionCoverageCollector :: new ( instance, function_coverage_info) ) ;
@@ -186,15 +176,16 @@ impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
186176 }
187177 CoverageKind :: CondBitmapUpdate { index, decision_depth } => {
188178 drop ( coverage_map) ;
189- let cond_bitmap = coverage_context
179+ let cond_bitmap = bx
180+ . coverage_cx ( )
190181 . try_get_mcdc_condition_bitmap ( & instance, decision_depth)
191182 . expect ( "mcdc cond bitmap should have been allocated for updating" ) ;
192183 let cond_index = bx. const_i32 ( index as i32 ) ;
193184 bx. mcdc_condbitmap_update ( cond_index, cond_bitmap) ;
194185 }
195186 CoverageKind :: TestVectorBitmapUpdate { bitmap_idx, decision_depth } => {
196187 drop ( coverage_map) ;
197- let cond_bitmap = coverage_context
188+ let cond_bitmap = bx . coverage_cx ( )
198189 . try_get_mcdc_condition_bitmap ( & instance, decision_depth)
199190 . expect ( "mcdc cond bitmap should have been allocated for merging into the global bitmap" ) ;
200191 assert ! (
0 commit comments