1
+ use std:: fmt:: { self , Debug } ;
2
+
1
3
use rustc_data_structures:: captures:: Captures ;
2
4
use rustc_data_structures:: fx:: FxHashMap ;
3
5
use rustc_data_structures:: graph:: WithNumNodes ;
4
- use rustc_index:: bit_set:: BitSet ;
5
6
use rustc_index:: IndexVec ;
6
- use rustc_middle:: mir:: coverage:: * ;
7
+ use rustc_middle:: mir:: coverage:: { CounterId , CovTerm , Expression , ExpressionId , Op } ;
7
8
8
- use super :: graph:: { BasicCoverageBlock , CoverageGraph , TraverseCoverageGraphWithLoops } ;
9
-
10
- use std:: fmt:: { self , Debug } ;
9
+ use crate :: coverage:: graph:: { BasicCoverageBlock , CoverageGraph , TraverseCoverageGraphWithLoops } ;
11
10
12
11
/// The coverage counter or counter expression associated with a particular
13
12
/// BCB node or BCB edge.
@@ -18,10 +17,6 @@ pub(super) enum BcbCounter {
18
17
}
19
18
20
19
impl BcbCounter {
21
- fn is_expression ( & self ) -> bool {
22
- matches ! ( self , Self :: Expression { .. } )
23
- }
24
-
25
20
pub ( super ) fn as_term ( & self ) -> CovTerm {
26
21
match * self {
27
22
BcbCounter :: Counter { id, .. } => CovTerm :: Counter ( id) ,
@@ -60,10 +55,6 @@ pub(super) struct CoverageCounters {
60
55
/// We currently don't iterate over this map, but if we do in the future,
61
56
/// switch it back to `FxIndexMap` to avoid query stability hazards.
62
57
bcb_edge_counters : FxHashMap < ( BasicCoverageBlock , BasicCoverageBlock ) , BcbCounter > ,
63
- /// Tracks which BCBs have a counter associated with some incoming edge.
64
- /// Only used by assertions, to verify that BCBs with incoming edge
65
- /// counters do not have their own physical counters (expressions are allowed).
66
- bcb_has_incoming_edge_counters : BitSet < BasicCoverageBlock > ,
67
58
/// Table of expression data, associating each expression ID with its
68
59
/// corresponding operator (+ or -) and its LHS/RHS operands.
69
60
expressions : IndexVec < ExpressionId , Expression > ,
@@ -83,7 +74,6 @@ impl CoverageCounters {
83
74
counter_increment_sites : IndexVec :: new ( ) ,
84
75
bcb_counters : IndexVec :: from_elem_n ( None , num_bcbs) ,
85
76
bcb_edge_counters : FxHashMap :: default ( ) ,
86
- bcb_has_incoming_edge_counters : BitSet :: new_empty ( num_bcbs) ,
87
77
expressions : IndexVec :: new ( ) ,
88
78
} ;
89
79
@@ -122,14 +112,6 @@ impl CoverageCounters {
122
112
}
123
113
124
114
fn set_bcb_counter ( & mut self , bcb : BasicCoverageBlock , counter_kind : BcbCounter ) -> BcbCounter {
125
- assert ! (
126
- // If the BCB has an edge counter (to be injected into a new `BasicBlock`), it can also
127
- // have an expression (to be injected into an existing `BasicBlock` represented by this
128
- // `BasicCoverageBlock`).
129
- counter_kind. is_expression( ) || !self . bcb_has_incoming_edge_counters. contains( bcb) ,
130
- "attempt to add a `Counter` to a BCB target with existing incoming edge counters"
131
- ) ;
132
-
133
115
if let Some ( replaced) = self . bcb_counters [ bcb] . replace ( counter_kind) {
134
116
bug ! (
135
117
"attempt to set a BasicCoverageBlock coverage counter more than once; \
@@ -146,19 +128,6 @@ impl CoverageCounters {
146
128
to_bcb : BasicCoverageBlock ,
147
129
counter_kind : BcbCounter ,
148
130
) -> BcbCounter {
149
- // If the BCB has an edge counter (to be injected into a new `BasicBlock`), it can also
150
- // have an expression (to be injected into an existing `BasicBlock` represented by this
151
- // `BasicCoverageBlock`).
152
- if let Some ( node_counter) = self . bcb_counter ( to_bcb)
153
- && !node_counter. is_expression ( )
154
- {
155
- bug ! (
156
- "attempt to add an incoming edge counter from {from_bcb:?} \
157
- when the target BCB already has {node_counter:?}"
158
- ) ;
159
- }
160
-
161
- self . bcb_has_incoming_edge_counters . insert ( to_bcb) ;
162
131
if let Some ( replaced) = self . bcb_edge_counters . insert ( ( from_bcb, to_bcb) , counter_kind) {
163
132
bug ! (
164
133
"attempt to set an edge counter more than once; from_bcb: \
0 commit comments