@@ -53,21 +53,12 @@ struct BcbExpression {
53
53
rhs : BcbCounter ,
54
54
}
55
55
56
- /// Enum representing either a node or an edge in the coverage graph.
57
- ///
58
- /// FIXME(#135481): This enum is no longer needed now that we only instrument
59
- /// nodes and not edges. It can be removed in a subsequent PR.
60
- #[ derive( Clone , Copy , Debug , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
61
- pub ( super ) enum Site {
62
- Node { bcb : BasicCoverageBlock } ,
63
- }
64
-
65
56
/// Generates and stores coverage counter and coverage expression information
66
- /// associated with nodes/edges in the BCB graph.
57
+ /// associated with nodes in the coverage graph.
67
58
pub ( super ) struct CoverageCounters {
68
59
/// List of places where a counter-increment statement should be injected
69
60
/// into MIR, each with its corresponding counter ID.
70
- counter_increment_sites : IndexVec < CounterId , Site > ,
61
+ counter_increment_sites : IndexVec < CounterId , BasicCoverageBlock > ,
71
62
72
63
/// Coverage counters/expressions that are associated with individual BCBs.
73
64
node_counters : IndexVec < BasicCoverageBlock , Option < BcbCounter > > ,
@@ -130,9 +121,9 @@ impl CoverageCounters {
130
121
}
131
122
}
132
123
133
- /// Creates a new physical counter for a BCB node or edge .
134
- fn make_phys_counter ( & mut self , site : Site ) -> BcbCounter {
135
- let id = self . counter_increment_sites . push ( site ) ;
124
+ /// Creates a new physical counter for a BCB node.
125
+ fn make_phys_counter ( & mut self , bcb : BasicCoverageBlock ) -> BcbCounter {
126
+ let id = self . counter_increment_sites . push ( bcb ) ;
136
127
BcbCounter :: Counter { id }
137
128
}
138
129
@@ -177,12 +168,12 @@ impl CoverageCounters {
177
168
self . node_counters [ bcb] . map ( |counter| counter. as_term ( ) )
178
169
}
179
170
180
- /// Returns an iterator over all the nodes/edges in the coverage graph that
171
+ /// Returns an iterator over all the nodes in the coverage graph that
181
172
/// should have a counter-increment statement injected into MIR, along with
182
173
/// each site's corresponding counter ID.
183
174
pub ( super ) fn counter_increment_sites (
184
175
& self ,
185
- ) -> impl Iterator < Item = ( CounterId , Site ) > + Captures < ' _ > {
176
+ ) -> impl Iterator < Item = ( CounterId , BasicCoverageBlock ) > + Captures < ' _ > {
186
177
self . counter_increment_sites . iter_enumerated ( ) . map ( |( id, & site) | ( id, site) )
187
178
}
188
179
@@ -221,15 +212,15 @@ impl CoverageCounters {
221
212
struct Transcriber {
222
213
old : NodeCounters < BasicCoverageBlock > ,
223
214
new : CoverageCounters ,
224
- phys_counter_for_site : FxHashMap < Site , BcbCounter > ,
215
+ phys_counter_for_node : FxHashMap < BasicCoverageBlock , BcbCounter > ,
225
216
}
226
217
227
218
impl Transcriber {
228
219
fn new ( num_nodes : usize , old : NodeCounters < BasicCoverageBlock > ) -> Self {
229
220
Self {
230
221
old,
231
222
new : CoverageCounters :: with_num_bcbs ( num_nodes) ,
232
- phys_counter_for_site : FxHashMap :: default ( ) ,
223
+ phys_counter_for_node : FxHashMap :: default ( ) ,
233
224
}
234
225
}
235
226
@@ -238,7 +229,6 @@ impl Transcriber {
238
229
bcb_needs_counter : & DenseBitSet < BasicCoverageBlock > ,
239
230
) -> CoverageCounters {
240
231
for bcb in bcb_needs_counter. iter ( ) {
241
- let site = Site :: Node { bcb } ;
242
232
let ( mut pos, mut neg) : ( Vec < _ > , Vec < _ > ) =
243
233
self . old . counter_expr ( bcb) . iter ( ) . partition_map (
244
234
|& CounterTerm { node, op } | match op {
@@ -251,7 +241,7 @@ impl Transcriber {
251
241
// If we somehow end up with no positive terms, fall back to
252
242
// creating a physical counter. There's no known way for this
253
243
// to happen, but we can avoid an ICE if it does.
254
- debug_assert ! ( false , "{site :?} has no positive counter terms" ) ;
244
+ debug_assert ! ( false , "{bcb :?} has no positive counter terms" ) ;
255
245
pos = vec ! [ bcb] ;
256
246
neg = vec ! [ ] ;
257
247
}
@@ -260,10 +250,7 @@ impl Transcriber {
260
250
neg. sort ( ) ;
261
251
262
252
let mut new_counters_for_sites = |sites : Vec < BasicCoverageBlock > | {
263
- sites
264
- . into_iter ( )
265
- . map ( |node| self . ensure_phys_counter ( Site :: Node { bcb : node } ) )
266
- . collect :: < Vec < _ > > ( )
253
+ sites. into_iter ( ) . map ( |node| self . ensure_phys_counter ( node) ) . collect :: < Vec < _ > > ( )
267
254
} ;
268
255
let mut pos = new_counters_for_sites ( pos) ;
269
256
let mut neg = new_counters_for_sites ( neg) ;
@@ -279,7 +266,7 @@ impl Transcriber {
279
266
self . new
280
267
}
281
268
282
- fn ensure_phys_counter ( & mut self , site : Site ) -> BcbCounter {
283
- * self . phys_counter_for_site . entry ( site ) . or_insert_with ( || self . new . make_phys_counter ( site ) )
269
+ fn ensure_phys_counter ( & mut self , bcb : BasicCoverageBlock ) -> BcbCounter {
270
+ * self . phys_counter_for_node . entry ( bcb ) . or_insert_with ( || self . new . make_phys_counter ( bcb ) )
284
271
}
285
272
}
0 commit comments