4 use crate::dataflow::BitDenotation;
7 pub struct MaybeStorageLive<'a, 'tcx: 'a> {
11 impl<'a, 'tcx: 'a> MaybeStorageLive<'a, 'tcx> {
12 pub fn new(mir: &'a Mir<'tcx>)
14 MaybeStorageLive { mir }
17 pub fn mir(&self) -> &Mir<'tcx> {
22 impl<'a, 'tcx> BitDenotation<'tcx> for MaybeStorageLive<'a, 'tcx> {
24 fn name() -> &'static str { "maybe_storage_live" }
25 fn bits_per_block(&self) -> usize {
26 self.mir.local_decls.len()
29 fn start_block_effect(&self, _sets: &mut BitSet<Local>) {
30 // Nothing is live on function entry
33 fn statement_effect(&self,
34 sets: &mut BlockSets<'_, Local>,
36 let stmt = &self.mir[loc.block].statements[loc.statement_index];
39 StatementKind::StorageLive(l) => sets.gen(l),
40 StatementKind::StorageDead(l) => sets.kill(l),
45 fn terminator_effect(&self,
46 sets: &mut BlockSets<'_, Local>,
48 match &self.mir[loc.block].terminator().kind {
49 TerminatorKind::Drop { location, .. } => if let Some(l) = location.local() {
56 fn propagate_call_return(
58 _in_out: &mut BitSet<Local>,
59 _call_bb: mir::BasicBlock,
60 _dest_bb: mir::BasicBlock,
61 _dest_place: &mir::Place<'tcx>,
63 // Nothing to do when a call returns successfully
67 impl<'a, 'tcx> BitSetOperator for MaybeStorageLive<'a, 'tcx> {
69 fn join<T: Idx>(&self, inout_set: &mut BitSet<T>, in_set: &BitSet<T>) -> bool {
70 inout_set.union(in_set) // "maybe" means we union effects of both preds
74 impl<'a, 'tcx> InitialFlow for MaybeStorageLive<'a, 'tcx> {
76 fn bottom_value() -> bool {
77 false // bottom = dead