[llvm-commits] [poolalloc] r157075 - in /poolalloc/trunk: include/poolalloc/Heuristic.h lib/PoolAllocate/AllNodesHeuristic.cpp

John Criswell criswell at uiuc.edu
Fri May 18 14:31:45 PDT 2012


Author: criswell
Date: Fri May 18 16:31:45 2012
New Revision: 157075

URL: http://llvm.org/viewvc/llvm-project?rev=157075&view=rev
Log:
Moved the SCHeuristic to the poolalloc project and renamed it the AllNodes
heuristic (as it should pool allocate all nodes whether they are heap or not).
Also fixed the pass by not having it require the Heuristic analysis group
(which I guess was required in older versions of LLVM but not now).

Added:
    poolalloc/trunk/lib/PoolAllocate/AllNodesHeuristic.cpp
      - copied, changed from r157067, safecode/trunk/lib/Utility/SCPoolHeuristic.cpp
Modified:
    poolalloc/trunk/include/poolalloc/Heuristic.h

Modified: poolalloc/trunk/include/poolalloc/Heuristic.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/poolalloc/Heuristic.h?rev=157075&r1=157074&r2=157075&view=diff
==============================================================================
--- poolalloc/trunk/include/poolalloc/Heuristic.h (original)
+++ poolalloc/trunk/include/poolalloc/Heuristic.h Fri May 18 16:31:45 2012
@@ -140,7 +140,7 @@
   //
   // Description:
   //  This class provides a pool allocation heuristic that forces all DSNodes
-  //  to be pool allocated.
+  //  to be pool allocated (all heap nodes, I think).
   //
   class AllHeapNodesHeuristic: public Heuristic, public ModulePass {
   protected:
@@ -189,6 +189,60 @@
                                   std::vector<OnePool> &ResultPools);
   };
 
+  //
+  // Class: AllNodesHeuristic
+  //
+  // Description:
+  //  This class provides a pool allocation heuristic that forces all DSNodes
+  //  to be pool allocated.  Unlike the AllHeapNodes heuristic, this heuristic
+  //  will also pool allocate globals and stack objects.
+  //
+  class AllNodesHeuristic: public Heuristic, public ModulePass {
+    protected:
+      /// Find globally reachable DSNodes that need a pool
+      virtual void findGlobalPoolNodes (DSNodeSet_t & Nodes);
+
+      // Map of DSNodes to pool handles
+      std::map<const DSNode *, OnePool> PoolMap;
+
+    public:
+      // Pass ID
+      static char ID;
+
+      // Method used to implement analysis groups without C++ inheritance
+      virtual void *getAdjustedAnalysisPointer(AnalysisID ID) {
+        if (ID == &Heuristic::ID)
+          return (Heuristic*)this;
+        return this;
+      }
+
+      AllNodesHeuristic (char & IDp = ID): ModulePass (IDp) { }
+      virtual ~AllNodesHeuristic () {return;}
+      virtual bool runOnModule (Module & M);
+      virtual void releaseMemory ();
+      virtual const char * getPassName () const {
+        return "All Nodes (SAFECode) Pool Allocation Heurisitic";
+      }
+
+      virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+        // We require DSA while this pass is still responding to queries
+        AU.addRequiredTransitive<EQTDDataStructures>();
+
+        // This pass does not modify anything when it runs
+        AU.setPreservesAll();
+      }
+
+      /// Find DSNodes local to a function that need a pool
+      virtual void getLocalPoolNodes (const Function & F, DSNodeList_t & Nodes);
+
+      //
+      // Interface methods
+      //
+      virtual void AssignToPools (const DSNodeList_t & NodesToPA,
+                                  Function *F, DSGraph* G,
+                                  std::vector<OnePool> &ResultPools);
+  };
+
   //===-- AllButUnreachableFromMemoryHeuristic Heuristic ------------------===//
   //
   // This heuristic pool allocates everything possible into separate pools,

Copied: poolalloc/trunk/lib/PoolAllocate/AllNodesHeuristic.cpp (from r157067, safecode/trunk/lib/Utility/SCPoolHeuristic.cpp)
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/AllNodesHeuristic.cpp?p2=poolalloc/trunk/lib/PoolAllocate/AllNodesHeuristic.cpp&p1=safecode/trunk/lib/Utility/SCPoolHeuristic.cpp&r1=157067&r2=157075&rev=157075&view=diff
==============================================================================
--- safecode/trunk/lib/Utility/SCPoolHeuristic.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/AllNodesHeuristic.cpp Fri May 18 16:31:45 2012
@@ -1,4 +1,4 @@
-//===-- SCPoolHeuristic.cpp - SAFECode Pool Allocation Heuristic ----------===//
+//===-- AllNodesHeuristic.cpp - All Nodes (SAFECode) Heuristic ------------===//
 // 
 //                     The LLVM Compiler Infrastructure
 //
@@ -8,11 +8,14 @@
 //===----------------------------------------------------------------------===//
 //
 // This file implements a heuristic class that pool allocates a program
-// according to SAFECode's requirements.
+// according to SAFECode's requirements (with all nodes, including global and
+// stack, being placed in pools).
 //
 //===----------------------------------------------------------------------===//
 
-#include "safecode/SCPoolHeuristic.h"
+#include "poolalloc/Heuristic.h"
+
+#include "llvm/Module.h"
 
 using namespace llvm;
 using namespace PA;
@@ -68,7 +71,7 @@
 //          have global pools will be *added* to this container.
 //
 void
-SCHeuristic::findGlobalPoolNodes (DSNodeSet_t & Nodes) {
+AllNodesHeuristic::findGlobalPoolNodes (DSNodeSet_t & Nodes) {
   // Get the globals graph for the program.
   DSGraph* GG = Graphs->getGlobalsGraph();
 
@@ -176,7 +179,7 @@
 //  local pools created for them.
 //
 void
-SCHeuristic::getLocalPoolNodes (const Function & F, DSNodeList_t & Nodes) {
+AllNodesHeuristic::getLocalPoolNodes (const Function & F, DSNodeList_t & Nodes) {
   //
   // Get the DSGraph of the specified function.  If the DSGraph has no nodes,
   // then there is nothing we need to do.
@@ -223,7 +226,7 @@
 }
 
 void
-SCHeuristic::AssignToPools (const std::vector<const DSNode*> &NodesToPA,
+AllNodesHeuristic::AssignToPools (const std::vector<const DSNode*> &NodesToPA,
                             Function *F, DSGraph* G,
                             std::vector<OnePool> &ResultPools) {
   for (unsigned i = 0, e = NodesToPA.size(); i != e; ++i)
@@ -241,14 +244,14 @@
 //  needed.
 //
 void
-SCHeuristic::releaseMemory () {
+AllNodesHeuristic::releaseMemory () {
   PoolMap.clear();
   GlobalPoolNodes.clear();
   return;
 }
 
 bool
-SCHeuristic::runOnModule (Module & Module) {
+AllNodesHeuristic::runOnModule (Module & Module) {
   //
   // Remember which module we are analyzing.
   //
@@ -270,9 +273,9 @@
   return false;
 }
 
-static RegisterPass<SCHeuristic>
-X ("paheur-sc", "Pool allocate for SAFECode heuristic");
+static RegisterPass<AllNodesHeuristic>
+X ("paheur-sc", "Pool allocate all nodes for SAFECode");
 
 RegisterAnalysisGroup<Heuristic> Heuristic(X);
 
-char SCHeuristic::ID = 0;
+char AllNodesHeuristic::ID = 0;





More information about the llvm-commits mailing list