From 78ea95258d6e3f603713ffde001334305044a4fb Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 2 Jul 2018 11:40:49 -0400 Subject: [PATCH] improve comments --- src/librustc_data_structures/indexed_set.rs | 6 ++++++ src/librustc_mir/util/liveness.rs | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/librustc_data_structures/indexed_set.rs b/src/librustc_data_structures/indexed_set.rs index 30b87c0390a..2e95a45479c 100644 --- a/src/librustc_data_structures/indexed_set.rs +++ b/src/librustc_data_structures/indexed_set.rs @@ -239,14 +239,20 @@ pub fn overwrite(&mut self, other: &IdxSet) { self.words_mut().clone_from_slice(other.words()); } + /// Set `self = self | other` and return true if `self` changed + /// (i.e., if new bits were added). pub fn union(&mut self, other: &IdxSet) -> bool { bitwise(self.words_mut(), other.words(), &Union) } + /// Set `self = self - other` and return true if `self` changed. + /// (i.e., if any bits were removed). pub fn subtract(&mut self, other: &IdxSet) -> bool { bitwise(self.words_mut(), other.words(), &Subtract) } + /// Set `self = self & other` and return true if `self` changed. + /// (i.e., if any bits were removed). pub fn intersect(&mut self, other: &IdxSet) -> bool { bitwise(self.words_mut(), other.words(), &Intersect) } diff --git a/src/librustc_mir/util/liveness.rs b/src/librustc_mir/util/liveness.rs index d4b93b896de..4630cdae47d 100644 --- a/src/librustc_mir/util/liveness.rs +++ b/src/librustc_mir/util/liveness.rs @@ -140,9 +140,12 @@ pub fn liveness_of_locals<'tcx>(mir: &Mir<'tcx>, mode: LivenessMode) -> Liveness bits.overwrite(&outs[bb]); def_use[bb].apply(&mut bits); - // add `bits` to the out set for each predecessor; if those + // `bits` now contains the live variables on entry. Therefore, + // add `bits` to the `out` set for each predecessor; if those // bits were not already present, then enqueue the predecessor // as dirty. + // + // (note that `union` returns true if the `self` set changed) for &pred_bb in &predecessors[bb] { if outs[pred_bb].union(&bits) { dirty_queue.insert(pred_bb);