add new spliceFrom methods.
[oota-llvm.git] / include / llvm / Analysis / DataStructure / DSGraph.h
1 //===- DSGraph.h - Represent a collection of data structures ----*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // This header defines the data structure graph (DSGraph) and the
11 // ReachabilityCloner class.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_ANALYSIS_DSGRAPH_H
16 #define LLVM_ANALYSIS_DSGRAPH_H
17
18 #include "llvm/Analysis/DataStructure/DSNode.h"
19 #include "llvm/ADT/hash_map"
20 #include "llvm/ADT/EquivalenceClasses.h"
21 #include <list>
22
23 namespace llvm {
24
25 class GlobalValue;
26
27 //===----------------------------------------------------------------------===//
28 /// DSScalarMap - An instance of this class is used to keep track of all of 
29 /// which DSNode each scalar in a function points to.  This is specialized to
30 /// keep track of globals with nodes in the function, and to keep track of the 
31 /// unique DSNodeHandle being used by the scalar map.
32 ///
33 /// This class is crucial to the efficiency of DSA with some large SCC's.  In 
34 /// these cases, the cost of iterating over the scalar map dominates the cost
35 /// of DSA.  In all of these cases, the DSA phase is really trying to identify 
36 /// globals or unique node handles active in the function.
37 ///
38 class DSScalarMap {
39   typedef hash_map<Value*, DSNodeHandle> ValueMapTy;
40   ValueMapTy ValueMap;
41
42   typedef hash_set<GlobalValue*> GlobalSetTy;
43   GlobalSetTy GlobalSet;
44
45   EquivalenceClasses<GlobalValue*> &GlobalECs;
46 public:
47   DSScalarMap(EquivalenceClasses<GlobalValue*> &ECs) : GlobalECs(ECs) {}
48
49   EquivalenceClasses<GlobalValue*> &getGlobalECs() const { return GlobalECs; }
50
51   // Compatibility methods: provide an interface compatible with a map of 
52   // Value* to DSNodeHandle's.
53   typedef ValueMapTy::const_iterator const_iterator;
54   typedef ValueMapTy::iterator iterator;
55   iterator begin() { return ValueMap.begin(); }
56   iterator end()   { return ValueMap.end(); }
57   const_iterator begin() const { return ValueMap.begin(); }
58   const_iterator end() const { return ValueMap.end(); }
59
60   GlobalValue *getLeaderForGlobal(GlobalValue *GV) const {
61     EquivalenceClasses<GlobalValue*>::iterator ECI = GlobalECs.findValue(GV);
62     if (ECI == GlobalECs.end()) return GV;
63     return *GlobalECs.findLeader(ECI);
64   }
65
66
67   iterator find(Value *V) {
68     iterator I = ValueMap.find(V);
69     if (I != ValueMap.end()) return I;
70
71     if (GlobalValue *GV = dyn_cast<GlobalValue>(V)) {
72       // If this is a global, check to see if it is equivalenced to something
73       // in the map.
74       GlobalValue *Leader = getLeaderForGlobal(GV);
75       if (Leader != GV)
76         I = ValueMap.find((Value*)Leader);
77     }
78     return I;
79   }
80   const_iterator find(Value *V) const {
81     const_iterator I = ValueMap.find(V);
82     if (I != ValueMap.end()) return I;
83
84     if (GlobalValue *GV = dyn_cast<GlobalValue>(V)) {
85       // If this is a global, check to see if it is equivalenced to something
86       // in the map.
87       GlobalValue *Leader = getLeaderForGlobal(GV);
88       if (Leader != GV)
89         I = ValueMap.find((Value*)Leader);
90     }
91     return I;
92   }
93
94   /// getRawEntryRef - This method can be used by clients that are aware of the
95   /// global value equivalence class in effect.
96   DSNodeHandle &getRawEntryRef(Value *V) {
97     std::pair<iterator,bool> IP =
98       ValueMap.insert(std::make_pair(V, DSNodeHandle()));
99      if (IP.second)   // Inserted the new entry into the map.
100        if (GlobalValue *GV = dyn_cast<GlobalValue>(V))
101          GlobalSet.insert(GV);
102      return IP.first->second;
103   }
104
105   unsigned count(Value *V) const { return ValueMap.find(V) != ValueMap.end(); }
106
107   void erase(Value *V) { erase(ValueMap.find(V)); }
108
109   void eraseIfExists(Value *V) {
110     iterator I = find(V);
111     if (I != end()) erase(I);
112   }
113
114   /// replaceScalar - When an instruction needs to be modified, this method can
115   /// be used to update the scalar map to remove the old and insert the new.
116   ///
117   void replaceScalar(Value *Old, Value *New) {
118     iterator I = find(Old);
119     assert(I != end() && "Old value is not in the map!");
120     ValueMap.insert(std::make_pair(New, I->second));
121     erase(I);
122   }
123
124   /// copyScalarIfExists - If Old exists in the scalar map, make New point to
125   /// whatever Old did.
126   void copyScalarIfExists(Value *Old, Value *New) {
127     iterator I = find(Old);
128     if (I != end())
129       ValueMap.insert(std::make_pair(New, I->second));
130   }
131
132   /// operator[] - Return the DSNodeHandle for the specified value, creating a
133   /// new null handle if there is no entry yet.
134   DSNodeHandle &operator[](Value *V) {
135     iterator I = ValueMap.find(V);
136     if (I != ValueMap.end())
137       return I->second;   // Return value if already exists.
138
139     if (GlobalValue *GV = dyn_cast<GlobalValue>(V))
140       return AddGlobal(GV);
141
142     return ValueMap.insert(std::make_pair(V, DSNodeHandle())).first->second;
143   }
144
145   void erase(iterator I) { 
146     assert(I != ValueMap.end() && "Cannot erase end!");
147     if (GlobalValue *GV = dyn_cast<GlobalValue>(I->first))
148       GlobalSet.erase(GV);
149     ValueMap.erase(I); 
150   }
151
152   void clear() {
153     ValueMap.clear();
154     GlobalSet.clear();
155   }
156
157   /// spliceFrom - Copy all entries from RHS, then clear RHS.
158   ///
159   void spliceFrom(DSScalarMap &RHS);
160
161   // Access to the global set: the set of all globals currently in the
162   // scalar map.
163   typedef GlobalSetTy::const_iterator global_iterator;
164   global_iterator global_begin() const { return GlobalSet.begin(); }
165   global_iterator global_end() const { return GlobalSet.end(); }
166   unsigned global_size() const { return GlobalSet.size(); }
167   unsigned global_count(GlobalValue *GV) const { return GlobalSet.count(GV); }
168 private:
169   DSNodeHandle &AddGlobal(GlobalValue *GV);
170 };
171
172
173 //===----------------------------------------------------------------------===//
174 /// DSGraph - The graph that represents a function.
175 ///
176 class DSGraph {
177 public:
178   // Public data-type declarations...
179   typedef DSScalarMap ScalarMapTy;
180   typedef hash_map<Function*, DSNodeHandle> ReturnNodesTy;
181   typedef ilist<DSNode> NodeListTy;
182
183   /// NodeMapTy - This data type is used when cloning one graph into another to
184   /// keep track of the correspondence between the nodes in the old and new
185   /// graphs.
186   typedef hash_map<const DSNode*, DSNodeHandle> NodeMapTy;
187
188   // InvNodeMapTy - This data type is used to represent the inverse of a node
189   // map.
190   typedef hash_multimap<DSNodeHandle, const DSNode*> InvNodeMapTy;
191 private:
192   DSGraph *GlobalsGraph;   // Pointer to the common graph of global objects
193   bool PrintAuxCalls;      // Should this graph print the Aux calls vector?
194
195   NodeListTy Nodes;
196   ScalarMapTy ScalarMap;
197
198   // ReturnNodes - A return value for every function merged into this graph.
199   // Each DSGraph may have multiple functions merged into it at any time, which
200   // is used for representing SCCs.
201   //
202   ReturnNodesTy ReturnNodes;
203
204   // FunctionCalls - This list maintains a single entry for each call
205   // instruction in the current graph.  The first entry in the vector is the
206   // scalar that holds the return value for the call, the second is the function
207   // scalar being invoked, and the rest are pointer arguments to the function.
208   // This vector is built by the Local graph and is never modified after that.
209   //
210   std::list<DSCallSite> FunctionCalls;
211
212   // AuxFunctionCalls - This vector contains call sites that have been processed
213   // by some mechanism.  In pratice, the BU Analysis uses this vector to hold
214   // the _unresolved_ call sites, because it cannot modify FunctionCalls.
215   //
216   std::list<DSCallSite> AuxFunctionCalls;
217
218   /// TD - This is the target data object for the machine this graph is
219   /// constructed for.
220   const TargetData &TD;
221
222   void operator=(const DSGraph &); // DO NOT IMPLEMENT
223   DSGraph(const DSGraph&);         // DO NOT IMPLEMENT
224 public:
225   // Create a new, empty, DSGraph.
226   DSGraph(EquivalenceClasses<GlobalValue*> &ECs, const TargetData &td)
227     : GlobalsGraph(0), PrintAuxCalls(false), ScalarMap(ECs), TD(td) {}
228
229   // Compute the local DSGraph
230   DSGraph(EquivalenceClasses<GlobalValue*> &ECs, const TargetData &TD,
231           Function &F, DSGraph *GlobalsGraph);
232
233   // Copy ctor - If you want to capture the node mapping between the source and
234   // destination graph, you may optionally do this by specifying a map to record
235   // this into.
236   //
237   // Note that a copied graph does not retain the GlobalsGraph pointer of the
238   // source.  You need to set a new GlobalsGraph with the setGlobalsGraph
239   // method.
240   //
241   DSGraph(const DSGraph &DSG, EquivalenceClasses<GlobalValue*> &ECs,
242           unsigned CloneFlags = 0);
243   ~DSGraph();
244
245   DSGraph *getGlobalsGraph() const { return GlobalsGraph; }
246   void setGlobalsGraph(DSGraph *G) { GlobalsGraph = G; }
247
248   /// getGlobalECs - Return the set of equivalence classes that the global
249   /// variables in the program form.
250   EquivalenceClasses<GlobalValue*> &getGlobalECs() const {
251     return ScalarMap.getGlobalECs();
252   }
253
254   /// getTargetData - Return the TargetData object for the current target.
255   ///
256   const TargetData &getTargetData() const { return TD; }
257
258   /// setPrintAuxCalls - If you call this method, the auxillary call vector will
259   /// be printed instead of the standard call vector to the dot file.
260   ///
261   void setPrintAuxCalls() { PrintAuxCalls = true; }
262   bool shouldPrintAuxCalls() const { return PrintAuxCalls; }
263
264   /// node_iterator/begin/end - Iterate over all of the nodes in the graph.  Be
265   /// extremely careful with these methods because any merging of nodes could
266   /// cause the node to be removed from this list.  This means that if you are
267   /// iterating over nodes and doing something that could cause _any_ node to
268   /// merge, your node_iterators into this graph can be invalidated.
269   typedef NodeListTy::iterator node_iterator;
270   node_iterator node_begin() { return Nodes.begin(); }
271   node_iterator node_end()   { return Nodes.end(); }
272
273   typedef NodeListTy::const_iterator node_const_iterator;
274   node_const_iterator node_begin() const { return Nodes.begin(); }
275   node_const_iterator node_end()   const { return Nodes.end(); }
276
277   /// getFunctionNames - Return a space separated list of the name of the
278   /// functions in this graph (if any)
279   ///
280   std::string getFunctionNames() const;
281
282   /// addNode - Add a new node to the graph.
283   ///
284   void addNode(DSNode *N) { Nodes.push_back(N); }
285   void unlinkNode(DSNode *N) { Nodes.remove(N); }
286
287   /// getScalarMap - Get a map that describes what the nodes the scalars in this
288   /// function point to...
289   ///
290   ScalarMapTy &getScalarMap() { return ScalarMap; }
291   const ScalarMapTy &getScalarMap() const { return ScalarMap; }
292
293   /// getFunctionCalls - Return the list of call sites in the original local
294   /// graph...
295   ///
296   const std::list<DSCallSite> &getFunctionCalls() const { return FunctionCalls;}
297   std::list<DSCallSite> &getFunctionCalls() { return FunctionCalls;}
298
299   /// getAuxFunctionCalls - Get the call sites as modified by whatever passes
300   /// have been run.
301   ///
302   std::list<DSCallSite> &getAuxFunctionCalls() { return AuxFunctionCalls; }
303   const std::list<DSCallSite> &getAuxFunctionCalls() const {
304     return AuxFunctionCalls;
305   }
306
307   // Function Call iteration
308   typedef std::list<DSCallSite>::const_iterator fc_iterator;
309   fc_iterator fc_begin() const { return FunctionCalls.begin(); }
310   fc_iterator fc_end() const { return FunctionCalls.end(); }
311
312
313   // Aux Function Call iteration
314   typedef std::list<DSCallSite>::const_iterator afc_iterator;
315   afc_iterator afc_begin() const { return AuxFunctionCalls.begin(); }
316   afc_iterator afc_end() const { return AuxFunctionCalls.end(); }
317
318   /// getNodeForValue - Given a value that is used or defined in the body of the
319   /// current function, return the DSNode that it points to.
320   ///
321   DSNodeHandle &getNodeForValue(Value *V) { return ScalarMap[V]; }
322
323   const DSNodeHandle &getNodeForValue(Value *V) const {
324     ScalarMapTy::const_iterator I = ScalarMap.find(V);
325     assert(I != ScalarMap.end() &&
326            "Use non-const lookup function if node may not be in the map");
327     return I->second;
328   }
329
330   /// retnodes_* iterator methods: expose iteration over return nodes in the
331   /// graph, which are also the set of functions incorporated in this graph.
332   typedef ReturnNodesTy::const_iterator retnodes_iterator;
333   retnodes_iterator retnodes_begin() const { return ReturnNodes.begin(); }
334   retnodes_iterator retnodes_end() const { return ReturnNodes.end(); }
335
336
337   /// getReturnNodes - Return the mapping of functions to their return nodes for
338   /// this graph.
339   ///
340   const ReturnNodesTy &getReturnNodes() const { return ReturnNodes; }
341         ReturnNodesTy &getReturnNodes()       { return ReturnNodes; }
342
343   /// getReturnNodeFor - Return the return node for the specified function.
344   ///
345   DSNodeHandle &getReturnNodeFor(Function &F) {
346     ReturnNodesTy::iterator I = ReturnNodes.find(&F);
347     assert(I != ReturnNodes.end() && "F not in this DSGraph!");
348     return I->second;
349   }
350
351   const DSNodeHandle &getReturnNodeFor(Function &F) const {
352     ReturnNodesTy::const_iterator I = ReturnNodes.find(&F);
353     assert(I != ReturnNodes.end() && "F not in this DSGraph!");
354     return I->second;
355   }
356
357   /// containsFunction - Return true if this DSGraph contains information for
358   /// the specified function.
359   bool containsFunction(Function *F) const {
360     return ReturnNodes.count(F);
361   }
362
363   /// getGraphSize - Return the number of nodes in this graph.
364   ///
365   unsigned getGraphSize() const {
366     return Nodes.size();
367   }
368
369   /// addObjectToGraph - This method can be used to add global, stack, and heap
370   /// objects to the graph.  This can be used when updating DSGraphs due to the
371   /// introduction of new temporary objects.  The new object is not pointed to
372   /// and does not point to any other objects in the graph.  Note that this
373   /// method initializes the type of the DSNode to the declared type of the
374   /// object if UseDeclaredType is true, otherwise it leaves the node type as
375   /// void.
376   DSNode *addObjectToGraph(Value *Ptr, bool UseDeclaredType = true);
377
378
379   /// print - Print a dot graph to the specified ostream...
380   ///
381   void print(std::ostream &O) const;
382
383   /// dump - call print(std::cerr), for use from the debugger...
384   ///
385   void dump() const;
386
387   /// viewGraph - Emit a dot graph, run 'dot', run gv on the postscript file,
388   /// then cleanup.  For use from the debugger.
389   ///
390   void viewGraph() const;
391
392   void writeGraphToFile(std::ostream &O, const std::string &GraphName) const;
393
394   /// maskNodeTypes - Apply a mask to all of the node types in the graph.  This
395   /// is useful for clearing out markers like Incomplete.
396   ///
397   void maskNodeTypes(unsigned Mask) {
398     for (node_iterator I = node_begin(), E = node_end(); I != E; ++I)
399       I->maskNodeTypes(Mask);
400   }
401   void maskIncompleteMarkers() { maskNodeTypes(~DSNode::Incomplete); }
402
403   // markIncompleteNodes - Traverse the graph, identifying nodes that may be
404   // modified by other functions that have not been resolved yet.  This marks
405   // nodes that are reachable through three sources of "unknownness":
406   //   Global Variables, Function Calls, and Incoming Arguments
407   //
408   // For any node that may have unknown components (because something outside
409   // the scope of current analysis may have modified it), the 'Incomplete' flag
410   // is added to the NodeType.
411   //
412   enum MarkIncompleteFlags {
413     MarkFormalArgs = 1, IgnoreFormalArgs = 0,
414     IgnoreGlobals = 2, MarkGlobalsIncomplete = 0,
415   };
416   void markIncompleteNodes(unsigned Flags);
417
418   // removeDeadNodes - Use a reachability analysis to eliminate subgraphs that
419   // are unreachable.  This often occurs because the data structure doesn't
420   // "escape" into it's caller, and thus should be eliminated from the caller's
421   // graph entirely.  This is only appropriate to use when inlining graphs.
422   //
423   enum RemoveDeadNodesFlags {
424     RemoveUnreachableGlobals = 1, KeepUnreachableGlobals = 0,
425   };
426   void removeDeadNodes(unsigned Flags);
427
428   /// CloneFlags enum - Bits that may be passed into the cloneInto method to
429   /// specify how to clone the function graph.
430   enum CloneFlags {
431     StripAllocaBit        = 1 << 0, KeepAllocaBit     = 0,
432     DontCloneCallNodes    = 1 << 1, CloneCallNodes    = 0,
433     DontCloneAuxCallNodes = 1 << 2, CloneAuxCallNodes = 0,
434     StripModRefBits       = 1 << 3, KeepModRefBits    = 0,
435     StripIncompleteBit    = 1 << 4, KeepIncompleteBit = 0,
436   };
437
438   void updateFromGlobalGraph();
439
440   /// computeNodeMapping - Given roots in two different DSGraphs, traverse the
441   /// nodes reachable from the two graphs, computing the mapping of nodes from
442   /// the first to the second graph.
443   ///
444   static void computeNodeMapping(const DSNodeHandle &NH1,
445                                  const DSNodeHandle &NH2, NodeMapTy &NodeMap,
446                                  bool StrictChecking = true);
447
448   /// computeGToGGMapping - Compute the mapping of nodes in the graph to nodes
449   /// in the globals graph.
450   void computeGToGGMapping(NodeMapTy &NodeMap);
451
452   /// computeGGToGMapping - Compute the mapping of nodes in the global
453   /// graph to nodes in this graph.
454   void computeGGToGMapping(InvNodeMapTy &InvNodeMap);
455
456   /// computeCalleeCallerMapping - Given a call from a function in the current
457   /// graph to the 'Callee' function (which lives in 'CalleeGraph'), compute the
458   /// mapping of nodes from the callee to nodes in the caller.
459   void computeCalleeCallerMapping(DSCallSite CS, const Function &Callee,
460                                   DSGraph &CalleeGraph, NodeMapTy &NodeMap);
461
462   /// spliceFrom - Logically perform the operation of cloning the RHS graph into
463   /// this graph, then clearing the RHS graph.  Instead of performing this as
464   /// two seperate operations, do it as a single, much faster, one.
465   ///
466   void spliceFrom(DSGraph &RHS);
467
468   /// cloneInto - Clone the specified DSGraph into the current graph.
469   ///
470   /// The CloneFlags member controls various aspects of the cloning process.
471   ///
472   void cloneInto(const DSGraph &G, unsigned CloneFlags = 0);
473
474   /// getFunctionArgumentsForCall - Given a function that is currently in this
475   /// graph, return the DSNodeHandles that correspond to the pointer-compatible
476   /// function arguments.  The vector is filled in with the return value (or
477   /// null if it is not pointer compatible), followed by all of the
478   /// pointer-compatible arguments.
479   void getFunctionArgumentsForCall(Function *F,
480                                    std::vector<DSNodeHandle> &Args) const;
481
482   /// mergeInGraph - This graph merges in the minimal number of
483   /// nodes from G2 into 'this' graph, merging the bindings specified by the
484   /// call site (in this graph) with the bindings specified by the vector in G2.
485   /// If the StripAlloca's argument is 'StripAllocaBit' then Alloca markers are
486   /// removed from nodes.
487   ///
488   void mergeInGraph(const DSCallSite &CS, std::vector<DSNodeHandle> &Args,
489                     const DSGraph &G2, unsigned CloneFlags);
490
491   /// mergeInGraph - This method is the same as the above method, but the
492   /// argument bindings are provided by using the formal arguments of F.
493   ///
494   void mergeInGraph(const DSCallSite &CS, Function &F, const DSGraph &Graph,
495                     unsigned CloneFlags);
496
497   /// getCallSiteForArguments - Get the arguments and return value bindings for
498   /// the specified function in the current graph.
499   ///
500   DSCallSite getCallSiteForArguments(Function &F) const;
501
502   /// getDSCallSiteForCallSite - Given an LLVM CallSite object that is live in
503   /// the context of this graph, return the DSCallSite for it.
504   DSCallSite getDSCallSiteForCallSite(CallSite CS) const;
505
506   // Methods for checking to make sure graphs are well formed...
507   void AssertNodeInGraph(const DSNode *N) const {
508     assert((!N || N->getParentGraph() == this) &&
509            "AssertNodeInGraph: Node is not in graph!");
510   }
511   void AssertNodeContainsGlobal(const DSNode *N, GlobalValue *GV) const;
512
513   void AssertCallSiteInGraph(const DSCallSite &CS) const;
514   void AssertCallNodesInGraph() const;
515   void AssertAuxCallNodesInGraph() const;
516
517   void AssertGraphOK() const;
518
519   /// removeTriviallyDeadNodes - After the graph has been constructed, this
520   /// method removes all unreachable nodes that are created because they got
521   /// merged with other nodes in the graph.  This is used as the first step of
522   /// removeDeadNodes.
523   ///
524   void removeTriviallyDeadNodes();
525 };
526
527
528 /// ReachabilityCloner - This class is used to incrementally clone and merge
529 /// nodes from a non-changing source graph into a potentially mutating
530 /// destination graph.  Nodes are only cloned over on demand, either in
531 /// responds to a merge() or getClonedNH() call.  When a node is cloned over,
532 /// all of the nodes reachable from it are automatically brought over as well.
533 ///
534 class ReachabilityCloner {
535   DSGraph &Dest;
536   const DSGraph &Src;
537
538   /// BitsToKeep - These bits are retained from the source node when the
539   /// source nodes are merged into the destination graph.
540   unsigned BitsToKeep;
541   unsigned CloneFlags;
542
543   // NodeMap - A mapping from nodes in the source graph to the nodes that
544   // represent them in the destination graph.
545   DSGraph::NodeMapTy NodeMap;
546 public:
547   ReachabilityCloner(DSGraph &dest, const DSGraph &src, unsigned cloneFlags)
548     : Dest(dest), Src(src), CloneFlags(cloneFlags) {
549     assert(&Dest != &Src && "Cannot clone from graph to same graph!");
550     BitsToKeep = ~DSNode::DEAD;
551     if (CloneFlags & DSGraph::StripAllocaBit)
552       BitsToKeep &= ~DSNode::AllocaNode;
553     if (CloneFlags & DSGraph::StripModRefBits)
554       BitsToKeep &= ~(DSNode::Modified | DSNode::Read);
555     if (CloneFlags & DSGraph::StripIncompleteBit)
556       BitsToKeep &= ~DSNode::Incomplete;
557   }
558   
559   DSNodeHandle getClonedNH(const DSNodeHandle &SrcNH);
560
561   void merge(const DSNodeHandle &NH, const DSNodeHandle &SrcNH);
562
563   /// mergeCallSite - Merge the nodes reachable from the specified src call
564   /// site into the nodes reachable from DestCS.
565   ///
566   void mergeCallSite(DSCallSite &DestCS, const DSCallSite &SrcCS);
567
568   bool clonedAnyNodes() const { return !NodeMap.empty(); }
569
570   /// hasClonedNode - Return true if the specified node has been cloned from
571   /// the source graph into the destination graph.
572   bool hasClonedNode(const DSNode *N) {
573     return NodeMap.count(N);
574   }
575
576   void destroy() { NodeMap.clear(); }
577 };
578
579 } // End llvm namespace
580
581 #endif