[MSSA] Print memory phis when inspecting walker.
authorAlina Sbirlea <asbirlea@google.com>
Wed, 6 Apr 2022 21:22:52 +0000 (14:22 -0700)
committerAlina Sbirlea <asbirlea@google.com>
Wed, 6 Apr 2022 23:06:14 +0000 (16:06 -0700)
This makes the MemorySSA and MemorySSA Walker printers consistent.
Invokation `-print<memoryssa-walker>` should also have the MemoryPhis.

llvm/lib/Analysis/MemorySSA.cpp

index fc9de56..f63898b 100644 (file)
@@ -130,6 +130,12 @@ public:
   MemorySSAWalkerAnnotatedWriter(MemorySSA *M)
       : MSSA(M), Walker(M->getWalker()) {}
 
+  void emitBasicBlockStartAnnot(const BasicBlock *BB,
+                                formatted_raw_ostream &OS) override {
+    if (MemoryAccess *MA = MSSA->getMemoryAccess(BB))
+      OS << "; " << *MA << "\n";
+  }
+
   void emitInstructionAnnot(const Instruction *I,
                             formatted_raw_ostream &OS) override {
     if (MemoryAccess *MA = MSSA->getMemoryAccess(I)) {