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

John Criswell criswell at cs.uiuc.edu
Tue Aug 12 13:18:01 PDT 2003


Changes in directory poolalloc/lib/PoolAllocate:

PoolAllocate.cpp updated: 1.16 -> 1.17

---
Log message:

Merged in a changes from the LLVM tree: Revision 1.16
Bug fix: Some nodes pointed to by globals may not be marked incomplete and need 
to be tracked to find pool arguments.



---
Diffs of the changes:

Index: poolalloc/lib/PoolAllocate/PoolAllocate.cpp
diff -u poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.16 poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.17
--- poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.16	Mon Aug 11 17:07:11 2003
+++ poolalloc/lib/PoolAllocate/PoolAllocate.cpp	Tue Aug 12 13:17:29 2003
@@ -254,14 +254,27 @@
 
 void PoolAllocate::FindFunctionPoolArgs(Function &F) {
 
-  // The DSGraph is merged with the globals graph. 
   DSGraph &G = BU->getDSGraph(F);
-  G.mergeInGlobalsGraph();
-
+ 
   // Inline the potential targets of indirect calls
   hash_set<Function*> visitedFuncs;
   InlineIndirectCalls(F, G, visitedFuncs);
 
+  // The DSGraph is merged with the globals graph. 
+  G.mergeInGlobalsGraph();
+
+  // The nodes reachable from globals need to be recognized as potential 
+  // arguments. This is required because, upon merging in the globals graph,
+  // the nodes pointed to by globals that are not live are not marked 
+  // incomplete.
+  hash_set<DSNode*> NodesFromGlobals;
+  for (DSGraph::ScalarMapTy::iterator I = G.getScalarMap().begin(), 
+	 E = G.getScalarMap().end(); I != E; ++I)
+    if (isa<GlobalValue>(I->first)) {             // Found a global
+      DSNodeHandle &GH = I->second;
+      GH.getNode()->markReachableNodes(NodesFromGlobals);
+    }
+
   // At this point the DS Graphs have been modified in place including
   // information about globals as well as indirect calls, making it useful
   // for pool allocation
@@ -296,8 +309,8 @@
     for (unsigned i = 0, e = Nodes.size(); i != e; ++i) {
       if (Nodes[i]->isGlobalNode() && !Nodes[i]->isIncomplete())
         DEBUG(std::cerr << "Global node is not Incomplete\n");
-      if ((Nodes[i]->isIncomplete() || Nodes[i]->isGlobalNode()) && 
-	  Nodes[i]->isHeapNode())
+      if ((Nodes[i]->isIncomplete() || Nodes[i]->isGlobalNode() || 
+	   NodesFromGlobals.count(Nodes[i])) && Nodes[i]->isHeapNode())
         Nodes[i]->markReachableNodes(MarkedNodes);
     }
 





More information about the llvm-commits mailing list