LLVM 22.0.0git
|
The basic data container for the call graph of a Module
of IR.
More...
#include "llvm/Analysis/CallGraph.h"
Public Types | |
using | iterator = FunctionMapTy::iterator |
using | const_iterator = FunctionMapTy::const_iterator |
Public Member Functions | |
LLVM_ABI | CallGraph (Module &M) |
LLVM_ABI | CallGraph (CallGraph &&Arg) |
LLVM_ABI | ~CallGraph () |
LLVM_ABI void | print (raw_ostream &OS) const |
LLVM_ABI void | dump () const |
Module & | getModule () const |
Returns the module the call graph corresponds to. | |
LLVM_ABI bool | invalidate (Module &, const PreservedAnalyses &PA, ModuleAnalysisManager::Invalidator &) |
iterator | begin () |
iterator | end () |
const_iterator | begin () const |
const_iterator | end () const |
const CallGraphNode * | operator[] (const Function *F) const |
Returns the call graph node for the provided function. | |
CallGraphNode * | operator[] (const Function *F) |
Returns the call graph node for the provided function. | |
CallGraphNode * | getExternalCallingNode () const |
Returns the CallGraphNode which is used to represent undetermined calls into the callgraph. | |
CallGraphNode * | getCallsExternalNode () const |
LLVM_ABI Function * | removeFunctionFromModule (CallGraphNode *CGN) |
Unlink the function from this module, returning it. | |
LLVM_ABI CallGraphNode * | getOrInsertFunction (const Function *F) |
Similar to operator[], but this will insert a new CallGraphNode for F if one does not already exist. | |
LLVM_ABI void | populateCallGraphNode (CallGraphNode *CGN) |
Populate CGN based on the calls inside the associated function. | |
LLVM_ABI void | addToCallGraph (Function *F) |
Add a function to the call graph, and link the node to all of the functions that it calls. | |
The basic data container for the call graph of a Module
of IR.
This class exposes both the interface to the call graph for a module of IR.
The core call graph itself can also be updated to reflect changes to the IR.
Definition at line 72 of file CallGraph.h.
using llvm::CallGraph::const_iterator = FunctionMapTy::const_iterator |
Definition at line 98 of file CallGraph.h.
using llvm::CallGraph::iterator = FunctionMapTy::iterator |
Definition at line 97 of file CallGraph.h.
|
explicit |
Definition at line 31 of file CallGraph.cpp.
References addToCallGraph(), and F.
CallGraph::CallGraph | ( | CallGraph && | Arg | ) |
Definition at line 39 of file CallGraph.cpp.
References P.
CallGraph::~CallGraph | ( | ) |
Definition at line 52 of file CallGraph.cpp.
References I.
void CallGraph::addToCallGraph | ( | Function * | F | ) |
Add a function to the call graph, and link the node to all of the functions that it calls.
Definition at line 73 of file CallGraph.cpp.
References llvm::CallGraphNode::addCalledFunction(), F, getOrInsertFunction(), and populateCallGraphNode().
Referenced by CallGraph().
|
inline |
Definition at line 106 of file CallGraph.h.
Referenced by llvm::GraphTraits< CallGraph * >::nodes_begin(), llvm::GraphTraits< CallGraphDOTInfo * >::nodes_begin(), and llvm::GraphTraits< const CallGraph * >::nodes_begin().
|
inline |
Definition at line 108 of file CallGraph.h.
LLVM_DUMP_METHOD void CallGraph::dump | ( | ) | const |
Definition at line 136 of file CallGraph.cpp.
References llvm::dbgs(), and print().
|
inline |
Definition at line 107 of file CallGraph.h.
Referenced by llvm::GraphTraits< CallGraph * >::nodes_end(), llvm::GraphTraits< CallGraphDOTInfo * >::nodes_end(), and llvm::GraphTraits< const CallGraph * >::nodes_end().
|
inline |
Definition at line 109 of file CallGraph.h.
|
inline |
Definition at line 129 of file CallGraph.h.
Referenced by llvm::DOTGraphTraits< CallGraphDOTInfo * >::getNodeLabel().
|
inline |
Returns the CallGraphNode
which is used to represent undetermined calls into the callgraph.
Definition at line 127 of file CallGraph.h.
Referenced by llvm::GraphTraits< CallGraph * >::getEntryNode(), llvm::GraphTraits< CallGraphDOTInfo * >::getEntryNode(), llvm::GraphTraits< const CallGraph * >::getEntryNode(), llvm::DOTGraphTraits< CallGraphDOTInfo * >::getNodeLabel(), and llvm::AMDGPU::removeFnAttrFromReachable().
|
inline |
Returns the module the call graph corresponds to.
Definition at line 101 of file CallGraph.h.
CallGraphNode * CallGraph::getOrInsertFunction | ( | const Function * | F | ) |
Similar to operator[], but this will insert a new CallGraphNode for F
if one does not already exist.
Definition at line 158 of file CallGraph.cpp.
Referenced by addToCallGraph(), populateCallGraphNode(), and llvm::CallGraphNode::replaceCallEdge().
bool CallGraph::invalidate | ( | Module & | , |
const PreservedAnalyses & | PA, | ||
ModuleAnalysisManager::Invalidator & | |||
) |
Definition at line 65 of file CallGraph.cpp.
References llvm::PreservedAnalyses::getChecker().
|
inline |
Returns the call graph node for the provided function.
Definition at line 119 of file CallGraph.h.
|
inline |
Returns the call graph node for the provided function.
Definition at line 112 of file CallGraph.h.
void CallGraph::populateCallGraphNode | ( | CallGraphNode * | CGN | ) |
Populate CGN
based on the calls inside the associated function.
Definition at line 87 of file CallGraph.cpp.
References F, llvm::forEachCallbackFunction(), getOrInsertFunction(), and I.
Referenced by addToCallGraph().
void CallGraph::print | ( | raw_ostream & | OS | ) | const |
Definition at line 113 of file CallGraph.cpp.
References I, if(), LHS, OS, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallVectorImpl< T >::reserve(), RHS, and llvm::sort().
Referenced by dump().
Function * CallGraph::removeFunctionFromModule | ( | CallGraphNode * | CGN | ) |
Unlink the function from this module, returning it.
Because this removes the function from the module, the call graph node is destroyed. This is only valid if the function does not call any other functions (ie, there are no edges in it's CGN). The easiest way to do this is to dropAllReferences before calling this.
Definition at line 145 of file CallGraph.cpp.
References assert(), llvm::CallGraphNode::empty(), F, llvm::CallGraphNode::getFunction(), llvm::Module::getFunctionList(), and llvm::iplist_impl< IntrusiveListT, TraitsT >::remove().