Skip to content

Commit d67d907

Browse files
committed
Use a plain bitset for liveness analyses.
1 parent 9ba8fd0 commit d67d907

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

compiler/rustc_mir_dataflow/src/impls/initialized.rs

+7
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,10 @@ impl<'a, 'tcx> DefinitelyInitializedPlaces<'a, 'tcx> {
305305
}
306306

307307
impl<'tcx> AnalysisDomain<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
308+
/// There can be many more `MovePathIndex` than there are locals in a MIR body.
309+
/// We use a chunked bitset to avoid paying too high a memory footprint.
308310
type Domain = MaybeReachable<ChunkedBitSet<MovePathIndex>>;
311+
309312
const NAME: &'static str = "maybe_init";
310313

311314
fn bottom_value(&self, _: &mir::Body<'tcx>) -> Self::Domain {
@@ -437,6 +440,8 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
437440
}
438441

439442
impl<'tcx> AnalysisDomain<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
443+
/// There can be many more `MovePathIndex` than there are locals in a MIR body.
444+
/// We use a chunked bitset to avoid paying too high a memory footprint.
440445
type Domain = ChunkedBitSet<MovePathIndex>;
441446

442447
const NAME: &'static str = "maybe_uninit";
@@ -636,6 +641,8 @@ impl<'tcx> GenKillAnalysis<'tcx> for DefinitelyInitializedPlaces<'_, 'tcx> {
636641
}
637642

638643
impl<'tcx> AnalysisDomain<'tcx> for EverInitializedPlaces<'_, 'tcx> {
644+
/// There can be many more `InitIndex` than there are locals in a MIR body.
645+
/// We use a chunked bitset to avoid paying too high a memory footprint.
639646
type Domain = ChunkedBitSet<InitIndex>;
640647

641648
const NAME: &'static str = "ever_init";

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,
@@ -26,14 +26,14 @@ use crate::{Analysis, AnalysisDomain, Backward, GenKill, GenKillAnalysis};
2626
pub struct MaybeLiveLocals;
2727

2828
impl<'tcx> AnalysisDomain<'tcx> for MaybeLiveLocals {
29-
type Domain = ChunkedBitSet<Local>;
29+
type Domain = BitSet<Local>;
3030
type Direction = Backward;
3131

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

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

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

235235
impl<'a, 'tcx> AnalysisDomain<'tcx> for MaybeTransitiveLiveLocals<'a> {
236-
type Domain = ChunkedBitSet<Local>;
236+
type Domain = BitSet<Local>;
237237
type Direction = Backward;
238238

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

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

246246
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
@@ -12,7 +12,7 @@ use crate::MoveDataParamEnv;
1212
use crate::{Analysis, JoinSemiLattice, ResultsCursor};
1313
use rustc_ast::MetaItem;
1414
use rustc_hir::def_id::DefId;
15-
use rustc_index::bit_set::ChunkedBitSet;
15+
use rustc_index::bit_set::BitSet;
1616
use rustc_middle::mir::MirPass;
1717
use rustc_middle::mir::{self, Body, Local, Location};
1818
use rustc_middle::ty::{self, Ty, TyCtxt};
@@ -275,7 +275,7 @@ impl<'tcx> RustcPeekAt<'tcx> for MaybeLiveLocals {
275275
&self,
276276
tcx: TyCtxt<'tcx>,
277277
place: mir::Place<'tcx>,
278-
flow_state: &ChunkedBitSet<Local>,
278+
flow_state: &BitSet<Local>,
279279
call: PeekCall,
280280
) {
281281
info!(?place, "peek_at");

0 commit comments

Comments
 (0)