From d5faa747e9089041e24308abf4eb680ffc6a28ae Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Fri, 27 Jun 2008 16:43:21 +0000 Subject: [PATCH] Add dominator info printer pass. llvm-svn: 52829 --- lib/VMCore/Dominators.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/lib/VMCore/Dominators.cpp b/lib/VMCore/Dominators.cpp index e9eca4eee4a..452b59d2181 100644 --- a/lib/VMCore/Dominators.cpp +++ b/lib/VMCore/Dominators.cpp @@ -286,3 +286,34 @@ void DominanceFrontierBase::print(std::ostream &o, const Module* ) const { void DominanceFrontierBase::dump() { print (llvm::cerr); } + +//===----------------------------------------------------------------------===// +// DomInfoPrinter Pass +//===----------------------------------------------------------------------===// + +namespace { + class VISIBILITY_HIDDEN DomInfoPrinter : public FunctionPass { + public: + static char ID; // Pass identification, replacement for typeid + DomInfoPrinter() : FunctionPass((intptr_t)&ID) {} + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesAll(); + AU.addRequired(); + AU.addRequired(); + + } + + virtual bool runOnFunction(Function &F) { + DominatorTree &DT = getAnalysis(); + DT.dump(); + DominanceFrontier &DF = getAnalysis(); + DF.dump(); + return false; + } + }; +} + +char DomInfoPrinter::ID = 0; +static RegisterPass +DIP("print-dom-info", "Dominator Info Printer", true, true);