LLVM  14.0.0git
Public Types | Public Member Functions | List of all members
llvm::CallGraph Class Reference

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

 CallGraph (Module &M)
 
 CallGraph (CallGraph &&Arg)
 
 ~CallGraph ()
 
void print (raw_ostream &OS) const
 
void dump () const
 
ModulegetModule () const
 Returns the module the call graph corresponds to. More...
 
bool invalidate (Module &, const PreservedAnalyses &PA, ModuleAnalysisManager::Invalidator &)
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
const CallGraphNodeoperator[] (const Function *F) const
 Returns the call graph node for the provided function. More...
 
CallGraphNodeoperator[] (const Function *F)
 Returns the call graph node for the provided function. More...
 
CallGraphNodegetExternalCallingNode () const
 Returns the CallGraphNode which is used to represent undetermined calls into the callgraph. More...
 
CallGraphNodegetCallsExternalNode () const
 
void ReplaceExternalCallEdge (CallGraphNode *Old, CallGraphNode *New)
 Old node has been deleted, and New is to be used in its place, update the ExternalCallingNode. More...
 
FunctionremoveFunctionFromModule (CallGraphNode *CGN)
 Unlink the function from this module, returning it. More...
 
CallGraphNodegetOrInsertFunction (const Function *F)
 Similar to operator[], but this will insert a new CallGraphNode for F if one does not already exist. More...
 
void populateCallGraphNode (CallGraphNode *CGN)
 Populate CGN based on the calls inside the associated function. More...
 
void addToCallGraph (Function *F)
 Add a function to the call graph, and link the node to all of the functions that it calls. More...
 

Detailed Description

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

Member Typedef Documentation

◆ const_iterator

using llvm::CallGraph::const_iterator = FunctionMapTy::const_iterator

Definition at line 99 of file CallGraph.h.

◆ iterator

using llvm::CallGraph::iterator = FunctionMapTy::iterator

Definition at line 98 of file CallGraph.h.

Constructor & Destructor Documentation

◆ CallGraph() [1/2]

CallGraph::CallGraph ( Module M)
explicit

Definition at line 33 of file CallGraph.cpp.

References addToCallGraph(), F, llvm::isDbgInfoIntrinsic(), and M.

◆ CallGraph() [2/2]

CallGraph::CallGraph ( CallGraph &&  Arg)

Definition at line 42 of file CallGraph.cpp.

References Arg, M, and P.

◆ ~CallGraph()

CallGraph::~CallGraph ( )

Definition at line 55 of file CallGraph.cpp.

References I.

Member Function Documentation

◆ addToCallGraph()

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

Referenced by CallGraph(), and llvm::CallGraphUpdater::registerOutlinedFunction().

◆ begin() [1/2]

iterator llvm::CallGraph::begin ( )
inline

◆ begin() [2/2]

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

Definition at line 109 of file CallGraph.h.

◆ dump()

LLVM_DUMP_METHOD void CallGraph::dump ( ) const

Definition at line 143 of file CallGraph.cpp.

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

◆ end() [1/2]

iterator llvm::CallGraph::end ( )
inline

◆ end() [2/2]

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

Definition at line 110 of file CallGraph.h.

◆ getCallsExternalNode()

CallGraphNode* llvm::CallGraph::getCallsExternalNode ( ) const
inline

Definition at line 130 of file CallGraph.h.

Referenced by prepareForSplit().

◆ getExternalCallingNode()

CallGraphNode* llvm::CallGraph::getExternalCallingNode ( ) const
inline

◆ getModule()

Module& llvm::CallGraph::getModule ( ) const
inline

Returns the module the call graph corresponds to.

Definition at line 102 of file CallGraph.h.

References M.

Referenced by createDevirtTriggerFunc(), and llvm::LegacyInlinerBase::doInitialization().

◆ getOrInsertFunction()

CallGraphNode * CallGraph::getOrInsertFunction ( const Function F)

◆ invalidate()

bool CallGraph::invalidate ( Module ,
const PreservedAnalyses PA,
ModuleAnalysisManager::Invalidator  
)

Definition at line 68 of file CallGraph.cpp.

References llvm::PreservedAnalyses::getChecker().

◆ operator[]() [1/2]

CallGraphNode* llvm::CallGraph::operator[] ( const Function F)
inline

Returns the call graph node for the provided function.

Definition at line 120 of file CallGraph.h.

References assert(), F, and I.

◆ operator[]() [2/2]

const CallGraphNode* llvm::CallGraph::operator[] ( const Function F) const
inline

Returns the call graph node for the provided function.

Definition at line 113 of file CallGraph.h.

References assert(), F, and I.

◆ populateCallGraphNode()

void CallGraph::populateCallGraphNode ( CallGraphNode CGN)

Populate CGN based on the calls inside the associated function.

Definition at line 91 of file CallGraph.cpp.

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

◆ print()

void CallGraph::print ( raw_ostream OS) const

◆ removeFunctionFromModule()

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

References assert(), llvm::CallGraphNode::empty(), F, llvm::CallGraphNode::getFunction(), and llvm::Module::getFunctionList().

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

◆ ReplaceExternalCallEdge()

void CallGraph::ReplaceExternalCallEdge ( CallGraphNode Old,
CallGraphNode New 
)

Old node has been deleted, and New is to be used in its place, update the ExternalCallingNode.

Definition at line 146 of file CallGraph.cpp.

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


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