@@ -108,7 +108,6 @@ pub struct Postorder<'a, 'tcx> {
108
108
basic_blocks : & ' a IndexSlice < BasicBlock , BasicBlockData < ' tcx > > ,
109
109
visited : DenseBitSet < BasicBlock > ,
110
110
visit_stack : Vec < ( BasicBlock , Successors < ' a > ) > ,
111
- root_is_start_block : bool ,
112
111
/// A non-empty `extra` allows for a precise calculation of the successors.
113
112
extra : Option < ( TyCtxt < ' tcx > , Instance < ' tcx > ) > ,
114
113
}
@@ -123,7 +122,6 @@ impl<'a, 'tcx> Postorder<'a, 'tcx> {
123
122
basic_blocks,
124
123
visited : DenseBitSet :: new_empty ( basic_blocks. len ( ) ) ,
125
124
visit_stack : Vec :: new ( ) ,
126
- root_is_start_block : root == START_BLOCK ,
127
125
extra,
128
126
} ;
129
127
@@ -211,16 +209,13 @@ impl<'tcx> Iterator for Postorder<'_, 'tcx> {
211
209
}
212
210
213
211
fn size_hint ( & self ) -> ( usize , Option < usize > ) {
214
- // All the blocks, minus the number of blocks we've visited.
215
- let upper = self . basic_blocks . len ( ) - self . visited . count ( ) ;
216
-
217
- let lower = if self . root_is_start_block {
218
- // We will visit all remaining blocks exactly once.
219
- upper
220
- } else {
221
- self . visit_stack . len ( )
222
- } ;
212
+ // These bounds are not at all tight, but that's fine.
213
+ // It's not worth a popcnt loop in `DenseBitSet` to improve the upper,
214
+ // and in mono-reachable we can't be precise anyway.
215
+ // Leaning on amortized growth is fine.
223
216
217
+ let lower = self . visit_stack . len ( ) ;
218
+ let upper = self . basic_blocks . len ( ) ;
224
219
( lower, Some ( upper) )
225
220
}
226
221
}
0 commit comments