Go to the documentation of this file.
45 #ifndef LLVM_ANALYSIS_CALLGRAPH_H
46 #define LLVM_ANALYSIS_CALLGRAPH_H
61 template <
class GraphType>
struct GraphTraits;
76 std::map<const Function *, std::unique_ptr<CallGraphNode>>;
79 FunctionMapTy FunctionMap;
87 std::unique_ptr<CallGraphNode> CallsExternalNode;
114 assert(
I != FunctionMap.end() &&
"Function not in callgraph!");
115 return I->second.get();
121 assert(
I != FunctionMap.end() &&
"Function not in callgraph!");
122 return I->second.get();
130 return CallsExternalNode.get();
190 assert(NumReferences == 0 &&
"Node deleted while references remain");
193 using iterator = std::vector<CallRecord>::iterator;
203 inline bool empty()
const {
return CalledFunctions.empty(); }
204 inline unsigned size()
const {
return (
unsigned)CalledFunctions.size(); }
212 assert(
i < CalledFunctions.size() &&
"Invalid index");
213 return CalledFunctions[
i].second;
228 while (!CalledFunctions.empty()) {
229 CalledFunctions.back().second->DropRef();
230 CalledFunctions.pop_back();
236 assert(CalledFunctions.empty() &&
237 "Cannot steal callsite information if I already have some");
238 std::swap(CalledFunctions,
N->CalledFunctions);
243 CalledFunctions.emplace_back(Call ? std::optional<WeakTrackingVH>(Call)
244 : std::optional<WeakTrackingVH>(),
250 I->second->DropRef();
251 *
I = CalledFunctions.back();
252 CalledFunctions.pop_back();
284 std::vector<CallRecord> CalledFunctions;
288 unsigned NumReferences = 0;
290 void DropRef() { --NumReferences; }
291 void AddRef() { ++NumReferences; }
294 void allReferencesDropped() { NumReferences = 0; }
346 std::unique_ptr<CallGraph> G;
381 return G->getExternalCallingNode();
385 return G->getCallsExternalNode();
400 return G->removeFunctionFromModule(CGN);
406 return G->getOrInsertFunction(
F);
435 using ChildIteratorType =
455 using ChildIteratorType =
478 std::pair<const Function *const, std::unique_ptr<CallGraphNode>>;
485 return P.second.get();
489 using nodes_iterator =
505 std::pair<const Function *const, std::unique_ptr<CallGraphNode>>;
512 return P.second.get();
516 using nodes_iterator =
530 #endif // LLVM_ANALYSIS_CALLGRAPH_H
void removeAnyCallEdgeTo(CallGraphNode *Callee)
Removes all call edges from this node to the specified callee function.
A set of analyses that are preserved following a run of a transformation pass.
const_iterator end() const
CallGraphNode & operator=(const CallGraphNode &)=delete
std::vector< CallRecord > CalledFunctionsVector
This is an optimization pass for GlobalISel generic memory operations.
const_iterator end() const
~CallGraphWrapperPass() override
static ChildIteratorType child_begin(NodeRef N)
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
std::vector< CallRecord >::iterator iterator
CallGraphNode * getExternalCallingNode() const
Returns the CallGraphNode which is used to represent undetermined calls into the callgraph.
An analysis pass to compute the CallGraph for a Module.
const_iterator end() const
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
A CRTP mix-in to automatically provide informational APIs needed for passes.
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
CallGraphNode(CallGraph *CG, Function *F)
Creates a node for the specified function.
const CallGraph & getCallGraph() const
The internal CallGraph around which the rest of this interface is wrapped.
static NodeRef getEntryNode(const CallGraphNode *CGN)
static const CallGraphNode * CGNGetValue(CGNPairTy P)
void removeCallEdgeFor(CallBase &Call)
Removes the edge in the node for the specified call site.
static ChildIteratorType child_end(NodeRef N)
const_iterator begin() const
The basic data container for the call graph of a Module of IR.
CallGraphSCCsPrinterPass(raw_ostream &OS)
Function * removeFunctionFromModule(CallGraphNode *CGN)
Unlink the function from this module, returning it.
void removeCallEdge(iterator I)
static NodeRef getEntryNode(CallGraphNode *CGN)
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
static nodes_iterator nodes_begin(const CallGraph *CG)
void addCalledFunction(CallBase *Call, CallGraphNode *M)
Adds a function to the list of functions called by this one.
bool invalidate(Module &, const PreservedAnalyses &PA, ModuleAnalysisManager::Invalidator &)
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
CallGraphNode * getOrInsertFunction(const Function *F)
Similar to operator[], but this will insert a new CallGraphNode for F if one does not already exist.
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
FunctionMapTy::iterator iterator
unsigned getNumReferences() const
Returns the number of other CallGraphNodes in this CallGraph that reference this node in their callee...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
CallGraphNode::CallRecord CGNPairTy
CallGraphNode::CallRecord CGNPairTy
void dump() const
Print out this call graph node.
Represent the analysis usage information of a pass.
CallGraph::iterator iterator
CallGraphNode * getExternalCallingNode() const
Returns the CallGraphNode which is used to represent undetermined calls into the callgraph.
Printer pass for the summarized CallGraphAnalysis results.
static nodes_iterator nodes_end(CallGraph *CG)
CallGraph & getCallGraph()
static const CallGraphNode * CGGetValuePtr(const PairTy &P)
FunctionMapTy::const_iterator const_iterator
This class implements an extremely fast bulk output stream that can only output to a stream.
CallGraphPrinterPass(raw_ostream &OS)
A node in the call graph for a module.
std::pair< const Function *const, std::unique_ptr< CallGraphNode > > PairTy
API to communicate dependencies between analyses during invalidation.
static NodeRef getEntryNode(CallGraph *CGN)
const_iterator begin() const
Printer pass for the CallGraphAnalysis results.
void ReplaceExternalCallEdge(CallGraphNode *Old, CallGraphNode *New)
Old node has been deleted, and New is to be used in its place, update the ExternalCallingNode.
void print(raw_ostream &o, const Module *) const override
print - Print out the internal state of the pass.
static ChildIteratorType child_end(NodeRef N)
void print(raw_ostream &OS) const
void populateCallGraphNode(CallGraphNode *CGN)
Populate CGN based on the calls inside the associated function.
void removeAllCalledFunctions()
Removes all edges from this CallGraphNode to any functions it calls.
static CallGraphNode * CGNGetValue(CGNPairTy P)
A special type used by analysis passes to provide an address that identifies that particular analysis...
The ModulePass which wraps up a CallGraph and the logic to build it.
static ChildIteratorType child_begin(NodeRef N)
static NodeRef getEntryNode(const CallGraph *CGN)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Function * removeFunctionFromModule(CallGraphNode *CGN)
Unlink the function from this module, returning it.
bool runOnModule(Module &M) override
runOnModule - Virtual method overriden by subclasses to process the module being operated on.
A Module instance is used to store all the information related to an LLVM module.
A CRTP mix-in that provides informational APIs needed for analysis passes.
CallGraph::const_iterator const_iterator
std::vector< CallRecord >::const_iterator const_iterator
static ChildEdgeIteratorType child_edge_begin(NodeRef N)
const CallGraphNode * operator[](const Function *F) const
Returns the call graph node for the provided function.
void addToCallGraph(Function *F)
Add a function to the call graph, and link the node to all of the functions that it calls.
Machine Check Debug Module
Function * getFunction() const
Returns the function that this call graph node represents.
void removeOneAbstractEdgeTo(CallGraphNode *Callee)
Removes one edge associated with a null callsite from this node to the specified callee function.
CallGraphNode * operator[](const Function *F)
Returns the call graph node for the provided function.
static ChildEdgeIteratorType child_edge_end(NodeRef N)
static NodeRef edge_dest(EdgeRef E)
const CallGraphNode * operator[](const Function *F) const
Returns the call graph node for the provided function.
static nodes_iterator nodes_end(const CallGraph *CG)
CallGraphNode * operator[](const Function *F)
Returns the call graph node for the provided function.
Module & getModule() const
Returns the module the call graph corresponds to.
static CallGraphNode * CGGetValuePtr(const PairTy &P)
CallGraphNode::const_iterator ChildEdgeIteratorType
std::pair< std::optional< WeakTrackingVH >, CallGraphNode * > CallRecord
A pair of the calling instruction (a call or invoke) and the call graph node being called.
void print(raw_ostream &OS) const
const CallGraphNode::CallRecord & EdgeRef
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
A container for analyses that lazily runs them and caches their results.
Module & getModule() const
Returns the module the call graph corresponds to.
CallGraphNode * getCallsExternalNode() const
CallGraph run(Module &M, ModuleAnalysisManager &)
Compute the CallGraph for the module M.
CallGraphNode * getCallsExternalNode() const
std::pair< const Function *const, std::unique_ptr< CallGraphNode > > PairTy
CallGraphNode * operator[](unsigned i) const
Returns the i'th called function.
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
void stealCalledFunctionsFrom(CallGraphNode *N)
Moves all the callee information from N to this node.
const_iterator begin() const
void replaceCallEdge(CallBase &Call, CallBase &NewCall, CallGraphNode *NewNode)
Replaces the edge in the node for the specified call site with a new one.
CallGraphNode * getOrInsertFunction(const Function *F)
Similar to operator[], but this will insert a new CallGraphNode for F if one does not already exist.
static nodes_iterator nodes_begin(CallGraph *CG)