[llvm-commits] CVS: llvm/include/llvm/Analysis/DSGraph.h DSNode.h DataStructure.h

Chris Lattner lattner at cs.uiuc.edu
Fri Nov 8 15:26:01 PST 2002


Changes in directory llvm/include/llvm/Analysis:

DSGraph.h updated: 1.30 -> 1.31
DSNode.h updated: 1.10 -> 1.11
DataStructure.h updated: 1.50 -> 1.51

---
Log message:

- Add support for an "auxillary" call site list
- Original call sites are now never modified after construction by the local 
  pass.
- DSGraph::cloneInto can now optionally not clone the call sites
- BUDataStructures no longer has a ton of book-keeping info for a broken 
  implementation of the TD data structures



---
Diffs of the changes:

Index: llvm/include/llvm/Analysis/DSGraph.h
diff -u llvm/include/llvm/Analysis/DSGraph.h:1.30 llvm/include/llvm/Analysis/DSGraph.h:1.31
--- llvm/include/llvm/Analysis/DSGraph.h:1.30	Thu Nov  7 23:03:37 2002
+++ llvm/include/llvm/Analysis/DSGraph.h	Fri Nov  8 15:24:51 2002
@@ -26,14 +26,19 @@
 #endif
 
   // FunctionCalls - This vector maintains a single entry for each call
-  // instruction in the current graph.  Each call entry contains DSNodeHandles
-  // that refer to the arguments that are passed into the function call.  The
-  // first entry in the vector is the scalar that holds the return value for the
-  // call, the second is the function scalar being invoked, and the rest are
-  // pointer arguments to the function.
+  // instruction in the current graph.  The first entry in the vector is the
+  // scalar that holds the return value for the call, the second is the function
+  // scalar being invoked, and the rest are pointer arguments to the function.
+  // This vector is built by the Local graph and is never modified after that.
   //
   std::vector<DSCallSite> FunctionCalls;
 
+  // AuxFunctionCalls - This vector contains call sites that have been processed
+  // by some mechanism.  In pratice, the BU Analysis uses this vector to hold
+  // the _unresolved_ call sites, because it cannot modify FunctionCalls.
+  //
+  std::vector<DSCallSite> AuxFunctionCalls;
+
   void operator=(const DSGraph &); // DO NOT IMPLEMENT
 public:
   DSGraph() : Func(0) {}           // Create a new, empty, DSGraph.
@@ -64,13 +69,20 @@
   std::map<Value*, DSNodeHandle> &getScalarMap() { return ScalarMap; }
   const std::map<Value*, DSNodeHandle> &getScalarMap() const {return ScalarMap;}
 
-  std::vector<DSCallSite> &getFunctionCalls() {
-    return FunctionCalls;
-  }
+  /// getFunctionCalls - Return the list of call sites in the original local
+  /// graph...
+  ///
   const std::vector<DSCallSite> &getFunctionCalls() const {
     return FunctionCalls;
   }
 
+  /// getAuxFunctionCalls - Get the call sites as modified by whatever passes
+  /// have been run.
+  ///
+  std::vector<DSCallSite> &getAuxFunctionCalls() {
+    return AuxFunctionCalls;
+  }
+
   /// getNodeForValue - Given a value that is used or defined in the body of the
   /// current function, return the DSNode that it points to.
   ///
@@ -125,9 +137,11 @@
   //
   void removeDeadNodes(bool KeepAllGlobals = false, bool KeepCalls = true);
 
-  enum AllocaBit {
-    StripAllocaBit,
-    KeepAllocaBit
+  // CloneFlags enum - Bits that may be passed into the cloneInto method to
+  // specify how to clone the function graph.
+  enum CloneFlags {
+    StripAllocaBit     = 1 << 0, KeepAllocaBit  = 0 << 0,
+    DontCloneCallNodes = 2 << 0, CloneCallNodes = 0 << 0,
   };
 
   // cloneInto - Clone the specified DSGraph into the current graph, returning
@@ -139,7 +153,7 @@
   DSNodeHandle cloneInto(const DSGraph &G,
                          std::map<Value*, DSNodeHandle> &OldValMap,
                          std::map<const DSNode*, DSNodeHandle> &OldNodeMap,
-                         AllocaBit StripAllocas = KeepAllocaBit);
+                         unsigned CloneFlags = 0);
 
   /// mergeInGraph - The method is used for merging graphs together.  If the
   /// argument graph is not *this, it makes a clone of the specified graph, then
@@ -147,8 +161,7 @@
   /// the graph.  If the StripAlloca's argument is 'StripAllocaBit' then Alloca
   /// markers are removed from nodes.
   ///
-  void mergeInGraph(DSCallSite &CS, const DSGraph &Graph,
-                    AllocaBit StripAllocas);
+  void mergeInGraph(DSCallSite &CS, const DSGraph &Graph, unsigned CloneFlags);
 
 #if 0
   // cloneGlobalInto - Clone the given global node (or the node for the given


Index: llvm/include/llvm/Analysis/DSNode.h
diff -u llvm/include/llvm/Analysis/DSNode.h:1.10 llvm/include/llvm/Analysis/DSNode.h:1.11
--- llvm/include/llvm/Analysis/DSNode.h:1.10	Thu Nov  7 23:03:37 2002
+++ llvm/include/llvm/Analysis/DSNode.h	Fri Nov  8 15:24:51 2002
@@ -98,6 +98,10 @@
   ///
   const std::vector<DSNodeHandle*> &getReferrers() const { return Referrers; }
 
+  /// hasNoReferrers - Return true if nothing is pointing to this node at all.
+  ///
+  bool hasNoReferrers() const { return Referrers.empty(); }
+
   /// isModified - Return true if this node may be modified in this context
   ///
   bool isModified() const { return (NodeType & Modified) != 0; }


Index: llvm/include/llvm/Analysis/DataStructure.h
diff -u llvm/include/llvm/Analysis/DataStructure.h:1.50 llvm/include/llvm/Analysis/DataStructure.h:1.51
--- llvm/include/llvm/Analysis/DataStructure.h:1.50	Thu Nov  7 18:23:23 2002
+++ llvm/include/llvm/Analysis/DataStructure.h	Fri Nov  8 15:24:51 2002
@@ -9,6 +9,7 @@
 
 #include "llvm/Analysis/DSSupport.h"
 #include "llvm/Pass.h"
+#include <set>
 
 class Type;
 class DSGraph;
@@ -66,7 +67,6 @@
 class BUDataStructures : public Pass {
   // DSInfo, one graph for each function
   std::map<const Function*, DSGraph*> DSInfo;
-  std::map<const Function*, std::vector<DSCallSite> > CallSites;
 public:
   ~BUDataStructures() { releaseMemory(); }
 
@@ -79,21 +79,12 @@
     return *I->second;
   }
 
-  /// getCallSites - Return all of the call sites for the specified function
-  ///
-  const std::vector<DSCallSite> *getCallSites(const Function &F) const {
-    std::map<const Function*, std::vector<DSCallSite> >::const_iterator I
-      = CallSites.find(&F);
-    return I != CallSites.end() ? &I->second : 0;
-  }
-
-  // print - Print out the analysis results...
+   // print - Print out the analysis results...
   void print(std::ostream &O, const Module *M) const;
 
   // If the pass pipeline is done with this pass, we can release our memory...
   virtual void releaseMemory();
 
-  // getAnalysisUsage - This obviously provides a data structure graph.
   virtual void getAnalysisUsage(AnalysisUsage &AU) const {
     AU.setPreservesAll();
     AU.addRequired<LocalDataStructures>();
@@ -109,24 +100,7 @@
 class TDDataStructures : public Pass {
   // DSInfo, one graph for each function
   std::map<const Function*, DSGraph*> DSInfo;
-
-  // Each graph in DSInfo is based on a graph in the BUDS object.  The BUMaps
-  // member keeps the mappings from the BU graphs to the TD graphs as they are
-  // calculated by calculateGraph.  This information is used to properly
-  // implement resolving of call sites, where the call sites in the BUGraph are
-  // in terms of the caller function's graph in the BUGraph.
-  //
-  typedef std::map<const DSNode*, DSNodeHandle> BUNodeMapTy;
-  std::map<const Function*, BUNodeMapTy> BUMaps;
-
-  // CallSitesForFunction - This is a temporary map that is only kept around
-  // when building the top-down closures for a program.  It traverses all of the
-  // call sites in the BU graph and holds all of the call sites that each
-  // function is the "resolving caller" for.
-  //
-  std::map<const Function*,
-           std::vector<const DSCallSite*> > CallSitesForFunction;
-
+  std::set<const Function*> GraphDone;
 public:
   ~TDDataStructures() { releaseMemory(); }
 
@@ -151,7 +125,8 @@
     AU.addRequired<BUDataStructures>();
   }
 private:
-  DSGraph &calculateGraph(Function &F);
+  void calculateGraph(Function &F);
+  DSGraph &getOrCreateDSGraph(Function &F);
 
   void ResolveCallSite(DSGraph &Graph, const DSCallSite &CallSite);
 };





More information about the llvm-commits mailing list