1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

[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
This commit is contained in:
Chandler Carruth 2016-03-10 11:08:44 +00:00
parent 937deba1b9
commit 3c5ca0deac
4 changed files with 28 additions and 20 deletions

View File

@ -82,6 +82,7 @@ void initializeBranchFolderPassPass(PassRegistry&);
void initializeBranchProbabilityInfoWrapperPassPass(PassRegistry&); void initializeBranchProbabilityInfoWrapperPassPass(PassRegistry&);
void initializeBreakCriticalEdgesPass(PassRegistry&); void initializeBreakCriticalEdgesPass(PassRegistry&);
void initializeCallGraphDOTPrinterPass(PassRegistry&); void initializeCallGraphDOTPrinterPass(PassRegistry&);
void initializeCallGraphPrinterLegacyPassPass(PassRegistry&);
void initializeCallGraphViewerPass(PassRegistry&); void initializeCallGraphViewerPass(PassRegistry&);
void initializeCFGOnlyPrinterPass(PassRegistry&); void initializeCFGOnlyPrinterPass(PassRegistry&);
void initializeCFGOnlyViewerPass(PassRegistry&); void initializeCFGOnlyViewerPass(PassRegistry&);

View File

@ -27,6 +27,7 @@ void llvm::initializeAnalysis(PassRegistry &Registry) {
initializeBranchProbabilityInfoWrapperPassPass(Registry); initializeBranchProbabilityInfoWrapperPassPass(Registry);
initializeCallGraphWrapperPassPass(Registry); initializeCallGraphWrapperPassPass(Registry);
initializeCallGraphDOTPrinterPass(Registry); initializeCallGraphDOTPrinterPass(Registry);
initializeCallGraphPrinterLegacyPassPass(Registry);
initializeCallGraphViewerPass(Registry); initializeCallGraphViewerPass(Registry);
initializeCostModelAnalysisPass(Registry); initializeCostModelAnalysisPass(Registry);
initializeCFGViewerPass(Registry); initializeCFGViewerPass(Registry);

View File

@ -302,3 +302,29 @@ void CallGraphWrapperPass::print(raw_ostream &OS, const Module *) const {
LLVM_DUMP_METHOD LLVM_DUMP_METHOD
void CallGraphWrapperPass::dump() const { print(dbgs(), nullptr); } 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)

View File

@ -71,23 +71,3 @@ char ExternalFunctionsPassedConstants::ID = 0;
static RegisterPass<ExternalFunctionsPassedConstants> static RegisterPass<ExternalFunctionsPassedConstants>
P1("print-externalfnconstants", P1("print-externalfnconstants",
"Print external fn callsites passed constants"); "Print external fn callsites passed constants");
namespace {
struct CallGraphPrinter : public ModulePass {
static char ID; // Pass ID, replacement for typeid
CallGraphPrinter() : ModulePass(ID) {}
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.setPreservesAll();
AU.addRequiredTransitive<CallGraphWrapperPass>();
}
bool runOnModule(Module &M) override {
getAnalysis<CallGraphWrapperPass>().print(errs(), &M);
return false;
}
};
}
char CallGraphPrinter::ID = 0;
static RegisterPass<CallGraphPrinter>
P2("print-callgraph", "Print a call graph");