]> git.lizzy.rs Git - rust.git/commitdiff
introduce `apply` helper that applies a DefUse set to live bits
authorNiko Matsakis <niko@alum.mit.edu>
Tue, 24 Oct 2017 15:57:22 +0000 (11:57 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Tue, 31 Oct 2017 16:41:38 +0000 (12:41 -0400)
src/librustc_mir/util/liveness.rs

index d0a37e8a22472a3e0615a1a1bb41c8107eaf05e4..d3a10225cdc2d7ad1016df70314b325e197ef9ec 100644 (file)
@@ -54,6 +54,10 @@ struct DefsUses {
 }
 
 impl DefsUses {
+    fn apply(&self, bits: &mut LocalSet) -> bool {
+        bits.subtract(&self.defs) | bits.union(&self.uses)
+    }
+
     fn add_def(&mut self, index: Local) {
         // If it was used already in the block, remove that use
         // now that we found a definition.
@@ -194,8 +198,9 @@ pub fn liveness_of_locals<'tcx>(mir: &Mir<'tcx>) -> LivenessResult {
 
             // in = use ∪ (out - def)
             ins[b].clone_from(&outs[b]);
-            ins[b].subtract(&def_use[b].defs);
-            ins[b].union(&def_use[b].uses);
+
+            // FIXME use the return value to detect if we have changed things
+            def_use[b].apply(&mut ins[b]);
         }
 
         if ins_ == ins && outs_ == outs {