51 #ifndef LLVM_ANALYSIS_CALLGRAPH_H
52 #define LLVM_ANALYSIS_CALLGRAPH_H
75 typedef std::map<const Function *, CallGraphNode *> FunctionMapTy;
76 FunctionMapTy FunctionMap;
123 assert(I != FunctionMap.end() &&
"Function not in callgraph!");
128 assert(I != FunctionMap.end() &&
"Function not in callgraph!");
183 std::vector<CallRecord> CalledFunctions;
187 unsigned NumReferences;
192 void DropRef() { --NumReferences; }
193 void AddRef() { ++NumReferences; }
201 assert(NumReferences == 0 &&
"Node deleted while references remain");
208 typedef std::vector<CallRecord>::iterator
iterator;
218 inline bool empty()
const {
return CalledFunctions.empty(); }
219 inline unsigned size()
const {
return (
unsigned)CalledFunctions.size(); }
228 assert(i < CalledFunctions.size() &&
"Invalid index");
229 return CalledFunctions[i].second;
245 while (!CalledFunctions.empty()) {
246 CalledFunctions.back().second->DropRef();
247 CalledFunctions.pop_back();
254 assert(CalledFunctions.empty() &&
255 "Cannot steal callsite information if I already have some");
256 std::swap(CalledFunctions, N->CalledFunctions);
266 CalledFunctions.push_back(std::make_pair(CS.
getInstruction(), M));
271 I->second->DropRef();
272 *I = CalledFunctions.back();
273 CalledFunctions.pop_back();
314 typedef std::pointer_to_unary_function<CGNPairTy, CallGraphNode*>
CGNDerefFun;
339 static inline ChildIteratorType
child_end (NodeType *
N) {
return N->
end(); }
346 typedef std::pair<const Function*, CallGraphNode*>
PairTy;
347 typedef std::pointer_to_unary_function<PairTy, CallGraphNode&>
DerefFun;
mapped_iterator< NodeType::iterator, CGNDerefFun > ChildIteratorType
CallGraphNode(Function *f)
virtual void releaseMemory()
const_iterator begin() const
The main container class for the LLVM Intermediate Representation.
FunctionMapTy::iterator iterator
CallGraphNode::CallRecord CGNPairTy
Module & getModule() const
Function * getFunction() const
unsigned getNumReferences() const
void removeOneAbstractEdgeTo(CallGraphNode *Callee)
const_iterator begin() const
void addCalledFunction(CallSite CS, CallGraphNode *M)
static NodeType * getEntryNode(CallGraphNode *CGN)
std::vector< CallRecord >::iterator iterator
static nodes_iterator nodes_end(const CallGraph *CG)
void replaceCallEdge(CallSite CS, CallSite NewCS, CallGraphNode *NewNode)
std::pair< const Function *, CallGraphNode * > PairTy
Function * removeFunctionFromModule(CallGraphNode *CGN)
CallGraphNode * getRoot()
CallGraphNode * operator[](const Function *F)
static nodes_iterator nodes_begin(const CallGraph *CG)
mapped_iterator< ItTy, FuncTy > map_iterator(const ItTy &I, FuncTy F)
FunctionMapTy::const_iterator const_iterator
mapped_iterator< CallGraph::iterator, DerefFun > nodes_iterator
const_iterator end() const
static NodeType * getEntryNode(const CallGraphNode *CGN)
#define FORCE_DEFINING_FILE_TO_BE_LINKED(name)
void removeAnyCallEdgeTo(CallGraphNode *Callee)
static nodes_iterator nodes_end(CallGraph *CG)
InstrTy * getInstruction() const
static nodes_iterator nodes_begin(CallGraph *CG)
void stealCalledFunctionsFrom(CallGraphNode *N)
std::pointer_to_unary_function< PairTy, CallGraphNode & > DerefFun
static NodeType * getEntryNode(const CallGraph *CGN)
virtual void getAnalysisUsage(AnalysisUsage &AU) const
void allReferencesDropped()
static ChildIteratorType child_end(NodeType *N)
static CallGraphNode & CGdereference(PairTy P)
NodeType::const_iterator ChildIteratorType
#define LLVM_DELETED_FUNCTION
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
static ChildIteratorType child_end(NodeType *N)
const CallGraphNode * getRoot() const
void print(raw_ostream &OS) const
void removeCallEdge(iterator I)
void removeAllCalledFunctions()
CallGraphNode * operator[](unsigned i) const
const_iterator end() const
static CallGraphNode * CGNDeref(CGNPairTy P)
static ChildIteratorType child_begin(NodeType *N)
static ChildIteratorType child_begin(NodeType *N)
static NodeType * getEntryNode(CallGraph *CGN)
const CallGraphNode NodeType
std::pointer_to_unary_function< CGNPairTy, CallGraphNode * > CGNDerefFun
virtual bool runOnModule(Module &M)
std::vector< CallRecord >::const_iterator const_iterator
CallGraphNode * getOrInsertFunction(const Function *F)
void removeCallEdgeFor(CallSite CS)
std::pair< WeakVH, CallGraphNode * > CallRecord
std::vector< CallRecord > CalledFunctionsVector
CallGraph::const_iterator nodes_iterator
CallGraphNode * getExternalCallingNode() const
void print(raw_ostream &o, const Module *) const
FunTy * getCalledFunction() const
const CallGraphNode * operator[](const Function *F) const
CallGraphNode * getCallsExternalNode() const