diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2016-03-10 11:08:44 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2016-03-10 11:08:44 +0000 |
commit | 1ecd740cf0b99a7c2ac79fdfdf08338588296910 (patch) | |
tree | 0802c9b569548e07b9145558cfe3a01c051bad15 /llvm/lib/Analysis/CallGraph.cpp | |
parent | 5f432292a672f13549656ee3639f5916c3e01586 (diff) | |
download | bcm5719-llvm-1ecd740cf0b99a7c2ac79fdfdf08338588296910.tar.gz bcm5719-llvm-1ecd740cf0b99a7c2ac79fdfdf08338588296910.zip |
[CG] Actually hoist up the generic CallGraphPrinter pass from a weird
location in the opt tool to live along side the analysis in LLVM's
libraries.
No functionality changed here, but this will allow me to port the
printer to the new pass manager as well.
llvm-svn: 263101
Diffstat (limited to 'llvm/lib/Analysis/CallGraph.cpp')
-rw-r--r-- | llvm/lib/Analysis/CallGraph.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/CallGraph.cpp b/llvm/lib/Analysis/CallGraph.cpp index 426684be58a..235d0f61263 100644 --- a/llvm/lib/Analysis/CallGraph.cpp +++ b/llvm/lib/Analysis/CallGraph.cpp @@ -302,3 +302,29 @@ void CallGraphWrapperPass::print(raw_ostream &OS, const Module *) const { LLVM_DUMP_METHOD void CallGraphWrapperPass::dump() const { print(dbgs(), nullptr); } + +namespace { +struct CallGraphPrinterLegacyPass : public ModulePass { + static char ID; // Pass ID, replacement for typeid + CallGraphPrinterLegacyPass() : ModulePass(ID) { + initializeCallGraphPrinterLegacyPassPass(*PassRegistry::getPassRegistry()); + } + + void getAnalysisUsage(AnalysisUsage &AU) const override { + AU.setPreservesAll(); + AU.addRequiredTransitive<CallGraphWrapperPass>(); + } + bool runOnModule(Module &M) override { + getAnalysis<CallGraphWrapperPass>().print(errs(), &M); + return false; + } +}; +} + +char CallGraphPrinterLegacyPass::ID = 0; + +INITIALIZE_PASS_BEGIN(CallGraphPrinterLegacyPass, "print-callgraph", + "Print a call graph", true, true) +INITIALIZE_PASS_DEPENDENCY(CallGraphWrapperPass) +INITIALIZE_PASS_END(CallGraphPrinterLegacyPass, "print-callgraph", + "Print a call graph", true, true) |