From c93760c3e55db7e5fadbbf0f75fa3587cd8bb9dc Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 16 Apr 2010 21:43:55 +0000 Subject: [PATCH] move PrintCallGraphPass out of the middle of CGPassManager. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101543 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/IPA/CallGraphSCCPass.cpp | 76 +++++++++++++++------------ 1 file changed, 43 insertions(+), 33 deletions(-) diff --git a/lib/Analysis/IPA/CallGraphSCCPass.cpp b/lib/Analysis/IPA/CallGraphSCCPass.cpp index fb0804190ac..8a2c03a3ad0 100644 --- a/lib/Analysis/IPA/CallGraphSCCPass.cpp +++ b/lib/Analysis/IPA/CallGraphSCCPass.cpp @@ -87,39 +87,10 @@ private: bool IsCheckingMode); }; -/// PrintCallGraphPass - Print a Module corresponding to a call graph. -/// -class PrintCallGraphPass : public CallGraphSCCPass { -private: - std::string Banner; - raw_ostream &Out; // raw_ostream to print on. - -public: - static char ID; - PrintCallGraphPass() : CallGraphSCCPass(&ID), Out(dbgs()) {} - PrintCallGraphPass(const std::string &B, raw_ostream &o) - : CallGraphSCCPass(&ID), Banner(B), Out(o) {} - - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.setPreservesAll(); - } - - bool runOnSCC(std::vector &SCC) { - Out << Banner; - for (std::vector::iterator n = SCC.begin(), ne = SCC.end(); - n != ne; - ++n) { - (*n)->getFunction()->print(Out); - } - return false; - } -}; - } // end anonymous namespace. char CGPassManager::ID = 0; -char PrintCallGraphPass::ID = 0; bool CGPassManager::RunPassOnSCC(Pass *P, std::vector &CurSCC, CallGraph &CG, bool &CallGraphUpToDate) { @@ -426,10 +397,9 @@ bool CGPassManager::doFinalization(CallGraph &CG) { return Changed; } -Pass *CallGraphSCCPass::createPrinterPass(raw_ostream &O, - const std::string &Banner) const { - return new PrintCallGraphPass(Banner, O); -} +//===----------------------------------------------------------------------===// +// CallGraphSCCPass Implementation +//===----------------------------------------------------------------------===// /// Assign pass manager to manage this pass. void CallGraphSCCPass::assignPassManager(PMStack &PMS, @@ -475,3 +445,43 @@ void CallGraphSCCPass::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); AU.addPreserved(); } + + +//===----------------------------------------------------------------------===// +// PrintCallGraphPass Implementation +//===----------------------------------------------------------------------===// + +namespace { + /// PrintCallGraphPass - Print a Module corresponding to a call graph. + /// + class PrintCallGraphPass : public CallGraphSCCPass { + std::string Banner; + raw_ostream &Out; // raw_ostream to print on. + + public: + static char ID; + PrintCallGraphPass() : CallGraphSCCPass(&ID), Out(dbgs()) {} + PrintCallGraphPass(const std::string &B, raw_ostream &o) + : CallGraphSCCPass(&ID), Banner(B), Out(o) {} + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesAll(); + } + + bool runOnSCC(std::vector &SCC) { + Out << Banner; + for (unsigned i = 0, e = SCC.size(); i != e; ++i) + SCC[i]->getFunction()->print(Out); + return false; + } + }; + +} // end anonymous namespace. + +char PrintCallGraphPass::ID = 0; + +Pass *CallGraphSCCPass::createPrinterPass(raw_ostream &O, + const std::string &Banner) const { + return new PrintCallGraphPass(Banner, O); +} +