forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstorage.rs
More file actions
19 lines (17 loc) · 714 Bytes
/
Copy pathstorage.rs
File metadata and controls
19 lines (17 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use rustc_index::bit_set::GrowableBitSet;
use rustc_middle::mir::{self, Local};
/// 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: &mir::Body<'_>, locals: &mut GrowableBitSet<Local>) {
locals.fill(body.local_decls.len());
let always_live_locals = locals;
for block in &*body.basic_blocks {
for statement in &block.statements {
use mir::StatementKind::{StorageDead, StorageLive};
if let StorageLive(l) | StorageDead(l) = statement.kind {
always_live_locals.remove(l);
}
}
}
}