]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_mir_dataflow/src/storage.rs
Rollup merge of #99259 - RalfJung:visit-a-place, r=oli-obk
[rust.git] / compiler / rustc_mir_dataflow / src / storage.rs
1 use rustc_index::bit_set::BitSet;
2 use rustc_middle::mir::{self, Local};
3
4 /// The set of locals in a MIR body that do not have `StorageLive`/`StorageDead` annotations.
5 ///
6 /// These locals have fixed storage for the duration of the body.
7 pub fn always_storage_live_locals(body: &mir::Body<'_>) -> BitSet<Local> {
8     let mut always_live_locals = BitSet::new_filled(body.local_decls.len());
9
10     for block in body.basic_blocks() {
11         for statement in &block.statements {
12             use mir::StatementKind::{StorageDead, StorageLive};
13             if let StorageLive(l) | StorageDead(l) = statement.kind {
14                 always_live_locals.remove(l);
15             }
16         }
17     }
18
19     always_live_locals
20 }