Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6e3e19f

Browse files
author
zhuyunxing
committedOct 8, 2024
coverage. Adapt to mcdc mapping formats introduced by llvm 19
1 parent 99bd601 commit 6e3e19f

File tree

22 files changed

+493
-488
lines changed

22 files changed

+493
-488
lines changed
 

‎compiler/rustc_codegen_llvm/src/builder.rs

Lines changed: 13 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,9 +1679,9 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
16791679
&mut self,
16801680
fn_name: &'ll Value,
16811681
hash: &'ll Value,
1682-
bitmap_bytes: &'ll Value,
1682+
bitmap_bits: &'ll Value,
16831683
) {
1684-
debug!("mcdc_parameters() with args ({:?}, {:?}, {:?})", fn_name, hash, bitmap_bytes);
1684+
debug!("mcdc_parameters() with args ({:?}, {:?}, {:?})", fn_name, hash, bitmap_bits);
16851685

16861686
assert!(
16871687
crate::llvm_util::get_version() >= (19, 0, 0),
@@ -1693,7 +1693,7 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
16931693
&[self.cx.type_ptr(), self.cx.type_i64(), self.cx.type_i32()],
16941694
self.cx.type_void(),
16951695
);
1696-
let args = &[fn_name, hash, bitmap_bytes];
1696+
let args = &[fn_name, hash, bitmap_bits];
16971697
let args = self.check_call("call", llty, llfn, args);
16981698

16991699
unsafe {
@@ -1713,13 +1713,12 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
17131713
&mut self,
17141714
fn_name: &'ll Value,
17151715
hash: &'ll Value,
1716-
bitmap_bytes: &'ll Value,
17171716
bitmap_index: &'ll Value,
17181717
mcdc_temp: &'ll Value,
17191718
) {
17201719
debug!(
1721-
"mcdc_tvbitmap_update() with args ({:?}, {:?}, {:?}, {:?}, {:?})",
1722-
fn_name, hash, bitmap_bytes, bitmap_index, mcdc_temp
1720+
"mcdc_tvbitmap_update() with args ({:?}, {:?}, {:?}, {:?})",
1721+
fn_name, hash, bitmap_index, mcdc_temp
17231722
);
17241723
assert!(
17251724
crate::llvm_util::get_version() >= (19, 0, 0),
@@ -1729,16 +1728,10 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
17291728
let llfn =
17301729
unsafe { llvm::LLVMRustGetInstrProfMCDCTVBitmapUpdateIntrinsic(self.cx().llmod) };
17311730
let llty = self.cx.type_func(
1732-
&[
1733-
self.cx.type_ptr(),
1734-
self.cx.type_i64(),
1735-
self.cx.type_i32(),
1736-
self.cx.type_i32(),
1737-
self.cx.type_ptr(),
1738-
],
1731+
&[self.cx.type_ptr(), self.cx.type_i64(), self.cx.type_i32(), self.cx.type_ptr()],
17391732
self.cx.type_void(),
17401733
);
1741-
let args = &[fn_name, hash, bitmap_bytes, bitmap_index, mcdc_temp];
1734+
let args = &[fn_name, hash, bitmap_index, mcdc_temp];
17421735
let args = self.check_call("call", llty, llfn, args);
17431736
unsafe {
17441737
let _ = llvm::LLVMRustBuildCall(
@@ -1754,45 +1747,15 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
17541747
self.store(self.const_i32(0), mcdc_temp, self.tcx.data_layout.i32_align.abi);
17551748
}
17561749

1757-
pub(crate) fn mcdc_condbitmap_update(
1758-
&mut self,
1759-
fn_name: &'ll Value,
1760-
hash: &'ll Value,
1761-
cond_loc: &'ll Value,
1762-
mcdc_temp: &'ll Value,
1763-
bool_value: &'ll Value,
1764-
) {
1765-
debug!(
1766-
"mcdc_condbitmap_update() with args ({:?}, {:?}, {:?}, {:?}, {:?})",
1767-
fn_name, hash, cond_loc, mcdc_temp, bool_value
1768-
);
1750+
pub(crate) fn mcdc_condbitmap_update(&mut self, cond_index: &'ll Value, mcdc_temp: &'ll Value) {
1751+
debug!("mcdc_condbitmap_update() with args ({:?}, {:?})", cond_index, mcdc_temp);
17691752
assert!(
17701753
crate::llvm_util::get_version() >= (19, 0, 0),
17711754
"MCDC intrinsics require LLVM 19 or later"
17721755
);
1773-
let llfn = unsafe { llvm::LLVMRustGetInstrProfMCDCCondBitmapIntrinsic(self.cx().llmod) };
1774-
let llty = self.cx.type_func(
1775-
&[
1776-
self.cx.type_ptr(),
1777-
self.cx.type_i64(),
1778-
self.cx.type_i32(),
1779-
self.cx.type_ptr(),
1780-
self.cx.type_i1(),
1781-
],
1782-
self.cx.type_void(),
1783-
);
1784-
let args = &[fn_name, hash, cond_loc, mcdc_temp, bool_value];
1785-
self.check_call("call", llty, llfn, args);
1786-
unsafe {
1787-
let _ = llvm::LLVMRustBuildCall(
1788-
self.llbuilder,
1789-
llty,
1790-
llfn,
1791-
args.as_ptr() as *const &llvm::Value,
1792-
args.len() as c_uint,
1793-
[].as_ptr(),
1794-
0 as c_uint,
1795-
);
1796-
}
1756+
let align = self.tcx.data_layout.i32_align.abi;
1757+
let current_tv_index = self.load(self.cx.type_i32(), mcdc_temp, align);
1758+
let new_tv_index = self.add(current_tv_index, cond_index);
1759+
self.store(new_tv_index, mcdc_temp, align);
17971760
}
17981761
}

‎compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,14 @@ impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
9898
};
9999

100100
// If there are no MC/DC bitmaps to set up, return immediately.
101-
if function_coverage_info.mcdc_bitmap_bytes == 0 {
101+
if function_coverage_info.mcdc_bitmap_bits == 0 {
102102
return;
103103
}
104104

105105
let fn_name = self.get_pgo_func_name_var(instance);
106106
let hash = self.const_u64(function_coverage_info.function_source_hash);
107-
let bitmap_bytes = self.const_u32(function_coverage_info.mcdc_bitmap_bytes);
108-
self.mcdc_parameters(fn_name, hash, bitmap_bytes);
107+
let bitmap_bits = self.const_u32(function_coverage_info.mcdc_bitmap_bits as u32);
108+
self.mcdc_parameters(fn_name, hash, bitmap_bits);
109109

110110
// Create pointers named `mcdc.addr.{i}` to stack-allocated condition bitmaps.
111111
let mut cond_bitmaps = vec![];
@@ -185,35 +185,28 @@ impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
185185
CoverageKind::ExpressionUsed { id } => {
186186
func_coverage.mark_expression_id_seen(id);
187187
}
188-
CoverageKind::CondBitmapUpdate { id, value, decision_depth } => {
188+
CoverageKind::CondBitmapUpdate { index, decision_depth } => {
189189
drop(coverage_map);
190-
assert_ne!(
191-
id.as_u32(),
192-
0,
193-
"ConditionId of evaluated conditions should never be zero"
194-
);
195190
let cond_bitmap = coverage_context
196191
.try_get_mcdc_condition_bitmap(&instance, decision_depth)
197192
.expect("mcdc cond bitmap should have been allocated for updating");
198-
let cond_loc = bx.const_i32(id.as_u32() as i32 - 1);
199-
let bool_value = bx.const_bool(value);
200-
let fn_name = bx.get_pgo_func_name_var(instance);
201-
let hash = bx.const_u64(function_coverage_info.function_source_hash);
202-
bx.mcdc_condbitmap_update(fn_name, hash, cond_loc, cond_bitmap, bool_value);
193+
let cond_index = bx.const_i32(index as i32);
194+
bx.mcdc_condbitmap_update(cond_index, cond_bitmap);
203195
}
204196
CoverageKind::TestVectorBitmapUpdate { bitmap_idx, decision_depth } => {
205197
drop(coverage_map);
206198
let cond_bitmap = coverage_context
207199
.try_get_mcdc_condition_bitmap(&instance, decision_depth)
208200
.expect("mcdc cond bitmap should have been allocated for merging into the global bitmap");
209-
let bitmap_bytes = function_coverage_info.mcdc_bitmap_bytes;
210-
assert!(bitmap_idx < bitmap_bytes, "bitmap index of the decision out of range");
201+
assert!(
202+
bitmap_idx as usize <= function_coverage_info.mcdc_bitmap_bits,
203+
"bitmap index of the decision out of range"
204+
);
211205

212206
let fn_name = bx.get_pgo_func_name_var(instance);
213207
let hash = bx.const_u64(function_coverage_info.function_source_hash);
214-
let bitmap_bytes = bx.const_u32(bitmap_bytes);
215208
let bitmap_index = bx.const_u32(bitmap_idx);
216-
bx.mcdc_tvbitmap_update(fn_name, hash, bitmap_bytes, bitmap_index, cond_bitmap);
209+
bx.mcdc_tvbitmap_update(fn_name, hash, bitmap_index, cond_bitmap);
217210
}
218211
}
219212
}

‎compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1614,7 +1614,6 @@ unsafe extern "C" {
16141614
pub fn LLVMRustGetInstrProfIncrementIntrinsic(M: &Module) -> &Value;
16151615
pub fn LLVMRustGetInstrProfMCDCParametersIntrinsic(M: &Module) -> &Value;
16161616
pub fn LLVMRustGetInstrProfMCDCTVBitmapUpdateIntrinsic(M: &Module) -> &Value;
1617-
pub fn LLVMRustGetInstrProfMCDCCondBitmapIntrinsic(M: &Module) -> &Value;
16181617

16191618
pub fn LLVMRustBuildCall<'a>(
16201619
B: &Builder<'a>,

‎compiler/rustc_middle/src/mir/coverage.rs

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ pub enum CoverageKind {
128128

129129
/// Marks the point in MIR control flow represented by a evaluated condition.
130130
///
131-
/// This is eventually lowered to `llvm.instrprof.mcdc.condbitmap.update` in LLVM IR.
132-
CondBitmapUpdate { id: ConditionId, value: bool, decision_depth: u16 },
131+
/// This is eventually lowered to instruments updating mcdc temp variables.
132+
CondBitmapUpdate { index: u32, decision_depth: u16 },
133133

134134
/// Marks the point in MIR control flow represented by a evaluated decision.
135135
///
@@ -145,14 +145,8 @@ impl Debug for CoverageKind {
145145
BlockMarker { id } => write!(fmt, "BlockMarker({:?})", id.index()),
146146
CounterIncrement { id } => write!(fmt, "CounterIncrement({:?})", id.index()),
147147
ExpressionUsed { id } => write!(fmt, "ExpressionUsed({:?})", id.index()),
148-
CondBitmapUpdate { id, value, decision_depth } => {
149-
write!(
150-
fmt,
151-
"CondBitmapUpdate({:?}, {:?}, depth={:?})",
152-
id.index(),
153-
value,
154-
decision_depth
155-
)
148+
CondBitmapUpdate { index, decision_depth } => {
149+
write!(fmt, "CondBitmapUpdate(index={:?}, depth={:?})", index, decision_depth)
156150
}
157151
TestVectorBitmapUpdate { bitmap_idx, decision_depth } => {
158152
write!(fmt, "TestVectorUpdate({:?}, depth={:?})", bitmap_idx, decision_depth)
@@ -253,7 +247,7 @@ pub struct Mapping {
253247
pub struct FunctionCoverageInfo {
254248
pub function_source_hash: u64,
255249
pub num_counters: usize,
256-
pub mcdc_bitmap_bytes: u32,
250+
pub mcdc_bitmap_bits: usize,
257251
pub expressions: IndexVec<ExpressionId, Expression>,
258252
pub mappings: Vec<Mapping>,
259253
/// The depth of the deepest decision is used to know how many
@@ -275,8 +269,10 @@ pub struct CoverageInfoHi {
275269
/// data structures without having to scan the entire body first.
276270
pub num_block_markers: usize,
277271
pub branch_spans: Vec<BranchSpan>,
278-
pub mcdc_branch_spans: Vec<MCDCBranchSpan>,
279-
pub mcdc_decision_spans: Vec<MCDCDecisionSpan>,
272+
/// Branch spans generated by mcdc. Because of some limits mcdc builder give up generating
273+
/// decisions including them so that they are handled as normal branch spans.
274+
pub mcdc_degraded_branch_spans: Vec<MCDCBranchSpan>,
275+
pub mcdc_spans: Vec<(MCDCDecisionSpan, Vec<MCDCBranchSpan>)>,
280276
}
281277

282278
#[derive(Clone, Debug)]
@@ -299,12 +295,9 @@ pub struct ConditionInfo {
299295
#[derive(TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable, TypeVisitable)]
300296
pub struct MCDCBranchSpan {
301297
pub span: Span,
302-
/// If `None`, this actually represents a normal branch span inserted for
303-
/// code that was too complex for MC/DC.
304-
pub condition_info: Option<ConditionInfo>,
298+
pub condition_info: ConditionInfo,
305299
pub true_marker: BlockMarkerId,
306300
pub false_marker: BlockMarkerId,
307-
pub decision_depth: u16,
308301
}
309302

310303
#[derive(Copy, Clone, Debug)]
@@ -318,7 +311,7 @@ pub struct DecisionInfo {
318311
#[derive(TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable, TypeVisitable)]
319312
pub struct MCDCDecisionSpan {
320313
pub span: Span,
321-
pub num_conditions: usize,
322314
pub end_markers: Vec<BlockMarkerId>,
323315
pub decision_depth: u16,
316+
pub num_conditions: usize,
324317
}

‎compiler/rustc_middle/src/mir/pretty.rs

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -538,8 +538,8 @@ fn write_coverage_info_hi(
538538
let coverage::CoverageInfoHi {
539539
num_block_markers: _,
540540
branch_spans,
541-
mcdc_branch_spans,
542-
mcdc_decision_spans,
541+
mcdc_degraded_branch_spans,
542+
mcdc_spans,
543543
} = coverage_info_hi;
544544

545545
// Only add an extra trailing newline if we printed at least one thing.
@@ -553,29 +553,35 @@ fn write_coverage_info_hi(
553553
did_print = true;
554554
}
555555

556-
for coverage::MCDCBranchSpan {
557-
span,
558-
condition_info,
559-
true_marker,
560-
false_marker,
561-
decision_depth,
562-
} in mcdc_branch_spans
556+
for coverage::MCDCBranchSpan { span, true_marker, false_marker, .. } in
557+
mcdc_degraded_branch_spans
563558
{
564559
writeln!(
565560
w,
566-
"{INDENT}coverage mcdc branch {{ condition_id: {:?}, true: {true_marker:?}, false: {false_marker:?}, depth: {decision_depth:?} }} => {span:?}",
567-
condition_info.map(|info| info.condition_id)
561+
"{INDENT}coverage branch {{ true: {true_marker:?}, false: {false_marker:?} }} => {span:?}",
568562
)?;
569563
did_print = true;
570564
}
571565

572-
for coverage::MCDCDecisionSpan { span, num_conditions, end_markers, decision_depth } in
573-
mcdc_decision_spans
566+
for (
567+
coverage::MCDCDecisionSpan { span, end_markers, decision_depth, num_conditions: _ },
568+
conditions,
569+
) in mcdc_spans
574570
{
571+
let num_conditions = conditions.len();
575572
writeln!(
576573
w,
577574
"{INDENT}coverage mcdc decision {{ num_conditions: {num_conditions:?}, end: {end_markers:?}, depth: {decision_depth:?} }} => {span:?}"
578575
)?;
576+
for coverage::MCDCBranchSpan { span, condition_info, true_marker, false_marker } in
577+
conditions
578+
{
579+
writeln!(
580+
w,
581+
"{INDENT}coverage mcdc branch {{ condition_id: {:?}, true: {true_marker:?}, false: {false_marker:?} }} => {span:?}",
582+
condition_info.condition_id
583+
)?;
584+
}
579585
did_print = true;
580586
}
581587

‎compiler/rustc_mir_build/src/build/coverageinfo.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,16 @@ impl CoverageInfoBuilder {
175175
let branch_spans =
176176
branch_info.map(|branch_info| branch_info.branch_spans).unwrap_or_default();
177177

178-
let (mcdc_decision_spans, mcdc_branch_spans) =
178+
let (mcdc_spans, mcdc_degraded_branch_spans) =
179179
mcdc_info.map(MCDCInfoBuilder::into_done).unwrap_or_default();
180180

181181
// For simplicity, always return an info struct (without Option), even
182182
// if there's nothing interesting in it.
183183
Box::new(CoverageInfoHi {
184184
num_block_markers,
185185
branch_spans,
186-
mcdc_branch_spans,
187-
mcdc_decision_spans,
186+
mcdc_degraded_branch_spans,
187+
mcdc_spans,
188188
})
189189
}
190190
}

‎compiler/rustc_mir_build/src/build/coverageinfo/mcdc.rs

Lines changed: 51 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ use rustc_span::Span;
1212
use crate::build::Builder;
1313
use crate::errors::MCDCExceedsConditionLimit;
1414

15-
/// The MCDC bitmap scales exponentially (2^n) based on the number of conditions seen,
16-
/// So llvm sets a maximum value prevents the bitmap footprint from growing too large without the user's knowledge.
17-
/// This limit may be relaxed if the [upstream change](https://github.com/llvm/llvm-project/pull/82448) is merged.
18-
const MAX_CONDITIONS_IN_DECISION: usize = 6;
15+
/// LLVM uses `i16` to represent condition id. Hence `i16::MAX` is the hard limit for number of
16+
/// conditions in a decision.
17+
const MAX_CONDITIONS_IN_DECISION: usize = i16::MAX as usize;
1918

2019
#[derive(Default)]
2120
struct MCDCDecisionCtx {
2221
/// To construct condition evaluation tree.
2322
decision_stack: VecDeque<ConditionInfo>,
2423
processing_decision: Option<MCDCDecisionSpan>,
24+
conditions: Vec<MCDCBranchSpan>,
2525
}
2626

2727
struct MCDCState {
@@ -155,16 +155,29 @@ impl MCDCState {
155155
decision_ctx.decision_stack.push_back(lhs);
156156
}
157157

158-
fn take_condition(
158+
fn try_finish_decision(
159159
&mut self,
160+
span: Span,
160161
true_marker: BlockMarkerId,
161162
false_marker: BlockMarkerId,
162-
) -> (Option<ConditionInfo>, Option<MCDCDecisionSpan>) {
163+
degraded_branches: &mut Vec<MCDCBranchSpan>,
164+
) -> Option<(MCDCDecisionSpan, Vec<MCDCBranchSpan>)> {
163165
let Some(decision_ctx) = self.decision_ctx_stack.last_mut() else {
164166
bug!("Unexpected empty decision_ctx_stack")
165167
};
166168
let Some(condition_info) = decision_ctx.decision_stack.pop_back() else {
167-
return (None, None);
169+
let branch = MCDCBranchSpan {
170+
span,
171+
condition_info: ConditionInfo {
172+
condition_id: ConditionId::START,
173+
true_next_id: None,
174+
false_next_id: None,
175+
},
176+
true_marker,
177+
false_marker,
178+
};
179+
degraded_branches.push(branch);
180+
return None;
168181
};
169182
let Some(decision) = decision_ctx.processing_decision.as_mut() else {
170183
bug!("Processing decision should have been created before any conditions are taken");
@@ -175,24 +188,31 @@ impl MCDCState {
175188
if condition_info.false_next_id.is_none() {
176189
decision.end_markers.push(false_marker);
177190
}
191+
decision_ctx.conditions.push(MCDCBranchSpan {
192+
span,
193+
condition_info,
194+
true_marker,
195+
false_marker,
196+
});
178197

179198
if decision_ctx.decision_stack.is_empty() {
180-
(Some(condition_info), decision_ctx.processing_decision.take())
199+
let conditions = std::mem::take(&mut decision_ctx.conditions);
200+
decision_ctx.processing_decision.take().map(|decision| (decision, conditions))
181201
} else {
182-
(Some(condition_info), None)
202+
None
183203
}
184204
}
185205
}
186206

187207
pub(crate) struct MCDCInfoBuilder {
188-
branch_spans: Vec<MCDCBranchSpan>,
189-
decision_spans: Vec<MCDCDecisionSpan>,
208+
degraded_spans: Vec<MCDCBranchSpan>,
209+
mcdc_spans: Vec<(MCDCDecisionSpan, Vec<MCDCBranchSpan>)>,
190210
state: MCDCState,
191211
}
192212

193213
impl MCDCInfoBuilder {
194214
pub(crate) fn new() -> Self {
195-
Self { branch_spans: vec![], decision_spans: vec![], state: MCDCState::new() }
215+
Self { degraded_spans: vec![], mcdc_spans: vec![], state: MCDCState::new() }
196216
}
197217

198218
pub(crate) fn visit_evaluated_condition(
@@ -206,50 +226,44 @@ impl MCDCInfoBuilder {
206226
let true_marker = inject_block_marker(source_info, true_block);
207227
let false_marker = inject_block_marker(source_info, false_block);
208228

209-
let decision_depth = self.state.decision_depth();
210-
let (mut condition_info, decision_result) =
211-
self.state.take_condition(true_marker, false_marker);
212229
// take_condition() returns Some for decision_result when the decision stack
213230
// is empty, i.e. when all the conditions of the decision were instrumented,
214231
// and the decision is "complete".
215-
if let Some(decision) = decision_result {
216-
match decision.num_conditions {
232+
if let Some((decision, conditions)) = self.state.try_finish_decision(
233+
source_info.span,
234+
true_marker,
235+
false_marker,
236+
&mut self.degraded_spans,
237+
) {
238+
let num_conditions = conditions.len();
239+
assert_eq!(
240+
num_conditions, decision.num_conditions,
241+
"final number of conditions is not correct"
242+
);
243+
match num_conditions {
217244
0 => {
218245
unreachable!("Decision with no condition is not expected");
219246
}
220247
1..=MAX_CONDITIONS_IN_DECISION => {
221-
self.decision_spans.push(decision);
248+
self.mcdc_spans.push((decision, conditions));
222249
}
223250
_ => {
224-
// Do not generate mcdc mappings and statements for decisions with too many conditions.
225-
// Therefore, first erase the condition info of the (N-1) previous branch spans.
226-
let rebase_idx = self.branch_spans.len() - (decision.num_conditions - 1);
227-
for branch in &mut self.branch_spans[rebase_idx..] {
228-
branch.condition_info = None;
229-
}
230-
231-
// Then, erase this last branch span's info too, for a total of N.
232-
condition_info = None;
251+
self.degraded_spans.extend(conditions);
233252

234253
tcx.dcx().emit_warn(MCDCExceedsConditionLimit {
235254
span: decision.span,
236-
num_conditions: decision.num_conditions,
255+
num_conditions,
237256
max_conditions: MAX_CONDITIONS_IN_DECISION,
238257
});
239258
}
240259
}
241260
}
242-
self.branch_spans.push(MCDCBranchSpan {
243-
span: source_info.span,
244-
condition_info,
245-
true_marker,
246-
false_marker,
247-
decision_depth,
248-
});
249261
}
250262

251-
pub(crate) fn into_done(self) -> (Vec<MCDCDecisionSpan>, Vec<MCDCBranchSpan>) {
252-
(self.decision_spans, self.branch_spans)
263+
pub(crate) fn into_done(
264+
self,
265+
) -> (Vec<(MCDCDecisionSpan, Vec<MCDCBranchSpan>)>, Vec<MCDCBranchSpan>) {
266+
(self.mcdc_spans, self.degraded_spans)
253267
}
254268
}
255269

‎compiler/rustc_mir_transform/src/coverage/mappings.rs

Lines changed: 172 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
use std::collections::BTreeSet;
22

3+
use rustc_data_structures::fx::FxIndexMap;
34
use rustc_data_structures::graph::DirectedGraph;
45
use rustc_index::IndexVec;
56
use rustc_index::bit_set::BitSet;
67
use rustc_middle::mir::coverage::{
7-
BlockMarkerId, BranchSpan, ConditionInfo, CoverageInfoHi, CoverageKind,
8+
BlockMarkerId, BranchSpan, ConditionId, ConditionInfo, CoverageInfoHi, CoverageKind,
89
};
910
use rustc_middle::mir::{self, BasicBlock, StatementKind};
1011
use rustc_middle::ty::TyCtxt;
@@ -38,22 +39,27 @@ pub(super) struct MCDCBranch {
3839
pub(super) span: Span,
3940
pub(super) true_bcb: BasicCoverageBlock,
4041
pub(super) false_bcb: BasicCoverageBlock,
41-
/// If `None`, this actually represents a normal branch mapping inserted
42-
/// for code that was too complex for MC/DC.
43-
pub(super) condition_info: Option<ConditionInfo>,
44-
pub(super) decision_depth: u16,
42+
pub(super) condition_info: ConditionInfo,
43+
// Offset added to test vector idx if this branch is evaluated to true.
44+
pub(super) true_index: usize,
45+
// Offset added to test vector idx if this branch is evaluated to false.
46+
pub(super) false_index: usize,
4547
}
4648

4749
/// Associates an MC/DC decision with its join BCBs.
4850
#[derive(Debug)]
4951
pub(super) struct MCDCDecision {
5052
pub(super) span: Span,
5153
pub(super) end_bcbs: BTreeSet<BasicCoverageBlock>,
52-
pub(super) bitmap_idx: u32,
53-
pub(super) num_conditions: u16,
54+
pub(super) bitmap_idx: usize,
55+
pub(super) num_test_vectors: usize,
5456
pub(super) decision_depth: u16,
5557
}
5658

59+
// LLVM uses `i32` to index the bitmap. Thus `i32::MAX` is the hard limit for number of all test vectors
60+
// in a function.
61+
const MCDC_MAX_BITMAP_SIZE: usize = i32::MAX as usize;
62+
5763
#[derive(Default)]
5864
pub(super) struct ExtractedMappings {
5965
/// Store our own copy of [`CoverageGraph::num_nodes`], so that we don't
@@ -62,9 +68,9 @@ pub(super) struct ExtractedMappings {
6268
pub(super) num_bcbs: usize,
6369
pub(super) code_mappings: Vec<CodeMapping>,
6470
pub(super) branch_pairs: Vec<BranchPair>,
65-
pub(super) mcdc_bitmap_bytes: u32,
66-
pub(super) mcdc_branches: Vec<MCDCBranch>,
67-
pub(super) mcdc_decisions: Vec<MCDCDecision>,
71+
pub(super) mcdc_bitmap_bits: usize,
72+
pub(super) mcdc_degraded_branches: Vec<MCDCBranch>,
73+
pub(super) mcdc_mappings: Vec<(MCDCDecision, Vec<MCDCBranch>)>,
6874
}
6975

7076
/// Extracts coverage-relevant spans from MIR, and associates them with
@@ -77,9 +83,9 @@ pub(super) fn extract_all_mapping_info_from_mir<'tcx>(
7783
) -> ExtractedMappings {
7884
let mut code_mappings = vec![];
7985
let mut branch_pairs = vec![];
80-
let mut mcdc_bitmap_bytes = 0;
81-
let mut mcdc_branches = vec![];
82-
let mut mcdc_decisions = vec![];
86+
let mut mcdc_bitmap_bits = 0;
87+
let mut mcdc_degraded_branches = vec![];
88+
let mut mcdc_mappings = vec![];
8389

8490
if hir_info.is_async_fn || tcx.sess.coverage_no_mir_spans() {
8591
// An async function desugars into a function that returns a future,
@@ -104,18 +110,18 @@ pub(super) fn extract_all_mapping_info_from_mir<'tcx>(
104110
mir_body,
105111
hir_info.body_span,
106112
basic_coverage_blocks,
107-
&mut mcdc_bitmap_bytes,
108-
&mut mcdc_branches,
109-
&mut mcdc_decisions,
113+
&mut mcdc_bitmap_bits,
114+
&mut mcdc_degraded_branches,
115+
&mut mcdc_mappings,
110116
);
111117

112118
ExtractedMappings {
113119
num_bcbs: basic_coverage_blocks.num_nodes(),
114120
code_mappings,
115121
branch_pairs,
116-
mcdc_bitmap_bytes,
117-
mcdc_branches,
118-
mcdc_decisions,
122+
mcdc_bitmap_bits,
123+
mcdc_degraded_branches,
124+
mcdc_mappings,
119125
}
120126
}
121127

@@ -126,9 +132,9 @@ impl ExtractedMappings {
126132
num_bcbs,
127133
code_mappings,
128134
branch_pairs,
129-
mcdc_bitmap_bytes: _,
130-
mcdc_branches,
131-
mcdc_decisions,
135+
mcdc_bitmap_bits: _,
136+
mcdc_degraded_branches,
137+
mcdc_mappings,
132138
} = self;
133139

134140
// Identify which BCBs have one or more mappings.
@@ -144,16 +150,19 @@ impl ExtractedMappings {
144150
insert(true_bcb);
145151
insert(false_bcb);
146152
}
147-
for &MCDCBranch { true_bcb, false_bcb, .. } in mcdc_branches {
153+
for &MCDCBranch { true_bcb, false_bcb, .. } in mcdc_degraded_branches
154+
.iter()
155+
.chain(mcdc_mappings.iter().map(|(_, branches)| branches.into_iter()).flatten())
156+
{
148157
insert(true_bcb);
149158
insert(false_bcb);
150159
}
151160

152161
// MC/DC decisions refer to BCBs, but don't require those BCBs to have counters.
153162
if bcbs_with_counter_mappings.is_empty() {
154163
debug_assert!(
155-
mcdc_decisions.is_empty(),
156-
"A function with no counter mappings shouldn't have any decisions: {mcdc_decisions:?}",
164+
mcdc_mappings.is_empty(),
165+
"A function with no counter mappings shouldn't have any decisions: {mcdc_mappings:?}",
157166
);
158167
}
159168

@@ -232,9 +241,9 @@ pub(super) fn extract_mcdc_mappings(
232241
mir_body: &mir::Body<'_>,
233242
body_span: Span,
234243
basic_coverage_blocks: &CoverageGraph,
235-
mcdc_bitmap_bytes: &mut u32,
236-
mcdc_branches: &mut impl Extend<MCDCBranch>,
237-
mcdc_decisions: &mut impl Extend<MCDCDecision>,
244+
mcdc_bitmap_bits: &mut usize,
245+
mcdc_degraded_branches: &mut impl Extend<MCDCBranch>,
246+
mcdc_mappings: &mut impl Extend<(MCDCDecision, Vec<MCDCBranch>)>,
238247
) {
239248
let Some(coverage_info_hi) = mir_body.coverage_info_hi.as_deref() else { return };
240249

@@ -257,43 +266,143 @@ pub(super) fn extract_mcdc_mappings(
257266
Some((span, true_bcb, false_bcb))
258267
};
259268

260-
mcdc_branches.extend(coverage_info_hi.mcdc_branch_spans.iter().filter_map(
261-
|&mir::coverage::MCDCBranchSpan {
262-
span: raw_span,
263-
condition_info,
264-
true_marker,
265-
false_marker,
266-
decision_depth,
267-
}| {
268-
let (span, true_bcb, false_bcb) =
269-
check_branch_bcb(raw_span, true_marker, false_marker)?;
270-
Some(MCDCBranch { span, true_bcb, false_bcb, condition_info, decision_depth })
271-
},
272-
));
273-
274-
mcdc_decisions.extend(coverage_info_hi.mcdc_decision_spans.iter().filter_map(
275-
|decision: &mir::coverage::MCDCDecisionSpan| {
276-
let span = unexpand_into_body_span(decision.span, body_span)?;
277-
278-
let end_bcbs = decision
279-
.end_markers
280-
.iter()
281-
.map(|&marker| bcb_from_marker(marker))
282-
.collect::<Option<_>>()?;
283-
284-
// Each decision containing N conditions needs 2^N bits of space in
285-
// the bitmap, rounded up to a whole number of bytes.
286-
// The decision's "bitmap index" points to its first byte in the bitmap.
287-
let bitmap_idx = *mcdc_bitmap_bytes;
288-
*mcdc_bitmap_bytes += (1_u32 << decision.num_conditions).div_ceil(8);
289-
290-
Some(MCDCDecision {
269+
let to_mcdc_branch = |&mir::coverage::MCDCBranchSpan {
270+
span: raw_span,
271+
condition_info,
272+
true_marker,
273+
false_marker,
274+
}| {
275+
let (span, true_bcb, false_bcb) = check_branch_bcb(raw_span, true_marker, false_marker)?;
276+
Some(MCDCBranch {
277+
span,
278+
true_bcb,
279+
false_bcb,
280+
condition_info,
281+
true_index: usize::MAX,
282+
false_index: usize::MAX,
283+
})
284+
};
285+
286+
let mut get_bitmap_idx = |num_test_vectors: usize| -> Option<usize> {
287+
let bitmap_idx = *mcdc_bitmap_bits;
288+
let next_bitmap_bits = bitmap_idx.saturating_add(num_test_vectors);
289+
(next_bitmap_bits <= MCDC_MAX_BITMAP_SIZE).then(|| {
290+
*mcdc_bitmap_bits = next_bitmap_bits;
291+
bitmap_idx
292+
})
293+
};
294+
mcdc_degraded_branches
295+
.extend(coverage_info_hi.mcdc_degraded_branch_spans.iter().filter_map(to_mcdc_branch));
296+
297+
mcdc_mappings.extend(coverage_info_hi.mcdc_spans.iter().filter_map(|(decision, branches)| {
298+
if branches.len() == 0 {
299+
return None;
300+
}
301+
let decision_span = unexpand_into_body_span(decision.span, body_span)?;
302+
303+
let end_bcbs = decision
304+
.end_markers
305+
.iter()
306+
.map(|&marker| bcb_from_marker(marker))
307+
.collect::<Option<_>>()?;
308+
let mut branch_mappings: Vec<_> = branches.into_iter().filter_map(to_mcdc_branch).collect();
309+
if branch_mappings.len() != branches.len() {
310+
mcdc_degraded_branches.extend(branch_mappings);
311+
return None;
312+
}
313+
let num_test_vectors = calc_test_vectors_index(&mut branch_mappings);
314+
let Some(bitmap_idx) = get_bitmap_idx(num_test_vectors) else {
315+
// TODO warn about bitmap
316+
mcdc_degraded_branches.extend(branch_mappings);
317+
return None;
318+
};
319+
// LLVM requires span of the decision contains all spans of its conditions.
320+
// Usually the decision span meets the requirement well but in cases like macros it may not.
321+
let span = branch_mappings
322+
.iter()
323+
.map(|branch| branch.span)
324+
.reduce(|lhs, rhs| lhs.to(rhs))
325+
.map(
326+
|joint_span| {
327+
if decision_span.contains(joint_span) { decision_span } else { joint_span }
328+
},
329+
)
330+
.expect("branch mappings are ensured to be non-empty as checked above");
331+
Some((
332+
MCDCDecision {
291333
span,
292334
end_bcbs,
293335
bitmap_idx,
294-
num_conditions: decision.num_conditions as u16,
336+
num_test_vectors,
295337
decision_depth: decision.decision_depth,
296-
})
297-
},
298-
));
338+
},
339+
branch_mappings,
340+
))
341+
}));
342+
}
343+
344+
// LLVM checks the executed test vector by accumulating indices of tested branches.
345+
// We calculate number of all possible test vectors of the decision and assign indices
346+
// to branches here.
347+
// See [the rfc](https://discourse.llvm.org/t/rfc-coverage-new-algorithm-and-file-format-for-mc-dc/76798/)
348+
// for more details about the algorithm.
349+
// This function is mostly like [`TVIdxBuilder::TvIdxBuilder`](https://github.com/llvm/llvm-project/blob/d594d9f7f4dc6eb748b3261917db689fdc348b96/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp#L226)
350+
fn calc_test_vectors_index(conditions: &mut Vec<MCDCBranch>) -> usize {
351+
let mut indegree_stats = IndexVec::<ConditionId, usize>::from_elem_n(0, conditions.len());
352+
// `num_paths` is `width` described at the llvm rfc, which indicates how many paths reaching the condition node.
353+
let mut num_paths_stats = IndexVec::<ConditionId, usize>::from_elem_n(0, conditions.len());
354+
let mut next_conditions = conditions
355+
.iter_mut()
356+
.map(|branch| {
357+
let ConditionInfo { condition_id, true_next_id, false_next_id } = branch.condition_info;
358+
[true_next_id, false_next_id]
359+
.into_iter()
360+
.filter_map(std::convert::identity)
361+
.for_each(|next_id| indegree_stats[next_id] += 1);
362+
(condition_id, branch)
363+
})
364+
.collect::<FxIndexMap<_, _>>();
365+
366+
let mut queue = std::collections::VecDeque::from_iter(
367+
next_conditions.swap_remove(&ConditionId::START).into_iter(),
368+
);
369+
num_paths_stats[ConditionId::START] = 1;
370+
let mut decision_end_nodes = Vec::new();
371+
while let Some(branch) = queue.pop_front() {
372+
let ConditionInfo { condition_id, true_next_id, false_next_id } = branch.condition_info;
373+
let (false_index, true_index) = (&mut branch.false_index, &mut branch.true_index);
374+
let this_paths_count = num_paths_stats[condition_id];
375+
// Note. First check the false next to ensure conditions are touched in same order with llvm-cov.
376+
for (next, index) in [(false_next_id, false_index), (true_next_id, true_index)] {
377+
if let Some(next_id) = next {
378+
let next_paths_count = &mut num_paths_stats[next_id];
379+
*index = *next_paths_count;
380+
*next_paths_count = next_paths_count.saturating_add(this_paths_count);
381+
let next_indegree = &mut indegree_stats[next_id];
382+
*next_indegree -= 1;
383+
if *next_indegree == 0 {
384+
queue.push_back(next_conditions.swap_remove(&next_id).expect(
385+
"conditions with non-zero indegree before must be in next_conditions",
386+
));
387+
}
388+
} else {
389+
decision_end_nodes.push((this_paths_count, condition_id, index));
390+
}
391+
}
392+
}
393+
assert!(next_conditions.is_empty(), "the decision tree has untouched nodes");
394+
let mut cur_idx = 0;
395+
// LLVM hopes the end nodes are sorted in descending order by `num_paths` so that it can
396+
// optimize bitmap size for decisions in tree form such as `a && b && c && d && ...`.
397+
decision_end_nodes.sort_by_key(|(num_paths, _, _)| usize::MAX - *num_paths);
398+
for (num_paths, condition_id, index) in decision_end_nodes {
399+
assert_eq!(
400+
num_paths, num_paths_stats[condition_id],
401+
"end nodes should not be updated since they were visited"
402+
);
403+
assert_eq!(*index, usize::MAX, "end nodes should not be assigned index before");
404+
*index = cur_idx;
405+
cur_idx += num_paths;
406+
}
407+
cur_idx
299408
}

‎compiler/rustc_mir_transform/src/coverage/mod.rs

Lines changed: 102 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,16 @@ fn instrument_function_for_coverage<'tcx>(tcx: TyCtxt<'tcx>, mir_body: &mut mir:
114114
inject_mcdc_statements(mir_body, &basic_coverage_blocks, &extracted_mappings);
115115

116116
let mcdc_num_condition_bitmaps = extracted_mappings
117-
.mcdc_decisions
117+
.mcdc_mappings
118118
.iter()
119-
.map(|&mappings::MCDCDecision { decision_depth, .. }| decision_depth)
119+
.map(|&(mappings::MCDCDecision { decision_depth, .. }, _)| decision_depth)
120120
.max()
121121
.map_or(0, |max| usize::from(max) + 1);
122122

123123
mir_body.function_coverage_info = Some(Box::new(FunctionCoverageInfo {
124124
function_source_hash: hir_info.function_source_hash,
125125
num_counters: coverage_counters.num_counters(),
126-
mcdc_bitmap_bytes: extracted_mappings.mcdc_bitmap_bytes,
126+
mcdc_bitmap_bits: extracted_mappings.mcdc_bitmap_bits,
127127
expressions: coverage_counters.into_expressions(),
128128
mappings,
129129
mcdc_num_condition_bitmaps,
@@ -161,9 +161,9 @@ fn create_mappings<'tcx>(
161161
num_bcbs: _,
162162
code_mappings,
163163
branch_pairs,
164-
mcdc_bitmap_bytes: _,
165-
mcdc_branches,
166-
mcdc_decisions,
164+
mcdc_bitmap_bits: _,
165+
mcdc_degraded_branches,
166+
mcdc_mappings,
167167
} = extracted_mappings;
168168
let mut mappings = Vec::new();
169169

@@ -186,26 +186,79 @@ fn create_mappings<'tcx>(
186186
},
187187
));
188188

189-
mappings.extend(mcdc_branches.iter().filter_map(
190-
|&mappings::MCDCBranch { span, true_bcb, false_bcb, condition_info, decision_depth: _ }| {
189+
let term_for_bcb =
190+
|bcb| coverage_counters.term_for_bcb(bcb).expect("all BCBs with spans were given counters");
191+
192+
// MCDC branch mappings are appended with their decisions in case decisions were ignored.
193+
mappings.extend(mcdc_degraded_branches.iter().filter_map(
194+
|&mappings::MCDCBranch {
195+
span,
196+
true_bcb,
197+
false_bcb,
198+
condition_info: _,
199+
true_index: _,
200+
false_index: _,
201+
}| {
191202
let source_region = region_for_span(span)?;
192203
let true_term = term_for_bcb(true_bcb);
193204
let false_term = term_for_bcb(false_bcb);
194-
let kind = match condition_info {
195-
Some(mcdc_params) => MappingKind::MCDCBranch { true_term, false_term, mcdc_params },
196-
None => MappingKind::Branch { true_term, false_term },
197-
};
198-
Some(Mapping { kind, source_region })
205+
Some(Mapping { kind: MappingKind::Branch { true_term, false_term }, source_region })
199206
},
200207
));
201208

202-
mappings.extend(mcdc_decisions.iter().filter_map(
203-
|&mappings::MCDCDecision { span, bitmap_idx, num_conditions, .. }| {
204-
let source_region = region_for_span(span)?;
205-
let kind = MappingKind::MCDCDecision(DecisionInfo { bitmap_idx, num_conditions });
206-
Some(Mapping { kind, source_region })
207-
},
208-
));
209+
for (decision, branches) in mcdc_mappings {
210+
let num_conditions = branches.len() as u16;
211+
let conditions = branches
212+
.into_iter()
213+
.filter_map(
214+
|&mappings::MCDCBranch {
215+
span,
216+
true_bcb,
217+
false_bcb,
218+
condition_info,
219+
true_index: _,
220+
false_index: _,
221+
}| {
222+
let source_region = region_for_span(span)?;
223+
let true_term = term_for_bcb(true_bcb);
224+
let false_term = term_for_bcb(false_bcb);
225+
Some(Mapping {
226+
kind: MappingKind::MCDCBranch {
227+
true_term,
228+
false_term,
229+
mcdc_params: condition_info,
230+
},
231+
source_region,
232+
})
233+
},
234+
)
235+
.collect::<Vec<_>>();
236+
237+
if conditions.len() == num_conditions as usize
238+
&& let Some(source_region) = region_for_span(decision.span)
239+
{
240+
// LLVM requires end index for counter mapping regions.
241+
let kind = MappingKind::MCDCDecision(DecisionInfo {
242+
bitmap_idx: (decision.bitmap_idx + decision.num_test_vectors) as u32,
243+
num_conditions,
244+
});
245+
mappings.extend(
246+
std::iter::once(Mapping { kind, source_region }).chain(conditions.into_iter()),
247+
);
248+
} else {
249+
mappings.extend(conditions.into_iter().map(|mapping| {
250+
let MappingKind::MCDCBranch { true_term, false_term, mcdc_params: _ } =
251+
mapping.kind
252+
else {
253+
unreachable!("all mappings here are MCDCBranch as shown above");
254+
};
255+
Mapping {
256+
kind: MappingKind::Branch { true_term, false_term },
257+
source_region: mapping.source_region,
258+
}
259+
}))
260+
}
261+
}
209262

210263
mappings
211264
}
@@ -274,44 +327,41 @@ fn inject_mcdc_statements<'tcx>(
274327
basic_coverage_blocks: &CoverageGraph,
275328
extracted_mappings: &ExtractedMappings,
276329
) {
277-
// Inject test vector update first because `inject_statement` always insert new statement at
278-
// head.
279-
for &mappings::MCDCDecision {
280-
span: _,
281-
ref end_bcbs,
282-
bitmap_idx,
283-
num_conditions: _,
284-
decision_depth,
285-
} in &extracted_mappings.mcdc_decisions
286-
{
287-
for end in end_bcbs {
288-
let end_bb = basic_coverage_blocks[*end].leader_bb();
330+
for (decision, conditions) in &extracted_mappings.mcdc_mappings {
331+
// Inject test vector update first because `inject_statement` always insert new statement at head.
332+
for &end in &decision.end_bcbs {
333+
let end_bb = basic_coverage_blocks[end].leader_bb();
289334
inject_statement(
290335
mir_body,
291-
CoverageKind::TestVectorBitmapUpdate { bitmap_idx, decision_depth },
336+
CoverageKind::TestVectorBitmapUpdate {
337+
bitmap_idx: decision.bitmap_idx as u32,
338+
decision_depth: decision.decision_depth,
339+
},
292340
end_bb,
293341
);
294342
}
295-
}
296-
297-
for &mappings::MCDCBranch { span: _, true_bcb, false_bcb, condition_info, decision_depth } in
298-
&extracted_mappings.mcdc_branches
299-
{
300-
let Some(condition_info) = condition_info else { continue };
301-
let id = condition_info.condition_id;
302343

303-
let true_bb = basic_coverage_blocks[true_bcb].leader_bb();
304-
inject_statement(
305-
mir_body,
306-
CoverageKind::CondBitmapUpdate { id, value: true, decision_depth },
307-
true_bb,
308-
);
309-
let false_bb = basic_coverage_blocks[false_bcb].leader_bb();
310-
inject_statement(
311-
mir_body,
312-
CoverageKind::CondBitmapUpdate { id, value: false, decision_depth },
313-
false_bb,
314-
);
344+
for &mappings::MCDCBranch {
345+
span: _,
346+
true_bcb,
347+
false_bcb,
348+
condition_info: _,
349+
true_index,
350+
false_index,
351+
} in conditions
352+
{
353+
for (index, bcb) in [(false_index, false_bcb), (true_index, true_bcb)] {
354+
let bb = basic_coverage_blocks[bcb].leader_bb();
355+
inject_statement(
356+
mir_body,
357+
CoverageKind::CondBitmapUpdate {
358+
index: index as u32,
359+
decision_depth: decision.decision_depth,
360+
},
361+
bb,
362+
);
363+
}
364+
}
315365
}
316366
}
317367

Lines changed: 12 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Function name: condition_limit::bad
2-
Raw bytes (204): 0x[01, 01, 2c, 01, 05, 05, 1d, 05, 1d, 7a, 19, 05, 1d, 7a, 19, 05, 1d, 76, 15, 7a, 19, 05, 1d, 76, 15, 7a, 19, 05, 1d, 72, 11, 76, 15, 7a, 19, 05, 1d, 72, 11, 76, 15, 7a, 19, 05, 1d, 6e, 0d, 72, 11, 76, 15, 7a, 19, 05, 1d, 6e, 0d, 72, 11, 76, 15, 7a, 19, 05, 1d, 9f, 01, 02, a3, 01, 1d, a7, 01, 19, ab, 01, 15, af, 01, 11, 09, 0d, 21, 9b, 01, 9f, 01, 02, a3, 01, 1d, a7, 01, 19, ab, 01, 15, af, 01, 11, 09, 0d, 11, 01, 14, 01, 03, 09, 20, 05, 02, 03, 08, 00, 09, 05, 00, 0d, 00, 0e, 20, 7a, 1d, 00, 0d, 00, 0e, 7a, 00, 12, 00, 13, 20, 76, 19, 00, 12, 00, 13, 76, 00, 17, 00, 18, 20, 72, 15, 00, 17, 00, 18, 72, 00, 1c, 00, 1d, 20, 6e, 11, 00, 1c, 00, 1d, 6e, 00, 21, 00, 22, 20, 6a, 0d, 00, 21, 00, 22, 6a, 00, 26, 00, 27, 20, 21, 09, 00, 26, 00, 27, 21, 00, 28, 02, 06, 9b, 01, 02, 06, 00, 07, 97, 01, 01, 01, 00, 02]
1+
Function name: condition_limit::accept_7_conditions
2+
Raw bytes (232): 0x[01, 01, 2c, 01, 05, 05, 1d, 05, 1d, 7a, 19, 05, 1d, 7a, 19, 05, 1d, 76, 15, 7a, 19, 05, 1d, 76, 15, 7a, 19, 05, 1d, 72, 11, 76, 15, 7a, 19, 05, 1d, 72, 11, 76, 15, 7a, 19, 05, 1d, 6e, 0d, 72, 11, 76, 15, 7a, 19, 05, 1d, 6e, 0d, 72, 11, 76, 15, 7a, 19, 05, 1d, 9f, 01, 02, a3, 01, 1d, a7, 01, 19, ab, 01, 15, af, 01, 11, 09, 0d, 21, 9b, 01, 9f, 01, 02, a3, 01, 1d, a7, 01, 19, ab, 01, 15, af, 01, 11, 09, 0d, 12, 01, 07, 01, 02, 09, 28, 08, 07, 02, 08, 00, 27, 30, 05, 02, 01, 07, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 7a, 1d, 07, 06, 00, 00, 0d, 00, 0e, 7a, 00, 12, 00, 13, 30, 76, 19, 06, 05, 00, 00, 12, 00, 13, 76, 00, 17, 00, 18, 30, 72, 15, 05, 04, 00, 00, 17, 00, 18, 72, 00, 1c, 00, 1d, 30, 6e, 11, 04, 03, 00, 00, 1c, 00, 1d, 6e, 00, 21, 00, 22, 30, 6a, 0d, 03, 02, 00, 00, 21, 00, 22, 6a, 00, 26, 00, 27, 30, 21, 09, 02, 00, 00, 00, 26, 00, 27, 21, 00, 28, 02, 06, 9b, 01, 02, 06, 00, 07, 97, 01, 01, 01, 00, 02]
33
Number of files: 1
44
- file 0 => global file 1
55
Number of expressions: 44
@@ -47,38 +47,39 @@ Number of expressions: 44
4747
- expression 41 operands: lhs = Expression(42, Add), rhs = Counter(5)
4848
- expression 42 operands: lhs = Expression(43, Add), rhs = Counter(4)
4949
- expression 43 operands: lhs = Counter(2), rhs = Counter(3)
50-
Number of file 0 mappings: 17
51-
- Code(Counter(0)) at (prev + 20, 1) to (start + 3, 9)
52-
- Branch { true: Counter(1), false: Expression(0, Sub) } at (prev + 3, 8) to (start + 0, 9)
50+
Number of file 0 mappings: 18
51+
- Code(Counter(0)) at (prev + 7, 1) to (start + 2, 9)
52+
- MCDCDecision { bitmap_idx: 8, conditions_num: 7 } at (prev + 2, 8) to (start + 0, 39)
53+
- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 7, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9)
5354
true = c1
5455
false = (c0 - c1)
5556
- Code(Counter(1)) at (prev + 0, 13) to (start + 0, 14)
56-
- Branch { true: Expression(30, Sub), false: Counter(7) } at (prev + 0, 13) to (start + 0, 14)
57+
- MCDCBranch { true: Expression(30, Sub), false: Counter(7), condition_id: 7, true_next_id: 6, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 14)
5758
true = (c1 - c7)
5859
false = c7
5960
- Code(Expression(30, Sub)) at (prev + 0, 18) to (start + 0, 19)
6061
= (c1 - c7)
61-
- Branch { true: Expression(29, Sub), false: Counter(6) } at (prev + 0, 18) to (start + 0, 19)
62+
- MCDCBranch { true: Expression(29, Sub), false: Counter(6), condition_id: 6, true_next_id: 5, false_next_id: 0 } at (prev + 0, 18) to (start + 0, 19)
6263
true = ((c1 - c7) - c6)
6364
false = c6
6465
- Code(Expression(29, Sub)) at (prev + 0, 23) to (start + 0, 24)
6566
= ((c1 - c7) - c6)
66-
- Branch { true: Expression(28, Sub), false: Counter(5) } at (prev + 0, 23) to (start + 0, 24)
67+
- MCDCBranch { true: Expression(28, Sub), false: Counter(5), condition_id: 5, true_next_id: 4, false_next_id: 0 } at (prev + 0, 23) to (start + 0, 24)
6768
true = (((c1 - c7) - c6) - c5)
6869
false = c5
6970
- Code(Expression(28, Sub)) at (prev + 0, 28) to (start + 0, 29)
7071
= (((c1 - c7) - c6) - c5)
71-
- Branch { true: Expression(27, Sub), false: Counter(4) } at (prev + 0, 28) to (start + 0, 29)
72+
- MCDCBranch { true: Expression(27, Sub), false: Counter(4), condition_id: 4, true_next_id: 3, false_next_id: 0 } at (prev + 0, 28) to (start + 0, 29)
7273
true = ((((c1 - c7) - c6) - c5) - c4)
7374
false = c4
7475
- Code(Expression(27, Sub)) at (prev + 0, 33) to (start + 0, 34)
7576
= ((((c1 - c7) - c6) - c5) - c4)
76-
- Branch { true: Expression(26, Sub), false: Counter(3) } at (prev + 0, 33) to (start + 0, 34)
77+
- MCDCBranch { true: Expression(26, Sub), false: Counter(3), condition_id: 3, true_next_id: 2, false_next_id: 0 } at (prev + 0, 33) to (start + 0, 34)
7778
true = (((((c1 - c7) - c6) - c5) - c4) - c3)
7879
false = c3
7980
- Code(Expression(26, Sub)) at (prev + 0, 38) to (start + 0, 39)
8081
= (((((c1 - c7) - c6) - c5) - c4) - c3)
81-
- Branch { true: Counter(8), false: Counter(2) } at (prev + 0, 38) to (start + 0, 39)
82+
- MCDCBranch { true: Counter(8), false: Counter(2), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 38) to (start + 0, 39)
8283
true = c8
8384
false = c2
8485
- Code(Counter(8)) at (prev + 0, 40) to (start + 2, 6)
@@ -87,76 +88,3 @@ Number of file 0 mappings: 17
8788
- Code(Expression(37, Add)) at (prev + 1, 1) to (start + 0, 2)
8889
= (c8 + ((((((c2 + c3) + c4) + c5) + c6) + c7) + (c0 - c1)))
8990

90-
Function name: condition_limit::good
91-
Raw bytes (180): 0x[01, 01, 20, 01, 05, 05, 19, 05, 19, 52, 15, 05, 19, 52, 15, 05, 19, 4e, 11, 52, 15, 05, 19, 4e, 11, 52, 15, 05, 19, 4a, 0d, 4e, 11, 52, 15, 05, 19, 4a, 0d, 4e, 11, 52, 15, 05, 19, 73, 02, 77, 19, 7b, 15, 7f, 11, 09, 0d, 1d, 6f, 73, 02, 77, 19, 7b, 15, 7f, 11, 09, 0d, 10, 01, 0c, 01, 03, 09, 28, 00, 06, 03, 08, 00, 22, 30, 05, 02, 01, 06, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 52, 19, 06, 05, 00, 00, 0d, 00, 0e, 52, 00, 12, 00, 13, 30, 4e, 15, 05, 04, 00, 00, 12, 00, 13, 4e, 00, 17, 00, 18, 30, 4a, 11, 04, 03, 00, 00, 17, 00, 18, 4a, 00, 1c, 00, 1d, 30, 46, 0d, 03, 02, 00, 00, 1c, 00, 1d, 46, 00, 21, 00, 22, 30, 1d, 09, 02, 00, 00, 00, 21, 00, 22, 1d, 00, 23, 02, 06, 6f, 02, 06, 00, 07, 6b, 01, 01, 00, 02]
92-
Number of files: 1
93-
- file 0 => global file 1
94-
Number of expressions: 32
95-
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
96-
- expression 1 operands: lhs = Counter(1), rhs = Counter(6)
97-
- expression 2 operands: lhs = Counter(1), rhs = Counter(6)
98-
- expression 3 operands: lhs = Expression(20, Sub), rhs = Counter(5)
99-
- expression 4 operands: lhs = Counter(1), rhs = Counter(6)
100-
- expression 5 operands: lhs = Expression(20, Sub), rhs = Counter(5)
101-
- expression 6 operands: lhs = Counter(1), rhs = Counter(6)
102-
- expression 7 operands: lhs = Expression(19, Sub), rhs = Counter(4)
103-
- expression 8 operands: lhs = Expression(20, Sub), rhs = Counter(5)
104-
- expression 9 operands: lhs = Counter(1), rhs = Counter(6)
105-
- expression 10 operands: lhs = Expression(19, Sub), rhs = Counter(4)
106-
- expression 11 operands: lhs = Expression(20, Sub), rhs = Counter(5)
107-
- expression 12 operands: lhs = Counter(1), rhs = Counter(6)
108-
- expression 13 operands: lhs = Expression(18, Sub), rhs = Counter(3)
109-
- expression 14 operands: lhs = Expression(19, Sub), rhs = Counter(4)
110-
- expression 15 operands: lhs = Expression(20, Sub), rhs = Counter(5)
111-
- expression 16 operands: lhs = Counter(1), rhs = Counter(6)
112-
- expression 17 operands: lhs = Expression(18, Sub), rhs = Counter(3)
113-
- expression 18 operands: lhs = Expression(19, Sub), rhs = Counter(4)
114-
- expression 19 operands: lhs = Expression(20, Sub), rhs = Counter(5)
115-
- expression 20 operands: lhs = Counter(1), rhs = Counter(6)
116-
- expression 21 operands: lhs = Expression(28, Add), rhs = Expression(0, Sub)
117-
- expression 22 operands: lhs = Expression(29, Add), rhs = Counter(6)
118-
- expression 23 operands: lhs = Expression(30, Add), rhs = Counter(5)
119-
- expression 24 operands: lhs = Expression(31, Add), rhs = Counter(4)
120-
- expression 25 operands: lhs = Counter(2), rhs = Counter(3)
121-
- expression 26 operands: lhs = Counter(7), rhs = Expression(27, Add)
122-
- expression 27 operands: lhs = Expression(28, Add), rhs = Expression(0, Sub)
123-
- expression 28 operands: lhs = Expression(29, Add), rhs = Counter(6)
124-
- expression 29 operands: lhs = Expression(30, Add), rhs = Counter(5)
125-
- expression 30 operands: lhs = Expression(31, Add), rhs = Counter(4)
126-
- expression 31 operands: lhs = Counter(2), rhs = Counter(3)
127-
Number of file 0 mappings: 16
128-
- Code(Counter(0)) at (prev + 12, 1) to (start + 3, 9)
129-
- MCDCDecision { bitmap_idx: 0, conditions_num: 6 } at (prev + 3, 8) to (start + 0, 34)
130-
- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 6, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9)
131-
true = c1
132-
false = (c0 - c1)
133-
- Code(Counter(1)) at (prev + 0, 13) to (start + 0, 14)
134-
- MCDCBranch { true: Expression(20, Sub), false: Counter(6), condition_id: 6, true_next_id: 5, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 14)
135-
true = (c1 - c6)
136-
false = c6
137-
- Code(Expression(20, Sub)) at (prev + 0, 18) to (start + 0, 19)
138-
= (c1 - c6)
139-
- MCDCBranch { true: Expression(19, Sub), false: Counter(5), condition_id: 5, true_next_id: 4, false_next_id: 0 } at (prev + 0, 18) to (start + 0, 19)
140-
true = ((c1 - c6) - c5)
141-
false = c5
142-
- Code(Expression(19, Sub)) at (prev + 0, 23) to (start + 0, 24)
143-
= ((c1 - c6) - c5)
144-
- MCDCBranch { true: Expression(18, Sub), false: Counter(4), condition_id: 4, true_next_id: 3, false_next_id: 0 } at (prev + 0, 23) to (start + 0, 24)
145-
true = (((c1 - c6) - c5) - c4)
146-
false = c4
147-
- Code(Expression(18, Sub)) at (prev + 0, 28) to (start + 0, 29)
148-
= (((c1 - c6) - c5) - c4)
149-
- MCDCBranch { true: Expression(17, Sub), false: Counter(3), condition_id: 3, true_next_id: 2, false_next_id: 0 } at (prev + 0, 28) to (start + 0, 29)
150-
true = ((((c1 - c6) - c5) - c4) - c3)
151-
false = c3
152-
- Code(Expression(17, Sub)) at (prev + 0, 33) to (start + 0, 34)
153-
= ((((c1 - c6) - c5) - c4) - c3)
154-
- MCDCBranch { true: Counter(7), false: Counter(2), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 33) to (start + 0, 34)
155-
true = c7
156-
false = c2
157-
- Code(Counter(7)) at (prev + 0, 35) to (start + 2, 6)
158-
- Code(Expression(27, Add)) at (prev + 2, 6) to (start + 0, 7)
159-
= (((((c2 + c3) + c4) + c5) + c6) + (c0 - c1))
160-
- Code(Expression(26, Add)) at (prev + 1, 1) to (start + 0, 2)
161-
= (c7 + (((((c2 + c3) + c4) + c5) + c6) + (c0 - c1)))
162-

‎tests/coverage/mcdc/condition-limit.coverage

Lines changed: 24 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,73 +4,53 @@
44
LL| |//@ compile-flags: -Zcoverage-options=mcdc
55
LL| |//@ llvm-cov-flags: --show-branches=count --show-mcdc
66
LL| |
7-
LL| |// Check that MC/DC instrumentation can gracefully handle conditions that
8-
LL| |// exceed LLVM's limit of 6 conditions per decision.
9-
LL| |//
10-
LL| |// (The limit is enforced in `compiler/rustc_mir_build/src/build/coverageinfo/mcdc.rs`.)
11-
LL| |
12-
LL| 1|fn good() {
13-
LL| 1| // With only 6 conditions, perform full MC/DC instrumentation.
14-
LL| 1| let [a, b, c, d, e, f] = <[bool; 6]>::default();
15-
LL| 1| if a && b && c && d && e && f {
16-
^0 ^0 ^0 ^0 ^0
7+
LL| 2|fn accept_7_conditions(bool_arr: [bool; 7]) {
8+
LL| 2| let [a, b, c, d, e, f, g] = bool_arr;
9+
LL| 2| if a && b && c && d && e && f && g {
10+
^1 ^1 ^1 ^1 ^1 ^1
1711
------------------
18-
| Branch (LL:8): [True: 0, False: 1]
19-
| Branch (LL:13): [True: 0, False: 0]
20-
| Branch (LL:18): [True: 0, False: 0]
21-
| Branch (LL:23): [True: 0, False: 0]
22-
| Branch (LL:28): [True: 0, False: 0]
23-
| Branch (LL:33): [True: 0, False: 0]
12+
| Branch (LL:8): [True: 1, False: 1]
13+
| Branch (LL:13): [True: 1, False: 0]
14+
| Branch (LL:18): [True: 1, False: 0]
15+
| Branch (LL:23): [True: 1, False: 0]
16+
| Branch (LL:28): [True: 1, False: 0]
17+
| Branch (LL:33): [True: 1, False: 0]
18+
| Branch (LL:38): [True: 1, False: 0]
2419
------------------
25-
|---> MC/DC Decision Region (LL:8) to (LL:34)
20+
|---> MC/DC Decision Region (LL:8) to (LL:39)
2621
|
27-
| Number of Conditions: 6
22+
| Number of Conditions: 7
2823
| Condition C1 --> (LL:8)
2924
| Condition C2 --> (LL:13)
3025
| Condition C3 --> (LL:18)
3126
| Condition C4 --> (LL:23)
3227
| Condition C5 --> (LL:28)
3328
| Condition C6 --> (LL:33)
29+
| Condition C7 --> (LL:38)
3430
|
3531
| Executed MC/DC Test Vectors:
3632
|
37-
| C1, C2, C3, C4, C5, C6 Result
38-
| 1 { F, -, -, -, -, - = F }
33+
| C1, C2, C3, C4, C5, C6, C7 Result
34+
| 1 { F, -, -, -, -, -, - = F }
35+
| 2 { T, T, T, T, T, T, T = T }
3936
|
40-
| C1-Pair: not covered
37+
| C1-Pair: covered: (1,2)
4138
| C2-Pair: not covered
4239
| C3-Pair: not covered
4340
| C4-Pair: not covered
4441
| C5-Pair: not covered
4542
| C6-Pair: not covered
46-
| MC/DC Coverage for Decision: 0.00%
43+
| C7-Pair: not covered
44+
| MC/DC Coverage for Decision: 14.29%
4745
|
4846
------------------
49-
LL| 0| core::hint::black_box("hello");
50-
LL| 1| }
51-
LL| 1|}
52-
LL| |
53-
LL| 1|fn bad() {
54-
LL| 1| // With 7 conditions, fall back to branch instrumentation only.
55-
LL| 1| let [a, b, c, d, e, f, g] = <[bool; 7]>::default();
56-
LL| 1| if a && b && c && d && e && f && g {
57-
^0 ^0 ^0 ^0 ^0 ^0
58-
------------------
59-
| Branch (LL:8): [True: 0, False: 1]
60-
| Branch (LL:13): [True: 0, False: 0]
61-
| Branch (LL:18): [True: 0, False: 0]
62-
| Branch (LL:23): [True: 0, False: 0]
63-
| Branch (LL:28): [True: 0, False: 0]
64-
| Branch (LL:33): [True: 0, False: 0]
65-
| Branch (LL:38): [True: 0, False: 0]
66-
------------------
67-
LL| 0| core::hint::black_box("hello");
47+
LL| 1| core::hint::black_box("hello");
6848
LL| 1| }
69-
LL| 1|}
49+
LL| 2|}
7050
LL| |
7151
LL| |#[coverage(off)]
7252
LL| |fn main() {
73-
LL| | good();
74-
LL| | bad();
53+
LL| | accept_7_conditions([false; 7]);
54+
LL| | accept_7_conditions([true; 7]);
7555
LL| |}
7656

‎tests/coverage/mcdc/condition-limit.rs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,15 @@
44
//@ compile-flags: -Zcoverage-options=mcdc
55
//@ llvm-cov-flags: --show-branches=count --show-mcdc
66

7-
// Check that MC/DC instrumentation can gracefully handle conditions that
8-
// exceed LLVM's limit of 6 conditions per decision.
9-
//
10-
// (The limit is enforced in `compiler/rustc_mir_build/src/build/coverageinfo/mcdc.rs`.)
11-
12-
fn good() {
13-
// With only 6 conditions, perform full MC/DC instrumentation.
14-
let [a, b, c, d, e, f] = <[bool; 6]>::default();
15-
if a && b && c && d && e && f {
16-
core::hint::black_box("hello");
17-
}
18-
}
19-
20-
fn bad() {
21-
// With 7 conditions, fall back to branch instrumentation only.
22-
let [a, b, c, d, e, f, g] = <[bool; 7]>::default();
7+
fn accept_7_conditions(bool_arr: [bool; 7]) {
8+
let [a, b, c, d, e, f, g] = bool_arr;
239
if a && b && c && d && e && f && g {
2410
core::hint::black_box("hello");
2511
}
2612
}
2713

2814
#[coverage(off)]
2915
fn main() {
30-
good();
31-
bad();
16+
accept_7_conditions([false; 7]);
17+
accept_7_conditions([true; 7]);
3218
}

‎tests/coverage/mcdc/if.cov-map

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Function name: if::mcdc_check_a
2-
Raw bytes (64): 0x[01, 01, 04, 01, 05, 09, 02, 0d, 0f, 09, 02, 08, 01, 0f, 01, 01, 09, 28, 00, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 0e, 0d, 00, 0f, 02, 06, 0f, 02, 0c, 02, 06, 0b, 03, 01, 00, 02]
2+
Raw bytes (64): 0x[01, 01, 04, 01, 05, 09, 02, 0d, 0f, 09, 02, 08, 01, 0f, 01, 01, 09, 28, 03, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 0e, 0d, 00, 0f, 02, 06, 0f, 02, 0c, 02, 06, 0b, 03, 01, 00, 02]
33
Number of files: 1
44
- file 0 => global file 1
55
Number of expressions: 4
@@ -9,7 +9,7 @@ Number of expressions: 4
99
- expression 3 operands: lhs = Counter(2), rhs = Expression(0, Sub)
1010
Number of file 0 mappings: 8
1111
- Code(Counter(0)) at (prev + 15, 1) to (start + 1, 9)
12-
- MCDCDecision { bitmap_idx: 0, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 14)
12+
- MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 14)
1313
- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9)
1414
true = c1
1515
false = (c0 - c1)
@@ -24,7 +24,7 @@ Number of file 0 mappings: 8
2424
= (c3 + (c2 + (c0 - c1)))
2525

2626
Function name: if::mcdc_check_b
27-
Raw bytes (64): 0x[01, 01, 04, 01, 05, 09, 02, 0d, 0f, 09, 02, 08, 01, 17, 01, 01, 09, 28, 00, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 0e, 0d, 00, 0f, 02, 06, 0f, 02, 0c, 02, 06, 0b, 03, 01, 00, 02]
27+
Raw bytes (64): 0x[01, 01, 04, 01, 05, 09, 02, 0d, 0f, 09, 02, 08, 01, 17, 01, 01, 09, 28, 03, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 0e, 0d, 00, 0f, 02, 06, 0f, 02, 0c, 02, 06, 0b, 03, 01, 00, 02]
2828
Number of files: 1
2929
- file 0 => global file 1
3030
Number of expressions: 4
@@ -34,7 +34,7 @@ Number of expressions: 4
3434
- expression 3 operands: lhs = Counter(2), rhs = Expression(0, Sub)
3535
Number of file 0 mappings: 8
3636
- Code(Counter(0)) at (prev + 23, 1) to (start + 1, 9)
37-
- MCDCDecision { bitmap_idx: 0, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 14)
37+
- MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 14)
3838
- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9)
3939
true = c1
4040
false = (c0 - c1)
@@ -49,7 +49,7 @@ Number of file 0 mappings: 8
4949
= (c3 + (c2 + (c0 - c1)))
5050

5151
Function name: if::mcdc_check_both
52-
Raw bytes (64): 0x[01, 01, 04, 01, 05, 09, 02, 0d, 0f, 09, 02, 08, 01, 1f, 01, 01, 09, 28, 00, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 0e, 0d, 00, 0f, 02, 06, 0f, 02, 0c, 02, 06, 0b, 03, 01, 00, 02]
52+
Raw bytes (64): 0x[01, 01, 04, 01, 05, 09, 02, 0d, 0f, 09, 02, 08, 01, 1f, 01, 01, 09, 28, 03, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 0e, 0d, 00, 0f, 02, 06, 0f, 02, 0c, 02, 06, 0b, 03, 01, 00, 02]
5353
Number of files: 1
5454
- file 0 => global file 1
5555
Number of expressions: 4
@@ -59,7 +59,7 @@ Number of expressions: 4
5959
- expression 3 operands: lhs = Counter(2), rhs = Expression(0, Sub)
6060
Number of file 0 mappings: 8
6161
- Code(Counter(0)) at (prev + 31, 1) to (start + 1, 9)
62-
- MCDCDecision { bitmap_idx: 0, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 14)
62+
- MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 14)
6363
- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9)
6464
true = c1
6565
false = (c0 - c1)
@@ -74,7 +74,7 @@ Number of file 0 mappings: 8
7474
= (c3 + (c2 + (c0 - c1)))
7575

7676
Function name: if::mcdc_check_neither
77-
Raw bytes (64): 0x[01, 01, 04, 01, 05, 09, 02, 0d, 0f, 09, 02, 08, 01, 07, 01, 01, 09, 28, 00, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 0e, 0d, 00, 0f, 02, 06, 0f, 02, 0c, 02, 06, 0b, 03, 01, 00, 02]
77+
Raw bytes (64): 0x[01, 01, 04, 01, 05, 09, 02, 0d, 0f, 09, 02, 08, 01, 07, 01, 01, 09, 28, 03, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 0e, 0d, 00, 0f, 02, 06, 0f, 02, 0c, 02, 06, 0b, 03, 01, 00, 02]
7878
Number of files: 1
7979
- file 0 => global file 1
8080
Number of expressions: 4
@@ -84,7 +84,7 @@ Number of expressions: 4
8484
- expression 3 operands: lhs = Counter(2), rhs = Expression(0, Sub)
8585
Number of file 0 mappings: 8
8686
- Code(Counter(0)) at (prev + 7, 1) to (start + 1, 9)
87-
- MCDCDecision { bitmap_idx: 0, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 14)
87+
- MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 14)
8888
- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9)
8989
true = c1
9090
false = (c0 - c1)
@@ -99,7 +99,7 @@ Number of file 0 mappings: 8
9999
= (c3 + (c2 + (c0 - c1)))
100100

101101
Function name: if::mcdc_check_not_tree_decision
102-
Raw bytes (87): 0x[01, 01, 08, 01, 05, 02, 09, 05, 09, 0d, 1e, 02, 09, 11, 1b, 0d, 1e, 02, 09, 0a, 01, 31, 01, 03, 0a, 28, 00, 03, 03, 08, 00, 15, 30, 05, 02, 01, 02, 03, 00, 09, 00, 0a, 02, 00, 0e, 00, 0f, 30, 09, 1e, 03, 02, 00, 00, 0e, 00, 0f, 0b, 00, 14, 00, 15, 30, 11, 0d, 02, 00, 00, 00, 14, 00, 15, 11, 00, 16, 02, 06, 1b, 02, 0c, 02, 06, 17, 03, 01, 00, 02]
102+
Raw bytes (87): 0x[01, 01, 08, 01, 05, 02, 09, 05, 09, 0d, 1e, 02, 09, 11, 1b, 0d, 1e, 02, 09, 0a, 01, 31, 01, 03, 0a, 28, 05, 03, 03, 08, 00, 15, 30, 05, 02, 01, 02, 03, 00, 09, 00, 0a, 02, 00, 0e, 00, 0f, 30, 09, 1e, 03, 02, 00, 00, 0e, 00, 0f, 0b, 00, 14, 00, 15, 30, 11, 0d, 02, 00, 00, 00, 14, 00, 15, 11, 00, 16, 02, 06, 1b, 02, 0c, 02, 06, 17, 03, 01, 00, 02]
103103
Number of files: 1
104104
- file 0 => global file 1
105105
Number of expressions: 8
@@ -113,7 +113,7 @@ Number of expressions: 8
113113
- expression 7 operands: lhs = Expression(0, Sub), rhs = Counter(2)
114114
Number of file 0 mappings: 10
115115
- Code(Counter(0)) at (prev + 49, 1) to (start + 3, 10)
116-
- MCDCDecision { bitmap_idx: 0, conditions_num: 3 } at (prev + 3, 8) to (start + 0, 21)
116+
- MCDCDecision { bitmap_idx: 5, conditions_num: 3 } at (prev + 3, 8) to (start + 0, 21)
117117
- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 3 } at (prev + 0, 9) to (start + 0, 10)
118118
true = c1
119119
false = (c0 - c1)
@@ -134,7 +134,7 @@ Number of file 0 mappings: 10
134134
= (c4 + (c3 + ((c0 - c1) - c2)))
135135

136136
Function name: if::mcdc_check_tree_decision
137-
Raw bytes (87): 0x[01, 01, 08, 01, 05, 05, 0d, 05, 0d, 0d, 11, 09, 02, 1b, 1f, 0d, 11, 09, 02, 0a, 01, 27, 01, 03, 09, 28, 00, 03, 03, 08, 00, 15, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0e, 00, 0f, 30, 0d, 0a, 02, 00, 03, 00, 0e, 00, 0f, 0a, 00, 13, 00, 14, 30, 11, 09, 03, 00, 00, 00, 13, 00, 14, 1b, 00, 16, 02, 06, 1f, 02, 0c, 02, 06, 17, 03, 01, 00, 02]
137+
Raw bytes (87): 0x[01, 01, 08, 01, 05, 05, 0d, 05, 0d, 0d, 11, 09, 02, 1b, 1f, 0d, 11, 09, 02, 0a, 01, 27, 01, 03, 09, 28, 04, 03, 03, 08, 00, 15, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0e, 00, 0f, 30, 0d, 0a, 02, 00, 03, 00, 0e, 00, 0f, 0a, 00, 13, 00, 14, 30, 11, 09, 03, 00, 00, 00, 13, 00, 14, 1b, 00, 16, 02, 06, 1f, 02, 0c, 02, 06, 17, 03, 01, 00, 02]
138138
Number of files: 1
139139
- file 0 => global file 1
140140
Number of expressions: 8
@@ -148,7 +148,7 @@ Number of expressions: 8
148148
- expression 7 operands: lhs = Counter(2), rhs = Expression(0, Sub)
149149
Number of file 0 mappings: 10
150150
- Code(Counter(0)) at (prev + 39, 1) to (start + 3, 9)
151-
- MCDCDecision { bitmap_idx: 0, conditions_num: 3 } at (prev + 3, 8) to (start + 0, 21)
151+
- MCDCDecision { bitmap_idx: 4, conditions_num: 3 } at (prev + 3, 8) to (start + 0, 21)
152152
- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9)
153153
true = c1
154154
false = (c0 - c1)
@@ -169,7 +169,7 @@ Number of file 0 mappings: 10
169169
= ((c3 + c4) + (c2 + (c0 - c1)))
170170

171171
Function name: if::mcdc_nested_if
172-
Raw bytes (124): 0x[01, 01, 0d, 01, 05, 02, 09, 05, 09, 1b, 15, 05, 09, 1b, 15, 05, 09, 11, 15, 02, 09, 2b, 32, 0d, 2f, 11, 15, 02, 09, 0e, 01, 3b, 01, 01, 09, 28, 00, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 00, 02, 00, 08, 00, 09, 02, 00, 0d, 00, 0e, 30, 09, 32, 02, 00, 00, 00, 0d, 00, 0e, 1b, 01, 09, 01, 0d, 28, 01, 02, 01, 0c, 00, 12, 30, 16, 15, 01, 02, 00, 00, 0c, 00, 0d, 16, 00, 11, 00, 12, 30, 0d, 11, 02, 00, 00, 00, 11, 00, 12, 0d, 00, 13, 02, 0a, 2f, 02, 0a, 00, 0b, 32, 01, 0c, 02, 06, 27, 03, 01, 00, 02]
172+
Raw bytes (124): 0x[01, 01, 0d, 01, 05, 02, 09, 05, 09, 1b, 15, 05, 09, 1b, 15, 05, 09, 11, 15, 02, 09, 2b, 32, 0d, 2f, 11, 15, 02, 09, 0e, 01, 3b, 01, 01, 09, 28, 03, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 00, 02, 00, 08, 00, 09, 02, 00, 0d, 00, 0e, 30, 09, 32, 02, 00, 00, 00, 0d, 00, 0e, 1b, 01, 09, 01, 0d, 28, 06, 02, 01, 0c, 00, 12, 30, 16, 15, 01, 02, 00, 00, 0c, 00, 0d, 16, 00, 11, 00, 12, 30, 0d, 11, 02, 00, 00, 00, 11, 00, 12, 0d, 00, 13, 02, 0a, 2f, 02, 0a, 00, 0b, 32, 01, 0c, 02, 06, 27, 03, 01, 00, 02]
173173
Number of files: 1
174174
- file 0 => global file 1
175175
Number of expressions: 13
@@ -188,7 +188,7 @@ Number of expressions: 13
188188
- expression 12 operands: lhs = Expression(0, Sub), rhs = Counter(2)
189189
Number of file 0 mappings: 14
190190
- Code(Counter(0)) at (prev + 59, 1) to (start + 1, 9)
191-
- MCDCDecision { bitmap_idx: 0, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 14)
191+
- MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 14)
192192
- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 0, false_next_id: 2 } at (prev + 0, 8) to (start + 0, 9)
193193
true = c1
194194
false = (c0 - c1)
@@ -199,7 +199,7 @@ Number of file 0 mappings: 14
199199
false = ((c0 - c1) - c2)
200200
- Code(Expression(6, Add)) at (prev + 1, 9) to (start + 1, 13)
201201
= (c1 + c2)
202-
- MCDCDecision { bitmap_idx: 1, conditions_num: 2 } at (prev + 1, 12) to (start + 0, 18)
202+
- MCDCDecision { bitmap_idx: 6, conditions_num: 2 } at (prev + 1, 12) to (start + 0, 18)
203203
- MCDCBranch { true: Expression(5, Sub), false: Counter(5), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 12) to (start + 0, 13)
204204
true = ((c1 + c2) - c5)
205205
false = c5

‎tests/coverage/mcdc/if.coverage

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,12 @@
145145
| C1, C2, C3 Result
146146
| 1 { F, -, - = F }
147147
| 2 { T, F, F = F }
148-
| 3 { T, T, - = T }
149-
| 4 { T, F, T = T }
148+
| 3 { T, F, T = T }
149+
| 4 { T, T, - = T }
150150
|
151151
| C1-Pair: covered: (1,3)
152-
| C2-Pair: covered: (2,3)
153-
| C3-Pair: covered: (2,4)
152+
| C2-Pair: covered: (2,4)
153+
| C3-Pair: covered: (2,3)
154154
| MC/DC Coverage for Decision: 100.00%
155155
|
156156
------------------
@@ -162,7 +162,7 @@
162162
LL| |
163163
LL| 4|fn mcdc_check_not_tree_decision(a: bool, b: bool, c: bool) {
164164
LL| 4| // Contradict to `mcdc_check_tree_decision`,
165-
LL| 4| // 100% branch coverage of this expression does not mean indicates 100% mcdc coverage.
165+
LL| 4| // 100% branch coverage of this expression does not indicate 100% mcdc coverage.
166166
LL| 4| if (a || b) && c {
167167
^1
168168
------------------
@@ -181,12 +181,12 @@
181181
|
182182
| C1, C2, C3 Result
183183
| 1 { T, -, F = F }
184-
| 2 { T, -, T = T }
185-
| 3 { F, T, T = T }
184+
| 2 { F, T, T = T }
185+
| 3 { T, -, T = T }
186186
|
187187
| C1-Pair: not covered
188188
| C2-Pair: not covered
189-
| C3-Pair: covered: (1,2)
189+
| C3-Pair: covered: (1,3)
190190
| MC/DC Coverage for Decision: 33.33%
191191
|
192192
------------------

‎tests/coverage/mcdc/if.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ fn mcdc_check_tree_decision(a: bool, b: bool, c: bool) {
4848

4949
fn mcdc_check_not_tree_decision(a: bool, b: bool, c: bool) {
5050
// Contradict to `mcdc_check_tree_decision`,
51-
// 100% branch coverage of this expression does not mean indicates 100% mcdc coverage.
51+
// 100% branch coverage of this expression does not indicate 100% mcdc coverage.
5252
if (a || b) && c {
5353
say("pass");
5454
} else {

‎tests/coverage/mcdc/inlined_expressions.cov-map

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Function name: inlined_expressions::inlined_instance
2-
Raw bytes (52): 0x[01, 01, 03, 01, 05, 0b, 02, 09, 0d, 06, 01, 08, 01, 01, 06, 28, 00, 02, 01, 05, 00, 0b, 30, 05, 02, 01, 02, 00, 00, 05, 00, 06, 05, 00, 0a, 00, 0b, 30, 09, 0d, 02, 00, 00, 00, 0a, 00, 0b, 07, 01, 01, 00, 02]
2+
Raw bytes (52): 0x[01, 01, 03, 01, 05, 0b, 02, 09, 0d, 06, 01, 08, 01, 01, 06, 28, 03, 02, 01, 05, 00, 0b, 30, 05, 02, 01, 02, 00, 00, 05, 00, 06, 05, 00, 0a, 00, 0b, 30, 09, 0d, 02, 00, 00, 00, 0a, 00, 0b, 07, 01, 01, 00, 02]
33
Number of files: 1
44
- file 0 => global file 1
55
Number of expressions: 3
@@ -8,7 +8,7 @@ Number of expressions: 3
88
- expression 2 operands: lhs = Counter(2), rhs = Counter(3)
99
Number of file 0 mappings: 6
1010
- Code(Counter(0)) at (prev + 8, 1) to (start + 1, 6)
11-
- MCDCDecision { bitmap_idx: 0, conditions_num: 2 } at (prev + 1, 5) to (start + 0, 11)
11+
- MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 1, 5) to (start + 0, 11)
1212
- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 5) to (start + 0, 6)
1313
true = c1
1414
false = (c0 - c1)

‎tests/coverage/mcdc/nested_if.cov-map

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Function name: nested_if::doubly_nested_if_in_condition
2-
Raw bytes (168): 0x[01, 01, 0e, 01, 05, 05, 11, 05, 11, 26, 19, 05, 11, 19, 1d, 19, 1d, 1d, 22, 26, 19, 05, 11, 11, 15, 09, 02, 0d, 37, 09, 02, 14, 01, 0f, 01, 01, 09, 28, 02, 02, 01, 08, 00, 4e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 4e, 05, 00, 10, 00, 11, 28, 01, 02, 00, 10, 00, 36, 30, 11, 26, 01, 00, 02, 00, 10, 00, 11, 30, 15, 21, 02, 00, 00, 00, 15, 00, 36, 26, 00, 18, 00, 19, 28, 00, 02, 00, 18, 00, 1e, 30, 19, 22, 01, 02, 00, 00, 18, 00, 19, 19, 00, 1d, 00, 1e, 30, 1a, 1d, 02, 00, 00, 00, 1d, 00, 1e, 1a, 00, 21, 00, 25, 1f, 00, 2f, 00, 34, 2b, 00, 39, 00, 3e, 21, 00, 48, 00, 4c, 0d, 00, 4f, 02, 06, 37, 02, 0c, 02, 06, 33, 03, 01, 00, 02]
2+
Raw bytes (168): 0x[01, 01, 0e, 01, 05, 05, 11, 05, 11, 26, 19, 05, 11, 19, 1d, 19, 1d, 1d, 22, 26, 19, 05, 11, 11, 15, 09, 02, 0d, 37, 09, 02, 14, 01, 0f, 01, 01, 09, 28, 09, 02, 01, 08, 00, 4e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 4e, 05, 00, 10, 00, 11, 28, 06, 02, 00, 10, 00, 36, 30, 11, 26, 01, 00, 02, 00, 10, 00, 11, 30, 15, 21, 02, 00, 00, 00, 15, 00, 36, 26, 00, 18, 00, 19, 28, 03, 02, 00, 18, 00, 1e, 30, 19, 22, 01, 02, 00, 00, 18, 00, 19, 19, 00, 1d, 00, 1e, 30, 1a, 1d, 02, 00, 00, 00, 1d, 00, 1e, 1a, 00, 21, 00, 25, 1f, 00, 2f, 00, 34, 2b, 00, 39, 00, 3e, 21, 00, 48, 00, 4c, 0d, 00, 4f, 02, 06, 37, 02, 0c, 02, 06, 33, 03, 01, 00, 02]
33
Number of files: 1
44
- file 0 => global file 1
55
Number of expressions: 14
@@ -19,15 +19,15 @@ Number of expressions: 14
1919
- expression 13 operands: lhs = Counter(2), rhs = Expression(0, Sub)
2020
Number of file 0 mappings: 20
2121
- Code(Counter(0)) at (prev + 15, 1) to (start + 1, 9)
22-
- MCDCDecision { bitmap_idx: 2, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 78)
22+
- MCDCDecision { bitmap_idx: 9, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 78)
2323
- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9)
2424
true = c1
2525
false = (c0 - c1)
2626
- MCDCBranch { true: Counter(3), false: Counter(2), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 78)
2727
true = c3
2828
false = c2
2929
- Code(Counter(1)) at (prev + 0, 16) to (start + 0, 17)
30-
- MCDCDecision { bitmap_idx: 1, conditions_num: 2 } at (prev + 0, 16) to (start + 0, 54)
30+
- MCDCDecision { bitmap_idx: 6, conditions_num: 2 } at (prev + 0, 16) to (start + 0, 54)
3131
- MCDCBranch { true: Counter(4), false: Expression(9, Sub), condition_id: 1, true_next_id: 0, false_next_id: 2 } at (prev + 0, 16) to (start + 0, 17)
3232
true = c4
3333
false = (c1 - c4)
@@ -36,7 +36,7 @@ Number of file 0 mappings: 20
3636
false = c8
3737
- Code(Expression(9, Sub)) at (prev + 0, 24) to (start + 0, 25)
3838
= (c1 - c4)
39-
- MCDCDecision { bitmap_idx: 0, conditions_num: 2 } at (prev + 0, 24) to (start + 0, 30)
39+
- MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 0, 24) to (start + 0, 30)
4040
- MCDCBranch { true: Counter(6), false: Expression(8, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 24) to (start + 0, 25)
4141
true = c6
4242
false = ((c1 - c4) - c6)
@@ -58,7 +58,7 @@ Number of file 0 mappings: 20
5858
= (c3 + (c2 + (c0 - c1)))
5959

6060
Function name: nested_if::nested_if_in_condition
61-
Raw bytes (120): 0x[01, 01, 0b, 01, 05, 05, 11, 05, 11, 1e, 15, 05, 11, 11, 15, 1e, 15, 05, 11, 09, 02, 0d, 2b, 09, 02, 0e, 01, 07, 01, 01, 09, 28, 01, 02, 01, 08, 00, 2e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 2e, 05, 00, 10, 00, 11, 28, 00, 02, 00, 10, 00, 16, 30, 11, 1e, 01, 00, 02, 00, 10, 00, 11, 1e, 00, 15, 00, 16, 30, 15, 1a, 02, 00, 00, 00, 15, 00, 16, 17, 00, 19, 00, 1d, 1a, 00, 27, 00, 2c, 0d, 00, 2f, 02, 06, 2b, 02, 0c, 02, 06, 27, 03, 01, 00, 02]
61+
Raw bytes (120): 0x[01, 01, 0b, 01, 05, 05, 11, 05, 11, 1e, 15, 05, 11, 11, 15, 1e, 15, 05, 11, 09, 02, 0d, 2b, 09, 02, 0e, 01, 07, 01, 01, 09, 28, 06, 02, 01, 08, 00, 2e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 2e, 05, 00, 10, 00, 11, 28, 03, 02, 00, 10, 00, 16, 30, 11, 1e, 01, 00, 02, 00, 10, 00, 11, 1e, 00, 15, 00, 16, 30, 15, 1a, 02, 00, 00, 00, 15, 00, 16, 17, 00, 19, 00, 1d, 1a, 00, 27, 00, 2c, 0d, 00, 2f, 02, 06, 2b, 02, 0c, 02, 06, 27, 03, 01, 00, 02]
6262
Number of files: 1
6363
- file 0 => global file 1
6464
Number of expressions: 11
@@ -75,15 +75,15 @@ Number of expressions: 11
7575
- expression 10 operands: lhs = Counter(2), rhs = Expression(0, Sub)
7676
Number of file 0 mappings: 14
7777
- Code(Counter(0)) at (prev + 7, 1) to (start + 1, 9)
78-
- MCDCDecision { bitmap_idx: 1, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 46)
78+
- MCDCDecision { bitmap_idx: 6, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 46)
7979
- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9)
8080
true = c1
8181
false = (c0 - c1)
8282
- MCDCBranch { true: Counter(3), false: Counter(2), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 46)
8383
true = c3
8484
false = c2
8585
- Code(Counter(1)) at (prev + 0, 16) to (start + 0, 17)
86-
- MCDCDecision { bitmap_idx: 0, conditions_num: 2 } at (prev + 0, 16) to (start + 0, 22)
86+
- MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 0, 16) to (start + 0, 22)
8787
- MCDCBranch { true: Counter(4), false: Expression(7, Sub), condition_id: 1, true_next_id: 0, false_next_id: 2 } at (prev + 0, 16) to (start + 0, 17)
8888
true = c4
8989
false = (c1 - c4)
@@ -103,7 +103,7 @@ Number of file 0 mappings: 14
103103
= (c3 + (c2 + (c0 - c1)))
104104

105105
Function name: nested_if::nested_in_then_block_in_condition
106-
Raw bytes (176): 0x[01, 01, 12, 01, 05, 05, 11, 05, 11, 3a, 15, 05, 11, 11, 15, 33, 19, 11, 15, 19, 1d, 19, 1d, 1d, 2e, 33, 19, 11, 15, 3a, 15, 05, 11, 09, 02, 0d, 47, 09, 02, 14, 01, 22, 01, 01, 09, 28, 02, 02, 01, 08, 00, 4b, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 4b, 05, 00, 10, 00, 11, 28, 00, 02, 00, 10, 00, 16, 30, 11, 3a, 01, 00, 02, 00, 10, 00, 11, 3a, 00, 15, 00, 16, 30, 15, 36, 02, 00, 00, 00, 15, 00, 16, 33, 00, 1c, 00, 1d, 28, 01, 02, 00, 1c, 00, 22, 30, 19, 2e, 01, 02, 00, 00, 1c, 00, 1d, 19, 00, 21, 00, 22, 30, 26, 1d, 02, 00, 00, 00, 21, 00, 22, 26, 00, 25, 00, 29, 2b, 00, 33, 00, 38, 36, 00, 44, 00, 49, 0d, 00, 4c, 02, 06, 47, 02, 0c, 02, 06, 43, 03, 01, 00, 02]
106+
Raw bytes (176): 0x[01, 01, 12, 01, 05, 05, 11, 05, 11, 3a, 15, 05, 11, 11, 15, 33, 19, 11, 15, 19, 1d, 19, 1d, 1d, 2e, 33, 19, 11, 15, 3a, 15, 05, 11, 09, 02, 0d, 47, 09, 02, 14, 01, 22, 01, 01, 09, 28, 09, 02, 01, 08, 00, 4b, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 4b, 05, 00, 10, 00, 11, 28, 03, 02, 00, 10, 00, 16, 30, 11, 3a, 01, 00, 02, 00, 10, 00, 11, 3a, 00, 15, 00, 16, 30, 15, 36, 02, 00, 00, 00, 15, 00, 16, 33, 00, 1c, 00, 1d, 28, 06, 02, 00, 1c, 00, 22, 30, 19, 2e, 01, 02, 00, 00, 1c, 00, 1d, 19, 00, 21, 00, 22, 30, 26, 1d, 02, 00, 00, 00, 21, 00, 22, 26, 00, 25, 00, 29, 2b, 00, 33, 00, 38, 36, 00, 44, 00, 49, 0d, 00, 4c, 02, 06, 47, 02, 0c, 02, 06, 43, 03, 01, 00, 02]
107107
Number of files: 1
108108
- file 0 => global file 1
109109
Number of expressions: 18
@@ -127,15 +127,15 @@ Number of expressions: 18
127127
- expression 17 operands: lhs = Counter(2), rhs = Expression(0, Sub)
128128
Number of file 0 mappings: 20
129129
- Code(Counter(0)) at (prev + 34, 1) to (start + 1, 9)
130-
- MCDCDecision { bitmap_idx: 2, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 75)
130+
- MCDCDecision { bitmap_idx: 9, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 75)
131131
- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9)
132132
true = c1
133133
false = (c0 - c1)
134134
- MCDCBranch { true: Counter(3), false: Counter(2), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 75)
135135
true = c3
136136
false = c2
137137
- Code(Counter(1)) at (prev + 0, 16) to (start + 0, 17)
138-
- MCDCDecision { bitmap_idx: 0, conditions_num: 2 } at (prev + 0, 16) to (start + 0, 22)
138+
- MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 0, 16) to (start + 0, 22)
139139
- MCDCBranch { true: Counter(4), false: Expression(14, Sub), condition_id: 1, true_next_id: 0, false_next_id: 2 } at (prev + 0, 16) to (start + 0, 17)
140140
true = c4
141141
false = (c1 - c4)
@@ -146,7 +146,7 @@ Number of file 0 mappings: 20
146146
false = ((c1 - c4) - c5)
147147
- Code(Expression(12, Add)) at (prev + 0, 28) to (start + 0, 29)
148148
= (c4 + c5)
149-
- MCDCDecision { bitmap_idx: 1, conditions_num: 2 } at (prev + 0, 28) to (start + 0, 34)
149+
- MCDCDecision { bitmap_idx: 6, conditions_num: 2 } at (prev + 0, 28) to (start + 0, 34)
150150
- MCDCBranch { true: Counter(6), false: Expression(11, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 28) to (start + 0, 29)
151151
true = c6
152152
false = ((c4 + c5) - c6)
@@ -167,7 +167,7 @@ Number of file 0 mappings: 20
167167
= (c3 + (c2 + (c0 - c1)))
168168

169169
Function name: nested_if::nested_single_condition_decision
170-
Raw bytes (85): 0x[01, 01, 06, 01, 05, 05, 11, 05, 11, 09, 02, 0d, 17, 09, 02, 0b, 01, 17, 01, 04, 09, 28, 00, 02, 04, 08, 00, 29, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 29, 05, 00, 10, 00, 11, 20, 11, 0a, 00, 10, 00, 11, 11, 00, 14, 00, 19, 0a, 00, 23, 00, 27, 0d, 00, 2a, 02, 06, 17, 02, 0c, 02, 06, 13, 03, 01, 00, 02]
170+
Raw bytes (85): 0x[01, 01, 06, 01, 05, 05, 11, 05, 11, 09, 02, 0d, 17, 09, 02, 0b, 01, 17, 01, 04, 09, 28, 03, 02, 04, 08, 00, 29, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 29, 05, 00, 10, 00, 11, 20, 11, 0a, 00, 10, 00, 11, 11, 00, 14, 00, 19, 0a, 00, 23, 00, 27, 0d, 00, 2a, 02, 06, 17, 02, 0c, 02, 06, 13, 03, 01, 00, 02]
171171
Number of files: 1
172172
- file 0 => global file 1
173173
Number of expressions: 6
@@ -179,7 +179,7 @@ Number of expressions: 6
179179
- expression 5 operands: lhs = Counter(2), rhs = Expression(0, Sub)
180180
Number of file 0 mappings: 11
181181
- Code(Counter(0)) at (prev + 23, 1) to (start + 4, 9)
182-
- MCDCDecision { bitmap_idx: 0, conditions_num: 2 } at (prev + 4, 8) to (start + 0, 41)
182+
- MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 4, 8) to (start + 0, 41)
183183
- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9)
184184
true = c1
185185
false = (c0 - c1)

‎tests/coverage/mcdc/nested_if.coverage

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@
4040
|
4141
| C1, C2 Result
4242
| 1 { F, F = F }
43-
| 2 { T, - = T }
44-
| 3 { F, T = T }
43+
| 2 { F, T = T }
44+
| 3 { T, - = T }
4545
|
46-
| C1-Pair: covered: (1,2)
47-
| C2-Pair: covered: (1,3)
46+
| C1-Pair: covered: (1,3)
47+
| C2-Pair: covered: (1,2)
4848
| MC/DC Coverage for Decision: 100.00%
4949
|
5050
------------------
@@ -92,11 +92,11 @@
9292
|
9393
| C1, C2 Result
9494
| 1 { F, F = F }
95-
| 2 { T, - = T }
96-
| 3 { F, T = T }
95+
| 2 { F, T = T }
96+
| 3 { T, - = T }
9797
|
98-
| C1-Pair: covered: (1,2)
99-
| C2-Pair: covered: (1,3)
98+
| C1-Pair: covered: (1,3)
99+
| C2-Pair: covered: (1,2)
100100
| MC/DC Coverage for Decision: 100.00%
101101
|
102102
|---> MC/DC Decision Region (LL:24) to (LL:30)
@@ -195,11 +195,11 @@
195195
|
196196
| C1, C2 Result
197197
| 1 { F, F = F }
198-
| 2 { T, - = T }
199-
| 3 { F, T = T }
198+
| 2 { F, T = T }
199+
| 3 { T, - = T }
200200
|
201-
| C1-Pair: covered: (1,2)
202-
| C2-Pair: covered: (1,3)
201+
| C1-Pair: covered: (1,3)
202+
| C2-Pair: covered: (1,2)
203203
| MC/DC Coverage for Decision: 100.00%
204204
|
205205
|---> MC/DC Decision Region (LL:28) to (LL:34)

‎tests/coverage/mcdc/non_control_flow.cov-map

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Function name: non_control_flow::assign_3
2-
Raw bytes (89): 0x[01, 01, 09, 05, 07, 0b, 11, 09, 0d, 01, 05, 01, 05, 22, 11, 01, 05, 22, 11, 01, 05, 0a, 01, 16, 01, 00, 28, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 00, 03, 00, 0d, 00, 18, 30, 05, 22, 01, 00, 02, 00, 0d, 00, 0e, 22, 00, 12, 00, 13, 30, 1e, 11, 02, 03, 00, 00, 12, 00, 13, 1e, 00, 17, 00, 18, 30, 09, 0d, 03, 00, 00, 00, 17, 00, 18, 03, 01, 05, 01, 02]
2+
Raw bytes (89): 0x[01, 01, 09, 05, 07, 0b, 11, 09, 0d, 01, 05, 01, 05, 22, 11, 01, 05, 22, 11, 01, 05, 0a, 01, 16, 01, 00, 28, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 04, 03, 00, 0d, 00, 18, 30, 05, 22, 01, 00, 02, 00, 0d, 00, 0e, 22, 00, 12, 00, 13, 30, 1e, 11, 02, 03, 00, 00, 12, 00, 13, 1e, 00, 17, 00, 18, 30, 09, 0d, 03, 00, 00, 00, 17, 00, 18, 03, 01, 05, 01, 02]
33
Number of files: 1
44
- file 0 => global file 1
55
Number of expressions: 9
@@ -17,7 +17,7 @@ Number of file 0 mappings: 10
1717
- Code(Expression(0, Add)) at (prev + 1, 9) to (start + 0, 10)
1818
= (c1 + ((c2 + c3) + c4))
1919
- Code(Counter(0)) at (prev + 0, 13) to (start + 0, 14)
20-
- MCDCDecision { bitmap_idx: 0, conditions_num: 3 } at (prev + 0, 13) to (start + 0, 24)
20+
- MCDCDecision { bitmap_idx: 4, conditions_num: 3 } at (prev + 0, 13) to (start + 0, 24)
2121
- MCDCBranch { true: Counter(1), false: Expression(8, Sub), condition_id: 1, true_next_id: 0, false_next_id: 2 } at (prev + 0, 13) to (start + 0, 14)
2222
true = c1
2323
false = (c0 - c1)
@@ -35,7 +35,7 @@ Number of file 0 mappings: 10
3535
= (c1 + ((c2 + c3) + c4))
3636

3737
Function name: non_control_flow::assign_3_bis
38-
Raw bytes (85): 0x[01, 01, 07, 07, 11, 09, 0d, 01, 05, 05, 09, 16, 1a, 05, 09, 01, 05, 0a, 01, 1b, 01, 00, 2c, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 00, 03, 00, 0d, 00, 18, 30, 05, 1a, 01, 03, 02, 00, 0d, 00, 0e, 05, 00, 12, 00, 13, 30, 09, 16, 03, 00, 02, 00, 12, 00, 13, 13, 00, 17, 00, 18, 30, 0d, 11, 02, 00, 00, 00, 17, 00, 18, 03, 01, 05, 01, 02]
38+
Raw bytes (85): 0x[01, 01, 07, 07, 11, 09, 0d, 01, 05, 05, 09, 16, 1a, 05, 09, 01, 05, 0a, 01, 1b, 01, 00, 2c, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 05, 03, 00, 0d, 00, 18, 30, 05, 1a, 01, 03, 02, 00, 0d, 00, 0e, 05, 00, 12, 00, 13, 30, 09, 16, 03, 00, 02, 00, 12, 00, 13, 13, 00, 17, 00, 18, 30, 0d, 11, 02, 00, 00, 00, 17, 00, 18, 03, 01, 05, 01, 02]
3939
Number of files: 1
4040
- file 0 => global file 1
4141
Number of expressions: 7
@@ -51,7 +51,7 @@ Number of file 0 mappings: 10
5151
- Code(Expression(0, Add)) at (prev + 1, 9) to (start + 0, 10)
5252
= ((c2 + c3) + c4)
5353
- Code(Counter(0)) at (prev + 0, 13) to (start + 0, 14)
54-
- MCDCDecision { bitmap_idx: 0, conditions_num: 3 } at (prev + 0, 13) to (start + 0, 24)
54+
- MCDCDecision { bitmap_idx: 5, conditions_num: 3 } at (prev + 0, 13) to (start + 0, 24)
5555
- MCDCBranch { true: Counter(1), false: Expression(6, Sub), condition_id: 1, true_next_id: 3, false_next_id: 2 } at (prev + 0, 13) to (start + 0, 14)
5656
true = c1
5757
false = (c0 - c1)
@@ -68,7 +68,7 @@ Number of file 0 mappings: 10
6868
= ((c2 + c3) + c4)
6969

7070
Function name: non_control_flow::assign_and
71-
Raw bytes (64): 0x[01, 01, 04, 07, 0e, 09, 0d, 01, 05, 01, 05, 08, 01, 0c, 01, 00, 21, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 00, 02, 00, 0d, 00, 13, 30, 05, 0e, 01, 02, 00, 00, 0d, 00, 0e, 05, 00, 12, 00, 13, 30, 09, 0d, 02, 00, 00, 00, 12, 00, 13, 03, 01, 05, 01, 02]
71+
Raw bytes (64): 0x[01, 01, 04, 07, 0e, 09, 0d, 01, 05, 01, 05, 08, 01, 0c, 01, 00, 21, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 03, 02, 00, 0d, 00, 13, 30, 05, 0e, 01, 02, 00, 00, 0d, 00, 0e, 05, 00, 12, 00, 13, 30, 09, 0d, 02, 00, 00, 00, 12, 00, 13, 03, 01, 05, 01, 02]
7272
Number of files: 1
7373
- file 0 => global file 1
7474
Number of expressions: 4
@@ -81,7 +81,7 @@ Number of file 0 mappings: 8
8181
- Code(Expression(0, Add)) at (prev + 1, 9) to (start + 0, 10)
8282
= ((c2 + c3) + (c0 - c1))
8383
- Code(Counter(0)) at (prev + 0, 13) to (start + 0, 14)
84-
- MCDCDecision { bitmap_idx: 0, conditions_num: 2 } at (prev + 0, 13) to (start + 0, 19)
84+
- MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 0, 13) to (start + 0, 19)
8585
- MCDCBranch { true: Counter(1), false: Expression(3, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 14)
8686
true = c1
8787
false = (c0 - c1)
@@ -93,7 +93,7 @@ Number of file 0 mappings: 8
9393
= ((c2 + c3) + (c0 - c1))
9494

9595
Function name: non_control_flow::assign_or
96-
Raw bytes (64): 0x[01, 01, 04, 07, 0d, 05, 09, 01, 05, 01, 05, 08, 01, 11, 01, 00, 20, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 00, 02, 00, 0d, 00, 13, 30, 05, 0e, 01, 00, 02, 00, 0d, 00, 0e, 0e, 00, 12, 00, 13, 30, 09, 0d, 02, 00, 00, 00, 12, 00, 13, 03, 01, 05, 01, 02]
96+
Raw bytes (64): 0x[01, 01, 04, 07, 0d, 05, 09, 01, 05, 01, 05, 08, 01, 11, 01, 00, 20, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 03, 02, 00, 0d, 00, 13, 30, 05, 0e, 01, 00, 02, 00, 0d, 00, 0e, 0e, 00, 12, 00, 13, 30, 09, 0d, 02, 00, 00, 00, 12, 00, 13, 03, 01, 05, 01, 02]
9797
Number of files: 1
9898
- file 0 => global file 1
9999
Number of expressions: 4
@@ -106,7 +106,7 @@ Number of file 0 mappings: 8
106106
- Code(Expression(0, Add)) at (prev + 1, 9) to (start + 0, 10)
107107
= ((c1 + c2) + c3)
108108
- Code(Counter(0)) at (prev + 0, 13) to (start + 0, 14)
109-
- MCDCDecision { bitmap_idx: 0, conditions_num: 2 } at (prev + 0, 13) to (start + 0, 19)
109+
- MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 0, 13) to (start + 0, 19)
110110
- MCDCBranch { true: Counter(1), false: Expression(3, Sub), condition_id: 1, true_next_id: 0, false_next_id: 2 } at (prev + 0, 13) to (start + 0, 14)
111111
true = c1
112112
false = (c0 - c1)
@@ -127,7 +127,7 @@ Number of file 0 mappings: 1
127127
- Code(Counter(0)) at (prev + 37, 1) to (start + 2, 2)
128128

129129
Function name: non_control_flow::func_call
130-
Raw bytes (52): 0x[01, 01, 03, 01, 05, 0b, 02, 09, 0d, 06, 01, 29, 01, 01, 0a, 28, 00, 02, 01, 09, 00, 0f, 30, 05, 02, 01, 02, 00, 00, 09, 00, 0a, 05, 00, 0e, 00, 0f, 30, 09, 0d, 02, 00, 00, 00, 0e, 00, 0f, 07, 01, 01, 00, 02]
130+
Raw bytes (52): 0x[01, 01, 03, 01, 05, 0b, 02, 09, 0d, 06, 01, 29, 01, 01, 0a, 28, 03, 02, 01, 09, 00, 0f, 30, 05, 02, 01, 02, 00, 00, 09, 00, 0a, 05, 00, 0e, 00, 0f, 30, 09, 0d, 02, 00, 00, 00, 0e, 00, 0f, 07, 01, 01, 00, 02]
131131
Number of files: 1
132132
- file 0 => global file 1
133133
Number of expressions: 3
@@ -136,7 +136,7 @@ Number of expressions: 3
136136
- expression 2 operands: lhs = Counter(2), rhs = Counter(3)
137137
Number of file 0 mappings: 6
138138
- Code(Counter(0)) at (prev + 41, 1) to (start + 1, 10)
139-
- MCDCDecision { bitmap_idx: 0, conditions_num: 2 } at (prev + 1, 9) to (start + 0, 15)
139+
- MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 1, 9) to (start + 0, 15)
140140
- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 9) to (start + 0, 10)
141141
true = c1
142142
false = (c0 - c1)
@@ -148,7 +148,7 @@ Number of file 0 mappings: 6
148148
= ((c2 + c3) + (c0 - c1))
149149

150150
Function name: non_control_flow::right_comb_tree
151-
Raw bytes (139): 0x[01, 01, 13, 07, 1a, 0b, 19, 0f, 15, 13, 11, 09, 0d, 01, 05, 01, 05, 05, 19, 05, 19, 4a, 15, 05, 19, 4a, 15, 05, 19, 46, 11, 4a, 15, 05, 19, 46, 11, 4a, 15, 05, 19, 0e, 01, 20, 01, 00, 41, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 00, 05, 00, 0d, 00, 2a, 30, 05, 1a, 01, 02, 00, 00, 0d, 00, 0e, 05, 00, 13, 00, 14, 30, 4a, 19, 02, 03, 00, 00, 13, 00, 14, 4a, 00, 19, 00, 1a, 30, 46, 15, 03, 04, 00, 00, 19, 00, 1a, 46, 00, 1f, 00, 20, 30, 42, 11, 04, 05, 00, 00, 1f, 00, 20, 42, 00, 24, 00, 27, 30, 09, 0d, 05, 00, 00, 00, 24, 00, 27, 03, 01, 05, 01, 02]
151+
Raw bytes (139): 0x[01, 01, 13, 07, 1a, 0b, 19, 0f, 15, 13, 11, 09, 0d, 01, 05, 01, 05, 05, 19, 05, 19, 4a, 15, 05, 19, 4a, 15, 05, 19, 46, 11, 4a, 15, 05, 19, 46, 11, 4a, 15, 05, 19, 0e, 01, 20, 01, 00, 41, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 06, 05, 00, 0d, 00, 2a, 30, 05, 1a, 01, 02, 00, 00, 0d, 00, 0e, 05, 00, 13, 00, 14, 30, 4a, 19, 02, 03, 00, 00, 13, 00, 14, 4a, 00, 19, 00, 1a, 30, 46, 15, 03, 04, 00, 00, 19, 00, 1a, 46, 00, 1f, 00, 20, 30, 42, 11, 04, 05, 00, 00, 1f, 00, 20, 42, 00, 24, 00, 27, 30, 09, 0d, 05, 00, 00, 00, 24, 00, 27, 03, 01, 05, 01, 02]
152152
Number of files: 1
153153
- file 0 => global file 1
154154
Number of expressions: 19
@@ -176,7 +176,7 @@ Number of file 0 mappings: 14
176176
- Code(Expression(0, Add)) at (prev + 1, 9) to (start + 0, 10)
177177
= (((((c2 + c3) + c4) + c5) + c6) + (c0 - c1))
178178
- Code(Counter(0)) at (prev + 0, 13) to (start + 0, 14)
179-
- MCDCDecision { bitmap_idx: 0, conditions_num: 5 } at (prev + 0, 13) to (start + 0, 42)
179+
- MCDCDecision { bitmap_idx: 6, conditions_num: 5 } at (prev + 0, 13) to (start + 0, 42)
180180
- MCDCBranch { true: Counter(1), false: Expression(6, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 14)
181181
true = c1
182182
false = (c0 - c1)

‎tests/coverage/mcdc/non_control_flow.coverage

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@
8383
|
8484
| C1, C2, C3 Result
8585
| 1 { F, F, - = F }
86-
| 2 { T, -, - = T }
87-
| 3 { F, T, T = T }
86+
| 2 { F, T, T = T }
87+
| 3 { T, -, - = T }
8888
|
89-
| C1-Pair: covered: (1,2)
90-
| C2-Pair: covered: (1,3)
89+
| C1-Pair: covered: (1,3)
90+
| C2-Pair: covered: (1,2)
9191
| C3-Pair: not covered
9292
| MC/DC Coverage for Decision: 66.67%
9393
|

‎tests/ui/instrument-coverage/mcdc-condition-limit.bad.stderr

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//@ edition: 2021
2-
//@ revisions: good bad
2+
//@ min-llvm-version: 19
3+
//@ revisions: good
34
//@ check-pass
45
//@ compile-flags: -Cinstrument-coverage -Zcoverage-options=mcdc -Zno-profiler-runtime
56

@@ -14,18 +15,9 @@
1415

1516
#[cfg(good)]
1617
fn main() {
17-
// 6 conditions is OK, so no diagnostic.
18-
let [a, b, c, d, e, f] = <[bool; 6]>::default();
19-
if a && b && c && d && e && f {
20-
core::hint::black_box("hello");
21-
}
22-
}
23-
24-
#[cfg(bad)]
25-
fn main() {
26-
// 7 conditions is too many, so issue a diagnostic.
18+
// 7 conditions is allowed, so no diagnostic.
2719
let [a, b, c, d, e, f, g] = <[bool; 7]>::default();
28-
if a && b && c && d && e && f && g { //[bad]~ WARNING number of conditions in decision
20+
if a && b && c && d && e && f && g {
2921
core::hint::black_box("hello");
3022
}
3123
}

0 commit comments

Comments
 (0)
Please sign in to comment.