LLVM  3.7.0
CallGraph.h
Go to the documentation of this file.
1 //===- CallGraph.h - Build a Module's call graph ----------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 /// \file
10 ///
11 /// This file provides interfaces used to build and manipulate a call graph,
12 /// which is a very useful tool for interprocedural optimization.
13 ///
14 /// Every function in a module is represented as a node in the call graph. The
15 /// callgraph node keeps track of which functions are called by the function
16 /// corresponding to the node.
17 ///
18 /// A call graph may contain nodes where the function that they correspond to
19 /// is null. These 'external' nodes are used to represent control flow that is
20 /// not represented (or analyzable) in the module. In particular, this
21 /// analysis builds one external node such that:
22 /// 1. All functions in the module without internal linkage will have edges
23 /// from this external node, indicating that they could be called by
24 /// functions outside of the module.
25 /// 2. All functions whose address is used for something more than a direct
26 /// call, for example being stored into a memory location will also have
27 /// an edge from this external node. Since they may be called by an
28 /// unknown caller later, they must be tracked as such.
29 ///
30 /// There is a second external node added for calls that leave this module.
31 /// Functions have a call edge to the external node iff:
32 /// 1. The function is external, reflecting the fact that they could call
33 /// anything without internal linkage or that has its address taken.
34 /// 2. The function contains an indirect function call.
35 ///
36 /// As an extension in the future, there may be multiple nodes with a null
37 /// function. These will be used when we can prove (through pointer analysis)
38 /// that an indirect call site can call only a specific set of functions.
39 ///
40 /// Because of these properties, the CallGraph captures a conservative superset
41 /// of all of the caller-callee relationships, which is useful for
42 /// transformations.
43 ///
44 /// The CallGraph class also attempts to figure out what the root of the
45 /// CallGraph is, which it currently does by looking for a function named
46 /// 'main'. If no function named 'main' is found, the external node is used as
47 /// the entry node, reflecting the fact that any function without internal
48 /// linkage could be called into (which is common for libraries).
49 ///
50 //===----------------------------------------------------------------------===//
51 
52 #ifndef LLVM_ANALYSIS_CALLGRAPH_H
53 #define LLVM_ANALYSIS_CALLGRAPH_H
54 
55 #include "llvm/ADT/GraphTraits.h"
56 #include "llvm/ADT/STLExtras.h"
57 #include "llvm/IR/CallSite.h"
58 #include "llvm/IR/Function.h"
59 #include "llvm/IR/Intrinsics.h"
60 #include "llvm/IR/ValueHandle.h"
61 #include "llvm/Pass.h"
62 #include <map>
63 
64 namespace llvm {
65 
66 class Function;
67 class Module;
68 class CallGraphNode;
69 
70 /// \brief The basic data container for the call graph of a \c Module of IR.
71 ///
72 /// This class exposes both the interface to the call graph for a module of IR.
73 ///
74 /// The core call graph itself can also be updated to reflect changes to the IR.
75 class CallGraph {
76  Module &M;
77 
78  typedef std::map<const Function *, CallGraphNode *> FunctionMapTy;
79 
80  /// \brief A map from \c Function* to \c CallGraphNode*.
81  FunctionMapTy FunctionMap;
82 
83  /// \brief Root is root of the call graph, or the external node if a 'main'
84  /// function couldn't be found.
85  CallGraphNode *Root;
86 
87  /// \brief This node has edges to all external functions and those internal
88  /// functions that have their address taken.
89  CallGraphNode *ExternalCallingNode;
90 
91  /// \brief This node has edges to it from all functions making indirect calls
92  /// or calling an external function.
93  CallGraphNode *CallsExternalNode;
94 
95  /// \brief Replace the function represented by this node by another.
96  ///
97  /// This does not rescan the body of the function, so it is suitable when
98  /// splicing the body of one function to another while also updating all
99  /// callers from the old function to the new.
100  void spliceFunction(const Function *From, const Function *To);
101 
102  /// \brief Add a function to the call graph, and link the node to all of the
103  /// functions that it calls.
104  void addToCallGraph(Function *F);
105 
106 public:
107  CallGraph(Module &M);
108  ~CallGraph();
109 
110  void print(raw_ostream &OS) const;
111  void dump() const;
112 
113  typedef FunctionMapTy::iterator iterator;
114  typedef FunctionMapTy::const_iterator const_iterator;
115 
116  /// \brief Returns the module the call graph corresponds to.
117  Module &getModule() const { return M; }
118 
119  inline iterator begin() { return FunctionMap.begin(); }
120  inline iterator end() { return FunctionMap.end(); }
121  inline const_iterator begin() const { return FunctionMap.begin(); }
122  inline const_iterator end() const { return FunctionMap.end(); }
123 
124  /// \brief Returns the call graph node for the provided function.
125  inline const CallGraphNode *operator[](const Function *F) const {
126  const_iterator I = FunctionMap.find(F);
127  assert(I != FunctionMap.end() && "Function not in callgraph!");
128  return I->second;
129  }
130 
131  /// \brief Returns the call graph node for the provided function.
132  inline CallGraphNode *operator[](const Function *F) {
133  const_iterator I = FunctionMap.find(F);
134  assert(I != FunctionMap.end() && "Function not in callgraph!");
135  return I->second;
136  }
137 
138  /// \brief Returns the \c CallGraphNode which is used to represent
139  /// undetermined calls into the callgraph.
140  CallGraphNode *getExternalCallingNode() const { return ExternalCallingNode; }
141 
142  CallGraphNode *getCallsExternalNode() const { return CallsExternalNode; }
143 
144  //===---------------------------------------------------------------------
145  // Functions to keep a call graph up to date with a function that has been
146  // modified.
147  //
148 
149  /// \brief Unlink the function from this module, returning it.
150  ///
151  /// Because this removes the function from the module, the call graph node is
152  /// destroyed. This is only valid if the function does not call any other
153  /// functions (ie, there are no edges in it's CGN). The easiest way to do
154  /// this is to dropAllReferences before calling this.
156 
157  /// \brief Similar to operator[], but this will insert a new CallGraphNode for
158  /// \c F if one does not already exist.
160 };
161 
162 /// \brief A node in the call graph for a module.
163 ///
164 /// Typically represents a function in the call graph. There are also special
165 /// "null" nodes used to represent theoretical entries in the call graph.
167 public:
168  /// \brief A pair of the calling instruction (a call or invoke)
169  /// and the call graph node being called.
170  typedef std::pair<WeakVH, CallGraphNode *> CallRecord;
171 
172 public:
173  typedef std::vector<CallRecord> CalledFunctionsVector;
174 
175  /// \brief Creates a node for the specified function.
176  inline CallGraphNode(Function *F) : F(F), NumReferences(0) {}
177 
179  assert(NumReferences == 0 && "Node deleted while references remain");
180  }
181 
182  typedef std::vector<CallRecord>::iterator iterator;
183  typedef std::vector<CallRecord>::const_iterator const_iterator;
184 
185  /// \brief Returns the function that this call graph node represents.
186  Function *getFunction() const { return F; }
187 
188  inline iterator begin() { return CalledFunctions.begin(); }
189  inline iterator end() { return CalledFunctions.end(); }
190  inline const_iterator begin() const { return CalledFunctions.begin(); }
191  inline const_iterator end() const { return CalledFunctions.end(); }
192  inline bool empty() const { return CalledFunctions.empty(); }
193  inline unsigned size() const { return (unsigned)CalledFunctions.size(); }
194 
195  /// \brief Returns the number of other CallGraphNodes in this CallGraph that
196  /// reference this node in their callee list.
197  unsigned getNumReferences() const { return NumReferences; }
198 
199  /// \brief Returns the i'th called function.
200  CallGraphNode *operator[](unsigned i) const {
201  assert(i < CalledFunctions.size() && "Invalid index");
202  return CalledFunctions[i].second;
203  }
204 
205  /// \brief Print out this call graph node.
206  void dump() const;
207  void print(raw_ostream &OS) const;
208 
209  //===---------------------------------------------------------------------
210  // Methods to keep a call graph up to date with a function that has been
211  // modified
212  //
213 
214  /// \brief Removes all edges from this CallGraphNode to any functions it
215  /// calls.
217  while (!CalledFunctions.empty()) {
218  CalledFunctions.back().second->DropRef();
219  CalledFunctions.pop_back();
220  }
221  }
222 
223  /// \brief Moves all the callee information from N to this node.
225  assert(CalledFunctions.empty() &&
226  "Cannot steal callsite information if I already have some");
227  std::swap(CalledFunctions, N->CalledFunctions);
228  }
229 
230  /// \brief Adds a function to the list of functions called by this one.
232  assert(!CS.getInstruction() || !CS.getCalledFunction() ||
233  !CS.getCalledFunction()->isIntrinsic() ||
235  CalledFunctions.emplace_back(CS.getInstruction(), M);
236  M->AddRef();
237  }
238 
240  I->second->DropRef();
241  *I = CalledFunctions.back();
242  CalledFunctions.pop_back();
243  }
244 
245  /// \brief Removes the edge in the node for the specified call site.
246  ///
247  /// Note that this method takes linear time, so it should be used sparingly.
249 
250  /// \brief Removes all call edges from this node to the specified callee
251  /// function.
252  ///
253  /// This takes more time to execute than removeCallEdgeTo, so it should not
254  /// be used unless necessary.
255  void removeAnyCallEdgeTo(CallGraphNode *Callee);
256 
257  /// \brief Removes one edge associated with a null callsite from this node to
258  /// the specified callee function.
260 
261  /// \brief Replaces the edge in the node for the specified call site with a
262  /// new one.
263  ///
264  /// Note that this method takes linear time, so it should be used sparingly.
265  void replaceCallEdge(CallSite CS, CallSite NewCS, CallGraphNode *NewNode);
266 
267 private:
268  friend class CallGraph;
269 
271 
272  std::vector<CallRecord> CalledFunctions;
273 
274  /// \brief The number of times that this CallGraphNode occurs in the
275  /// CalledFunctions array of this or other CallGraphNodes.
276  unsigned NumReferences;
277 
278  CallGraphNode(const CallGraphNode &) = delete;
279  void operator=(const CallGraphNode &) = delete;
280 
281  void DropRef() { --NumReferences; }
282  void AddRef() { ++NumReferences; }
283 
284  /// \brief A special function that should only be used by the CallGraph class.
285  void allReferencesDropped() { NumReferences = 0; }
286 };
287 
288 /// \brief An analysis pass to compute the \c CallGraph for a \c Module.
289 ///
290 /// This class implements the concept of an analysis pass used by the \c
291 /// ModuleAnalysisManager to run an analysis over a module and cache the
292 /// resulting data.
294 public:
295  /// \brief A formulaic typedef to inform clients of the result type.
296  typedef CallGraph Result;
297 
298  static void *ID() { return (void *)&PassID; }
299 
300  /// \brief Compute the \c CallGraph for the module \c M.
301  ///
302  /// The real work here is done in the \c CallGraph constructor.
303  CallGraph run(Module *M) { return CallGraph(*M); }
304 
305 private:
306  static char PassID;
307 };
308 
309 /// \brief The \c ModulePass which wraps up a \c CallGraph and the logic to
310 /// build it.
311 ///
312 /// This class exposes both the interface to the call graph container and the
313 /// module pass which runs over a module of IR and produces the call graph. The
314 /// call graph interface is entirelly a wrapper around a \c CallGraph object
315 /// which is stored internally for each module.
317  std::unique_ptr<CallGraph> G;
318 
319 public:
320  static char ID; // Class identification, replacement for typeinfo
321 
323  ~CallGraphWrapperPass() override;
324 
325  /// \brief The internal \c CallGraph around which the rest of this interface
326  /// is wrapped.
327  const CallGraph &getCallGraph() const { return *G; }
328  CallGraph &getCallGraph() { return *G; }
329 
332 
333  /// \brief Returns the module the call graph corresponds to.
334  Module &getModule() const { return G->getModule(); }
335 
336  inline iterator begin() { return G->begin(); }
337  inline iterator end() { return G->end(); }
338  inline const_iterator begin() const { return G->begin(); }
339  inline const_iterator end() const { return G->end(); }
340 
341  /// \brief Returns the call graph node for the provided function.
342  inline const CallGraphNode *operator[](const Function *F) const {
343  return (*G)[F];
344  }
345 
346  /// \brief Returns the call graph node for the provided function.
347  inline CallGraphNode *operator[](const Function *F) { return (*G)[F]; }
348 
349  /// \brief Returns the \c CallGraphNode which is used to represent
350  /// undetermined calls into the callgraph.
352  return G->getExternalCallingNode();
353  }
354 
356  return G->getCallsExternalNode();
357  }
358 
359  //===---------------------------------------------------------------------
360  // Functions to keep a call graph up to date with a function that has been
361  // modified.
362  //
363 
364  /// \brief Unlink the function from this module, returning it.
365  ///
366  /// Because this removes the function from the module, the call graph node is
367  /// destroyed. This is only valid if the function does not call any other
368  /// functions (ie, there are no edges in it's CGN). The easiest way to do
369  /// this is to dropAllReferences before calling this.
371  return G->removeFunctionFromModule(CGN);
372  }
373 
374  /// \brief Similar to operator[], but this will insert a new CallGraphNode for
375  /// \c F if one does not already exist.
377  return G->getOrInsertFunction(F);
378  }
379 
380  //===---------------------------------------------------------------------
381  // Implementation of the ModulePass interface needed here.
382  //
383 
384  void getAnalysisUsage(AnalysisUsage &AU) const override;
385  bool runOnModule(Module &M) override;
386  void releaseMemory() override;
387 
388  void print(raw_ostream &o, const Module *) const override;
389  void dump() const;
390 };
391 
392 //===----------------------------------------------------------------------===//
393 // GraphTraits specializations for call graphs so that they can be treated as
394 // graphs by the generic graph algorithms.
395 //
396 
397 // Provide graph traits for tranversing call graphs using standard graph
398 // traversals.
399 template <> struct GraphTraits<CallGraphNode *> {
401 
403  typedef std::pointer_to_unary_function<CGNPairTy, CallGraphNode *>
405 
406  static NodeType *getEntryNode(CallGraphNode *CGN) { return CGN; }
407 
409 
410  static inline ChildIteratorType child_begin(NodeType *N) {
411  return map_iterator(N->begin(), CGNDerefFun(CGNDeref));
412  }
413  static inline ChildIteratorType child_end(NodeType *N) {
414  return map_iterator(N->end(), CGNDerefFun(CGNDeref));
415  }
416 
417  static CallGraphNode *CGNDeref(CGNPairTy P) { return P.second; }
418 };
419 
420 template <> struct GraphTraits<const CallGraphNode *> {
421  typedef const CallGraphNode NodeType;
422 
424  typedef std::pointer_to_unary_function<CGNPairTy, const CallGraphNode *>
426 
427  static NodeType *getEntryNode(const CallGraphNode *CGN) { return CGN; }
428 
431 
432  static inline ChildIteratorType child_begin(NodeType *N) {
433  return map_iterator(N->begin(), CGNDerefFun(CGNDeref));
434  }
435  static inline ChildIteratorType child_end(NodeType *N) {
436  return map_iterator(N->end(), CGNDerefFun(CGNDeref));
437  }
438 
439  static const CallGraphNode *CGNDeref(CGNPairTy P) { return P.second; }
440 };
441 
442 template <>
445  return CGN->getExternalCallingNode(); // Start at the external node!
446  }
447  typedef std::pair<const Function *, CallGraphNode *> PairTy;
448  typedef std::pointer_to_unary_function<PairTy, CallGraphNode &> DerefFun;
449 
450  // nodes_iterator/begin/end - Allow iteration over all nodes in the graph
452  static nodes_iterator nodes_begin(CallGraph *CG) {
453  return map_iterator(CG->begin(), DerefFun(CGdereference));
454  }
455  static nodes_iterator nodes_end(CallGraph *CG) {
456  return map_iterator(CG->end(), DerefFun(CGdereference));
457  }
458 
459  static CallGraphNode &CGdereference(PairTy P) { return *P.second; }
460 };
461 
462 template <>
464  const CallGraphNode *> {
465  static NodeType *getEntryNode(const CallGraph *CGN) {
466  return CGN->getExternalCallingNode(); // Start at the external node!
467  }
468  typedef std::pair<const Function *, const CallGraphNode *> PairTy;
469  typedef std::pointer_to_unary_function<PairTy, const CallGraphNode &>
471 
472  // nodes_iterator/begin/end - Allow iteration over all nodes in the graph
474  static nodes_iterator nodes_begin(const CallGraph *CG) {
475  return map_iterator(CG->begin(), DerefFun(CGdereference));
476  }
477  static nodes_iterator nodes_end(const CallGraph *CG) {
478  return map_iterator(CG->end(), DerefFun(CGdereference));
479  }
480 
481  static const CallGraphNode &CGdereference(PairTy P) { return *P.second; }
482 };
483 
484 } // End llvm namespace
485 
486 #endif
mapped_iterator< NodeType::iterator, CGNDerefFun > ChildIteratorType
Definition: CallGraph.h:408
const_iterator begin() const
Definition: CallGraph.h:338
mapped_iterator< CallGraph::const_iterator, DerefFun > nodes_iterator
Definition: CallGraph.h:473
const CallGraphNode * operator[](const Function *F) const
Returns the call graph node for the provided function.
Definition: CallGraph.h:342
const_iterator begin() const
Definition: CallGraph.h:190
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:114
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
Definition: GraphTraits.h:27
InstrTy * getInstruction() const
Definition: CallSite.h:82
bool isIntrinsic() const
Definition: Function.h:160
static void * ID()
Definition: CallGraph.h:298
mapped_iterator< NodeType::const_iterator, CGNDerefFun > ChildIteratorType
Definition: CallGraph.h:430
FunctionMapTy::iterator iterator
Definition: CallGraph.h:113
static const CallGraphNode & CGdereference(PairTy P)
Definition: CallGraph.h:481
bool empty() const
Definition: CallGraph.h:192
F(f)
CallGraphNode::CallRecord CGNPairTy
Definition: CallGraph.h:402
bool runOnModule(Module &M) override
runOnModule - Virtual method overriden by subclasses to process the module being operated on...
Definition: CallGraph.cpp:277
A node in the call graph for a module.
Definition: CallGraph.h:166
void dump() const
Print out this call graph node.
Definition: CallGraph.cpp:194
Module & getModule() const
Returns the module the call graph corresponds to.
Definition: CallGraph.h:117
Function * getFunction() const
Returns the function that this call graph node represents.
Definition: CallGraph.h:186
unsigned getNumReferences() const
Returns the number of other CallGraphNodes in this CallGraph that reference this node in their callee...
Definition: CallGraph.h:197
void removeOneAbstractEdgeTo(CallGraphNode *Callee)
Removes one edge associated with a null callsite from this node to the specified callee function...
Definition: CallGraph.cpp:227
const_iterator begin() const
Definition: CallGraph.h:121
void addCalledFunction(CallSite CS, CallGraphNode *M)
Adds a function to the list of functions called by this one.
Definition: CallGraph.h:231
static NodeType * getEntryNode(CallGraphNode *CGN)
Definition: CallGraph.h:406
std::vector< CallRecord >::iterator iterator
Definition: CallGraph.h:182
static nodes_iterator nodes_end(const CallGraph *CG)
Definition: CallGraph.h:477
CallGraphNode * getOrInsertFunction(const Function *F)
Similar to operator[], but this will insert a new CallGraphNode for F if one does not already exist...
Definition: CallGraph.h:376
const_iterator end() const
Definition: CallGraph.h:339
std::pointer_to_unary_function< CGNPairTy, CallGraphNode * > CGNDerefFun
Definition: CallGraph.h:404
void print(raw_ostream &OS) const
Definition: CallGraph.cpp:93
iterator end()
Definition: CallGraph.h:189
CallGraph run(Module *M)
Compute the CallGraph for the module M.
Definition: CallGraph.h:303
void replaceCallEdge(CallSite CS, CallSite NewCS, CallGraphNode *NewNode)
Replaces the edge in the node for the specified call site with a new one.
Definition: CallGraph.cpp:243
Function * removeFunctionFromModule(CallGraphNode *CGN)
Unlink the function from this module, returning it.
Definition: CallGraph.cpp:133
std::pointer_to_unary_function< CGNPairTy, const CallGraphNode * > CGNDerefFun
Definition: CallGraph.h:425
CallGraphNode * operator[](const Function *F)
Returns the call graph node for the provided function.
Definition: CallGraph.h:132
static nodes_iterator nodes_begin(const CallGraph *CG)
Definition: CallGraph.h:474
mapped_iterator< ItTy, FuncTy > map_iterator(const ItTy &I, FuncTy F)
Definition: STLExtras.h:195
FunctionMapTy::const_iterator const_iterator
Definition: CallGraph.h:114
mapped_iterator< CallGraph::iterator, DerefFun > nodes_iterator
Definition: CallGraph.h:451
CallGraph::iterator iterator
Definition: CallGraph.h:330
const_iterator end() const
Definition: CallGraph.h:191
static NodeType * getEntryNode(const CallGraphNode *CGN)
Definition: CallGraph.h:427
#define P(N)
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
void removeAnyCallEdgeTo(CallGraphNode *Callee)
Removes all call edges from this node to the specified callee function.
Definition: CallGraph.cpp:215
The ModulePass which wraps up a CallGraph and the logic to build it.
Definition: CallGraph.h:316
bool isLeaf(ID id)
Returns true if the intrinsic is a leaf, i.e.
Definition: Function.cpp:849
CallGraphNode * operator[](const Function *F)
Returns the call graph node for the provided function.
Definition: CallGraph.h:347
static nodes_iterator nodes_end(CallGraph *CG)
Definition: CallGraph.h:455
static nodes_iterator nodes_begin(CallGraph *CG)
Definition: CallGraph.h:452
FunTy * getCalledFunction() const
getCalledFunction - Return the function being called if this is a direct call, otherwise return null ...
Definition: CallSite.h:99
CallGraphNode * getCallsExternalNode() const
Definition: CallGraph.h:355
void stealCalledFunctionsFrom(CallGraphNode *N)
Moves all the callee information from N to this node.
Definition: CallGraph.h:224
static NodeType * getEntryNode(const CallGraph *CGN)
Definition: CallGraph.h:465
Represent the analysis usage information of a pass.
CallGraph(Module &M)
Definition: CallGraph.cpp:23
~CallGraphWrapperPass() override
Definition: CallGraph.cpp:271
std::pointer_to_unary_function< PairTy, CallGraphNode & > DerefFun
Definition: CallGraph.h:448
Module & getModule() const
Returns the module the call graph corresponds to.
Definition: CallGraph.h:334
std::pair< const Function *, CallGraphNode * > PairTy
Definition: CallGraph.h:447
static ChildIteratorType child_end(NodeType *N)
Definition: CallGraph.h:435
CallGraph::const_iterator const_iterator
Definition: CallGraph.h:331
static CallGraphNode & CGdereference(PairTy P)
Definition: CallGraph.h:459
CallGraphNode(Function *F)
Creates a node for the specified function.
Definition: CallGraph.h:176
unsigned size() const
Definition: CallGraph.h:193
CallGraphNode::CallRecord CGNPairTy
Definition: CallGraph.h:423
Function * removeFunctionFromModule(CallGraphNode *CGN)
Unlink the function from this module, returning it.
Definition: CallGraph.h:370
CallGraphNode * getExternalCallingNode() const
Returns the CallGraphNode which is used to represent undetermined calls into the callgraph.
Definition: CallGraph.h:351
Value handle that asserts if the Value is deleted.
Definition: ValueHandle.h:187
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
Definition: Function.h:159
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition: BitVector.h:576
static ChildIteratorType child_end(NodeType *N)
Definition: CallGraph.h:413
std::pair< const Function *, const CallGraphNode * > PairTy
Definition: CallGraph.h:468
void print(raw_ostream &OS) const
Definition: CallGraph.cpp:175
void removeCallEdge(iterator I)
Definition: CallGraph.h:239
An analysis pass to compute the CallGraph for a Module.
Definition: CallGraph.h:293
The basic data container for the call graph of a Module of IR.
Definition: CallGraph.h:75
void removeAllCalledFunctions()
Removes all edges from this CallGraphNode to any functions it calls.
Definition: CallGraph.h:216
CallGraphNode * operator[](unsigned i) const
Returns the i'th called function.
Definition: CallGraph.h:200
const_iterator end() const
Definition: CallGraph.h:122
static CallGraphNode * CGNDeref(CGNPairTy P)
Definition: CallGraph.h:417
static ChildIteratorType child_begin(NodeType *N)
Definition: CallGraph.h:432
CallGraph & getCallGraph()
Definition: CallGraph.h:328
static ChildIteratorType child_begin(NodeType *N)
Definition: CallGraph.h:410
static NodeType * getEntryNode(CallGraph *CGN)
Definition: CallGraph.h:444
#define I(x, y, z)
Definition: MD5.cpp:54
#define N
CallGraph Result
A formulaic typedef to inform clients of the result type.
Definition: CallGraph.h:296
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Definition: Pass.h:236
iterator end()
Definition: CallGraph.h:120
std::pair< WeakVH, CallGraphNode * > CallRecord
A pair of the calling instruction (a call or invoke) and the call graph node being called...
Definition: CallGraph.h:170
std::vector< CallRecord >::const_iterator const_iterator
Definition: CallGraph.h:183
aarch64 promote const
const CallGraph & getCallGraph() const
The internal CallGraph around which the rest of this interface is wrapped.
Definition: CallGraph.h:327
CallGraphNode * getOrInsertFunction(const Function *F)
Similar to operator[], but this will insert a new CallGraphNode for F if one does not already exist...
Definition: CallGraph.cpp:162
void removeCallEdgeFor(CallSite CS)
Removes the edge in the node for the specified call site.
Definition: CallGraph.cpp:200
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:38
iterator begin()
Definition: CallGraph.h:188
std::vector< CallRecord > CalledFunctionsVector
Definition: CallGraph.h:173
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Definition: CallGraph.cpp:273
std::pointer_to_unary_function< PairTy, const CallGraphNode & > DerefFun
Definition: CallGraph.h:470
void dump() const
Definition: CallGraph.cpp:124
CallGraphNode * getExternalCallingNode() const
Returns the CallGraphNode which is used to represent undetermined calls into the callgraph.
Definition: CallGraph.h:140
void print(raw_ostream &o, const Module *) const override
print - Print out the internal state of the pass.
Definition: CallGraph.cpp:290
static const CallGraphNode * CGNDeref(CGNPairTy P)
Definition: CallGraph.h:439
iterator begin()
Definition: CallGraph.h:119
const CallGraphNode * operator[](const Function *F) const
Returns the call graph node for the provided function.
Definition: CallGraph.h:125
CallGraphNode * getCallsExternalNode() const
Definition: CallGraph.h:142