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

Chris Lattner lattner at cs.uiuc.edu
Wed Nov 10 14:06:16 PST 2004



Changes in directory poolalloc/lib/PoolAllocate:

PoolAllocate.cpp updated: 1.91 -> 1.92

---
Log message:

Instead of making pools local to main have descriptors that are local to main,
make them global.  This lets IPCP eliminate a lot more of them.


---
Diffs of the changes:  (+15 -6)

Index: poolalloc/lib/PoolAllocate/PoolAllocate.cpp
diff -u poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.91 poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.92
--- poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.91	Wed Nov 10 15:13:47 2004
+++ poolalloc/lib/PoolAllocate/PoolAllocate.cpp	Wed Nov 10 16:06:05 2004
@@ -471,17 +471,26 @@
 
   std::set<DSNode*> UnallocatedNodes(NodesToPA.begin(), NodesToPA.end());
 
-  Instruction *InsertPoint = F.front().begin();
+  BasicBlock::iterator InsertPoint = F.front().begin();
+  while (isa<AllocaInst>(InsertPoint)) ++InsertPoint;
+
+  // Is this main?  If so, make the pool descriptors globals, not automatic
+  // vars.
+  bool IsMain = F.getName() == "main" && F.hasExternalLinkage();
 
   // Perform all global assignments as specified.
   for (unsigned i = 0, e = ResultPools.size(); i != e; ++i) {
     Heuristic::OnePool &Pool = ResultPools[i];
     Value *PoolDesc = Pool.PoolDesc;
-    if (PoolDesc == 0)
-      // Create a new alloca instruction for the pool.  The poolinit will be
-      // inserted later.
-      PoolDesc = new AllocaInst(PoolDescType, 0, "PD", InsertPoint);
-
+    if (PoolDesc == 0) {
+      // Create a pool descriptor for the pool.  The poolinit will be inserted
+      // later.
+      if (!IsMain)
+        PoolDesc = new AllocaInst(PoolDescType, 0, "PD", InsertPoint);
+      else
+        PoolDesc = CreateGlobalPool(Pool.PoolSize, Pool.PoolAlignment,
+                                    InsertPoint);
+    }
     for (unsigned N = 0, e = Pool.NodesInPool.size(); N != e; ++N) {
       PoolDescriptors[Pool.NodesInPool[N]] = PoolDesc;
       UnallocatedNodes.erase(Pool.NodesInPool[N]);  // Handled!





More information about the llvm-commits mailing list