]> granicus.if.org Git - llvm/commitdiff
MemorySSA: fix memory access local dominance function for live on entry
authorSebastian Pop <spop@codeaurora.org>
Fri, 10 Jun 2016 21:36:41 +0000 (21:36 +0000)
committerSebastian Pop <spop@codeaurora.org>
Fri, 10 Jun 2016 21:36:41 +0000 (21:36 +0000)
A memory access defined on function entry cannot be locally dominated by another memory access.
The patch was split from http://reviews.llvm.org/D19338 which exposes the problem.

Differential Revision: http://reviews.llvm.org/D21039

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272436 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Utils/MemorySSA.cpp

index 5946b99d14695c2d10d532b8c307cd3f9ab604eb..85d21b1007e33a17d6346400efbde9e46ffdab4f 100644 (file)
@@ -623,6 +623,21 @@ bool MemorySSA::locallyDominates(const MemoryAccess *Dominator,
 
   assert((Dominator->getBlock() == Dominatee->getBlock()) &&
          "Asking for local domination when accesses are in different blocks!");
+
+  // A node dominates itself.
+  if (Dominatee == Dominator)
+    return true;
+
+  // When Dominatee is defined on function entry, it is not dominated by another
+  // memory access.
+  if (isLiveOnEntryDef(Dominatee))
+    return false;
+
+  // When Dominator is defined on function entry, it dominates the other memory
+  // access.
+  if (isLiveOnEntryDef(Dominator))
+    return true;
+
   // Get the access list for the block
   const AccessListType *AccessList = getBlockAccesses(Dominator->getBlock());
   AccessListType::const_reverse_iterator It(Dominator->getIterator());