diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2023-10-30 21:42:10 +1100 |
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2023-11-25 12:29:20 +1100 |
| commit | df23279e1e57d47ee1fc8d40395cefc05eb63674 (patch) | |
| tree | b2dac5825d9bb85cfdb4cebf781e833e53742daa /compiler/rustc_mir_transform/src/coverage/counters.rs | |
| parent | 0a17f0697a726bf714fdeea0366ad364bc030023 (diff) | |
| download | rust-df23279e1e57d47ee1fc8d40395cefc05eb63674.tar.gz rust-df23279e1e57d47ee1fc8d40395cefc05eb63674.zip | |
coverage: Push down creation of a visited node's counter
Now that this code path unconditionally calls `make_branch_counters`, we might as well make that method responsible for creating the node's counter as well, since it needs the resulting term anyway.
Diffstat (limited to 'compiler/rustc_mir_transform/src/coverage/counters.rs')
| -rw-r--r-- | compiler/rustc_mir_transform/src/coverage/counters.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/compiler/rustc_mir_transform/src/coverage/counters.rs b/compiler/rustc_mir_transform/src/coverage/counters.rs index 4b0014e502a..bb07c2d390c 100644 --- a/compiler/rustc_mir_transform/src/coverage/counters.rs +++ b/compiler/rustc_mir_transform/src/coverage/counters.rs @@ -226,9 +226,7 @@ impl<'a> MakeBcbCounters<'a> { while let Some(bcb) = traversal.next() { if bcb_has_coverage_spans(bcb) { debug!("{:?} has at least one coverage span. Get or make its counter", bcb); - let branching_counter_operand = self.get_or_make_counter_operand(bcb); - - self.make_branch_counters(&traversal, bcb, branching_counter_operand); + self.make_node_and_branch_counters(&traversal, bcb); } else { debug!( "{:?} does not have any coverage spans. A counter will only be added if \ @@ -245,12 +243,15 @@ impl<'a> MakeBcbCounters<'a> { ); } - fn make_branch_counters( + fn make_node_and_branch_counters( &mut self, traversal: &TraverseCoverageGraphWithLoops<'_>, from_bcb: BasicCoverageBlock, - branching_counter_operand: CovTerm, ) { + // First, ensure that this node has a counter of some kind. + // We might also use its term later to compute one of the branch counters. + let from_bcb_operand = self.get_or_make_counter_operand(from_bcb); + let branches = self.bcb_branches(from_bcb); // If this node doesn't have multiple out-edges, or all of its out-edges @@ -321,7 +322,7 @@ impl<'a> MakeBcbCounters<'a> { self.bcb_predecessors(expression_branch.target_bcb), ); let expression = self.coverage_counters.make_expression( - branching_counter_operand, + from_bcb_operand, Op::Subtract, sumup_counter_operand, ); |
