[llvm-commits] [see] CVS: llvm-poolalloc/lib/DSA/DataStructure.cpp Local.cpp

2007-03-13 Thread Andrew Lenharth


Changes in directory llvm-poolalloc/lib/DSA:

DataStructure.cpp updated: 1.248.2.4.2.4 - 1.248.2.4.2.5
Local.cpp updated: 1.158.2.4.2.7 - 1.158.2.4.2.8
---
Log message:

assign a meta pool to all dsnodes

---
Diffs of the changes:  (+7 -27)

 DataStructure.cpp |   22 +-
 Local.cpp |   12 ++--
 2 files changed, 7 insertions(+), 27 deletions(-)


Index: llvm-poolalloc/lib/DSA/DataStructure.cpp
diff -u llvm-poolalloc/lib/DSA/DataStructure.cpp:1.248.2.4.2.4 
llvm-poolalloc/lib/DSA/DataStructure.cpp:1.248.2.4.2.5
--- llvm-poolalloc/lib/DSA/DataStructure.cpp:1.248.2.4.2.4  Fri Mar  9 
11:27:51 2007
+++ llvm-poolalloc/lib/DSA/DataStructure.cppTue Mar 13 20:24:01 2007
@@ -128,7 +128,7 @@
 DSNode::DSNode(const Type *T, DSGraph *G)
   : NumReferrers(0), Size(0), ParentGraph(G), Ty(Type::VoidTy), NodeType(0)
 #ifdef LLVA_KERNEL
-  , MP(0)
+  , MP()
 #endif
  {
   // Add the type entry if it is specified...
@@ -198,11 +198,7 @@
   Size = 0;
   Ty = Type::VoidTy;
 #ifdef LLVA_KERNEL
-  MetaPool* MP = new MetaPool();
-  MP-merge(getMP());
-  MP-merge(To-getMP());
-  setMP(MP);
-  To-setMP(MP);
+  To-getMP()-merge(getMP());
 #endif
 
   // Remove this node from the parent graph's Nodes list.
@@ -265,7 +261,7 @@
 DestNode-Size = 1;
 DestNode-Globals.swap(Globals);
 #ifdef LLVA_KERNEL
-DestNode-setMP(getMP());
+DestNode-getMP()-merge(getMP());
 #endif
 
 #if JTC
@@ -866,11 +862,7 @@
 #endif
   }
 #ifdef LLVA_KERNEL
-  MetaPool* MP = new MetaPool();
-  MP-merge(CurNodeH.getNode()-getMP());
-  MP-merge(NH.getNode()-getMP());
-  CurNodeH.getNode()-setMP(MP);
-  NH.getNode()-setMP(MP);
+  NH.getNode()-getMP()-merge(CurNodeH.getNode()-getMP());
 #endif  
   // Merge the type entries of the two nodes together...
   if (NH.getNode()-Ty != Type::VoidTy)
@@ -1193,11 +1185,7 @@
 
 
 #ifdef LLVA_KERNEL
-  MetaPool* MP = new MetaPool();
-  MP-merge(NH.getNode()-getMP());
-  MP-merge(SrcNH.getNode()-getMP());
-  NH.getNode()-setMP(MP);
-  SrcNH.getNode()-setMP(MP);
+  SrcNH.getNode()-getMP()-merge(NH.getNode()-getMP());
 #endif  
 
   // Next, recursively merge all outgoing links as necessary.  Note that


Index: llvm-poolalloc/lib/DSA/Local.cpp
diff -u llvm-poolalloc/lib/DSA/Local.cpp:1.158.2.4.2.7 
llvm-poolalloc/lib/DSA/Local.cpp:1.158.2.4.2.8
--- llvm-poolalloc/lib/DSA/Local.cpp:1.158.2.4.2.7  Tue Mar 13 13:48:36 2007
+++ llvm-poolalloc/lib/DSA/Local.cppTue Mar 13 20:24:01 2007
@@ -350,10 +350,6 @@
 ///
 void GraphBuilder::handleAlloc(AllocationInst AI, bool isHeap) {
   DSNode *N = createNode();
-#ifdef LLVA_KERNEL
-  MetaPool* MP = new MetaPool();
-  N-setMP(MP);
-#endif
   if (isHeap)
 N-setHeapNodeMarker();
   else
@@ -1158,8 +1154,7 @@
 if (AllocList.end() != std::find(AllocList.begin(), AllocList.end(), 
F-getName())) {
   DSNode* N = createNode()-setHeapNodeMarker()-setModifiedMarker();
   setDestTo(*CS.getInstruction(), N);
-  MetaPool* MP = new MetaPool(CS);
-  N-setMP(MP);
+  N-getMP()-addCallSite(CS);
   return;
 }
 
@@ -1317,10 +1312,7 @@
   // Get a node handle to the global node and merge the initializer into it.
   DSNodeHandle NH = getValueDest(*GV);
   MergeConstantInitIntoNode(NH, GV-getInitializer());
-  MetaPool* MP = new MetaPool(GV);
-  if (NH.getNode()-getMP())
-MP-merge(NH.getNode()-getMP());
-  NH.getNode()-setMP(MP);
+  NH.getNode()-getMP()-addGlobal(GV);
 }
 
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [see] CVS: llvm-poolalloc/lib/DSA/DataStructure.cpp Local.cpp

2007-03-09 Thread Andrew Lenharth


Changes in directory llvm-poolalloc/lib/DSA:

DataStructure.cpp updated: 1.248.2.4.2.3 - 1.248.2.4.2.4
Local.cpp updated: 1.158.2.4.2.3 - 1.158.2.4.2.4
---
Log message:

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

---
Diffs of the changes:  (+49 -553)

 DataStructure.cpp |  243 
 Local.cpp |  359 ++
 2 files changed, 49 insertions(+), 553 deletions(-)


Index: llvm-poolalloc/lib/DSA/DataStructure.cpp
diff -u llvm-poolalloc/lib/DSA/DataStructure.cpp:1.248.2.4.2.3 
llvm-poolalloc/lib/DSA/DataStructure.cpp:1.248.2.4.2.4
--- llvm-poolalloc/lib/DSA/DataStructure.cpp:1.248.2.4.2.3  Wed Mar  7 
16:49:43 2007
+++ llvm-poolalloc/lib/DSA/DataStructure.cppFri Mar  9 11:27:51 2007
@@ -98,6 +98,7 @@
 
 DSNodeHandle DSScalarMap::AddGlobal(GlobalValue *GV) {
   assert(ValueMap.count(GV) == 0  GV already exists!);
+  assert(isaGlobalValue((Value*)GV)  not a global);
 
   // If the node doesn't exist, check to see if it's a global that is
   // equated to another global in the program.
@@ -125,7 +126,11 @@
 
//===--===//
 
 DSNode::DSNode(const Type *T, DSGraph *G)
-  : NumReferrers(0), Size(0), ParentGraph(G), Ty(Type::VoidTy), NodeType(0) {
+  : NumReferrers(0), Size(0), ParentGraph(G), Ty(Type::VoidTy), NodeType(0)
+#ifdef LLVA_KERNEL
+  , MP(0)
+#endif
+ {
   // Add the type entry if it is specified...
   if (T) mergeTypeInfo(T, 0);
   if (G) G-addNode(this);
@@ -138,7 +143,11 @@
 // DSNode copy constructor... do not copy over the referrers list!
 DSNode::DSNode(const DSNode N, DSGraph *G, bool NullLinks)
   : NumReferrers(0), Size(N.Size), ParentGraph(G),
-Ty(N.Ty), Globals(N.Globals), NodeType(N.NodeType) {
+Ty(N.Ty), Globals(N.Globals), NodeType(N.NodeType)
+#ifdef LLVA_KERNEL
+  , MP(N.MP.getPool())
+#endif
+ {
   if (!NullLinks) {
 Links = N.Links;
   } else
@@ -153,19 +162,6 @@
 DSNode::~DSNode() {
   dropAllReferences();
   assert(hasNoReferrers()  Referrers to dead node exist!);
-
-#ifdef LLVA_KERNEL
-  //
-  // Remove all references to this node from the Pool Descriptor Map.
-  //
-#if JTC
-  std::cerr  LLVA: Removing   this  \n;
-#endif
-  if (ParentGraph) {
-hash_mapconst DSNode *, MetaPoolHandle* 
pdm=ParentGraph-getPoolDescriptorsMap();
-pdm.erase (this);
-  }
-#endif
 }
 
 /// getTargetData - Get the target data object used to construct this node.
@@ -201,6 +197,13 @@
   NodeType = DEAD;
   Size = 0;
   Ty = Type::VoidTy;
+#ifdef LLVA_KERNEL
+  MetaPool* MP = new MetaPool();
+  MP-merge(getMP());
+  MP-merge(To-getMP());
+  setMP(MP);
+  To-setMP(MP);
+#endif
 
   // Remove this node from the parent graph's Nodes list.
   ParentGraph-unlinkNode(this);
@@ -261,21 +264,13 @@
 DestNode-Ty = Type::VoidTy;
 DestNode-Size = 1;
 DestNode-Globals.swap(Globals);
+#ifdef LLVA_KERNEL
+DestNode-setMP(getMP());
+#endif
 
 #if JTC
 std::cerr  LLVA: foldNode:   this   becomes   DestNode  \n;
 #endif
-#ifdef LLVA_KERNEL
-//Again we have created a new DSNode, we need to fill in the
-// pool desc map appropriately
-assert(ParentGraph  parent graph is not null \n); 
-hash_mapconst DSNode *, MetaPoolHandle* pdm = 
ParentGraph-getPoolDescriptorsMap();
-if (pdm.count(this)  0) {
-  pdm[DestNode] = pdm[this];
-} else {
-  //do nothing 
-}
-#endif
 
 // Start forwarding to the destination node...
 forwardNode(DestNode, 0);
@@ -871,60 +866,11 @@
 #endif
   }
 #ifdef LLVA_KERNEL
-  DSNode *currNode  = CurNodeH.getNode();
-  DSNode *NNode  = NH.getNode();
-  DSGraph *pGraph =  currNode-getParentGraph();
-  assert((pGraph == NNode-getParentGraph())  LLVA_KERNEL : merging nodes 
in two different graphs?);
-  //get the pooldescriptor map
-  hash_mapconst DSNode *, MetaPoolHandle* pdm = 
pGraph-getPoolDescriptorsMap();
-  if (pdm.count(currNode) == 0) {
-if (pdm.count(NNode) == 0) {
-  //do nothing  (common case)
-} else {
-  if (pdm[NNode]) {
-#if JTC
-   std::cerr  LLVA: 1: currNode (  currNode  ) becomes   
pdm[NNode]-getName()  (  NNode  )\n;
-#endif
-   pdm[currNode] = pdm[NNode];
-  }
-}
-  } else {
-if (pdm.count(NNode) == 0) {
-#if 1
-  //
-  // FIXME:
-  //  Verify that this is correct.  I believe it is; it seems to make sense
-  //  since either node can be used after the merge.
-  //
-#if JTC
-std::cerr  LLVA: MergeNodes: currnode has something, newnode has nothing\n;
-   std::cerr  LLVA: 2: currNode (  currNode  ) becomes no name 
 (  NNode  )\n;
-#endif
-  pdm[NNode] = pdm[currNode];
-#endif
-  //do nothing 
-} else {
-  if (pdm[currNode] != pdm[NNode]) {
-   //The following is commented because pdm[..] could be null!
-   //std::cerr  LLVA: OldPool:   pdm[currNode]-getName()  (
-//