3 use crate::dataflow::BottomValue;
4 use crate::dataflow::{self, GenKill};
5 use crate::util::storage::AlwaysLiveLocals;
6 use rustc_middle::mir::*;
9 pub struct MaybeStorageLive {
10 always_live_locals: AlwaysLiveLocals,
13 impl MaybeStorageLive {
14 pub fn new(always_live_locals: AlwaysLiveLocals) -> Self {
15 MaybeStorageLive { always_live_locals }
19 impl dataflow::AnalysisDomain<'tcx> for MaybeStorageLive {
22 const NAME: &'static str = "maybe_storage_live";
24 fn bits_per_block(&self, body: &mir::Body<'tcx>) -> usize {
25 body.local_decls.len()
28 fn initialize_start_block(&self, body: &mir::Body<'tcx>, on_entry: &mut BitSet<Self::Idx>) {
29 assert_eq!(body.local_decls.len(), self.always_live_locals.domain_size());
30 for local in self.always_live_locals.iter() {
31 on_entry.insert(local);
34 for arg in body.args_iter() {
40 impl dataflow::GenKillAnalysis<'tcx> for MaybeStorageLive {
43 trans: &mut impl GenKill<Self::Idx>,
44 stmt: &mir::Statement<'tcx>,
48 StatementKind::StorageLive(l) => trans.gen(l),
49 StatementKind::StorageDead(l) => trans.kill(l),
56 _trans: &mut impl GenKill<Self::Idx>,
57 _: &mir::Terminator<'tcx>,
60 // Terminators have no effect
63 fn call_return_effect(
65 _trans: &mut impl GenKill<Self::Idx>,
67 _func: &mir::Operand<'tcx>,
68 _args: &[mir::Operand<'tcx>],
69 _return_place: mir::Place<'tcx>,
71 // Nothing to do when a call returns successfully
75 impl BottomValue for MaybeStorageLive {
77 const BOTTOM_VALUE: bool = false;