[llvm-commits] [poolalloc] r115628 - /poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp

John Criswell criswell at uiuc.edu
Tue Oct 5 09:42:21 PDT 2010


Author: criswell
Date: Tue Oct  5 11:42:21 2010
New Revision: 115628

URL: http://llvm.org/viewvc/llvm-project?rev=115628&view=rev
Log:
Modified the code that selects DSNodes for global pools as follows:

1) Ensure that nodes that are both in the local and global graphs are either
   both pool allocated or not pool allocated.

Modified:
    poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp

Modified: poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp?rev=115628&r1=115627&r2=115628&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp Tue Oct  5 11:42:21 2010
@@ -212,7 +212,8 @@
 // Description:
 //  This function finds all DSNodes which are reachable from globals.  It finds
 //  DSNodes both within the local DSGraph as well as in the Globals graph that
-//  are reachable from globals.
+//  are reachable from globals.  It does, however, filter out those DSNodes
+//  which are of no interest to automatic pool allocation.
 //
 // Inputs:
 //  G - The DSGraph for which to find DSNodes which are reachable by globals.
@@ -245,6 +246,33 @@
   }
 
   //
+  // Remove those global nodes which we know will never be pool allocated.
+  //
+  std::vector<const DSNode *> toRemove;
+  for (DenseSet<const DSNode*>::iterator I = NodesFromGlobals.begin(),
+         E = NodesFromGlobals.end(); I != E; ) {
+    DenseSet<const DSNode*>::iterator Last = I; ++I;
+    //
+    // Nodes that escape to external code could be reachable from globals.
+    // Nodes that are incomplete could be heap nodes.
+    // Unknown nodes could be anything.
+    //
+    const DSNode *tmp = *Last;
+    if (!(tmp->isHeapNode() ||
+          tmp->isExternalNode() ||
+          tmp->isIncompleteNode() ||
+          tmp->isUnknownNode()))
+      toRemove.push_back (tmp);
+  }
+ 
+  //
+  // Remove all globally reachable DSNodes which do not require pools.
+  //
+  for (unsigned index = 0; index < toRemove.size(); ++index) {
+    NodesFromGlobals.erase(toRemove[index]);
+  }
+
+  //
   // Now the fun part.  Find DSNodes in the local graph that correspond to
   // those nodes reachable in the globals graph.  Add them to the set of
   // reachable nodes, too.
@@ -311,6 +339,7 @@
     }
   }
 
+#if 0
   //
   // We do not want to create pools for all memory objects reachable from
   // globals.  We only want those that are or could be heap objects.
@@ -339,6 +368,7 @@
   for (unsigned index = 0; index < toRemove.size(); ++index) {
     GlobalHeapNodes.erase(toRemove[index]);
   }
+#endif
 
   //
   // Scan through all the local graphs looking for DSNodes which may be
@@ -353,8 +383,7 @@
          I != E;
          ++I) {
       DSNode * Node = I;
-      if (Node->isExternalNode() || Node->isIncompleteNode() ||
-          Node->isUnknownNode()) {
+      if (Node->isExternalNode() || Node->isUnknownNode()) {
         GlobalHeapNodes.insert (Node);
       }
     }





More information about the llvm-commits mailing list