1 use rustc_index::bit_set::BitSet;
2 use rustc_middle::mir::{self, Local};
4 /// The set of locals in a MIR body that do not have `StorageLive`/`StorageDead` annotations.
6 /// These locals have fixed storage for the duration of the body.
8 // FIXME: Currently, we need to traverse the entire MIR to compute this. We should instead store it
9 // as a field in the `LocalDecl` for each `Local`.
10 pub fn always_storage_live_locals(body: &mir::Body<'_>) -> BitSet<Local> {
11 let mut always_live_locals = BitSet::new_filled(body.local_decls.len());
13 for block in body.basic_blocks() {
14 for statement in &block.statements {
15 use mir::StatementKind::{StorageDead, StorageLive};
16 if let StorageLive(l) | StorageDead(l) = statement.kind {
17 always_live_locals.remove(l);