mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
coverage: Replace max_decision_depth
with num_condition_bitmaps
This clearly distinguishes individual decision-depth indices from the total number of condition bitmaps to allocate.
This commit is contained in:
parent
0b3a47900e
commit
de972b7321
@ -110,7 +110,7 @@ impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
|
|||||||
|
|
||||||
// Create pointers named `mcdc.addr.{i}` to stack-allocated condition bitmaps.
|
// Create pointers named `mcdc.addr.{i}` to stack-allocated condition bitmaps.
|
||||||
let mut cond_bitmaps = vec![];
|
let mut cond_bitmaps = vec![];
|
||||||
for i in 0..=function_coverage_info.mcdc_max_decision_depth {
|
for i in 0..function_coverage_info.mcdc_num_condition_bitmaps {
|
||||||
// MC/DC intrinsics will perform loads/stores that use the ABI default
|
// MC/DC intrinsics will perform loads/stores that use the ABI default
|
||||||
// alignment for i32, so our variable declaration should match.
|
// alignment for i32, so our variable declaration should match.
|
||||||
let align = self.tcx.data_layout.i32_align.abi;
|
let align = self.tcx.data_layout.i32_align.abi;
|
||||||
|
@ -277,7 +277,7 @@ pub struct FunctionCoverageInfo {
|
|||||||
pub mappings: Vec<Mapping>,
|
pub mappings: Vec<Mapping>,
|
||||||
/// The depth of the deepest decision is used to know how many
|
/// The depth of the deepest decision is used to know how many
|
||||||
/// temp condbitmaps should be allocated for the function.
|
/// temp condbitmaps should be allocated for the function.
|
||||||
pub mcdc_max_decision_depth: u16,
|
pub mcdc_num_condition_bitmaps: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Branch information recorded during THIR-to-MIR lowering, and stored in MIR.
|
/// Branch information recorded during THIR-to-MIR lowering, and stored in MIR.
|
||||||
|
@ -102,7 +102,7 @@ fn instrument_function_for_coverage<'tcx>(tcx: TyCtxt<'tcx>, mir_body: &mut mir:
|
|||||||
|
|
||||||
inject_mcdc_statements(mir_body, &basic_coverage_blocks, &coverage_spans);
|
inject_mcdc_statements(mir_body, &basic_coverage_blocks, &coverage_spans);
|
||||||
|
|
||||||
let mcdc_max_decision_depth = coverage_spans
|
let mcdc_num_condition_bitmaps = coverage_spans
|
||||||
.mappings
|
.mappings
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|bcb_mapping| match bcb_mapping.kind {
|
.filter_map(|bcb_mapping| match bcb_mapping.kind {
|
||||||
@ -110,7 +110,7 @@ fn instrument_function_for_coverage<'tcx>(tcx: TyCtxt<'tcx>, mir_body: &mut mir:
|
|||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.max()
|
.max()
|
||||||
.unwrap_or(0);
|
.map_or(0, |max| usize::from(max) + 1);
|
||||||
|
|
||||||
mir_body.function_coverage_info = Some(Box::new(FunctionCoverageInfo {
|
mir_body.function_coverage_info = Some(Box::new(FunctionCoverageInfo {
|
||||||
function_source_hash: hir_info.function_source_hash,
|
function_source_hash: hir_info.function_source_hash,
|
||||||
@ -118,7 +118,7 @@ fn instrument_function_for_coverage<'tcx>(tcx: TyCtxt<'tcx>, mir_body: &mut mir:
|
|||||||
mcdc_bitmap_bytes: coverage_spans.test_vector_bitmap_bytes(),
|
mcdc_bitmap_bytes: coverage_spans.test_vector_bitmap_bytes(),
|
||||||
expressions: coverage_counters.into_expressions(),
|
expressions: coverage_counters.into_expressions(),
|
||||||
mappings,
|
mappings,
|
||||||
mcdc_max_decision_depth,
|
mcdc_num_condition_bitmaps,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user