Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ddfcb6b

Browse files
committed
wip
1 parent b7ec415 commit ddfcb6b

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

‎compiler/rustc_borrowck/src/type_check/liveness/trace.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
1+
use rustc_data_structures::fx::{FxHashMap,FxIndexMap, FxIndexSet};
22
use rustc_index::bit_set::DenseBitSet;
33
use rustc_index::interval::IntervalSet;
44
use rustc_infer::infer::canonical::QueryRegionConstraints;
@@ -8,7 +8,7 @@ use rustc_middle::traits::query::DropckOutlivesResult;
88
use rustc_middle::ty::relate::Relate;
99
use rustc_middle::ty::{Ty, TyCtxt, TypeVisitable, TypeVisitableExt};
1010
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};
1212
use rustc_mir_dataflow::points::{DenseLocationMap, PointIndex};
1313
use rustc_mir_dataflow::{Analysis, ResultsCursor, on_all_children_bits};
1414
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span};
@@ -46,7 +46,8 @@ pub(super) fn trace<'tcx>(
4646
) {
4747
let local_use_map = &LocalUseMap::build(&relevant_live_locals, location_map, typeck.body);
4848

49-
let mut dense_mpis = smallvec::SmallVec::new();
49+
let mut dense_mpis = FxHashMap::default();
50+
// let mut dense_mpis = smallvec::SmallVec::new();
5051
for &local in relevant_live_locals.iter() {
5152
let Some(mpi) = move_data.rev_lookup.find_local(local) else { unreachable!() };
5253

@@ -56,7 +57,10 @@ pub(super) fn trace<'tcx>(
5657
}
5758

5859
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);
6064
});
6165
}
6266

@@ -105,7 +109,8 @@ struct LivenessContext<'a, 'typeck, 'tcx> {
105109
/// dropped.
106110
local_use_map: &'a LocalUseMap,
107111

108-
dense_mpis: smallvec::SmallVec<[MovePathIndex; 1]>,
112+
// dense_mpis: smallvec::SmallVec<[MovePathIndex; 1]>,
113+
dense_mpis: FxHashMap<MovePathIndex, SparseMovePathIndex>,
109114
}
110115

111116
struct DropData<'tcx> {
@@ -566,8 +571,9 @@ impl<'a, 'typeck, 'tcx> LivenessContext<'a, 'typeck, 'tcx> {
566571
// let mapper = sparse_bitset;
567572

568573
// let timer = std::time::Instant::now();
574+
let x = std::mem::take(&mut self.dense_mpis);
569575
let flow_inits = MaybeInitializedPlaces2::new(tcx, body, self.move_data)
570-
.filter_move_paths(&self.dense_mpis)
576+
.filter_move_paths(x)
571577
// .with_mapper(mapper)
572578
.iterate_to_fixpoint(tcx, body, Some("borrowck"))
573579
.into_results_cursor(body);

‎compiler/rustc_mir_dataflow/src/impls/initialized2.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_data_structures::fx::{FxBuildHasher,FxHashMap};
1+
use rustc_data_structures::fx::FxHashMap;
22
use rustc_index::Idx;
33
use rustc_index::bit_set::MixedBitSet;
44
use rustc_middle::mir::{
@@ -131,14 +131,16 @@ impl MovePathIndexMapper for FilteringMovePathIndexMapper {
131131
impl<'a, 'tcx> MaybeInitializedPlaces2<'a, 'tcx, DefaultMovePathIndexMapper> {
132132
pub fn filter_move_paths(
133133
self,
134-
interesting_move_paths: &[MovePathIndex],
134+
// interesting_move_paths: &[MovePathIndex],
135+
sparse_map: FxHashMap<MovePathIndex, SparseMovePathIndex>,
135136
) -> MaybeInitializedPlaces2<'a, 'tcx, FilteringMovePathIndexMapper> {
136-
let mut sparse_map =
137-
FxHashMap::with_capacity_and_hasher(interesting_move_paths.len(), FxBuildHasher);
138-
for (idx, &dense_idx) in interesting_move_paths.iter().enumerate() {
139-
let sparse_idx = SparseMovePathIndex::from_u32(idx.try_into().unwrap());
140-
sparse_map.insert(dense_idx, sparse_idx);
141-
}
137+
// use rustc_data_structures::fx::FxBuildHasher;
138+
// let mut sparse_map =
139+
// FxHashMap::with_capacity_and_hasher(interesting_move_paths.len(), FxBuildHasher);
140+
// for (idx, &dense_idx) in interesting_move_paths.iter().enumerate() {
141+
// let sparse_idx = SparseMovePathIndex::from_u32(idx.try_into().unwrap());
142+
// sparse_map.insert(dense_idx, sparse_idx);
143+
// }
142144
let index_mapper = FilteringMovePathIndexMapper { sparse_map };
143145
MaybeInitializedPlaces2 {
144146
tcx: self.tcx,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /