Skip to content

Commit a8ff937

Browse files
authored
Rollup merge of #125108 - Zalathar:info-bitmap-bytes, r=nnethercote
coverage: `CoverageIdsInfo::mcdc_bitmap_bytes` is never needed This code for recalculating `mcdc_bitmap_bytes` in a query doesn't provide any benefit, because its result won't have changed from the value in `FunctionCoverageInfo` that was computed during the MIR instrumentation pass. Extracted from #124571, to avoid having this held up by unrelated issues with condition count checks. `@rustbot` label +A-code-coverage
2 parents 03ff673 + c81be68 commit a8ff937

File tree

4 files changed

+2
-27
lines changed

4 files changed

+2
-27
lines changed

Diff for: compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,8 @@ impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
207207
let cond_bitmap = coverage_context
208208
.try_get_mcdc_condition_bitmap(&instance, decision_depth)
209209
.expect("mcdc cond bitmap should have been allocated for merging into the global bitmap");
210-
let bitmap_bytes = bx.tcx().coverage_ids_info(instance.def).mcdc_bitmap_bytes;
210+
let bitmap_bytes = function_coverage_info.mcdc_bitmap_bytes;
211211
assert!(bitmap_idx < bitmap_bytes, "bitmap index of the decision out of range");
212-
assert!(
213-
bitmap_bytes <= function_coverage_info.mcdc_bitmap_bytes,
214-
"bitmap length disagreement: query says {bitmap_bytes} but function info only has {}",
215-
function_coverage_info.mcdc_bitmap_bytes
216-
);
217212

218213
let fn_name = bx.get_pgo_func_name_var(instance);
219214
let hash = bx.const_u64(function_coverage_info.function_source_hash);

Diff for: compiler/rustc_middle/src/mir/coverage.rs

-6
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,11 @@ pub enum CoverageKind {
129129
/// Marks the point in MIR control flow represented by a evaluated condition.
130130
///
131131
/// This is eventually lowered to `llvm.instrprof.mcdc.condbitmap.update` in LLVM IR.
132-
///
133-
/// If this statement does not survive MIR optimizations, the condition would never be
134-
/// taken as evaluated.
135132
CondBitmapUpdate { id: ConditionId, value: bool, decision_depth: u16 },
136133

137134
/// Marks the point in MIR control flow represented by a evaluated decision.
138135
///
139136
/// This is eventually lowered to `llvm.instrprof.mcdc.tvbitmap.update` in LLVM IR.
140-
///
141-
/// If this statement does not survive MIR optimizations, the decision would never be
142-
/// taken as evaluated.
143137
TestVectorBitmapUpdate { bitmap_idx: u32, decision_depth: u16 },
144138
}
145139

Diff for: compiler/rustc_middle/src/mir/query.rs

-4
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,4 @@ pub struct CoverageIdsInfo {
362362
/// InstrumentCoverage MIR pass, if the highest-numbered counter increments
363363
/// were removed by MIR optimizations.
364364
pub max_counter_id: mir::coverage::CounterId,
365-
366-
/// Coverage codegen for mcdc needs to know the size of the global bitmap so that it can
367-
/// set the `bytemap-bytes` argument of the `llvm.instrprof.mcdc.tvbitmap.update` intrinsic.
368-
pub mcdc_bitmap_bytes: u32,
369365
}

Diff for: compiler/rustc_mir_transform/src/coverage/query.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,7 @@ fn coverage_ids_info<'tcx>(
6161
.max()
6262
.unwrap_or(CounterId::ZERO);
6363

64-
let mcdc_bitmap_bytes = mir_body
65-
.coverage_branch_info
66-
.as_deref()
67-
.map(|info| {
68-
info.mcdc_decision_spans
69-
.iter()
70-
.fold(0, |acc, decision| acc + (1_u32 << decision.conditions_num).div_ceil(8))
71-
})
72-
.unwrap_or_default();
73-
74-
CoverageIdsInfo { max_counter_id, mcdc_bitmap_bytes }
64+
CoverageIdsInfo { max_counter_id }
7565
}
7666

7767
fn all_coverage_in_mir_body<'a, 'tcx>(

0 commit comments

Comments
 (0)