Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Coverage][MCDC] Prepare MCDC Builder for pattern matching and llvm 19 #126677

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
coverage. Refactor MCDCInfoBuilder for pattern matching implementatio…
…n and change the way to calculate decision depth
  • Loading branch information
zhuyunxing committed Jul 25, 2024
commit e16030817b8bb5d0039239b8c9f5f9fb256a41e9
7 changes: 6 additions & 1 deletion compiler/rustc_middle/src/mir/coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ rustc_index::newtype_index! {
#[debug_format = "ExpressionId({})"]
pub struct ExpressionId {}
}

rustc_index::newtype_index! {
/// ID of a mcdc condition. Used by llvm to check mcdc coverage.
///
Expand Down Expand Up @@ -332,3 +331,9 @@ pub struct MCDCDecisionSpan {
pub end_markers: Vec<BlockMarkerId>,
pub decision_depth: u16,
}

impl MCDCDecisionSpan {
pub fn new(span: Span) -> Self {
Self { span, num_conditions: 0, end_markers: Vec::new(), decision_depth: 0 }
}
}
11 changes: 8 additions & 3 deletions compiler/rustc_mir_build/src/build/coverageinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ impl CoverageInfoBuilder {
// Separate path for handling branches when MC/DC is enabled.
if let Some(mcdc_info) = self.mcdc_info.as_mut() {
let inject_block_marker =
|source_info, block| self.markers.inject_block_marker(cfg, source_info, block);
|block| self.markers.inject_block_marker(cfg, source_info, block);
mcdc_info.visit_evaluated_condition(
tcx,
source_info,
source_info.span,
true_block,
false_block,
inject_block_marker,
Expand Down Expand Up @@ -175,8 +175,13 @@ impl CoverageInfoBuilder {
let branch_spans =
branch_info.map(|branch_info| branch_info.branch_spans).unwrap_or_default();

let (mcdc_decision_spans, mcdc_branch_spans) =
let (mut mcdc_branch_spans, mcdc_spans) =
mcdc_info.map(MCDCInfoBuilder::into_done).unwrap_or_default();
let mut mcdc_decision_spans = Vec::with_capacity(mcdc_spans.len());
for (decision, conditions) in mcdc_spans {
mcdc_branch_spans.extend(conditions);
mcdc_decision_spans.push(decision);
}

// For simplicity, always return an info struct (without Option), even
// if there's nothing interesting in it.
Expand Down
Loading