[llvm-commits] [poolalloc] r75174 - in /poolalloc/trunk: include/dsa/DataStructure.h include/poolalloc/PoolAllocate.h lib/DSA/Steensgaard.cpp lib/PoolAllocate/PAMultipleGlobalPool.cpp

Haohui Mai mai4 at uiuc.edu
Thu Jul 9 13:51:57 PDT 2009


Author: mai4
Date: Thu Jul  9 15:51:57 2009
New Revision: 75174

URL: http://llvm.org/viewvc/llvm-project?rev=75174&view=rev
Log:
In multiple global pools, also generate pools for globals graph.

Modified:
    poolalloc/trunk/include/dsa/DataStructure.h
    poolalloc/trunk/include/poolalloc/PoolAllocate.h
    poolalloc/trunk/lib/DSA/Steensgaard.cpp
    poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp

Modified: poolalloc/trunk/include/dsa/DataStructure.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DataStructure.h?rev=75174&r1=75173&r2=75174&view=diff

==============================================================================
--- poolalloc/trunk/include/dsa/DataStructure.h (original)
+++ poolalloc/trunk/include/dsa/DataStructure.h Thu Jul  9 15:51:57 2009
@@ -438,10 +438,10 @@
   /// getDSGraph - Return the data structure graph for the specified function.
   ///
   virtual DSGraph *getDSGraph(const Function &F) const {
-    return getResultGraph() ;
+    return getResultGraph();
   }
   
-	virtual bool hasDSGraph(const Function &F) const {
+  virtual bool hasDSGraph(const Function &F) const {
     return true;
   }
 

Modified: poolalloc/trunk/include/poolalloc/PoolAllocate.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/poolalloc/PoolAllocate.h?rev=75174&r1=75173&r2=75174&view=diff

==============================================================================
--- poolalloc/trunk/include/poolalloc/PoolAllocate.h (original)
+++ poolalloc/trunk/include/poolalloc/PoolAllocate.h Thu Jul  9 15:51:57 2009
@@ -479,6 +479,9 @@
   /// Mapping between DSNodes and Pool descriptors. For this pass, it is a
   /// one-to-one relationship.
   DenseMap<const DSNode *, GlobalVariable *> PoolMap;
+  void generatePool(unsigned RecSize, unsigned Align,
+                    Module& M, BasicBlock * InsertAtEnd, const DSNode * Node);
+
 public:
   static char ID;
   PoolAllocateMultipleGlobalPool(bool passAllArgs=false, bool SAFECode = true)

Modified: poolalloc/trunk/lib/DSA/Steensgaard.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Steensgaard.cpp?rev=75174&r1=75173&r2=75174&view=diff

==============================================================================
--- poolalloc/trunk/lib/DSA/Steensgaard.cpp (original)
+++ poolalloc/trunk/lib/DSA/Steensgaard.cpp Thu Jul  9 15:51:57 2009
@@ -27,9 +27,7 @@
 
 void
 SteensgaardDataStructures::releaseMemory() {
-  // Here we don't need to delete the result graph, because it aliases with the
-  // GlobalsGraph, which is deleted by DataStructures::releaseMemory().
-  ResultGraph = 0;
+  delete ResultGraph; ResultGraph = 0;
   DataStructures::releaseMemory();
 }
 
@@ -58,16 +56,15 @@
 bool
 SteensgaardDataStructures::runOnModuleInternal(Module &M) {
   assert(ResultGraph == 0 && "Result graph already allocated!");
-	
 
   // Create a new, empty, graph...
   ResultGraph = new DSGraph(GlobalECs, getTargetData());
-  ResultGraph->setGlobalsGraph(ResultGraph);
   ResultGraph->spliceFrom(DS->getGlobalsGraph());
 
-  // Assign the result graph to globals graph. It should be the same.
-  GlobalsGraph = ResultGraph;
-
+  // Get a copy for the globals graph.
+  GlobalsGraph = new DSGraph(ResultGraph, ResultGraph->getGlobalECs());
+  ResultGraph->setGlobalsGraph(GlobalsGraph);
+  
   // Loop over the rest of the module, merging graphs for non-external functions
   // into this graph.
   //
@@ -134,9 +131,8 @@
   ResultGraph->markIncompleteNodes(DSGraph::MarkFormalArgs | DSGraph::IgnoreGlobals);
 
   // Remove any nodes that are dead after all of the merging we have done...
-  // FIXME: We should be able to disable the globals graph for steens!
-  
-  //  ResultGraph->removeDeadNodes(DSGraph::KeepUnreachableGlobals);
+
+  ResultGraph->removeDeadNodes(DSGraph::KeepUnreachableGlobals);
 
   print(DOUT, &M);
   return false;

Modified: poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp?rev=75174&r1=75173&r2=75174&view=diff

==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp Thu Jul  9 15:51:57 2009
@@ -319,24 +319,43 @@
   DSGraph * G = DS->getResultGraph();
   for(DSGraph::node_const_iterator I = G->node_begin(), 
         E = G->node_end(); I != E; ++I) {
-  
+    generatePool(RecSize, Align, M, BB, I);
+  }
+
+  DSGraph * GG = DS->getGlobalsGraph();
+  for(DSGraph::node_const_iterator I = GG->node_begin(), 
+        E = GG->node_end(); I != E; ++I) {
+    generatePool(RecSize, Align, M, BB, I);
+  }
+
+  ReturnInst::Create(BB);
+}
+
+void
+PoolAllocateMultipleGlobalPool::generatePool(unsigned RecSize,
+                                             unsigned Align,
+                                             Module& M,
+                                             BasicBlock * InsertAtEnd, 
+                                             const DSNode * Node) {
+
+  if (!PoolMap[Node]) {
     GlobalVariable *GV =
-      new GlobalVariable(M,
-                         getPoolType(), false, GlobalValue::ExternalLinkage, 
-                         Constant::getNullValue(getPoolType()),
-                         "__poolalloc_GlobalPool");
+      new GlobalVariable
+      (M,
+       getPoolType(), false, GlobalValue::ExternalLinkage, 
+       Constant::getNullValue(getPoolType()),
+       "__poolalloc_GlobalPool");
 
     Value *ElSize = ConstantInt::get(Type::Int32Ty, RecSize);
     Value *AlignV = ConstantInt::get(Type::Int32Ty, Align);
     Value* Opts[3] = {GV, ElSize, AlignV};
     
-    CallInst::Create(PoolInit, Opts, Opts + 3, "", BB);
-    PoolMap[&(*I)] = GV;
+    CallInst::Create(PoolInit, Opts, Opts + 3, "", InsertAtEnd);
+    PoolMap[Node] = GV;
   }
-
-  ReturnInst::Create(BB);
 }
 
+
 Value *
 PoolAllocateMultipleGlobalPool::getGlobalPool (const DSNode * Node) {
   Value * Pool = PoolMap[Node];





More information about the llvm-commits mailing list