Skip to content

Commit 865320f

Browse files
committed
remove the ins set altogether
1 parent be0e778 commit 865320f

File tree

3 files changed

+20
-30
lines changed

3 files changed

+20
-30
lines changed

src/librustc_mir/borrow_check/nll/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -261,13 +261,6 @@ fn dump_mir_results<'a, 'gcx, 'tcx>(
261261
}
262262
}
263263

264-
// Before each basic block, dump out the values
265-
// that are live on entry to the basic block.
266-
PassWhere::BeforeBlock(bb) => {
267-
let s = live_variable_set(&liveness.regular.ins[bb], &liveness.drop.ins[bb]);
268-
writeln!(out, " | Live variables on entry to {:?}: {}", bb, s)?;
269-
}
270-
271264
PassWhere::BeforeLocation(location) => {
272265
let s = live_variable_set(
273266
&regular_liveness_per_location[&location],
@@ -283,7 +276,14 @@ fn dump_mir_results<'a, 'gcx, 'tcx>(
283276
)?;
284277
}
285278

286-
PassWhere::AfterLocation(_) | PassWhere::AfterCFG => {}
279+
// After each basic block, dump out the values
280+
// that are live on exit from the basic block.
281+
PassWhere::AfterTerminator(bb) => {
282+
let s = live_variable_set(&liveness.regular.outs[bb], &liveness.drop.outs[bb]);
283+
writeln!(out, " | Live variables on entry to {:?}: {}", bb, s)?;
284+
}
285+
286+
PassWhere::BeforeBlock(_) | PassWhere::AfterLocation(_) | PassWhere::AfterCFG => {}
287287
}
288288
Ok(())
289289
},

src/librustc_mir/util/liveness.rs

+8-22
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ pub struct LivenessResult {
5656
/// Liveness mode in use when these results were computed.
5757
pub mode: LivenessMode,
5858

59-
/// Live variables on entry to each basic block.
60-
pub ins: IndexVec<BasicBlock, LocalSet>,
61-
6259
/// Live variables on exit to each basic block. This is equal to
6360
/// the union of the `ins` for each successor.
6461
pub outs: IndexVec<BasicBlock, LocalSet>,
@@ -125,11 +122,10 @@ pub fn liveness_of_locals<'tcx>(mir: &Mir<'tcx>, mode: LivenessMode) -> Liveness
125122
.map(|b| block(mode, b, locals))
126123
.collect();
127124

128-
let mut ins: IndexVec<_, _> = mir.basic_blocks()
125+
let mut outs: IndexVec<_, _> = mir.basic_blocks()
129126
.indices()
130127
.map(|_| LocalSet::new_empty(locals))
131128
.collect();
132-
let mut outs = ins.clone();
133129

134130
let mut bits = LocalSet::new_empty(locals);
135131

@@ -140,28 +136,21 @@ pub fn liveness_of_locals<'tcx>(mir: &Mir<'tcx>, mode: LivenessMode) -> Liveness
140136
let predecessors = mir.predecessors();
141137

142138
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-
150139
// bits = use ∪ (bits - def)
140+
bits.overwrite(&outs[bb]);
151141
def_use[bb].apply(&mut bits);
152142

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) {
159148
dirty_queue.insert(pred_bb);
160149
}
161150
}
162151
}
163152

164-
LivenessResult { mode, ins, outs }
153+
LivenessResult { mode, outs }
165154
}
166155

167156
impl LivenessResult {
@@ -202,8 +191,6 @@ impl LivenessResult {
202191
statement_defs_uses.apply(&mut bits);
203192
callback(statement_location, &bits);
204193
}
205-
206-
assert_eq!(bits, self.ins[block]);
207194
}
208195

209196
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>(
445432
.collect();
446433
writeln!(w, "{} {{{}}}", prefix, live.join(", "))
447434
};
448-
print(w, " ", &result.ins)?;
449435
write_basic_block(tcx, block, mir, &mut |_, _| Ok(()), w)?;
450436
print(w, " ", &result.outs)?;
451437
if block.index() + 1 != mir.basic_blocks().len() {

src/librustc_mir/util/pretty.rs

+4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ pub enum PassWhere {
4444

4545
/// We just dumped the given statement or terminator.
4646
AfterLocation(Location),
47+
48+
/// We just dumped the terminator for a block but not the closing `}`.
49+
AfterTerminator(BasicBlock),
4750
}
4851

4952
/// If the session is properly configured, dumps a human-readable
@@ -351,6 +354,7 @@ where
351354
})?;
352355

353356
extra_data(PassWhere::AfterLocation(current_location), w)?;
357+
extra_data(PassWhere::AfterTerminator(block), w)?;
354358

355359
writeln!(w, "{}}}", INDENT)
356360
}

0 commit comments

Comments
 (0)