Skip to content

Commit a3e432c

Browse files
committed
Use a plain bitset for liveness analyses.
1 parent 796a045 commit a3e432c

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
@@ -308,7 +308,10 @@ impl<'a, 'tcx> DefinitelyInitializedPlaces<'a, 'tcx> {
308308
}
309309

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

314317
fn bottom_value(&self, _: &mir::Body<'tcx>) -> Self::Domain {
@@ -444,6 +447,8 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
444447
}
445448

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

449454
const NAME: &'static str = "maybe_uninit";
@@ -649,6 +654,8 @@ impl<'tcx> GenKillAnalysis<'tcx> for DefinitelyInitializedPlaces<'_, 'tcx> {
649654
}
650655

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

654661
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,
@@ -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");

0 commit comments

Comments
 (0)