LLVM 20.0.0git
|
A node in the call graph for a module. More...
#include "llvm/Analysis/CallGraph.h"
Public Types | |
using | CallRecord = std::pair< std::optional< WeakTrackingVH >, CallGraphNode * > |
A pair of the calling instruction (a call or invoke) and the call graph node being called. | |
using | CalledFunctionsVector = std::vector< CallRecord > |
using | iterator = std::vector< CallRecord >::iterator |
using | const_iterator = std::vector< CallRecord >::const_iterator |
Public Member Functions | |
CallGraphNode (CallGraph *CG, Function *F) | |
Creates a node for the specified function. | |
CallGraphNode (const CallGraphNode &)=delete | |
CallGraphNode & | operator= (const CallGraphNode &)=delete |
~CallGraphNode () | |
Function * | getFunction () const |
Returns the function that this call graph node represents. | |
iterator | begin () |
iterator | end () |
const_iterator | begin () const |
const_iterator | end () const |
bool | empty () const |
unsigned | size () const |
unsigned | getNumReferences () const |
Returns the number of other CallGraphNodes in this CallGraph that reference this node in their callee list. | |
CallGraphNode * | operator[] (unsigned i) const |
Returns the i'th called function. | |
void | dump () const |
Print out this call graph node. | |
void | print (raw_ostream &OS) const |
void | removeAllCalledFunctions () |
Removes all edges from this CallGraphNode to any functions it calls. | |
void | stealCalledFunctionsFrom (CallGraphNode *N) |
Moves all the callee information from N to this node. | |
void | addCalledFunction (CallBase *Call, CallGraphNode *M) |
Adds a function to the list of functions called by this one. | |
void | removeCallEdge (iterator I) |
void | removeCallEdgeFor (CallBase &Call) |
Removes the edge in the node for the specified call site. | |
void | removeAnyCallEdgeTo (CallGraphNode *Callee) |
Removes all call edges from this node to the specified callee function. | |
void | removeOneAbstractEdgeTo (CallGraphNode *Callee) |
Removes one edge associated with a null callsite from this node to the specified callee function. | |
void | replaceCallEdge (CallBase &Call, CallBase &NewCall, CallGraphNode *NewNode) |
Replaces the edge in the node for the specified call site with a new one. | |
Friends | |
class | CallGraph |
A node in the call graph for a module.
Typically represents a function in the call graph. There are also special "null" nodes used to represent theoretical entries in the call graph.
Definition at line 165 of file CallGraph.h.
using llvm::CallGraphNode::CalledFunctionsVector = std::vector<CallRecord> |
Definition at line 180 of file CallGraph.h.
using llvm::CallGraphNode::CallRecord = std::pair<std::optional<WeakTrackingVH>, CallGraphNode *> |
A pair of the calling instruction (a call or invoke) and the call graph node being called.
Call graph node may have two types of call records which represent an edge in the call graph - reference or a call edge. Reference edges are not associated with any call instruction and are created with the first field set to None
, while real call edges have instruction address in this field. Therefore, all real call edges are expected to have a value in the first field and it is not supposed to be nullptr
. Reference edges, for example, are used for connecting broker function caller to the callback function for callback call sites.
Definition at line 177 of file CallGraph.h.
using llvm::CallGraphNode::const_iterator = std::vector<CallRecord>::const_iterator |
Definition at line 193 of file CallGraph.h.
using llvm::CallGraphNode::iterator = std::vector<CallRecord>::iterator |
Definition at line 192 of file CallGraph.h.
Creates a node for the specified function.
Definition at line 183 of file CallGraph.h.
References F.
|
delete |
|
inline |
Definition at line 188 of file CallGraph.h.
References assert().
|
inline |
Adds a function to the list of functions called by this one.
Definition at line 241 of file CallGraph.h.
Referenced by llvm::CallGraph::addToCallGraph(), and replaceCallEdge().
|
inline |
Definition at line 198 of file CallGraph.h.
|
inline |
Definition at line 200 of file CallGraph.h.
LLVM_DUMP_METHOD void CallGraphNode::dump | ( | ) | const |
Print out this call graph node.
Definition at line 203 of file CallGraph.cpp.
References llvm::dbgs(), and print().
|
inline |
Definition at line 202 of file CallGraph.h.
Referenced by llvm::CallGraph::removeFunctionFromModule().
|
inline |
Definition at line 199 of file CallGraph.h.
|
inline |
Definition at line 201 of file CallGraph.h.
|
inline |
Returns the function that this call graph node represents.
Definition at line 196 of file CallGraph.h.
Referenced by getDescription(), print(), and llvm::CallGraph::removeFunctionFromModule().
|
inline |
Returns the number of other CallGraphNodes in this CallGraph that reference this node in their callee list.
Definition at line 207 of file CallGraph.h.
Referenced by print().
|
delete |
|
inline |
void CallGraphNode::print | ( | raw_ostream & | OS | ) | const |
Definition at line 184 of file CallGraph.cpp.
References getFunction(), llvm::Value::getName(), getNumReferences(), I, and OS.
Referenced by dump().
|
inline |
Removes all edges from this CallGraphNode to any functions it calls.
Definition at line 226 of file CallGraph.h.
void CallGraphNode::removeAnyCallEdgeTo | ( | CallGraphNode * | Callee | ) |
Removes all call edges from this node to the specified callee function.
This takes more time to execute than removeCallEdgeTo, so it should not be used unless necessary.
Definition at line 229 of file CallGraph.cpp.
|
inline |
Definition at line 248 of file CallGraph.h.
References I.
void CallGraphNode::removeCallEdgeFor | ( | CallBase & | Call | ) |
Removes the edge in the node for the specified call site.
removeCallEdgeFor - This method removes the edge in the node for the specified call site.
Note that this method takes linear time, so it should be used sparingly.
Definition at line 209 of file CallGraph.cpp.
References assert(), llvm::forEachCallbackFunction(), llvm::CallGraph::getOrInsertFunction(), I, and removeOneAbstractEdgeTo().
void CallGraphNode::removeOneAbstractEdgeTo | ( | CallGraphNode * | Callee | ) |
Removes one edge associated with a null callsite from this node to the specified callee function.
removeOneAbstractEdgeTo - Remove one edge associated with a null callsite from this node to the specified callee function.
Definition at line 241 of file CallGraph.cpp.
Referenced by removeCallEdgeFor(), and replaceCallEdge().
void CallGraphNode::replaceCallEdge | ( | CallBase & | Call, |
CallBase & | NewCall, | ||
CallGraphNode * | NewNode | ||
) |
Replaces the edge in the node for the specified call site with a new one.
replaceCallEdge - This method replaces the edge in the node for the specified call site with a new one.
Note that this method takes linear time, so it should be used sparingly.
Definition at line 257 of file CallGraph.cpp.
References addCalledFunction(), assert(), llvm::forEachCallbackFunction(), llvm::CallGraph::getOrInsertFunction(), I, N, llvm::SmallVectorTemplateBase< T, bool >::push_back(), removeOneAbstractEdgeTo(), and llvm::SmallVectorBase< Size_T >::size().
|
inline |
Definition at line 203 of file CallGraph.h.
|
inline |
Moves all the callee information from N to this node.
Definition at line 234 of file CallGraph.h.
References assert(), N, and std::swap().
|
friend |
Definition at line 278 of file CallGraph.h.