summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJingyue Wu <jingyue@google.com>2015-12-18 21:44:26 +0000
committerJingyue Wu <jingyue@google.com>2015-12-18 21:44:26 +0000
commit509e2e953b0981a66cb58a45cb5a3070dff5fed5 (patch)
treebbb3883488acd5809ed5872c4ba327b43714cee1 /lib
parent8ed8b4f3b1b0c5cc51008afeb88514cb307a8e83 (diff)
[DivergenceAnalysis] fix a bug in computing influence regions
Fixes PR25864 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256036 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/DivergenceAnalysis.cpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/lib/Analysis/DivergenceAnalysis.cpp b/lib/Analysis/DivergenceAnalysis.cpp
index 93a288858ba..5ae6d74130a 100644
--- a/lib/Analysis/DivergenceAnalysis.cpp
+++ b/lib/Analysis/DivergenceAnalysis.cpp
@@ -96,7 +96,7 @@ private:
// A helper function that explores sync dependents of TI.
void exploreSyncDependency(TerminatorInst *TI);
// Computes the influence region from Start to End. This region includes all
- // basic blocks on any path from Start to End.
+ // basic blocks on any simple path from Start to End.
void computeInfluenceRegion(BasicBlock *Start, BasicBlock *End,
DenseSet<BasicBlock *> &InfluenceRegion);
// Finds all users of I that are outside the influence region, and add these
@@ -198,21 +198,33 @@ void DivergencePropagator::findUsersOutsideInfluenceRegion(
}
}
+// A helper function for computeInfluenceRegion that adds successors of "ThisBB"
+// to the influence region.
+static void
+addSuccessorsToInfluenceRegion(BasicBlock *ThisBB, BasicBlock *End,
+ DenseSet<BasicBlock *> &InfluenceRegion,
+ std::vector<BasicBlock *> &InfluenceStack) {
+ for (BasicBlock *Succ : successors(ThisBB)) {
+ if (Succ != End && InfluenceRegion.insert(Succ).second)
+ InfluenceStack.push_back(Succ);
+ }
+}
+
void DivergencePropagator::computeInfluenceRegion(
BasicBlock *Start, BasicBlock *End,
DenseSet<BasicBlock *> &InfluenceRegion) {
assert(PDT.properlyDominates(End, Start) &&
"End does not properly dominate Start");
+
+ // The influence region starts from the end of "Start" to the beginning of
+ // "End". Therefore, "Start" should not be in the region unless "Start" is in
+ // a loop that doesn't contain "End".
std::vector<BasicBlock *> InfluenceStack;
- InfluenceStack.push_back(Start);
- InfluenceRegion.insert(Start);
+ addSuccessorsToInfluenceRegion(Start, End, InfluenceRegion, InfluenceStack);
while (!InfluenceStack.empty()) {
BasicBlock *BB = InfluenceStack.back();
InfluenceStack.pop_back();
- for (BasicBlock *Succ : successors(BB)) {
- if (End != Succ && InfluenceRegion.insert(Succ).second)
- InfluenceStack.push_back(Succ);
- }
+ addSuccessorsToInfluenceRegion(BB, End, InfluenceRegion, InfluenceStack);
}
}