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.
This commit is contained in:
@@ -15,4 +15,6 @@ pub use self::initialized::{
|
||||
pub use self::liveness::{
|
||||
MaybeLiveLocals, MaybeTransitiveLiveLocals, TransferFunction as LivenessTransferFunction,
|
||||
};
|
||||
pub use self::storage_liveness::{MaybeRequiresStorage, MaybeStorageDead, MaybeStorageLive};
|
||||
pub use self::storage_liveness::{
|
||||
MaybeRequiresStorage, MaybeStorageDead, MaybeStorageLive, always_storage_live_locals,
|
||||
};
|
||||
|
||||
@@ -7,6 +7,23 @@ use rustc_middle::mir::*;
|
||||
use super::MaybeBorrowedLocals;
|
||||
use crate::{Analysis, GenKill, ResultsCursor};
|
||||
|
||||
/// The set of locals in a MIR body that do not have `StorageLive`/`StorageDead` annotations.
|
||||
///
|
||||
/// These locals have fixed storage for the duration of the body.
|
||||
pub fn always_storage_live_locals(body: &Body<'_>) -> BitSet<Local> {
|
||||
let mut always_live_locals = BitSet::new_filled(body.local_decls.len());
|
||||
|
||||
for block in &*body.basic_blocks {
|
||||
for statement in &block.statements {
|
||||
if let StatementKind::StorageLive(l) | StatementKind::StorageDead(l) = statement.kind {
|
||||
always_live_locals.remove(l);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
always_live_locals
|
||||
}
|
||||
|
||||
pub struct MaybeStorageLive<'a> {
|
||||
always_live_locals: Cow<'a, BitSet<Local>>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user