Skip to content

Commit

Permalink
coverage: Remove code for making expression copies of BCB counters
Browse files Browse the repository at this point in the history
Now that coverage statements can have multiple code regions attached to them,
this code is never used.
  • Loading branch information
Zalathar committed Oct 3, 2023
1 parent 86a66c8 commit b1cf0c8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
4 changes: 0 additions & 4 deletions compiler/rustc_mir_transform/src/coverage/counters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@ impl CoverageCounters {
BcbCounter::Expression { id, lhs, op, rhs }
}

pub fn make_identity_counter(&mut self, counter_operand: Operand) -> BcbCounter {
self.make_expression(counter_operand, Op::Add, Operand::Zero)
}

/// Counter IDs start from one and go up.
fn next_counter(&mut self) -> CounterId {
let next = self.next_counter_id;
Expand Down
12 changes: 2 additions & 10 deletions compiler/rustc_mir_transform/src/coverage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ use self::spans::CoverageSpans;

use crate::MirPass;

use rustc_data_structures::graph::WithNumNodes;
use rustc_data_structures::sync::Lrc;
use rustc_index::IndexVec;
use rustc_middle::hir;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::mir::coverage::*;
Expand Down Expand Up @@ -223,16 +221,10 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> {
let body_span = self.body_span;
let file_name = Symbol::intern(&self.source_file.name.prefer_remapped().to_string_lossy());

let mut bcb_counters = IndexVec::from_elem_n(None, self.basic_coverage_blocks.num_nodes());
for (bcb, spans) in coverage_spans.bcbs_with_coverage_spans() {
let counter_kind = if let Some(&counter_operand) = bcb_counters[bcb].as_ref() {
self.coverage_counters.make_identity_counter(counter_operand)
} else if let Some(counter_kind) = self.coverage_counters.take_bcb_counter(bcb) {
bcb_counters[bcb] = Some(counter_kind.as_operand());
counter_kind
} else {
let counter_kind = self.coverage_counters.take_bcb_counter(bcb).unwrap_or_else(|| {
bug!("Every BasicCoverageBlock should have a Counter or Expression");
};
});

// Convert the coverage spans into a vector of code regions to be
// associated with this BCB's coverage statement.
Expand Down

0 comments on commit b1cf0c8

Please sign in to comment.