[llvm] r260387 - Constify two functions, make them accessible to unit tests

Daniel Berlin via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 10 09:39:43 PST 2016


Author: dannyb
Date: Wed Feb 10 11:39:43 2016
New Revision: 260387

URL: http://llvm.org/viewvc/llvm-project?rev=260387&view=rev
Log:
Constify two functions, make them accessible to unit tests

Modified:
    llvm/trunk/include/llvm/Transforms/Utils/MemorySSA.h
    llvm/trunk/lib/Transforms/Utils/MemorySSA.cpp

Modified: llvm/trunk/include/llvm/Transforms/Utils/MemorySSA.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/MemorySSA.h?rev=260387&r1=260386&r2=260387&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Utils/MemorySSA.h (original)
+++ llvm/trunk/include/llvm/Transforms/Utils/MemorySSA.h Wed Feb 10 11:39:43 2016
@@ -522,15 +522,19 @@ public:
   /// whether MemoryAccess \p A dominates MemoryAccess \p B.
   bool locallyDominates(const MemoryAccess *A, const MemoryAccess *B) const;
 
+  /// \brief Verify that MemorySSA is self consistent (IE definitions dominate
+  /// all uses, uses appear in the right places).  This is used by unit tests.
+  void verifyMemorySSA() const;
+
 protected:
   // Used by Memory SSA annotater, dumpers, and wrapper pass
   friend class MemorySSAAnnotatedWriter;
   friend class MemorySSAPrinterPass;
-  void verifyDefUses(Function &F);
-  void verifyDomination(Function &F);
+  void verifyDefUses(Function &F) const;
+  void verifyDomination(Function &F) const;
 
 private:
-  void verifyUseInDefs(MemoryAccess *, MemoryAccess *);
+  void verifyUseInDefs(MemoryAccess *, MemoryAccess *) const;
   using AccessMap =
       DenseMap<const BasicBlock *, std::unique_ptr<AccessListType>>;
 

Modified: llvm/trunk/lib/Transforms/Utils/MemorySSA.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/MemorySSA.cpp?rev=260387&r1=260386&r2=260387&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/MemorySSA.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/MemorySSA.cpp Wed Feb 10 11:39:43 2016
@@ -439,9 +439,14 @@ void MemorySSA::dump() const {
   F.print(dbgs(), &Writer);
 }
 
+void MemorySSA::verifyMemorySSA() const {
+  verifyDefUses(F);
+  verifyDomination(F);
+}
+
 /// \brief Verify the domination properties of MemorySSA by checking that each
 /// definition dominates all of its uses.
-void MemorySSA::verifyDomination(Function &F) {
+void MemorySSA::verifyDomination(Function &F) const {
   for (BasicBlock &B : F) {
     // Phi nodes are attached to basic blocks
     if (MemoryPhi *MP = getMemoryAccess(&B)) {
@@ -496,7 +501,7 @@ void MemorySSA::verifyDomination(Functio
 /// llvm_unreachable is used instead of asserts because this may be called in
 /// a build without asserts. In that case, we don't want this to turn into a
 /// nop.
-void MemorySSA::verifyUseInDefs(MemoryAccess *Def, MemoryAccess *Use) {
+void MemorySSA::verifyUseInDefs(MemoryAccess *Def, MemoryAccess *Use) const {
   // The live on entry use may cause us to get a NULL def here
   if (!Def) {
     if (!isLiveOnEntryDef(Use))
@@ -510,7 +515,7 @@ void MemorySSA::verifyUseInDefs(MemoryAc
 /// \brief Verify the immediate use information, by walking all the memory
 /// accesses and verifying that, for each use, it appears in the
 /// appropriate def's use list
-void MemorySSA::verifyDefUses(Function &F) {
+void MemorySSA::verifyDefUses(Function &F) const {
   for (BasicBlock &B : F) {
     // Phi nodes are attached to basic blocks
     if (MemoryPhi *Phi = getMemoryAccess(&B))
@@ -655,8 +660,7 @@ bool MemorySSAPrinterPass::runOnFunction
   Walker.reset(MSSA->buildMemorySSA(AA, DT));
 
   if (VerifyMemorySSA) {
-    MSSA->verifyDefUses(F);
-    MSSA->verifyDomination(F);
+    MSSA->verifyMemorySSA();
   }
 
   return false;




More information about the llvm-commits mailing list