@@ -16,27 +16,27 @@ use rustc::ty::TyCtxt;
16
16
17
17
use super :: dataflow:: * ;
18
18
19
- pub struct LocalLivenessAnalysis ;
19
+ pub struct DeadCode ;
20
20
21
- impl Pass for LocalLivenessAnalysis { }
21
+ impl Pass for DeadCode { }
22
22
23
- impl < ' tcx > MirPass < ' tcx > for LocalLivenessAnalysis {
23
+ impl < ' tcx > MirPass < ' tcx > for DeadCode {
24
24
fn run_pass < ' a > ( & mut self , _: TyCtxt < ' a , ' tcx , ' tcx > , _: MirSource , mir : & mut Mir < ' tcx > ) {
25
- let new_mir = Dataflow :: backward ( mir, LiveValueTransfer , LiveValueRewrite ) ;
25
+ let new_mir = Dataflow :: backward ( mir, DeadCodeTransfer , DeadCodeRewrite ) ;
26
26
* mir = new_mir;
27
27
}
28
28
}
29
29
30
30
#[ derive( Debug , Clone ) ]
31
- struct LiveValueLattice {
31
+ struct DeadCodeLattice {
32
32
vars : BitVector ,
33
33
args : BitVector ,
34
34
tmps : BitVector ,
35
35
}
36
36
37
- impl Lattice for LiveValueLattice {
37
+ impl Lattice for DeadCodeLattice {
38
38
fn bottom ( ) -> Self {
39
- LiveValueLattice {
39
+ DeadCodeLattice {
40
40
vars : BitVector :: new ( 0 ) ,
41
41
tmps : BitVector :: new ( 0 ) ,
42
42
args : BitVector :: new ( 0 )
@@ -53,7 +53,7 @@ impl Lattice for LiveValueLattice {
53
53
}
54
54
}
55
55
56
- impl LiveValueLattice {
56
+ impl DeadCodeLattice {
57
57
fn set_lvalue_live < ' a > ( & mut self , l : & Lvalue < ' a > ) {
58
58
match * l {
59
59
Lvalue :: Arg ( a) => {
@@ -82,29 +82,29 @@ impl LiveValueLattice {
82
82
}
83
83
}
84
84
85
- struct LiveValueTransfer ;
86
- impl < ' tcx > Transfer < ' tcx > for LiveValueTransfer {
87
- type Lattice = LiveValueLattice ;
88
- type TerminatorReturn = LiveValueLattice ;
85
+ struct DeadCodeTransfer ;
86
+ impl < ' tcx > Transfer < ' tcx > for DeadCodeTransfer {
87
+ type Lattice = DeadCodeLattice ;
88
+ type TerminatorReturn = DeadCodeLattice ;
89
89
90
- fn stmt ( & self , s : & Statement < ' tcx > , lat : LiveValueLattice ) -> LiveValueLattice {
91
- let mut vis = LiveValueVisitor ( lat) ;
90
+ fn stmt ( & self , s : & Statement < ' tcx > , lat : DeadCodeLattice ) -> DeadCodeLattice {
91
+ let mut vis = DeadCodeVisitor ( lat) ;
92
92
vis. visit_statement ( START_BLOCK , s) ;
93
93
vis. 0
94
94
}
95
95
96
- fn term ( & self , t : & Terminator < ' tcx > , lat : LiveValueLattice ) -> LiveValueLattice {
97
- let mut vis = LiveValueVisitor ( lat) ;
96
+ fn term ( & self , t : & Terminator < ' tcx > , lat : DeadCodeLattice ) -> DeadCodeLattice {
97
+ let mut vis = DeadCodeVisitor ( lat) ;
98
98
vis. visit_terminator ( START_BLOCK , t) ;
99
99
vis. 0
100
100
}
101
101
}
102
102
103
- struct LiveValueRewrite ;
104
- impl < ' tcx , T > Rewrite < ' tcx , T > for LiveValueRewrite
105
- where T : Transfer < ' tcx , Lattice =LiveValueLattice >
103
+ struct DeadCodeRewrite ;
104
+ impl < ' tcx , T > Rewrite < ' tcx , T > for DeadCodeRewrite
105
+ where T : Transfer < ' tcx , Lattice =DeadCodeLattice >
106
106
{
107
- fn stmt ( & self , s : & Statement < ' tcx > , lat : & LiveValueLattice )
107
+ fn stmt ( & self , s : & Statement < ' tcx > , lat : & DeadCodeLattice )
108
108
-> StatementChange < ' tcx >
109
109
{
110
110
let StatementKind :: Assign ( ref lval, ref rval) = s. kind ;
@@ -121,15 +121,15 @@ where T: Transfer<'tcx, Lattice=LiveValueLattice>
121
121
}
122
122
}
123
123
124
- fn term ( & self , t : & Terminator < ' tcx > , _: & LiveValueLattice )
124
+ fn term ( & self , t : & Terminator < ' tcx > , _: & DeadCodeLattice )
125
125
-> TerminatorChange < ' tcx >
126
126
{
127
127
TerminatorChange :: Terminator ( t. clone ( ) )
128
128
}
129
129
}
130
130
131
- struct LiveValueVisitor ( LiveValueLattice ) ;
132
- impl < ' tcx > Visitor < ' tcx > for LiveValueVisitor {
131
+ struct DeadCodeVisitor ( DeadCodeLattice ) ;
132
+ impl < ' tcx > Visitor < ' tcx > for DeadCodeVisitor {
133
133
fn visit_lvalue ( & mut self , lval : & Lvalue < ' tcx > , ctx : LvalueContext ) {
134
134
if ctx == LvalueContext :: Store || ctx == LvalueContext :: CallStore {
135
135
match * lval {
0 commit comments