|
1 | 1 | pub use super::*;
|
2 | 2 |
|
3 |
| -use crate::dataflow::generic::{Results, ResultsRefCursor}; |
4 |
| -use crate::dataflow::BitDenotation; |
5 |
| -use crate::dataflow::MaybeBorrowedLocals; |
| 3 | +use crate::dataflow::generic::{self as dataflow, GenKill, Results, ResultsRefCursor}; |
| 4 | +use crate::dataflow::BottomValue; |
6 | 5 | use rustc::mir::visit::{NonMutatingUseContext, PlaceContext, Visitor};
|
7 | 6 | use rustc::mir::*;
|
8 | 7 | use std::cell::RefCell;
|
9 | 8 |
|
10 | 9 | #[derive(Copy, Clone)]
|
11 |
| -pub struct MaybeStorageLive<'a, 'tcx> { |
12 |
| - body: &'a Body<'tcx>, |
13 |
| -} |
| 10 | +pub struct MaybeStorageLive; |
14 | 11 |
|
15 |
| -impl<'a, 'tcx> MaybeStorageLive<'a, 'tcx> { |
16 |
| - pub fn new(body: &'a Body<'tcx>) -> Self { |
17 |
| - MaybeStorageLive { body } |
18 |
| - } |
| 12 | +impl dataflow::AnalysisDomain<'tcx> for MaybeStorageLive { |
| 13 | + type Idx = Local; |
19 | 14 |
|
20 |
| - pub fn body(&self) -> &Body<'tcx> { |
21 |
| - self.body |
22 |
| - } |
23 |
| -} |
| 15 | + const NAME: &'static str = "maybe_storage_live"; |
24 | 16 |
|
25 |
| -impl<'a, 'tcx> BitDenotation<'tcx> for MaybeStorageLive<'a, 'tcx> { |
26 |
| - type Idx = Local; |
27 |
| - fn name() -> &'static str { |
28 |
| - "maybe_storage_live" |
29 |
| - } |
30 |
| - fn bits_per_block(&self) -> usize { |
31 |
| - self.body.local_decls.len() |
| 17 | + fn bits_per_block(&self, body: &mir::Body<'tcx>) -> usize { |
| 18 | + body.local_decls.len() |
32 | 19 | }
|
33 | 20 |
|
34 |
| - fn start_block_effect(&self, on_entry: &mut BitSet<Local>) { |
| 21 | + fn initialize_start_block(&self, body: &mir::Body<'tcx>, on_entry: &mut BitSet<Self::Idx>) { |
35 | 22 | // The resume argument is live on function entry (we don't care about
|
36 | 23 | // the `self` argument)
|
37 |
| - for arg in self.body.args_iter().skip(1) { |
| 24 | + for arg in body.args_iter().skip(1) { |
38 | 25 | on_entry.insert(arg);
|
39 | 26 | }
|
40 | 27 | }
|
| 28 | +} |
41 | 29 |
|
42 |
| - fn statement_effect(&self, trans: &mut GenKillSet<Local>, loc: Location) { |
43 |
| - let stmt = &self.body[loc.block].statements[loc.statement_index]; |
44 |
| - |
| 30 | +impl dataflow::GenKillAnalysis<'tcx> for MaybeStorageLive { |
| 31 | + fn statement_effect( |
| 32 | + &self, |
| 33 | + trans: &mut impl GenKill<Self::Idx>, |
| 34 | + stmt: &mir::Statement<'tcx>, |
| 35 | + _: Location, |
| 36 | + ) { |
45 | 37 | match stmt.kind {
|
46 | 38 | StatementKind::StorageLive(l) => trans.gen(l),
|
47 | 39 | StatementKind::StorageDead(l) => trans.kill(l),
|
48 | 40 | _ => (),
|
49 | 41 | }
|
50 | 42 | }
|
51 | 43 |
|
52 |
| - fn terminator_effect(&self, _trans: &mut GenKillSet<Local>, _loc: Location) { |
| 44 | + fn terminator_effect( |
| 45 | + &self, |
| 46 | + _trans: &mut impl GenKill<Self::Idx>, |
| 47 | + _: &mir::Terminator<'tcx>, |
| 48 | + _: Location, |
| 49 | + ) { |
53 | 50 | // Terminators have no effect
|
54 | 51 | }
|
55 | 52 |
|
56 |
| - fn propagate_call_return( |
| 53 | + fn call_return_effect( |
57 | 54 | &self,
|
58 |
| - _in_out: &mut BitSet<Local>, |
59 |
| - _call_bb: mir::BasicBlock, |
60 |
| - _dest_bb: mir::BasicBlock, |
61 |
| - _dest_place: &mir::Place<'tcx>, |
| 55 | + _trans: &mut impl GenKill<Self::Idx>, |
| 56 | + _block: BasicBlock, |
| 57 | + _func: &mir::Operand<'tcx>, |
| 58 | + _args: &[mir::Operand<'tcx>], |
| 59 | + _return_place: &mir::Place<'tcx>, |
62 | 60 | ) {
|
63 | 61 | // Nothing to do when a call returns successfully
|
64 | 62 | }
|
65 | 63 | }
|
66 | 64 |
|
67 |
| -impl<'a, 'tcx> BottomValue for MaybeStorageLive<'a, 'tcx> { |
| 65 | +impl BottomValue for MaybeStorageLive { |
68 | 66 | /// bottom = dead
|
69 | 67 | const BOTTOM_VALUE: bool = false;
|
70 | 68 | }
|
|
0 commit comments