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

Chris Lattner lattner at cs.uiuc.edu
Mon Feb 14 15:09:08 PST 2005



Changes in directory llvm-poolalloc/lib/PoolAllocate:

PoolAllocate.cpp updated: 1.102 -> 1.103
PoolAllocate.h updated: 1.39 -> 1.40
---
Log message:

Change a #define used to change pool allocator behavior into something that
can be selected based on AU.addRequired.


---
Diffs of the changes:  (+25 -8)

 PoolAllocate.cpp |   14 ++++++--------
 PoolAllocate.h   |   19 +++++++++++++++++++
 2 files changed, 25 insertions(+), 8 deletions(-)


Index: llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp
diff -u llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.102 llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.103
--- llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.102	Wed Feb  9 13:04:48 2005
+++ llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp	Mon Feb 14 17:08:52 2005
@@ -34,16 +34,13 @@
 using namespace llvm;
 using namespace PA;
 
-// PASS_ALL_ARGUMENTS - If this is set to true, pass in pool descriptors for all
-// DSNodes in a function, even if there are no allocations or frees in it.  This
-// is useful for SafeCode.
-#define PASS_ALL_ARGUMENTS 0
-
 const Type *PoolAllocate::PoolDescPtrTy = 0;
 
 namespace {
   RegisterOpt<PoolAllocate>
   X("poolalloc", "Pool allocate disjoint data structures");
+  RegisterPass<PoolAllocatePassAllPools>
+  Y("poolalloc-passing-all-pools", "Pool allocate disjoint data structures");
 
   Statistic<> NumArgsAdded("poolalloc", "Number of function arguments added");
   Statistic<> NumCloned   ("poolalloc", "Number of functions cloned");
@@ -232,7 +229,8 @@
 }
 
 static void MarkNodesWhichMustBePassedIn(hash_set<const DSNode*> &MarkedNodes,
-                                         Function &F, DSGraph &G) {
+                                         Function &F, DSGraph &G,
+                                         bool PassAllArguments) {
   // Mark globals and incomplete nodes as live... (this handles arguments)
   if (F.getName() != "main") {
     // All DSNodes reachable from arguments must be passed in.
@@ -261,7 +259,7 @@
   for (hash_set<const DSNode*>::iterator I = MarkedNodes.begin(),
          E = MarkedNodes.end(); I != E; ) {
     const DSNode *N = *I++;
-    if ((!N->isHeapNode() && !PASS_ALL_ARGUMENTS) || NodesFromGlobals.count(N))
+    if ((!N->isHeapNode() && !PassAllArguments) || NodesFromGlobals.count(N))
       MarkedNodes.erase(N);
   }
 }
@@ -284,7 +282,7 @@
   // Find DataStructure nodes which are allocated in pools non-local to the
   // current function.  This set will contain all of the DSNodes which require
   // pools to be passed in from outside of the function.
-  MarkNodesWhichMustBePassedIn(MarkedNodes, F, G);
+  MarkNodesWhichMustBePassedIn(MarkedNodes, F, G, PassAllArguments);
   
   FI.ArgNodes.insert(FI.ArgNodes.end(), MarkedNodes.begin(), MarkedNodes.end());
 }


Index: llvm-poolalloc/lib/PoolAllocate/PoolAllocate.h
diff -u llvm-poolalloc/lib/PoolAllocate/PoolAllocate.h:1.39 llvm-poolalloc/lib/PoolAllocate/PoolAllocate.h:1.40
--- llvm-poolalloc/lib/PoolAllocate/PoolAllocate.h:1.39	Wed Feb  9 13:04:47 2005
+++ llvm-poolalloc/lib/PoolAllocate/PoolAllocate.h	Mon Feb 14 17:08:53 2005
@@ -93,6 +93,12 @@
 /// PoolAllocate - The main pool allocation pass
 ///
 class PoolAllocate : public ModulePass {
+  /// PassAllArguments - If set to true, we should pass pool descriptor
+  /// arguments into any function that loads or stores to a pool, in addition to
+  /// those functions that allocate or deallocate.  See also the
+  /// PoolAllocatePassAllPools pass below.
+  bool PassAllArguments;
+
   Module *CurModule;
   PA::EquivClassGraphs *ECGraphs;
 
@@ -112,6 +118,9 @@
   std::map<const DSNode*, Value*> GlobalNodes;
 
  public:
+  PoolAllocate(bool passAllArguments = false) 
+    : PassAllArguments(passAllArguments) {}
+
   bool runOnModule(Module &M);
   
   virtual void getAnalysisUsage(AnalysisUsage &AU) const;
@@ -234,6 +243,16 @@
   void CalculateLivePoolFreeBlocks(std::set<BasicBlock*> &LiveBlocks,Value *PD);
 };
 
+
+/// PoolAllocatePassAllPools - This class is the same as the pool allocator,
+/// except that it passes pool descriptors into functions that do not do
+/// allocations or deallocations.  This is needed by the pointer compression
+/// pass, which requires a pool descriptor to be available for a pool if any
+/// load or store to that pool is performed.
+struct PoolAllocatePassAllPools : public PoolAllocate {
+  PoolAllocatePassAllPools() : PoolAllocate(true) {}
+};
+
 }
 
 #endif






More information about the llvm-commits mailing list