Skip to content

Commit ea03a43

Browse files
committed
introduce apply helper that applies a DefUse set to live bits
1 parent bd25116 commit ea03a43

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/librustc_mir/util/liveness.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ struct DefsUses {
5454
}
5555

5656
impl DefsUses {
57+
fn apply(&self, bits: &mut LocalSet) -> bool {
58+
bits.subtract(&self.defs) | bits.union(&self.uses)
59+
}
60+
5761
fn add_def(&mut self, index: Local) {
5862
// If it was used already in the block, remove that use
5963
// now that we found a definition.
@@ -194,8 +198,9 @@ pub fn liveness_of_locals<'tcx>(mir: &Mir<'tcx>) -> LivenessResult {
194198

195199
// in = use ∪ (out - def)
196200
ins[b].clone_from(&outs[b]);
197-
ins[b].subtract(&def_use[b].defs);
198-
ins[b].union(&def_use[b].uses);
201+
202+
// FIXME use the return value to detect if we have changed things
203+
def_use[b].apply(&mut ins[b]);
199204
}
200205

201206
if ins_ == ins && outs_ == outs {

0 commit comments

Comments
 (0)