summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorAlina Sbirlea <asbirlea@google.com>2019-04-12 18:48:46 +0000
committerAlina Sbirlea <asbirlea@google.com>2019-04-12 18:48:46 +0000
commit57769382b1fb5f597e503eebc5cf302e87cc7e16 (patch)
tree3e61a0bad74463c15b3ffac6fba1328975af7c00 /llvm/lib
parent11bbb5831ba5d5823bccea7f84eaaab54276e32c (diff)
downloadbcm5719-llvm-57769382b1fb5f597e503eebc5cf302e87cc7e16.tar.gz
bcm5719-llvm-57769382b1fb5f597e503eebc5cf302e87cc7e16.zip
[MemorySSA] Small fix for the clobber limit.
Summary: After introducing the limit for clobber walking, `walkToPhiOrClobber` would assert that the limit is at least 1 on entry. The test included triggered that assert. The callsite in `tryOptimizePhi` making the calls to `walkToPhiOrClobber` is structured like this: ``` while (true) { if (getBlockingAccess()) { // calls walkToPhiOrClobber } for (...) { walkToPhiOrClobber(); } } ``` The cleanest fix is to check if the limit was reached inside `walkToPhiOrClobber`, and give an allowence of 1. This approach not make any alias() calls (no calls to instructionClobbersQuery), so the performance condition is enforced. The limit is set back to 0 if not used, as this provides info on the fact that we stopped before reaching a true clobber. Reviewers: george.burgess.iv Subscribers: jlebar, Prazek, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D60479 llvm-svn: 358303
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Analysis/MemorySSA.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/MemorySSA.cpp b/llvm/lib/Analysis/MemorySSA.cpp
index a8100312f21..cd6235de685 100644
--- a/llvm/lib/Analysis/MemorySSA.cpp
+++ b/llvm/lib/Analysis/MemorySSA.cpp
@@ -544,10 +544,15 @@ template <class AliasAnalysisType> class ClobberWalker {
const MemoryAccess *SkipStopAt = nullptr) const {
assert(!isa<MemoryUse>(Desc.Last) && "Uses don't exist in my world");
assert(UpwardWalkLimit && "Need a valid walk limit");
- // This will not do any alias() calls. It returns in the first iteration in
- // the loop below.
- if (*UpwardWalkLimit == 0)
- (*UpwardWalkLimit)++;
+ bool LimitAlreadyReached = false;
+ // (*UpwardWalkLimit) may be 0 here, due to the loop in tryOptimizePhi. Set
+ // it to 1. This will not do any alias() calls. It either returns in the
+ // first iteration in the loop below, or is set back to 0 if all def chains
+ // are free of MemoryDefs.
+ if (!*UpwardWalkLimit) {
+ *UpwardWalkLimit = 1;
+ LimitAlreadyReached = true;
+ }
for (MemoryAccess *Current : def_chain(Desc.Last)) {
Desc.Last = Current;
@@ -568,6 +573,9 @@ template <class AliasAnalysisType> class ClobberWalker {
}
}
+ if (LimitAlreadyReached)
+ *UpwardWalkLimit = 0;
+
assert(isa<MemoryPhi>(Desc.Last) &&
"Ended at a non-clobber that's not a phi?");
return {Desc.Last, false, MayAlias};
OpenPOWER on IntegriCloud