[PATCH] Make the MemDepPrinter to print something

Dmitry Mikushin dmitry at kernelgen.org
Wed Dec 4 16:03:08 PST 2013


dmikushin added you to the CC list for the revision "Make the MemDepPrinter to print something".

Hi sunfish,

While exploring dependency analysis capabilities, I've discovered by current design MemDepPrinter has a print() function, which is never called anywhere. Thus, `opt -print-memdeps` never prints anything. This trivial patch change the pass to print the dependencies right from the function pass.

http://llvm-reviews.chandlerc.com/D2333

Files:
  lib/Analysis/MemDepPrinter.cpp

Index: lib/Analysis/MemDepPrinter.cpp
===================================================================
--- lib/Analysis/MemDepPrinter.cpp
+++ lib/Analysis/MemDepPrinter.cpp
@@ -16,6 +16,7 @@
 #include "llvm/Assembly/Writer.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/Support/CallSite.h"
+#include "llvm/Support/Debug.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/InstIterator.h"
 #include "llvm/Support/raw_ostream.h"
@@ -47,8 +48,6 @@
 
     virtual bool runOnFunction(Function &F);
 
-    void print(raw_ostream &OS, const Module * = 0) const;
-
     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
       AU.addRequiredTransitive<AliasAnalysis>();
       AU.addRequiredTransitive<MemoryDependenceAnalysis>();
@@ -74,6 +73,7 @@
     static InstTypePair getInstTypePair(const Instruction* inst, DepType type) {
       return InstTypePair(inst, type);
     }
+    void print(raw_ostream &OS, const Module * = 0) const;
   };
 }
 
@@ -153,11 +153,14 @@
       }
     }
   }
+  
+  print(dbgs(), F.getParent());
 
   return false;
 }
 
 void MemDepPrinter::print(raw_ostream &OS, const Module *M) const {
+  OS << "Function " << F->getName() << " memory dependencies:\n\n";
   for (const_inst_iterator I = inst_begin(*F), E = inst_end(*F); I != E; ++I) {
     const Instruction *Inst = &*I;
 
@@ -189,4 +192,5 @@
     Inst->print(OS);
     OS << "\n\n";
   }
+  OS << "\n";
 }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2333.1.patch
Type: text/x-patch
Size: 1418 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131204/17ed1616/attachment.bin>


More information about the llvm-commits mailing list