@@ -56,9 +56,6 @@ pub struct LivenessResult {
56
56
/// Liveness mode in use when these results were computed.
57
57
pub mode : LivenessMode ,
58
58
59
- /// Live variables on entry to each basic block.
60
- pub ins : IndexVec < BasicBlock , LocalSet > ,
61
-
62
59
/// Live variables on exit to each basic block. This is equal to
63
60
/// the union of the `ins` for each successor.
64
61
pub outs : IndexVec < BasicBlock , LocalSet > ,
@@ -125,11 +122,10 @@ pub fn liveness_of_locals<'tcx>(mir: &Mir<'tcx>, mode: LivenessMode) -> Liveness
125
122
. map ( |b| block ( mode, b, locals) )
126
123
. collect ( ) ;
127
124
128
- let mut ins : IndexVec < _ , _ > = mir. basic_blocks ( )
125
+ let mut outs : IndexVec < _ , _ > = mir. basic_blocks ( )
129
126
. indices ( )
130
127
. map ( |_| LocalSet :: new_empty ( locals) )
131
128
. collect ( ) ;
132
- let mut outs = ins. clone ( ) ;
133
129
134
130
let mut bits = LocalSet :: new_empty ( locals) ;
135
131
@@ -140,28 +136,21 @@ pub fn liveness_of_locals<'tcx>(mir: &Mir<'tcx>, mode: LivenessMode) -> Liveness
140
136
let predecessors = mir. predecessors ( ) ;
141
137
142
138
while let Some ( bb) = dirty_queue. pop ( ) {
143
- // outs[b] = ∪ {ins of successors}
144
- bits. clear ( ) ;
145
- for & successor in mir[ bb] . terminator ( ) . successors ( ) {
146
- bits. union ( & ins[ successor] ) ;
147
- }
148
- outs[ bb] . overwrite ( & bits) ;
149
-
150
139
// bits = use ∪ (bits - def)
140
+ bits. overwrite ( & outs[ bb] ) ;
151
141
def_use[ bb] . apply ( & mut bits) ;
152
142
153
- // update bits on entry and, if they have changed, enqueue all
154
- // of our predecessors, since their inputs have now changed
155
- if ins[ bb] != bits {
156
- ins[ bb] . overwrite ( & bits) ;
157
-
158
- for & pred_bb in & predecessors[ bb] {
143
+ // add `bits` to the out set for each predecessor; if those
144
+ // bits were not already present, then enqueue the predecessor
145
+ // as dirty.
146
+ for & pred_bb in & predecessors[ bb] {
147
+ if outs[ pred_bb] . union ( & bits) {
159
148
dirty_queue. insert ( pred_bb) ;
160
149
}
161
150
}
162
151
}
163
152
164
- LivenessResult { mode, ins , outs }
153
+ LivenessResult { mode, outs }
165
154
}
166
155
167
156
impl LivenessResult {
@@ -202,8 +191,6 @@ impl LivenessResult {
202
191
statement_defs_uses. apply ( & mut bits) ;
203
192
callback ( statement_location, & bits) ;
204
193
}
205
-
206
- assert_eq ! ( bits, self . ins[ block] ) ;
207
194
}
208
195
209
196
fn defs_uses < ' tcx , V > ( & self , mir : & Mir < ' tcx > , location : Location , thing : & V ) -> DefsUses
@@ -445,7 +432,6 @@ pub fn write_mir_fn<'a, 'tcx>(
445
432
. collect ( ) ;
446
433
writeln ! ( w, "{} {{{}}}" , prefix, live. join( ", " ) )
447
434
} ;
448
- print ( w, " " , & result. ins ) ?;
449
435
write_basic_block ( tcx, block, mir, & mut |_, _| Ok ( ( ) ) , w) ?;
450
436
print ( w, " " , & result. outs ) ?;
451
437
if block. index ( ) + 1 != mir. basic_blocks ( ) . len ( ) {
0 commit comments