Skip to content

Commit ae85b37

Browse files
committed
mcdc-coverage: rename Decision marker to MCDCDecisionEntryMarker, add output marker
1 parent 156bb78 commit ae85b37

File tree

5 files changed

+29
-16
lines changed

5 files changed

+29
-16
lines changed

compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
107107
CoverageKind::SpanMarker
108108
| CoverageKind::BlockMarker { .. }
109109
| CoverageKind::MCDCBlockMarker { .. }
110-
| CoverageKind::MCDCDecisionMarker { .. } => unreachable!(
110+
| CoverageKind::MCDCDecisionEntryMarker { .. }
111+
| CoverageKind::MCDCDecisionOutputMarker { .. } => unreachable!(
111112
"marker statement {kind:?} should have been removed by CleanupPostBorrowck"
112113
),
113114
CoverageKind::CounterIncrement { id } => {

compiler/rustc_middle/src/mir/coverage.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,14 @@ pub enum CoverageKind {
114114
/// conditions in the same decision will reference this id.
115115
///
116116
/// Has no effect during codegen.
117-
MCDCDecisionMarker { id: DecisionMarkerId },
117+
MCDCDecisionEntryMarker { id: DecisionMarkerId },
118+
119+
/// Marks one of the basic blocks following the decision referenced with `id`.
120+
/// the outcome bool designates which branch of the decision it is:
121+
/// `true` for the then block, `false` for the else block.
122+
///
123+
/// Has no effect during codegen.
124+
MCDCDecisionOutputMarker { id: DecisionMarkerId, outcome: bool },
118125

119126
/// Declares the number of bytes needed to store the test-vector bitmaps of
120127
/// all the decisions in the function body.
@@ -151,8 +158,15 @@ impl Debug for CoverageKind {
151158
MCDCBlockMarker { id, decision_id } => {
152159
write!(fmt, "MCDCBlockMarker({:?}, {:?})", id.index(), decision_id.index())
153160
}
154-
MCDCDecisionMarker { id } => write!(fmt, "MCDCDecisionMarker({:?})", id.index()),
155-
MCDCBitmapRequire { needed_bytes } => write!(fmt, "MCDCBitmapRequire({needed_bytes} bytes)"),
161+
MCDCDecisionEntryMarker { id } => {
162+
write!(fmt, "MCDCDecisionEntryMarker({:?})", id.index())
163+
}
164+
&MCDCDecisionOutputMarker { id, outcome } => {
165+
write!(fmt, "MCDCDecisionOutputMarker({:?}, {})", id.index(), outcome)
166+
}
167+
MCDCBitmapRequire { needed_bytes } => {
168+
write!(fmt, "MCDCBitmapRequire({needed_bytes} bytes)")
169+
}
156170
CounterIncrement { id } => write!(fmt, "CounterIncrement({:?})", id.index()),
157171
ExpressionUsed { id } => write!(fmt, "ExpressionUsed({:?})", id.index()),
158172
}

compiler/rustc_mir_build/src/build/coverageinfo.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,7 @@ impl BranchInfoBuilder {
106106
}
107107

108108
let mut decision_spans = IndexVec::from_iter(
109-
decisions
110-
.into_iter()
111-
.map(|span| DecisionSpan { span, num_conditions: 0 }),
109+
decisions.into_iter().map(|span| DecisionSpan { span, num_conditions: 0 }),
112110
);
113111

114112
// Count the number of conditions linked to each decision.
@@ -161,10 +159,8 @@ impl Builder<'_, '_> {
161159
CoverageKind::BlockMarker { id }
162160
};
163161

164-
let marker_statement = mir::Statement {
165-
source_info,
166-
kind: mir::StatementKind::Coverage(cov_kind),
167-
};
162+
let marker_statement =
163+
mir::Statement { source_info, kind: mir::StatementKind::Coverage(cov_kind) };
168164
self.cfg.push(block, marker_statement);
169165

170166
id
@@ -204,9 +200,9 @@ impl Builder<'_, '_> {
204200
let source_info = self.source_info(span);
205201
let marker_statement = mir::Statement {
206202
source_info,
207-
kind: mir::StatementKind::Coverage(
208-
CoverageKind::MCDCDecisionMarker { id: decision_id },
209-
),
203+
kind: mir::StatementKind::Coverage(CoverageKind::MCDCDecisionEntryMarker {
204+
id: decision_id,
205+
}),
210206
};
211207
self.cfg.push(block, marker_statement);
212208

compiler/rustc_mir_transform/src/cleanup_post_borrowck.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ impl<'tcx> MirPass<'tcx> for CleanupPostBorrowck {
3838
CoverageKind::BlockMarker { .. }
3939
| CoverageKind::SpanMarker { .. }
4040
| CoverageKind::MCDCBlockMarker { .. }
41-
| CoverageKind::MCDCDecisionMarker { .. },
41+
| CoverageKind::MCDCDecisionEntryMarker { .. }
42+
| CoverageKind::MCDCDecisionOutputMarker { .. },
4243
)
4344
| StatementKind::FakeRead(..) => statement.make_nop(),
4445
_ => (),

compiler/rustc_mir_transform/src/coverage/spans/from_mir.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ fn filtered_statement_span(statement: &Statement<'_>) -> Option<Span> {
227227
CoverageKind::BlockMarker {..}
228228
// Ignore MCDC markers as well
229229
| CoverageKind::MCDCBlockMarker{ .. }
230-
| CoverageKind::MCDCDecisionMarker{ .. }
230+
| CoverageKind::MCDCDecisionEntryMarker{ .. }
231+
| CoverageKind::MCDCDecisionOutputMarker { .. }
231232
) => None,
232233

233234
// These coverage statements should not exist prior to coverage instrumentation.

0 commit comments

Comments
 (0)