aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/MemorySSAUpdater.cpp
diff options
context:
space:
mode:
authorAlina Sbirlea <asbirlea@google.com>2019-05-02 23:41:58 +0000
committerAlina Sbirlea <asbirlea@google.com>2019-05-02 23:41:58 +0000
commit0363c3b8bbf1c72e7a7da65444a8095cdc63f32d (patch)
tree07164a49b71070fb5d30a572dd065825985b2f97 /llvm/lib/Analysis/MemorySSAUpdater.cpp
parentf7d3048e5b90c9d71ea462a721efce360260fd60 (diff)
downloadllvm-0363c3b8bbf1c72e7a7da65444a8095cdc63f32d.zip
llvm-0363c3b8bbf1c72e7a7da65444a8095cdc63f32d.tar.gz
llvm-0363c3b8bbf1c72e7a7da65444a8095cdc63f32d.tar.bz2
[MemorySSA] Check that block is reachable when adding phis.
Summary: Originally the insertDef method was only used when building MemorySSA, and was limiting the number of Phi nodes that it created. Now it's used for updates as well, and it can create additional Phis needed for correctness. Make sure no Phis are created in unreachable blocks (condition met during MSSA build), otherwise the renamePass will find a null DTNode. Resolves PR41640. Reviewers: george.burgess.iv Subscribers: jlebar, Prazek, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D61410 llvm-svn: 359845
Diffstat (limited to 'llvm/lib/Analysis/MemorySSAUpdater.cpp')
-rw-r--r--llvm/lib/Analysis/MemorySSAUpdater.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/MemorySSAUpdater.cpp b/llvm/lib/Analysis/MemorySSAUpdater.cpp
index 7c675b7..8fe7c68 100644
--- a/llvm/lib/Analysis/MemorySSAUpdater.cpp
+++ b/llvm/lib/Analysis/MemorySSAUpdater.cpp
@@ -72,7 +72,10 @@ MemoryAccess *MemorySSAUpdater::getPreviousDefRecursive(
// potential phi node. This will insert phi nodes if we cycle in order to
// break the cycle and have an operand.
for (auto *Pred : predecessors(BB))
- PhiOps.push_back(getPreviousDefFromEnd(Pred, CachedPreviousDef));
+ if (MSSA->DT->isReachableFromEntry(Pred))
+ PhiOps.push_back(getPreviousDefFromEnd(Pred, CachedPreviousDef));
+ else
+ PhiOps.push_back(MSSA->getLiveOnEntryDef());
// Now try to simplify the ops to avoid placing a phi.
// This may return null if we never created a phi yet, that's okay