[llvm-commits] [see] CVS: llvm-poolalloc/include/dsa/DSGraph.h DSNode.h

Andrew Lenharth alenhar2 at cs.uiuc.edu
Fri Mar 9 09:28:29 PST 2007



Changes in directory llvm-poolalloc/include/dsa:

DSGraph.h updated: 1.110.2.4.2.1 -> 1.110.2.4.2.2
DSNode.h updated: 1.58.2.2 -> 1.58.2.2.2.1
---
Log message:

use nifty new, simpler, smaller, easy to understand metapool inference (yea yea, theres a memory leak in it

---
Diffs of the changes:  (+69 -89)

 DSGraph.h |   91 ++------------------------------------------------------------
 DSNode.h  |   67 ++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 69 insertions(+), 89 deletions(-)


Index: llvm-poolalloc/include/dsa/DSGraph.h
diff -u llvm-poolalloc/include/dsa/DSGraph.h:1.110.2.4.2.1 llvm-poolalloc/include/dsa/DSGraph.h:1.110.2.4.2.2
--- llvm-poolalloc/include/dsa/DSGraph.h:1.110.2.4.2.1	Wed Feb 28 11:35:41 2007
+++ llvm-poolalloc/include/dsa/DSGraph.h	Fri Mar  9 11:27:50 2007
@@ -23,6 +23,8 @@
 #include <list>
 #include <map>
 #include <iostream>
+#include <vector>
+
 namespace llvm {
 
   //typedef map<const DSNode *, Value*> PoolDescriptorMapType;
@@ -174,63 +176,6 @@
   DSNodeHandle &AddGlobal(GlobalValue *GV);
 };
 
-
-#ifdef LLVA_KERNEL
-class MetaPool;
-class MetaPoolHandle {
-  MetaPool *Rep;
-  Instruction * Creator;
-public:
-  MetaPoolHandle(MetaPool *mp, Instruction * Maker = 0);
-  
-  MetaPool *getMetaPool() {
-    return Rep;
-  }
-  void setMetaPool(MetaPool *v) {
-    Rep = v;
-  }
-  ~MetaPoolHandle() {
-    //do nothing for now
-  }
-  const std::string &getName();
-  Value *getMetaPoolValue();
-  void merge(MetaPoolHandle *other);
-};
-
-  class MetaPool {
-    Value *MPD;
-    hash_set<MetaPoolHandle *> HandleSet;
-    
-  public:
-    MetaPool(Value *mpd) : MPD(mpd) {
-    }
-    void addMetaPoolHandles(hash_set<MetaPoolHandle *> & mpHS) {
-      HandleSet.insert(mpHS.begin(), mpHS.end());
-    }
-    hash_set<MetaPoolHandle *>& getHandleSet() {
-      return HandleSet;
-    }
-    Value * getMetaPoolValue() {
-      return MPD;
-    }
-    void setMetaPoolValue(Value *V) {
-      MPD = V;
-    }
-    void insert(MetaPoolHandle *mph) {
-      HandleSet.insert(mph);
-    }
-    const std::string& getName() {
-      return MPD->getName();
-    }
-    ~MetaPool() {
-      HandleSet.clear();
-    }
-  };
-
-#endif
-  
-
-  
 //===----------------------------------------------------------------------===//
 /// DSGraph - The graph that represents a function.
 ///
@@ -280,12 +225,6 @@
   /// constructed for.
   const TargetData &TD;
 
-#ifdef LLVA_KERNEL
-  hash_map<const DSNode*, MetaPoolHandle*> PoolDescriptors;
-#endif  
-
-  
-
   void operator=(const DSGraph &); // DO NOT IMPLEMENT
   DSGraph(const DSGraph&);         // DO NOT IMPLEMENT
 public:
@@ -311,31 +250,6 @@
   DSGraph *getGlobalsGraph() const { return GlobalsGraph; }
   void setGlobalsGraph(DSGraph *G) { GlobalsGraph = G; }
 
-#ifdef LLVA_KERNEL
-#if 1
-  hash_map<const DSNode *, MetaPoolHandle*>& getPoolDescriptorsMap() {
-    return PoolDescriptors;
-  }
-  MetaPoolHandle *getPoolForNode(const DSNode *N) {
-    if (PoolDescriptors.count(N) > 0) {
-      return PoolDescriptors[N];
-    }
-    return 0;
-  }
-#else
-  hash_map<const DSNodeHandle *, MetaPoolHandle*>& getPoolDescriptorsMap() {
-    return PoolDescriptors;
-  }
-  MetaPoolHandle *getPoolForNode(const DSNodeHandle *N) {
-    if (PoolDescriptors.count(N) > 0) {
-      return PoolDescriptors[N];
-    }
-    return 0;
-  }
-#endif
-
-#endif  
-
   /// getGlobalECs - Return the set of equivalence classes that the global
   /// variables in the program form.
   EquivalenceClasses<GlobalValue*> &getGlobalECs() const {
@@ -615,6 +529,7 @@
   /// removeDeadNodes.
   ///
   void removeTriviallyDeadNodes();
+
 };
 
 


Index: llvm-poolalloc/include/dsa/DSNode.h
diff -u llvm-poolalloc/include/dsa/DSNode.h:1.58.2.2 llvm-poolalloc/include/dsa/DSNode.h:1.58.2.2.2.1
--- llvm-poolalloc/include/dsa/DSNode.h:1.58.2.2	Wed Dec 13 10:24:48 2006
+++ llvm-poolalloc/include/dsa/DSNode.h	Fri Mar  9 11:27:50 2007
@@ -16,6 +16,7 @@
 
 #include "dsa/DSSupport.h"
 #include "llvm/ADT/hash_map"
+#include <list>
 
 namespace llvm {
 
@@ -23,6 +24,62 @@
 class DSNodeIterator;          // Data structure graph traversal iterator
 class TargetData;
 
+#if 1
+  class MetaPool {
+  protected:
+    Value *MPD;
+    MetaPool* fw;
+
+  public:
+    std::list<CallSite> allocs;
+    std::list<GlobalValue*> GVs;
+    MetaPool(CallSite& C) : MPD(0), fw(0) {
+      allocs.push_back(C);
+    }
+    MetaPool(GlobalValue* GV) : MPD(0),fw(0) {
+      GVs.push_back(GV);
+    }
+
+    MetaPool() : MPD(0),fw(0) {}
+    MetaPool(const MetaPool& M) :MPD(0), fw(const_cast<MetaPool*>(&M)) {}
+
+    Value * getMetaPoolValue() {
+      return MPD;
+    }
+    void setMetaPoolValue(Value *V) {
+      MPD = V;
+    }
+    void merge(MetaPool* M) {
+      if(!M || M == this) return;
+      allocs.splice(allocs.begin(), M->allocs);
+      GVs.splice(GVs.begin(), M->GVs);
+      M->fw = this;
+    }
+    MetaPool* getFW() { return fw; }
+  };
+  class MetaPoolHandle {
+    MetaPool* MP;
+
+  public:
+    MetaPoolHandle(MetaPool* P) :MP(P) {}
+    //    MetaPoolHandle() : MP(0) {}
+    MetaPool* getPool() {
+      while(MP && MP->getFW())
+        MP = MP->getFW();
+      return MP;
+    }
+    MetaPool* getPool() const{
+      MetaPool* RP = MP;
+      while(RP && RP->getFW())
+        RP = RP->getFW();
+      return RP;
+    }
+    void set(MetaPool* P) { MP = P; }
+  };
+#endif
+
+
+
 //===----------------------------------------------------------------------===//
 /// DSNode - Data structure node class
 ///
@@ -105,8 +162,16 @@
   ///
 private:
   unsigned short NodeType;
-public:
 
+#if 1
+protected:
+  MetaPoolHandle MP;
+public:
+  MetaPool* getMP() { return MP.getPool(); }
+  MetaPool* getMP() const { return MP.getPool(); }
+  void setMP(MetaPool* P) { MP.set(P); }
+#endif
+    public:
   /// DSNode ctor - Create a node of the specified type, inserting it into the
   /// specified graph.
   ///






More information about the llvm-commits mailing list