Skip to content

Commit 934a99e

Browse files
committed
Move domain_size to GenKillAnalysis.
1 parent 8726cbc commit 934a99e

File tree

8 files changed

+43
-14
lines changed

8 files changed

+43
-14
lines changed

compiler/rustc_borrowck/src/dataflow.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,10 @@ impl<'tcx> rustc_mir_dataflow::AnalysisDomain<'tcx> for Borrows<'_, 'tcx> {
334334
impl<'tcx> rustc_mir_dataflow::GenKillAnalysis<'tcx> for Borrows<'_, 'tcx> {
335335
type Idx = BorrowIndex;
336336

337+
fn domain_size(&self, _: &mir::Body<'tcx>) -> usize {
338+
self.borrow_set.len()
339+
}
340+
337341
fn before_statement_effect(
338342
&mut self,
339343
trans: &mut impl GenKill<Self::Idx>,

compiler/rustc_mir_dataflow/src/framework/engine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ where
165165

166166
// Otherwise, compute and store the cumulative transfer function for each block.
167167

168-
let identity = GenKillSet::identity(analysis.bottom_value(body).domain_size());
168+
let identity = GenKillSet::identity(analysis.domain_size(body));
169169
let mut trans_for_block = IndexVec::from_elem(identity, &body.basic_blocks);
170170

171171
for (block, block_data) in body.basic_blocks.iter_enumerated() {

compiler/rustc_mir_dataflow/src/framework/lattice.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,6 @@ impl<T: Idx> MeetSemiLattice for ChunkedBitSet<T> {
187187
pub struct Dual<T>(pub T);
188188

189189
impl<T: Idx> BitSetExt<T> for Dual<BitSet<T>> {
190-
fn domain_size(&self) -> usize {
191-
self.0.domain_size()
192-
}
193-
194190
fn contains(&self, elem: T) -> bool {
195191
self.0.contains(elem)
196192
}

compiler/rustc_mir_dataflow/src/framework/mod.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,12 @@ pub use self::visitor::{visit_results, ResultsVisitable, ResultsVisitor};
5454
/// Analysis domains are all bitsets of various kinds. This trait holds
5555
/// operations needed by all of them.
5656
pub trait BitSetExt<T> {
57-
fn domain_size(&self) -> usize;
5857
fn contains(&self, elem: T) -> bool;
5958
fn union(&mut self, other: &HybridBitSet<T>);
6059
fn subtract(&mut self, other: &HybridBitSet<T>);
6160
}
6261

6362
impl<T: Idx> BitSetExt<T> for BitSet<T> {
64-
fn domain_size(&self) -> usize {
65-
self.domain_size()
66-
}
67-
6863
fn contains(&self, elem: T) -> bool {
6964
self.contains(elem)
7065
}
@@ -79,10 +74,6 @@ impl<T: Idx> BitSetExt<T> for BitSet<T> {
7974
}
8075

8176
impl<T: Idx> BitSetExt<T> for ChunkedBitSet<T> {
82-
fn domain_size(&self) -> usize {
83-
self.domain_size()
84-
}
85-
8677
fn contains(&self, elem: T) -> bool {
8778
self.contains(elem)
8879
}
@@ -295,6 +286,8 @@ where
295286
pub trait GenKillAnalysis<'tcx>: Analysis<'tcx> {
296287
type Idx: Idx;
297288

289+
fn domain_size(&self, body: &mir::Body<'tcx>) -> usize;
290+
298291
/// See `Analysis::apply_statement_effect`.
299292
fn statement_effect(
300293
&mut self,

compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ impl<'tcx> AnalysisDomain<'tcx> for MaybeBorrowedLocals {
3737
impl<'tcx> GenKillAnalysis<'tcx> for MaybeBorrowedLocals {
3838
type Idx = Local;
3939

40+
fn domain_size(&self, body: &Body<'tcx>) -> usize {
41+
body.local_decls.len()
42+
}
43+
4044
fn statement_effect(
4145
&mut self,
4246
trans: &mut impl GenKill<Self::Idx>,

compiler/rustc_mir_dataflow/src/impls/initialized.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,10 @@ impl<'tcx> AnalysisDomain<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
290290
impl<'tcx> GenKillAnalysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
291291
type Idx = MovePathIndex;
292292

293+
fn domain_size(&self, _: &Body<'tcx>) -> usize {
294+
self.move_data().move_paths.len()
295+
}
296+
293297
fn statement_effect(
294298
&mut self,
295299
trans: &mut impl GenKill<Self::Idx>,
@@ -416,6 +420,10 @@ impl<'tcx> AnalysisDomain<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
416420
impl<'tcx> GenKillAnalysis<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
417421
type Idx = MovePathIndex;
418422

423+
fn domain_size(&self, _: &Body<'tcx>) -> usize {
424+
self.move_data().move_paths.len()
425+
}
426+
419427
fn statement_effect(
420428
&mut self,
421429
trans: &mut impl GenKill<Self::Idx>,
@@ -536,6 +544,10 @@ impl<'a, 'tcx> AnalysisDomain<'tcx> for DefinitelyInitializedPlaces<'a, 'tcx> {
536544
impl<'tcx> GenKillAnalysis<'tcx> for DefinitelyInitializedPlaces<'_, 'tcx> {
537545
type Idx = MovePathIndex;
538546

547+
fn domain_size(&self, _: &Body<'tcx>) -> usize {
548+
self.move_data().move_paths.len()
549+
}
550+
539551
fn statement_effect(
540552
&mut self,
541553
trans: &mut impl GenKill<Self::Idx>,
@@ -600,6 +612,10 @@ impl<'tcx> AnalysisDomain<'tcx> for EverInitializedPlaces<'_, 'tcx> {
600612
impl<'tcx> GenKillAnalysis<'tcx> for EverInitializedPlaces<'_, 'tcx> {
601613
type Idx = InitIndex;
602614

615+
fn domain_size(&self, _: &Body<'tcx>) -> usize {
616+
self.move_data().inits.len()
617+
}
618+
603619
#[instrument(skip(self, trans), level = "debug")]
604620
fn statement_effect(
605621
&mut self,

compiler/rustc_mir_dataflow/src/impls/liveness.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ impl<'tcx> AnalysisDomain<'tcx> for MaybeLiveLocals {
4343
impl<'tcx> GenKillAnalysis<'tcx> for MaybeLiveLocals {
4444
type Idx = Local;
4545

46+
fn domain_size(&self, body: &mir::Body<'tcx>) -> usize {
47+
body.local_decls.len()
48+
}
49+
4650
fn statement_effect(
4751
&mut self,
4852
trans: &mut impl GenKill<Self::Idx>,

compiler/rustc_mir_dataflow/src/impls/storage_liveness.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ impl<'tcx, 'a> crate::AnalysisDomain<'tcx> for MaybeStorageLive<'a> {
4949
impl<'tcx, 'a> crate::GenKillAnalysis<'tcx> for MaybeStorageLive<'a> {
5050
type Idx = Local;
5151

52+
fn domain_size(&self, body: &Body<'tcx>) -> usize {
53+
body.local_decls.len()
54+
}
55+
5256
fn statement_effect(
5357
&mut self,
5458
trans: &mut impl GenKill<Self::Idx>,
@@ -116,6 +120,10 @@ impl<'tcx> crate::AnalysisDomain<'tcx> for MaybeStorageDead {
116120
impl<'tcx> crate::GenKillAnalysis<'tcx> for MaybeStorageDead {
117121
type Idx = Local;
118122

123+
fn domain_size(&self, body: &Body<'tcx>) -> usize {
124+
body.local_decls.len()
125+
}
126+
119127
fn statement_effect(
120128
&mut self,
121129
trans: &mut impl GenKill<Self::Idx>,
@@ -191,6 +199,10 @@ impl<'tcx> crate::AnalysisDomain<'tcx> for MaybeRequiresStorage<'_, '_, 'tcx> {
191199
impl<'tcx> crate::GenKillAnalysis<'tcx> for MaybeRequiresStorage<'_, '_, 'tcx> {
192200
type Idx = Local;
193201

202+
fn domain_size(&self, body: &Body<'tcx>) -> usize {
203+
body.local_decls.len()
204+
}
205+
194206
fn before_statement_effect(
195207
&mut self,
196208
trans: &mut impl GenKill<Self::Idx>,

0 commit comments

Comments
 (0)