[llvm-dev] [MemorySSA] bug in MemorySSA construction

Geoff Berry via llvm-dev llvm-dev at lists.llvm.org
Thu Aug 4 14:35:27 PDT 2016


There appears to be a bug in MemorySSA that sometimes results in memory 
defs that don't dominate their uses.  If you apply the below patch and 
run the following command you should be able to reproduce the issue.  I 
haven't been able to investigate it yet, but may do so tomorrow if no 
one gets to it first.


$ opt -print-memoryssa 
llvm/test/Transforms/GlobalDCE/complex-constantexpr.ll

diff --git a/lib/Transforms/Utils/MemorySSA.cpp 
b/lib/Transforms/Utils/MemorySSA.cpp
index 4a604c9..ed2574b 100644
--- a/lib/Transforms/Utils/MemorySSA.cpp
+++ b/lib/Transforms/Utils/MemorySSA.cpp
@@ -1900,7 +1900,9 @@ void MemorySSA::verifyDomination(Function &F) const {
              }
            }
          } else {
-          UseBlock = cast<MemoryAccess>(U)->getBlock();
+          auto *MA = cast<MemoryAccess>(U);
+          UseBlock = MA->getBlock();
+          assert(MD->getBlock() != UseBlock || locallyDominates(MD, MA));
          }
          assert(DT->dominates(MD->getBlock(), UseBlock) &&
                 "Memory Def does not dominate it's uses");

-- 
Geoff Berry
Employee of Qualcomm Innovation Center, Inc.
  Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project



More information about the llvm-dev mailing list