coverage: Remove debug code from the instrumentor
This commit is contained in:
parent
4b91288484
commit
3d66513fe4
9 changed files with 18 additions and 1030 deletions
|
@ -1,10 +1,8 @@
|
|||
use super::Error;
|
||||
|
||||
use super::debug;
|
||||
use super::graph;
|
||||
use super::spans;
|
||||
|
||||
use debug::{DebugCounters, NESTED_INDENT};
|
||||
use graph::{BasicCoverageBlock, BcbBranch, CoverageGraph, TraverseCoverageGraphWithLoops};
|
||||
use spans::CoverageSpan;
|
||||
|
||||
|
@ -16,6 +14,8 @@ use rustc_middle::mir::coverage::*;
|
|||
|
||||
use std::fmt::{self, Debug};
|
||||
|
||||
const NESTED_INDENT: &str = " ";
|
||||
|
||||
/// The coverage counter or counter expression associated with a particular
|
||||
/// BCB node or BCB edge.
|
||||
#[derive(Clone)]
|
||||
|
@ -75,8 +75,6 @@ pub(super) struct CoverageCounters {
|
|||
/// BCB/edge, but are needed as operands to more complex expressions.
|
||||
/// These are always [`BcbCounter::Expression`].
|
||||
pub(super) intermediate_expressions: Vec<BcbCounter>,
|
||||
|
||||
pub debug_counters: DebugCounters,
|
||||
}
|
||||
|
||||
impl CoverageCounters {
|
||||
|
@ -91,17 +89,9 @@ impl CoverageCounters {
|
|||
bcb_edge_counters: FxHashMap::default(),
|
||||
bcb_has_incoming_edge_counters: BitSet::new_empty(num_bcbs),
|
||||
intermediate_expressions: Vec::new(),
|
||||
|
||||
debug_counters: DebugCounters::new(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Activate the `DebugCounters` data structures, to provide additional debug formatting
|
||||
/// features when formatting [`BcbCounter`] (counter) values.
|
||||
pub fn enable_debug(&mut self) {
|
||||
self.debug_counters.enable();
|
||||
}
|
||||
|
||||
/// Makes [`BcbCounter`] `Counter`s and `Expressions` for the `BasicCoverageBlock`s directly or
|
||||
/// indirectly associated with `CoverageSpans`, and accumulates additional `Expression`s
|
||||
/// representing intermediate values.
|
||||
|
@ -113,15 +103,12 @@ impl CoverageCounters {
|
|||
MakeBcbCounters::new(self, basic_coverage_blocks).make_bcb_counters(coverage_spans)
|
||||
}
|
||||
|
||||
fn make_counter<F>(&mut self, debug_block_label_fn: F) -> BcbCounter
|
||||
fn make_counter<F>(&mut self, _debug_block_label_fn: F) -> BcbCounter
|
||||
where
|
||||
F: Fn() -> Option<String>,
|
||||
{
|
||||
let counter = BcbCounter::Counter { id: self.next_counter() };
|
||||
if self.debug_counters.is_enabled() {
|
||||
self.debug_counters.add_counter(&counter, (debug_block_label_fn)());
|
||||
}
|
||||
counter
|
||||
let id = self.next_counter();
|
||||
BcbCounter::Counter { id }
|
||||
}
|
||||
|
||||
fn make_expression<F>(
|
||||
|
@ -129,28 +116,17 @@ impl CoverageCounters {
|
|||
lhs: Operand,
|
||||
op: Op,
|
||||
rhs: Operand,
|
||||
debug_block_label_fn: F,
|
||||
_debug_block_label_fn: F,
|
||||
) -> BcbCounter
|
||||
where
|
||||
F: Fn() -> Option<String>,
|
||||
{
|
||||
let id = self.next_expression();
|
||||
let expression = BcbCounter::Expression { id, lhs, op, rhs };
|
||||
if self.debug_counters.is_enabled() {
|
||||
self.debug_counters.add_counter(&expression, (debug_block_label_fn)());
|
||||
}
|
||||
expression
|
||||
BcbCounter::Expression { id, lhs, op, rhs }
|
||||
}
|
||||
|
||||
pub fn make_identity_counter(&mut self, counter_operand: Operand) -> BcbCounter {
|
||||
let some_debug_block_label = if self.debug_counters.is_enabled() {
|
||||
self.debug_counters.some_block_label(counter_operand).cloned()
|
||||
} else {
|
||||
None
|
||||
};
|
||||
self.make_expression(counter_operand, Op::Add, Operand::Zero, || {
|
||||
some_debug_block_label.clone()
|
||||
})
|
||||
self.make_expression(counter_operand, Op::Add, Operand::Zero, || unreachable!())
|
||||
}
|
||||
|
||||
/// Counter IDs start from one and go up.
|
||||
|
@ -713,6 +689,6 @@ impl<'a> MakeBcbCounters<'a> {
|
|||
|
||||
#[inline]
|
||||
fn format_counter(&self, counter_kind: &BcbCounter) -> String {
|
||||
self.coverage_counters.debug_counters.format_counter(counter_kind)
|
||||
format!("{counter_kind:?}")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue