[PATCH] D70618: [MemorySSA] Combine two verifications into one.

Alina Sbirlea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 22 14:15:51 PST 2019


asbirlea created this revision.
Herald added subscribers: sanjoy.google, george.burgess.iv, hiraditya, Prazek.
Herald added a project: LLVM.

Combine two verification method into one to improve compile time when
asserts are enabled.
Aiming to improve PR44066.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70618

Files:
  llvm/include/llvm/Analysis/MemorySSA.h
  llvm/lib/Analysis/MemorySSA.cpp


Index: llvm/lib/Analysis/MemorySSA.cpp
===================================================================
--- llvm/lib/Analysis/MemorySSA.cpp
+++ llvm/lib/Analysis/MemorySSA.cpp
@@ -1872,7 +1872,7 @@
 void MemorySSA::verifyMemorySSA() const {
   verifyDefUses(F);
   verifyDomination(F);
-  verifyOrdering(F);
+  verifyOrderingAndDomination(F);
   verifyDominationNumbers(F);
   verifyPrevDefInPhis(F);
   // Previously, the verification used to also verify that the clobberingAccess
@@ -1961,8 +1961,10 @@
 
 /// Verify that the order and existence of MemoryAccesses matches the
 /// order and existence of memory affecting instructions.
-void MemorySSA::verifyOrdering(Function &F) const {
-#ifndef NDEBUG
+/// Verify the domination properties of MemorySSA by checking that each
+/// definition dominates all of its uses.
+void MemorySSA::verifyOrderingAndDomination(Function &F) const {
+#if !defined(NDEBUG)
   // Walk all the blocks, comparing what the lookups think and what the access
   // lists think, as well as the order in the blocks vs the order in the access
   // lists.
@@ -1975,6 +1977,8 @@
     if (Phi) {
       ActualAccesses.push_back(Phi);
       ActualDefs.push_back(Phi);
+      for (const Use &U : Phi->uses())
+        assert(dominates(Phi, U) && "Memory PHI does not dominate it's uses");
     }
 
     for (Instruction &I : B) {
@@ -1985,8 +1989,11 @@
              "access list or defs list");
       if (MA) {
         ActualAccesses.push_back(MA);
-        if (isa<MemoryDef>(MA))
+        if (MemoryAccess *MD = dyn_cast<MemoryDef>(MA)) {
+          for (const Use &U : MD->uses())
+            assert(dominates(MD, U) && "Memory Def does not dominate it's uses");
           ActualDefs.push_back(MA);
+        }
       }
     }
     // Either we hit the assert, really have no accesses, or we have both
@@ -2027,7 +2034,7 @@
 /// Verify the domination properties of MemorySSA by checking that each
 /// definition dominates all of its uses.
 void MemorySSA::verifyDomination(Function &F) const {
-#ifndef NDEBUG
+#if 0
   for (BasicBlock &B : F) {
     // Phi nodes are attached to basic blocks
     if (MemoryPhi *MP = getMemoryAccess(&B))
Index: llvm/include/llvm/Analysis/MemorySSA.h
===================================================================
--- llvm/include/llvm/Analysis/MemorySSA.h
+++ llvm/include/llvm/Analysis/MemorySSA.h
@@ -797,7 +797,7 @@
   void verifyPrevDefInPhis(Function &F) const;
   void verifyDefUses(Function &F) const;
   void verifyDomination(Function &F) const;
-  void verifyOrdering(Function &F) const;
+  void verifyOrderingAndDomination(Function &F) const;
   void verifyDominationNumbers(const Function &F) const;
 
   // This is used by the use optimizer and updater.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70618.230721.patch
Type: text/x-patch
Size: 2742 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191122/250b009e/attachment.bin>


More information about the llvm-commits mailing list