|
28 | 28 | //! return.
|
29 | 29 |
|
30 | 30 | use crate::MirPass;
|
31 |
| -use rustc_data_structures::fx::{FxHashSet, FxIndexSet}; |
| 31 | +use rustc_data_structures::fx::FxHashSet; |
32 | 32 | use rustc_index::vec::{Idx, IndexSlice, IndexVec};
|
33 | 33 | use rustc_middle::mir::coverage::*;
|
34 | 34 | use rustc_middle::mir::visit::{MutVisitor, MutatingUseContext, PlaceContext, Visitor};
|
@@ -99,7 +99,7 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
|
99 | 99 | // statements itself to avoid moving the (relatively) large statements twice.
|
100 | 100 | // We do not push the statements directly into the target block (`bb`) as that is slower
|
101 | 101 | // due to additional reallocations
|
102 |
| - let mut merged_blocks = Vec::new(); |
| 102 | + let mut merged_blocks = SmallVec::new(); |
103 | 103 | loop {
|
104 | 104 | let mut changed = false;
|
105 | 105 |
|
@@ -203,7 +203,7 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
|
203 | 203 | // merge a block with 1 `goto` predecessor to its parent
|
204 | 204 | fn merge_successor(
|
205 | 205 | &mut self,
|
206 |
| - merged_blocks: &mut Vec<BasicBlock>, |
| 206 | + merged_blocks: &mut SmallVec<[BasicBlock; 2]>, |
207 | 207 | terminator: &mut Terminator<'tcx>,
|
208 | 208 | ) -> bool {
|
209 | 209 | let target = match terminator.kind {
|
@@ -263,7 +263,7 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
|
263 | 263 | pub fn remove_duplicate_unreachable_blocks<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
264 | 264 | struct OptApplier<'tcx> {
|
265 | 265 | tcx: TyCtxt<'tcx>,
|
266 |
| - duplicates: FxIndexSet<BasicBlock>, |
| 266 | + duplicates: SmallVec<[BasicBlock; 2]>, |
267 | 267 | }
|
268 | 268 |
|
269 | 269 | impl<'tcx> MutVisitor<'tcx> for OptApplier<'tcx> {
|
@@ -296,7 +296,7 @@ pub fn remove_duplicate_unreachable_blocks<'tcx>(tcx: TyCtxt<'tcx>, body: &mut B
|
296 | 296 | bb.terminator.is_some() && bb.is_empty_unreachable() && !bb.is_cleanup
|
297 | 297 | })
|
298 | 298 | .map(|(block, _)| block)
|
299 |
| - .collect::<FxIndexSet<_>>(); |
| 299 | + .collect::<SmallVec<[_; 2]>>(); |
300 | 300 |
|
301 | 301 | if unreachable_blocks.len() > 1 {
|
302 | 302 | OptApplier { tcx, duplicates: unreachable_blocks }.visit_body(body);
|
|
0 commit comments