Skip to content

Commit ecff1bc

Browse files
committed
Move always_storage_live_locals.
It's very closely related to `MaybeStorageLive` and `MaybeStorageDead`. It's weird that it's currently in a different module.
1 parent 8744225 commit ecff1bc

File tree

9 files changed

+25
-30
lines changed

9 files changed

+25
-30
lines changed

compiler/rustc_const_eval/src/check_consts/check.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ use rustc_middle::span_bug;
1717
use rustc_middle::ty::adjustment::PointerCoercion;
1818
use rustc_middle::ty::{self, Ty, TypeVisitableExt};
1919
use rustc_mir_dataflow::Analysis;
20-
use rustc_mir_dataflow::impls::MaybeStorageLive;
21-
use rustc_mir_dataflow::storage::always_storage_live_locals;
20+
use rustc_mir_dataflow::impls::{MaybeStorageLive, always_storage_live_locals};
2221
use rustc_span::{Span, Symbol, sym};
2322
use rustc_trait_selection::traits::{
2423
Obligation, ObligationCause, ObligationCauseCode, ObligationCtxt,

compiler/rustc_const_eval/src/interpret/stack.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_index::IndexVec;
1010
use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
1111
use rustc_middle::ty::{self, Ty, TyCtxt};
1212
use rustc_middle::{bug, mir};
13-
use rustc_mir_dataflow::storage::always_storage_live_locals;
13+
use rustc_mir_dataflow::impls::always_storage_live_locals;
1414
use rustc_span::Span;
1515
use tracing::{info_span, instrument, trace};
1616

compiler/rustc_mir_dataflow/src/impls/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ pub use self::initialized::{
1515
pub use self::liveness::{
1616
MaybeLiveLocals, MaybeTransitiveLiveLocals, TransferFunction as LivenessTransferFunction,
1717
};
18-
pub use self::storage_liveness::{MaybeRequiresStorage, MaybeStorageDead, MaybeStorageLive};
18+
pub use self::storage_liveness::{
19+
MaybeRequiresStorage, MaybeStorageDead, MaybeStorageLive, always_storage_live_locals,
20+
};

compiler/rustc_mir_dataflow/src/impls/storage_liveness.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,23 @@ use rustc_middle::mir::*;
55
use super::MaybeBorrowedLocals;
66
use crate::{Analysis, GenKill, ResultsCursor};
77

8+
/// The set of locals in a MIR body that do not have `StorageLive`/`StorageDead` annotations.
9+
///
10+
/// These locals have fixed storage for the duration of the body.
11+
pub fn always_storage_live_locals(body: &Body<'_>) -> BitSet<Local> {
12+
let mut always_live_locals = BitSet::new_filled(body.local_decls.len());
13+
14+
for block in &*body.basic_blocks {
15+
for statement in &block.statements {
16+
if let StatementKind::StorageLive(l) | StatementKind::StorageDead(l) = statement.kind {
17+
always_live_locals.remove(l);
18+
}
19+
}
20+
}
21+
22+
always_live_locals
23+
}
24+
825
pub struct MaybeStorageLive<'a> {
926
always_live_locals: &'a BitSet<Local>,
1027
}

compiler/rustc_mir_dataflow/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ pub mod impls;
3333
pub mod move_paths;
3434
pub mod points;
3535
pub mod rustc_peek;
36-
pub mod storage;
3736
pub mod un_derefer;
3837
pub mod value_analysis;
3938

compiler/rustc_mir_dataflow/src/storage.rs

Lines changed: 0 additions & 20 deletions
This file was deleted.

compiler/rustc_mir_transform/src/coroutine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ use rustc_middle::ty::{
7070
use rustc_middle::{bug, span_bug};
7171
use rustc_mir_dataflow::impls::{
7272
MaybeBorrowedLocals, MaybeLiveLocals, MaybeRequiresStorage, MaybeStorageLive,
73+
always_storage_live_locals,
7374
};
74-
use rustc_mir_dataflow::storage::always_storage_live_locals;
7575
use rustc_mir_dataflow::{Analysis, Results, ResultsVisitor};
7676
use rustc_span::Span;
7777
use rustc_span::def_id::{DefId, LocalDefId};

compiler/rustc_mir_transform/src/lint.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ use rustc_index::bit_set::BitSet;
77
use rustc_middle::mir::visit::{PlaceContext, Visitor};
88
use rustc_middle::mir::*;
99
use rustc_middle::ty::TyCtxt;
10-
use rustc_mir_dataflow::impls::{MaybeStorageDead, MaybeStorageLive};
11-
use rustc_mir_dataflow::storage::always_storage_live_locals;
10+
use rustc_mir_dataflow::impls::{MaybeStorageDead, MaybeStorageLive, always_storage_live_locals};
1211
use rustc_mir_dataflow::{Analysis, ResultsCursor};
1312

1413
pub(super) fn lint_body<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, when: String) {

compiler/rustc_mir_transform/src/ref_prop.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ use rustc_middle::mir::visit::*;
66
use rustc_middle::mir::*;
77
use rustc_middle::ty::TyCtxt;
88
use rustc_mir_dataflow::Analysis;
9-
use rustc_mir_dataflow::impls::MaybeStorageDead;
10-
use rustc_mir_dataflow::storage::always_storage_live_locals;
9+
use rustc_mir_dataflow::impls::{MaybeStorageDead, always_storage_live_locals};
1110
use tracing::{debug, instrument};
1211

1312
use crate::ssa::{SsaLocals, StorageLiveLocals};

0 commit comments

Comments
 (0)