LLVM  12.0.0git
Public Types | Public Member Functions | Friends | List of all members
llvm::CallGraphNode Class Reference

A node in the call graph for a module. More...

#include "llvm/Analysis/CallGraph.h"

Public Types

using CallRecord = std::pair< Optional< WeakTrackingVH >, CallGraphNode * >
 A pair of the calling instruction (a call or invoke) and the call graph node being called. More...
 
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. More...
 
 CallGraphNode (const CallGraphNode &)=delete
 
CallGraphNodeoperator= (const CallGraphNode &)=delete
 
 ~CallGraphNode ()
 
FunctiongetFunction () const
 Returns the function that this call graph node represents. More...
 
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. More...
 
CallGraphNodeoperator[] (unsigned i) const
 Returns the i'th called function. More...
 
void dump () const
 Print out this call graph node. More...
 
void print (raw_ostream &OS) const
 
void removeAllCalledFunctions ()
 Removes all edges from this CallGraphNode to any functions it calls. More...
 
void stealCalledFunctionsFrom (CallGraphNode *N)
 Moves all the callee information from N to this node. More...
 
void addCalledFunction (CallBase *Call, CallGraphNode *M)
 Adds a function to the list of functions called by this one. More...
 
void removeCallEdge (iterator I)
 
void removeCallEdgeFor (CallBase &Call)
 Removes the edge in the node for the specified call site. More...
 
void removeAnyCallEdgeTo (CallGraphNode *Callee)
 Removes all call edges from this node to the specified callee function. More...
 
void removeOneAbstractEdgeTo (CallGraphNode *Callee)
 Removes one edge associated with a null callsite from this node to the specified callee function. More...
 
void replaceCallEdge (CallBase &Call, CallBase &NewCall, CallGraphNode *NewNode)
 Replaces the edge in the node for the specified call site with a new one. More...
 

Friends

class CallGraph
 

Detailed Description

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 174 of file CallGraph.h.

Member Typedef Documentation

◆ CalledFunctionsVector

Definition at line 189 of file CallGraph.h.

◆ CallRecord

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 186 of file CallGraph.h.

◆ const_iterator

Definition at line 202 of file CallGraph.h.

◆ iterator

Definition at line 201 of file CallGraph.h.

Constructor & Destructor Documentation

◆ CallGraphNode() [1/2]

llvm::CallGraphNode::CallGraphNode ( CallGraph CG,
Function F 
)
inline

Creates a node for the specified function.

Definition at line 192 of file CallGraph.h.

◆ CallGraphNode() [2/2]

llvm::CallGraphNode::CallGraphNode ( const CallGraphNode )
delete

◆ ~CallGraphNode()

llvm::CallGraphNode::~CallGraphNode ( )
inline

Definition at line 197 of file CallGraph.h.

References assert().

Member Function Documentation

◆ addCalledFunction()

void llvm::CallGraphNode::addCalledFunction ( CallBase Call,
CallGraphNode M 
)
inline

Adds a function to the list of functions called by this one.

Definition at line 250 of file CallGraph.h.

References assert(), llvm::CallBase::getCalledFunction(), llvm::Function::getIntrinsicID(), llvm::Function::isIntrinsic(), and llvm::Intrinsic::isLeaf().

Referenced by replacePrepare(), and UpdateCallGraphAfterInlining().

◆ begin() [1/2]

iterator llvm::CallGraphNode::begin ( )
inline

◆ begin() [2/2]

const_iterator llvm::CallGraphNode::begin ( ) const
inline

Definition at line 209 of file CallGraph.h.

◆ dump()

LLVM_DUMP_METHOD void CallGraphNode::dump ( ) const

Print out this call graph node.

Definition at line 220 of file CallGraph.cpp.

References llvm::dbgs(), and llvm::CallGraph::print().

◆ empty()

bool llvm::CallGraphNode::empty ( ) const
inline

Definition at line 211 of file CallGraph.h.

Referenced by llvm::CallGraph::removeFunctionFromModule().

◆ end() [1/2]

iterator llvm::CallGraphNode::end ( )
inline

◆ end() [2/2]

const_iterator llvm::CallGraphNode::end ( ) const
inline

Definition at line 210 of file CallGraph.h.

◆ getFunction()

Function* llvm::CallGraphNode::getFunction ( ) const
inline

◆ getNumReferences()

unsigned llvm::CallGraphNode::getNumReferences ( ) const
inline

Returns the number of other CallGraphNodes in this CallGraph that reference this node in their callee list.

Definition at line 216 of file CallGraph.h.

Referenced by llvm::CallGraphUpdater::finalize().

◆ operator=()

CallGraphNode& llvm::CallGraphNode::operator= ( const CallGraphNode )
delete

◆ operator[]()

CallGraphNode* llvm::CallGraphNode::operator[] ( unsigned  i) const
inline

Returns the i'th called function.

Definition at line 219 of file CallGraph.h.

References assert(), llvm::CallGraph::dump(), and llvm::CallGraph::print().

◆ print()

void CallGraphNode::print ( raw_ostream OS) const

Definition at line 201 of file CallGraph.cpp.

References F(), getFunction(), and I.

◆ removeAllCalledFunctions()

void llvm::CallGraphNode::removeAllCalledFunctions ( )
inline

Removes all edges from this CallGraphNode to any functions it calls.

Definition at line 235 of file CallGraph.h.

Referenced by llvm::CallGraphUpdater::finalize(), llvm::CallGraphUpdater::reanalyzeFunction(), and llvm::CallGraphUpdater::removeFunction().

◆ removeAnyCallEdgeTo()

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 246 of file CallGraph.cpp.

References llvm::numbers::e.

Referenced by llvm::CallGraphUpdater::finalize(), and llvm::LegacyInlinerBase::removeDeadFunctions().

◆ removeCallEdge()

void llvm::CallGraphNode::removeCallEdge ( iterator  I)
inline

Definition at line 259 of file CallGraph.h.

References Callee.

◆ removeCallEdgeFor()

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 226 of file CallGraph.cpp.

References assert(), llvm::forEachCallbackFunction(), and I.

Referenced by DeleteBasicBlock(), llvm::CallGraphUpdater::removeCallSite(), replacePrepare(), and UpdateCallGraphAfterInlining().

◆ 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 258 of file CallGraph.cpp.

References assert(), and I.

Referenced by llvm::InternalizePass::internalizeModule().

◆ 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 274 of file CallGraph.cpp.

References assert(), llvm::forEachCallbackFunction(), and I.

Referenced by llvm::createArgumentPromotionPass(), and llvm::CallGraphUpdater::replaceCallSite().

◆ size()

unsigned llvm::CallGraphNode::size ( ) const
inline

Definition at line 212 of file CallGraph.h.

◆ stealCalledFunctionsFrom()

void llvm::CallGraphNode::stealCalledFunctionsFrom ( CallGraphNode N)
inline

Moves all the callee information from N to this node.

Definition at line 243 of file CallGraph.h.

References assert(), and std::swap().

Referenced by llvm::createArgumentPromotionPass(), and llvm::CallGraphUpdater::replaceFunctionWith().

Friends And Related Function Documentation

◆ CallGraph

friend class CallGraph
friend

Definition at line 289 of file CallGraph.h.


The documentation for this class was generated from the following files: