@@ -30,7 +30,7 @@ pub struct CrateCoverageContext<'ll, 'tcx> {
30
30
pub ( crate ) function_coverage_map :
31
31
RefCell < FxIndexMap < Instance < ' tcx > , FunctionCoverageCollector < ' tcx > > > ,
32
32
pub ( crate ) pgo_func_name_var_map : RefCell < FxHashMap < Instance < ' tcx > , & ' ll llvm:: Value > > ,
33
- pub ( crate ) mcdc_condition_bitmap_map : RefCell < FxHashMap < Instance < ' tcx > , & ' ll llvm:: Value > > ,
33
+ pub ( crate ) mcdc_condition_bitmap_map : RefCell < FxHashMap < Instance < ' tcx > , Vec < & ' ll llvm:: Value > > > ,
34
34
}
35
35
36
36
impl < ' ll , ' tcx > CrateCoverageContext < ' ll , ' tcx > {
@@ -50,8 +50,11 @@ impl<'ll, 'tcx> CrateCoverageContext<'ll, 'tcx> {
50
50
51
51
/// LLVM use a temp value to record evaluated mcdc test vector of each decision, which is called condition bitmap.
52
52
/// This value is named `mcdc.addr` (same as clang) and is a 32-bit integer.
53
- fn try_get_mcdc_condition_bitmap ( & self , instance : & Instance < ' tcx > ) -> Option < & ' ll llvm:: Value > {
54
- self . mcdc_condition_bitmap_map . borrow ( ) . get ( instance) . copied ( )
53
+ fn try_get_mcdc_condition_bitmap (
54
+ & self ,
55
+ instance : & Instance < ' tcx > ,
56
+ ) -> Option < Vec < & ' ll llvm:: Value > > {
57
+ self . mcdc_condition_bitmap_map . borrow ( ) . get ( instance) . cloned ( )
55
58
}
56
59
}
57
60
@@ -150,9 +153,11 @@ impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
150
153
0 ,
151
154
"ConditionId of evaluated conditions should never be zero"
152
155
) ;
153
- let cond_bitmap = coverage_context
156
+ let cond_bitmaps = coverage_context
154
157
. try_get_mcdc_condition_bitmap ( & instance)
155
158
. expect ( "mcdc cond bitmap should have been allocated for updating" ) ;
159
+ let cond_bitmap =
160
+ cond_bitmaps. get ( 0 ) . expect ( "no mcdc cond bitmap with the given depth" ) ;
156
161
let cond_loc = bx. const_i32 ( id. as_u32 ( ) as i32 - 1 ) ;
157
162
let bool_value = bx. const_bool ( value) ;
158
163
let fn_name = bx. get_pgo_func_name_var ( instance) ;
@@ -161,9 +166,11 @@ impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
161
166
}
162
167
CoverageKind :: TestVectorBitmapUpdate { bitmap_idx } => {
163
168
drop ( coverage_map) ;
164
- let cond_bitmap = coverage_context
169
+ let cond_bitmaps = coverage_context
165
170
. try_get_mcdc_condition_bitmap ( & instance)
166
171
. expect ( "mcdc cond bitmap should have been allocated for merging into the global bitmap" ) ;
172
+ let cond_bitmap =
173
+ cond_bitmaps. get ( 0 ) . expect ( "no mcdc cond bitmap with the given depth" ) ;
167
174
let bitmap_bytes = bx. tcx ( ) . coverage_ids_info ( instance. def ) . mcdc_bitmap_bytes ;
168
175
assert ! ( bitmap_idx < bitmap_bytes, "bitmap index of the decision out of range" ) ;
169
176
assert ! (
@@ -195,7 +202,7 @@ fn ensure_mcdc_parameters<'ll, 'tcx>(
195
202
let fn_name = bx. get_pgo_func_name_var ( instance) ;
196
203
let hash = bx. const_u64 ( function_coverage_info. function_source_hash ) ;
197
204
let bitmap_bytes = bx. const_u32 ( function_coverage_info. mcdc_bitmap_bytes ) ;
198
- let cond_bitmap = bx. mcdc_parameters ( fn_name, hash, bitmap_bytes) ;
205
+ let cond_bitmap = bx. mcdc_parameters ( fn_name, hash, bitmap_bytes, 1_u32 ) ;
199
206
bx. coverage_context ( )
200
207
. expect ( "already checked above" )
201
208
. mcdc_condition_bitmap_map
0 commit comments