1
- use rustc_data_structures:: fx:: { FxIndexMap , FxIndexSet } ;
1
+ use rustc_data_structures:: fx:: { FxHashMap , FxIndexMap , FxIndexSet } ;
2
2
use rustc_index:: bit_set:: DenseBitSet ;
3
3
use rustc_index:: interval:: IntervalSet ;
4
4
use rustc_infer:: infer:: canonical:: QueryRegionConstraints ;
@@ -8,7 +8,7 @@ use rustc_middle::traits::query::DropckOutlivesResult;
8
8
use rustc_middle:: ty:: relate:: Relate ;
9
9
use rustc_middle:: ty:: { Ty , TyCtxt , TypeVisitable , TypeVisitableExt } ;
10
10
use rustc_mir_dataflow:: impls:: { FilteringMovePathIndexMapper , MaybeInitializedPlaces2 } ;
11
- use rustc_mir_dataflow:: move_paths:: { HasMoveData , MoveData , MovePathIndex } ;
11
+ use rustc_mir_dataflow:: move_paths:: { HasMoveData , MoveData , MovePathIndex , SparseMovePathIndex } ;
12
12
use rustc_mir_dataflow:: points:: { DenseLocationMap , PointIndex } ;
13
13
use rustc_mir_dataflow:: { Analysis , ResultsCursor , on_all_children_bits} ;
14
14
use rustc_span:: { DUMMY_SP , ErrorGuaranteed , Span } ;
@@ -46,7 +46,8 @@ pub(super) fn trace<'tcx>(
46
46
) {
47
47
let local_use_map = & LocalUseMap :: build ( & relevant_live_locals, location_map, typeck. body ) ;
48
48
49
- let mut dense_mpis = smallvec:: SmallVec :: new ( ) ;
49
+ let mut dense_mpis = FxHashMap :: default ( ) ;
50
+ // let mut dense_mpis = smallvec::SmallVec::new();
50
51
for & local in relevant_live_locals. iter ( ) {
51
52
let Some ( mpi) = move_data. rev_lookup . find_local ( local) else { unreachable ! ( ) } ;
52
53
@@ -56,7 +57,10 @@ pub(super) fn trace<'tcx>(
56
57
}
57
58
58
59
on_all_children_bits ( move_data, mpi, |child| {
59
- dense_mpis. push ( child) ;
60
+ // dense_mpis.push(child);
61
+ let dense_idx = dense_mpis. len ( ) ;
62
+ let sparse_idx = SparseMovePathIndex :: from_u32 ( dense_idx. try_into ( ) . unwrap ( ) ) ;
63
+ dense_mpis. insert ( child, sparse_idx) ;
60
64
} ) ;
61
65
}
62
66
@@ -105,7 +109,8 @@ struct LivenessContext<'a, 'typeck, 'tcx> {
105
109
/// dropped.
106
110
local_use_map : & ' a LocalUseMap ,
107
111
108
- dense_mpis : smallvec:: SmallVec < [ MovePathIndex ; 1 ] > ,
112
+ // dense_mpis: smallvec::SmallVec<[MovePathIndex; 1]>,
113
+ dense_mpis : FxHashMap < MovePathIndex , SparseMovePathIndex > ,
109
114
}
110
115
111
116
struct DropData < ' tcx > {
@@ -566,8 +571,9 @@ impl<'a, 'typeck, 'tcx> LivenessContext<'a, 'typeck, 'tcx> {
566
571
// let mapper = sparse_bitset;
567
572
568
573
// let timer = std::time::Instant::now();
574
+ let x = std:: mem:: take ( & mut self . dense_mpis ) ;
569
575
let flow_inits = MaybeInitializedPlaces2 :: new ( tcx, body, self . move_data )
570
- . filter_move_paths ( & self . dense_mpis )
576
+ . filter_move_paths ( x )
571
577
// .with_mapper(mapper)
572
578
. iterate_to_fixpoint ( tcx, body, Some ( "borrowck" ) )
573
579
. into_results_cursor ( body) ;
0 commit comments