Go to the documentation of this file.
39 cl::desc(
"Show heat colors in call-graph"));
43 cl::desc(
"Show edges labeled with weights"));
47 cl::desc(
"Show call-multigraph (do not remove parallel edges)"));
51 cl::desc(
"The prefix used for the CallGraph dot file names."));
73 for (
User *U :
F.users())
78 if (localSumFreq >= MaxFreq)
79 MaxFreq = localSumFreq;
80 Freq[&
F] = localSumFreq;
83 removeParallelEdges();
95 void removeParallelEdges() {
96 for (
auto &
I : (*CG)) {
99 bool FoundParallelEdge =
true;
100 while (FoundParallelEdge) {
102 FoundParallelEdge =
false;
103 for (
auto CI = Node->begin(), CE = Node->end(); CI != CE; CI++) {
104 if (!(Visited.
insert(CI->second->getFunction())).second) {
105 FoundParallelEdge =
true;
106 Node->removeCallEdge(CI);
123 typedef std::pair<const Function *const, std::unique_ptr<CallGraphNode>>
126 return P.second.get();
147 return "Call graph: " +
161 return "external caller";
163 return "external callee";
165 if (
Function *Func = Node->getFunction())
166 return std::string(Func->getName());
167 return "external node";
175 decltype(&CGGetValuePtr)>
183 Function *Caller = Node->getFunction();
184 if (Caller ==
nullptr || Caller->isDeclaration())
211 attrs =
"color=\"" + edgeColor +
"ff\", style=filled, fillcolor=\"" +
221 void doCallGraphDOTPrinting(
223 std::string Filename;
227 Filename = (std::string(
M.getModuleIdentifier()) +
".callgraph.dot");
228 errs() <<
"Writing '" << Filename <<
"'...";
239 errs() <<
" error opening file for writing!";
243 void viewCallGraph(
Module &M,
250 ViewGraph(&CFGInfo,
"callgraph",
true, Title);
264 doCallGraphDOTPrinting(
M, LookupBFI);
279 viewCallGraph(
M, LookupBFI);
296 void CallGraphViewer::getAnalysisUsage(
AnalysisUsage &AU)
const {
297 ModulePass::getAnalysisUsage(AU);
302 bool CallGraphViewer::runOnModule(
Module &
M) {
304 return &this->getAnalysis<BlockFrequencyInfoWrapperPass>(
F).getBFI();
307 viewCallGraph(
M, LookupBFI);
314 class CallGraphDOTPrinter :
public ModulePass {
323 void CallGraphDOTPrinter::getAnalysisUsage(
AnalysisUsage &AU)
const {
324 ModulePass::getAnalysisUsage(AU);
329 bool CallGraphDOTPrinter::runOnModule(
Module &
M) {
331 return &this->getAnalysis<BlockFrequencyInfoWrapperPass>(
F).getBFI();
334 doCallGraphDOTPrinting(
M, LookupBFI);
342 INITIALIZE_PASS(CallGraphViewer,
"view-callgraph",
"View call graph",
false,
345 char CallGraphDOTPrinter::
ID = 0;
356 return new CallGraphDOTPrinter();
A set of analyses that are preserved following a run of a transformation pass.
DOTGraphTraits(bool isSimple=false)
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
This is an optimization pass for GlobalISel generic memory operations.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
CallGraphNode * getExternalCallingNode() const
Returns the CallGraphNode which is used to represent undetermined calls into the callgraph.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
static Function * getFunction(Constant *C)
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Legacy analysis pass which computes BlockFrequencyInfo.
std::pair< Optional< WeakTrackingVH >, CallGraphNode * > CallRecord
A pair of the calling instruction (a call or invoke) and the call graph node being called.
into xmm2 addss xmm2 xmm1 xmm3 addss xmm3 movaps xmm0 unpcklps xmm0 ret seems silly when it could just be one addps Expand libm rounding functions main should enable SSE DAZ mode and other fast SSE modes Think about doing i64 math in SSE regs on x86 This testcase should have no SSE instructions in and only one load from a constant double
std::function< BlockFrequencyInfo *(Function &)> LookupBFI
CallGraphDOTInfo(Module *M, CallGraph *CG, function_ref< BlockFrequencyInfo *(Function &)> LookupBFI)
The basic data container for the call graph of a Module of IR.
FunctionAnalysisManager FAM
static const CallGraphNode * CGGetValuePtr(CallGraphNode::CallRecord P)
uint64_t getFreq(const Function *F)
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
static cl::opt< bool > ShowEdgeWeight("callgraph-show-weights", cl::init(false), cl::Hidden, cl::desc("Show edges labeled with weights"))
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
void ViewGraph(const GraphType &G, const Twine &Name, bool ShortNames=false, const Twine &Title="", GraphProgram::Name Program=GraphProgram::DOT)
ViewGraph - Emit a dot graph, run 'dot', run gv on the postscript file, then cleanup.
std::string getHeatColor(uint64_t freq, uint64_t maxFreq)
std::pair< const Function *const, std::unique_ptr< CallGraphNode > > PairTy
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
static const CallGraphNode * CGGetValuePtr(const PairTy &P)
ModulePass * createCallGraphViewerPass()
Represent the analysis usage information of a pass.
std::string getNodeAttributes(const CallGraphNode *Node, CallGraphDOTInfo *CGInfo)
FunctionMapTy::const_iterator const_iterator
A node in the call graph for a module.
Analysis pass which computes BlockFrequencyInfo.
mapped_iterator< CallGraphNode::const_iterator, decltype(&CGGetValuePtr)> nodes_iterator
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
static cl::opt< bool > CallMultiGraph("callgraph-multigraph", cl::init(false), cl::Hidden, cl::desc("Show call-multigraph (do not remove parallel edges)"))
DOTGraphTraits - Template class that can be specialized to customize how graphs are converted to 'dot...
std::string getEdgeAttributes(const CallGraphNode *Node, nodes_iterator I, CallGraphDOTInfo *CGInfo)
An efficient, type-erasing, non-owning reference to a callable.
static std::string getGraphName(CallGraphDOTInfo *CGInfo)
static nodes_iterator nodes_begin(CallGraphDOTInfo *CGInfo)
dot regions Print regions of function to dot file(with no function bodies)"
@ OF_Text
The file should be opened in text mode on platforms like z/OS that make this distinction.
static std::string getGraphName(const GraphType &)
getGraphName - Return the label for the graph as a whole.
S is passed via registers r2 But gcc stores them to the and then reload them to and r3 before issuing the call(r0 contains the address of the format string)
initializer< Ty > init(const Ty &Val)
static cl::opt< std::string > CallGraphDotFilenamePrefix("callgraph-dot-filename-prefix", cl::Hidden, cl::desc("The prefix used for the CallGraph dot file names."))
mapped_iterator< CallGraph::const_iterator, decltype(&CGGetValuePtr)> nodes_iterator
virtual bool runOnModule(Module &M)=0
runOnModule - Virtual method overriden by subclasses to process the module being operated on.
raw_ostream & WriteGraph(raw_ostream &O, const GraphType &G, bool ShortNames=false, const Twine &Title="")
const std::string & getModuleIdentifier() const
Get the module identifier which is, essentially, the name of the module.
print Print MemDeps of function
A Module instance is used to store all the information related to an LLVM module.
std::vector< CallRecord >::const_iterator const_iterator
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
A raw_ostream that writes to a file descriptor.
amdgpu Simplify well known AMD library false FunctionCallee Callee
static bool isNodeHidden(const CallGraphNode *Node, const CallGraphDOTInfo *CGInfo)
void setPreservesAll()
Set by analyses that do not transform their input at all.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
CallGraph * getCallGraph() const
ModulePass * createCallGraphDOTPrinterPass()
std::string getNodeLabel(const CallGraphNode *Node, CallGraphDOTInfo *CGInfo)
static cl::opt< bool > ShowHeatColors("callgraph-heat-colors", cl::init(false), cl::Hidden, cl::desc("Show heat colors in call-graph"))
Module * getModule() const
static bool isSimple(Instruction *I)
static nodes_iterator nodes_end(CallGraphDOTInfo *CGInfo)
std::string to_string(const T &Value)
DefaultDOTGraphTraits - This class provides the default implementations of all of the DOTGraphTraits ...
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
A container for analyses that lazily runs them and caches their results.
An analysis over an "outer" IR unit that provides access to an analysis manager over an "inner" IR un...
AnalysisUsage & addRequired()
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
static NodeRef getEntryNode(CallGraphDOTInfo *CGInfo)
CallGraphNode * getCallsExternalNode() const
INITIALIZE_PASS(CallGraphViewer, "view-callgraph", "View call graph", false, false) char CallGraphDOTPrinter INITIALIZE_PASS(CallGraphDOTPrinter, "dot-callgraph", "Print call graph to 'dot' file", false, false) ModulePass *llvm
uint64_t getNumOfCalls(Function &callerFunction, Function &calledFunction)