[llvm-commits] CVS: poolalloc/lib/PoolAllocate/Heuristic.cpp PoolAllocate.cpp

Chris Lattner lattner at cs.uiuc.edu
Tue Nov 9 12:16:36 PST 2004



Changes in directory poolalloc/lib/PoolAllocate:

Heuristic.cpp updated: 1.2 -> 1.3
PoolAllocate.cpp updated: 1.88 -> 1.89

---
Log message:

Count number of type-safe pools correctly, pass an extra argument to poolinit
(though for now it's always dynamically zero).


---
Diffs of the changes:  (+29 -14)

Index: poolalloc/lib/PoolAllocate/Heuristic.cpp
diff -u poolalloc/lib/PoolAllocate/Heuristic.cpp:1.2 poolalloc/lib/PoolAllocate/Heuristic.cpp:1.3
--- poolalloc/lib/PoolAllocate/Heuristic.cpp:1.2	Mon Nov  8 00:49:14 2004
+++ poolalloc/lib/PoolAllocate/Heuristic.cpp	Tue Nov  9 14:16:25 2004
@@ -86,15 +86,23 @@
                      Function *F, DSGraph &G,
                      std::vector<OnePool> &ResultPools) {
     // Build a set of all nodes that are reachable from another node in the
-    // graph.
+    // graph.  Here we ignore scalar nodes that are only globals as they are
+    // often global pointers to big arrays.
     std::set<const DSNode*> ReachableFromMemory;
     for (DSGraph::node_iterator I = G.node_begin(), E = G.node_end();
          I != E; ++I) {
       DSNode *N = *I;
-      for (DSNode::iterator NI = N->begin(), E = N->end(); NI != E; ++NI)
-        for (df_ext_iterator<const DSNode*>
-               DI = df_ext_begin(*NI, ReachableFromMemory),
-               E = df_ext_end(*NI, ReachableFromMemory); DI != E; ++DI)
+      // Ignore nodes that are just globals and not arrays.
+      /*
+      if (N->isArray() || N->isHeapNode() || N->isAllocaNode() ||
+          N->isUnknownNode())
+      */
+      // If a node is marked, all children are too.
+      if (!ReachableFromMemory.count(N))
+        for (DSNode::iterator NI = N->begin(), E = N->end(); NI != E; ++NI)
+          for (df_ext_iterator<const DSNode*>
+                 DI = df_ext_begin(*NI, ReachableFromMemory),
+                 E = df_ext_end(*NI, ReachableFromMemory); DI != E; ++DI)
           /*empty*/;
     }
 


Index: poolalloc/lib/PoolAllocate/PoolAllocate.cpp
diff -u poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.88 poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.89
--- poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.88	Mon Nov  8 00:32:31 2004
+++ poolalloc/lib/PoolAllocate/PoolAllocate.cpp	Tue Nov  9 14:16:25 2004
@@ -146,7 +146,8 @@
   
   // Get poolinit function.
   PoolInit = CurModule->getOrInsertFunction("poolinit", Type::VoidTy,
-                                            PoolDescPtrTy, Type::UIntTy, 0);
+                                            PoolDescPtrTy, Type::UIntTy,
+                                            Type::UIntTy, 0);
 
   // Get pooldestroy function.
   PoolDestroy = CurModule->getOrInsertFunction("pooldestroy", Type::VoidTy,
@@ -406,8 +407,13 @@
   for (unsigned i = 0, e = ResultPools.size(); i != e; ++i) {
     Heuristic::OnePool &Pool = ResultPools[i];
     Value *PoolDesc = Pool.PoolDesc;
-    if (PoolDesc == 0)
+    if (PoolDesc == 0) {
       PoolDesc = CreateGlobalPool(Pool.PoolSize);
+
+      if (Pool.NodesInPool.size() == 1 &&
+          !Pool.NodesInPool[0]->isNodeCompletelyFolded())
+        ++NumTSPools;
+    }
     for (unsigned N = 0, e = Pool.NodesInPool.size(); N != e; ++N) {
       GlobalNodes[Pool.NodesInPool[N]] = PoolDesc;
       GlobalHeapNodes.erase(Pool.NodesInPool[N]);  // Handled!
@@ -436,8 +442,11 @@
   BasicBlock::iterator InsertPt = MainFunc->getEntryBlock().begin();
   while (isa<AllocaInst>(InsertPt)) ++InsertPt;
 
+  unsigned Alignment = 0;
   Value *ElSize = ConstantUInt::get(Type::UIntTy, RecSize);
-  new CallInst(PoolInit, make_vector((Value*)GV, ElSize, 0), "", InsertPt);
+  Value *Align = ConstantUInt::get(Type::UIntTy, Alignment);
+  new CallInst(PoolInit, make_vector((Value*)GV, ElSize, Align, 0),
+               "", InsertPt);
   ++NumPools;
   return GV;
 }
@@ -767,15 +776,13 @@
     DEBUG(std::cerr << "\n  Init in blocks: ");
 
     // Insert the calls to initialize the pool.
-    unsigned ElSizeV = 0;
-    if (!Node->isArray() && Node->getType()->isSized())
-      ElSizeV = TD.getTypeSize(Node->getType());
-    if (ElSizeV == 1) ElSizeV = 0;
+    unsigned ElSizeV = Heuristic::getRecommendedSize(Node);
     Value *ElSize = ConstantUInt::get(Type::UIntTy, ElSizeV);
+    Value *Align  = ConstantUInt::get(Type::UIntTy, 0);
 
     for (unsigned i = 0, e = PoolInitPoints.size(); i != e; ++i) {
-      new CallInst(PoolInit, make_vector((Value*)PD, ElSize, 0), "",
-                   PoolInitPoints[i]);
+      new CallInst(PoolInit, make_vector((Value*)PD, ElSize, Align, 0),
+                   "", PoolInitPoints[i]);
       DEBUG(std::cerr << PoolInitPoints[i]->getParent()->getName() << " ");
     }
     if (!DisableInitDestroyOpt)





More information about the llvm-commits mailing list