move PrintCallGraphPass out of the middle of CGPassManager.

llvm-svn: 101543
This commit is contained in:
Chris Lattner 2010-04-16 21:43:55 +00:00
parent 7afa85b8fa
commit 6d1208fd2b
1 changed files with 43 additions and 33 deletions

View File

@ -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<CallGraphNode *> &SCC) {
Out << Banner;
for (std::vector<CallGraphNode *>::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<CallGraphNode*> &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<CallGraph>();
AU.addPreserved<CallGraph>();
}
//===----------------------------------------------------------------------===//
// 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<CallGraphNode *> &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);
}