Skip to content

Commit b5f969f

Browse files
committed
Auto merge of #116152 - cjgillot:unchunck, r=<try>
Experiment: only use dense bitsets r? `@ghost`
2 parents 9d32ba3 + f528b4c commit b5f969f

File tree

8 files changed

+26
-27
lines changed

8 files changed

+26
-27
lines changed

compiler/rustc_borrowck/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use rustc_errors::{Diagnostic, DiagnosticBuilder, DiagnosticMessage, Subdiagnost
2424
use rustc_fluent_macro::fluent_messages;
2525
use rustc_hir as hir;
2626
use rustc_hir::def_id::LocalDefId;
27-
use rustc_index::bit_set::{BitSet, ChunkedBitSet};
27+
use rustc_index::bit_set::BitSet;
2828
use rustc_index::{IndexSlice, IndexVec};
2929
use rustc_infer::infer::{
3030
InferCtxt, NllRegionVariableOrigin, RegionVariableOrigin, TyCtxtInferExt,
@@ -1657,7 +1657,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
16571657
location: Location,
16581658
desired_action: InitializationRequiringAction,
16591659
place_span: (PlaceRef<'tcx>, Span),
1660-
maybe_uninits: &ChunkedBitSet<MovePathIndex>,
1660+
maybe_uninits: &BitSet<MovePathIndex>,
16611661
from: u64,
16621662
to: u64,
16631663
) {

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
2-
use rustc_index::bit_set::HybridBitSet;
2+
use rustc_index::bit_set::BitSet;
33
use rustc_index::interval::IntervalSet;
44
use rustc_infer::infer::canonical::QueryRegionConstraints;
55
use rustc_middle::mir::{BasicBlock, Body, ConstraintCategory, Local, Location};
@@ -106,7 +106,7 @@ struct LivenessResults<'me, 'typeck, 'flow, 'tcx> {
106106
cx: LivenessContext<'me, 'typeck, 'flow, 'tcx>,
107107

108108
/// Set of points that define the current local.
109-
defs: HybridBitSet<PointIndex>,
109+
defs: BitSet<PointIndex>,
110110

111111
/// Points where the current variable is "use live" -- meaning
112112
/// that there is a future "full use" that may use its value.
@@ -129,7 +129,7 @@ impl<'me, 'typeck, 'flow, 'tcx> LivenessResults<'me, 'typeck, 'flow, 'tcx> {
129129
let num_points = cx.elements.num_points();
130130
LivenessResults {
131131
cx,
132-
defs: HybridBitSet::new_empty(num_points),
132+
defs: BitSet::new_empty(num_points),
133133
use_live_at: IntervalSet::new(num_points),
134134
drop_live_at: IntervalSet::new(num_points),
135135
drop_locations: vec![],

compiler/rustc_index/src/bit_set.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ impl<T: Idx> BitSet<T> {
293293
not_already
294294
}
295295

296-
fn last_set_in(&self, range: impl RangeBounds<T>) -> Option<T> {
296+
pub fn last_set_in(&self, range: impl RangeBounds<T>) -> Option<T> {
297297
let (start, end) = inclusive_start_end(range, self.domain_size)?;
298298
let (start_word_index, _) = word_index_and_mask(start);
299299
let (end_word_index, end_mask) = word_index_and_mask(end);
@@ -1278,7 +1278,7 @@ impl<T: Idx> SparseBitSet<T> {
12781278
}
12791279

12801280
impl<T: Idx + Ord> SparseBitSet<T> {
1281-
fn last_set_in(&self, range: impl RangeBounds<T>) -> Option<T> {
1281+
pub fn last_set_in(&self, range: impl RangeBounds<T>) -> Option<T> {
12821282
let mut last_leq = None;
12831283
for e in self.iter() {
12841284
if range.contains(e) {

compiler/rustc_mir_dataflow/src/impls/initialized.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_index::bit_set::{BitSet, ChunkedBitSet};
1+
use rustc_index::bit_set::BitSet;
22
use rustc_index::Idx;
33
use rustc_middle::mir::{self, Body, CallReturnPlaces, Location, TerminatorEdges};
44
use rustc_middle::ty::{self, TyCtxt};
@@ -68,7 +68,7 @@ impl<'a, 'tcx> MaybeInitializedPlaces<'a, 'tcx> {
6868
pub fn is_unwind_dead(
6969
&self,
7070
place: mir::Place<'tcx>,
71-
state: &MaybeReachable<ChunkedBitSet<MovePathIndex>>,
71+
state: &MaybeReachable<BitSet<MovePathIndex>>,
7272
) -> bool {
7373
if let LookupResult::Exact(path) = self.move_data().rev_lookup.find(place.as_ref()) {
7474
let mut maybe_live = false;
@@ -308,7 +308,7 @@ impl<'a, 'tcx> DefinitelyInitializedPlaces<'a, 'tcx> {
308308
}
309309

310310
impl<'tcx> AnalysisDomain<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
311-
type Domain = MaybeReachable<ChunkedBitSet<MovePathIndex>>;
311+
type Domain = MaybeReachable<BitSet<MovePathIndex>>;
312312
const NAME: &'static str = "maybe_init";
313313

314314
fn bottom_value(&self, _: &mir::Body<'tcx>) -> Self::Domain {
@@ -317,8 +317,7 @@ impl<'tcx> AnalysisDomain<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
317317
}
318318

319319
fn initialize_start_block(&self, _: &mir::Body<'tcx>, state: &mut Self::Domain) {
320-
*state =
321-
MaybeReachable::Reachable(ChunkedBitSet::new_empty(self.move_data().move_paths.len()));
320+
*state = MaybeReachable::Reachable(BitSet::new_empty(self.move_data().move_paths.len()));
322321
drop_flag_effects_for_function_entry(self.tcx, self.body, self.mdpe, |path, s| {
323322
assert!(s == DropFlagState::Present);
324323
state.gen(path);
@@ -444,13 +443,13 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
444443
}
445444

446445
impl<'tcx> AnalysisDomain<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
447-
type Domain = ChunkedBitSet<MovePathIndex>;
446+
type Domain = BitSet<MovePathIndex>;
448447

449448
const NAME: &'static str = "maybe_uninit";
450449

451450
fn bottom_value(&self, _: &mir::Body<'tcx>) -> Self::Domain {
452451
// bottom = initialized (start_block_effect counters this at outset)
453-
ChunkedBitSet::new_empty(self.move_data().move_paths.len())
452+
BitSet::new_empty(self.move_data().move_paths.len())
454453
}
455454

456455
// sets on_entry bits for Arg places
@@ -649,13 +648,13 @@ impl<'tcx> GenKillAnalysis<'tcx> for DefinitelyInitializedPlaces<'_, 'tcx> {
649648
}
650649

651650
impl<'tcx> AnalysisDomain<'tcx> for EverInitializedPlaces<'_, 'tcx> {
652-
type Domain = ChunkedBitSet<InitIndex>;
651+
type Domain = BitSet<InitIndex>;
653652

654653
const NAME: &'static str = "ever_init";
655654

656655
fn bottom_value(&self, _: &mir::Body<'tcx>) -> Self::Domain {
657656
// bottom = no initialized variables by default
658-
ChunkedBitSet::new_empty(self.move_data().inits.len())
657+
BitSet::new_empty(self.move_data().inits.len())
659658
}
660659

661660
fn initialize_start_block(&self, body: &mir::Body<'tcx>, state: &mut Self::Domain) {

compiler/rustc_mir_dataflow/src/impls/liveness.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_index::bit_set::{BitSet, ChunkedBitSet};
1+
use rustc_index::bit_set::BitSet;
22
use rustc_middle::mir::visit::{MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor};
33
use rustc_middle::mir::{
44
self, CallReturnPlaces, Local, Location, Place, StatementKind, TerminatorEdges,
@@ -27,14 +27,14 @@ use crate::{Analysis, AnalysisDomain, Backward, GenKill, GenKillAnalysis};
2727
pub struct MaybeLiveLocals;
2828

2929
impl<'tcx> AnalysisDomain<'tcx> for MaybeLiveLocals {
30-
type Domain = ChunkedBitSet<Local>;
30+
type Domain = BitSet<Local>;
3131
type Direction = Backward;
3232

3333
const NAME: &'static str = "liveness";
3434

3535
fn bottom_value(&self, body: &mir::Body<'tcx>) -> Self::Domain {
3636
// bottom = not live
37-
ChunkedBitSet::new_empty(body.local_decls.len())
37+
BitSet::new_empty(body.local_decls.len())
3838
}
3939

4040
fn initialize_start_block(&self, _: &mir::Body<'tcx>, _: &mut Self::Domain) {
@@ -234,14 +234,14 @@ impl<'a> MaybeTransitiveLiveLocals<'a> {
234234
}
235235

236236
impl<'a, 'tcx> AnalysisDomain<'tcx> for MaybeTransitiveLiveLocals<'a> {
237-
type Domain = ChunkedBitSet<Local>;
237+
type Domain = BitSet<Local>;
238238
type Direction = Backward;
239239

240240
const NAME: &'static str = "transitive liveness";
241241

242242
fn bottom_value(&self, body: &mir::Body<'tcx>) -> Self::Domain {
243243
// bottom = not live
244-
ChunkedBitSet::new_empty(body.local_decls.len())
244+
BitSet::new_empty(body.local_decls.len())
245245
}
246246

247247
fn initialize_start_block(&self, _: &mir::Body<'tcx>, _: &mut Self::Domain) {

compiler/rustc_mir_dataflow/src/rustc_peek.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc_span::symbol::sym;
22
use rustc_span::Span;
33

4-
use rustc_index::bit_set::ChunkedBitSet;
4+
use rustc_index::bit_set::BitSet;
55
use rustc_middle::mir::MirPass;
66
use rustc_middle::mir::{self, Body, Local, Location};
77
use rustc_middle::ty::{self, Ty, TyCtxt};
@@ -264,7 +264,7 @@ impl<'tcx> RustcPeekAt<'tcx> for MaybeLiveLocals {
264264
&self,
265265
tcx: TyCtxt<'tcx>,
266266
place: mir::Place<'tcx>,
267-
flow_state: &ChunkedBitSet<Local>,
267+
flow_state: &BitSet<Local>,
268268
call: PeekCall,
269269
) {
270270
info!(?place, "peek_at");

compiler/rustc_mir_transform/src/nrvo.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! See the docs for [`RenameReturnPlace`].
22
33
use rustc_hir::Mutability;
4-
use rustc_index::bit_set::HybridBitSet;
4+
use rustc_index::bit_set::BitSet;
55
use rustc_middle::mir::visit::{MutVisitor, NonUseContext, PlaceContext, Visitor};
66
use rustc_middle::mir::{self, BasicBlock, Local, Location};
77
use rustc_middle::ty::TyCtxt;
@@ -123,7 +123,7 @@ fn find_local_assigned_to_return_place(
123123
body: &mut mir::Body<'_>,
124124
) -> Option<Local> {
125125
let mut block = start;
126-
let mut seen = HybridBitSet::new_empty(body.basic_blocks.len());
126+
let mut seen = BitSet::new_empty(body.basic_blocks.len());
127127

128128
// Iterate as long as `block` has exactly one predecessor that we have not yet visited.
129129
while seen.insert(block) {

compiler/rustc_mir_transform/src/remove_uninit_drops.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_index::bit_set::ChunkedBitSet;
1+
use rustc_index::bit_set::BitSet;
22
use rustc_middle::mir::{Body, TerminatorKind};
33
use rustc_middle::ty::GenericArgsRef;
44
use rustc_middle::ty::{self, ParamEnv, Ty, TyCtxt, VariantDef};
@@ -79,7 +79,7 @@ impl<'tcx> MirPass<'tcx> for RemoveUninitDrops {
7979
fn is_needs_drop_and_init<'tcx>(
8080
tcx: TyCtxt<'tcx>,
8181
param_env: ParamEnv<'tcx>,
82-
maybe_inits: &ChunkedBitSet<MovePathIndex>,
82+
maybe_inits: &BitSet<MovePathIndex>,
8383
move_data: &MoveData<'tcx>,
8484
ty: Ty<'tcx>,
8585
mpi: MovePathIndex,

0 commit comments

Comments
 (0)