#include "llvm/Analysis/CallPrinter.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/Analysis/BlockFrequencyInfo.h"
#include "llvm/Analysis/CallGraph.h"
#include "llvm/Analysis/HeatUtils.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Module.h"
#include "llvm/InitializePasses.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/DOTGraphTraits.h"
#include "llvm/Support/GraphWriter.h"
usingnamespacellvm;
namespace llvm {
template <class GraphType> struct GraphTraits;
}
static cl::opt<bool> ShowHeatColors("callgraph-heat-colors", cl::init(false),
cl::Hidden,
cl::desc("Show heat colors in call-graph"));
static cl::opt<bool>
ShowEdgeWeight("callgraph-show-weights", cl::init(false), cl::Hidden,
cl::desc("Show edges labeled with weights"));
static cl::opt<bool>
CallMultiGraph("callgraph-multigraph", cl::init(false), cl::Hidden,
cl::desc("Show call-multigraph (do not remove parallel edges)"));
static cl::opt<std::string> CallGraphDotFilenamePrefix(
"callgraph-dot-filename-prefix", cl::Hidden,
cl::desc("The prefix used for the CallGraph dot file names."));
namespace llvm {
class CallGraphDOTInfo { … };
template <>
struct GraphTraits<CallGraphDOTInfo *>
: public GraphTraits<const CallGraphNode *> { … };
template <>
struct DOTGraphTraits<CallGraphDOTInfo *> : public DefaultDOTGraphTraits { … };
}
namespace {
void doCallGraphDOTPrinting(
Module &M, function_ref<BlockFrequencyInfo *(Function &)> LookupBFI) { … }
void viewCallGraph(Module &M,
function_ref<BlockFrequencyInfo *(Function &)> LookupBFI) { … }
}
namespace llvm {
PreservedAnalyses CallGraphDOTPrinterPass::run(Module &M,
ModuleAnalysisManager &AM) { … }
PreservedAnalyses CallGraphViewerPass::run(Module &M,
ModuleAnalysisManager &AM) { … }
}
namespace {
class CallGraphViewer : public ModulePass { … };
void CallGraphViewer::getAnalysisUsage(AnalysisUsage &AU) const { … }
bool CallGraphViewer::runOnModule(Module &M) { … }
class CallGraphDOTPrinter : public ModulePass { … };
void CallGraphDOTPrinter::getAnalysisUsage(AnalysisUsage &AU) const { … }
bool CallGraphDOTPrinter::runOnModule(Module &M) { … }
}
char CallGraphViewer::ID = …;
INITIALIZE_PASS(…)
char CallGraphDOTPrinter::ID = …;
INITIALIZE_PASS(…)
ModulePass *llvm::createCallGraphViewerPass() { … }
ModulePass *llvm::createCallGraphDOTPrinterPass() { … }