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

Haohui Mai mai4 at uiuc.edu
Tue Jul 7 09:58:22 PDT 2009


Author: mai4
Date: Tue Jul  7 11:58:21 2009
New Revision: 74916

URL: http://llvm.org/viewvc/llvm-project?rev=74916&view=rev
Log:
Don't delete ResultsGraph in SteensgaardDataStructures::releaseMyMemory() during
destruction since it is deleted by DataStructures::releaseMemory().

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

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

==============================================================================
--- poolalloc/trunk/include/dsa/DataStructure.h (original)
+++ poolalloc/trunk/include/dsa/DataStructure.h Tue Jul  7 11:58:21 2009
@@ -140,13 +140,13 @@
 
   virtual void releaseMemory();
 
-  bool hasDSGraph(const Function &F) const {
+  virtual bool hasDSGraph(const Function &F) const {
     return DSInfo.find(&F) != DSInfo.end();
   }
 
   /// getDSGraph - Return the data structure graph for the specified function.
   ///
-  DSGraph *getDSGraph(const Function &F) const {
+  virtual DSGraph *getDSGraph(const Function &F) const {
     hash_map<const Function*, DSGraph*>::const_iterator I = DSInfo.find(&F);
     assert(I != DSInfo.end() && "Function not in module!");
     return I->second;
@@ -427,7 +427,7 @@
     ResultGraph(NULL) {}
   ~SteensgaardDataStructures();
   virtual bool runOnModule(Module &M);
-  virtual void releaseMyMemory();
+  virtual void releaseMemory();
 
   virtual void getAnalysisUsage(AnalysisUsage &AU) const {
     AU.addRequired<StdLibDataStructures>();
@@ -436,8 +436,12 @@
   
   /// getDSGraph - Return the data structure graph for the specified function.
   ///
-  DSGraph *getDSGraph(const Function &F) const {
-    return ResultGraph;
+  virtual DSGraph *getDSGraph(const Function &F) const {
+    return getResultGraph() ;
+  }
+  
+	virtual bool hasDSGraph(const Function &F) const {
+    return true;
   }
 
   /// getDSGraph - Return the data structure graph for the whole program.

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

==============================================================================
--- poolalloc/trunk/lib/DSA/Steensgaard.cpp (original)
+++ poolalloc/trunk/lib/DSA/Steensgaard.cpp Tue Jul  7 11:58:21 2009
@@ -23,15 +23,14 @@
 
 using namespace llvm;
 
-SteensgaardDataStructures::~SteensgaardDataStructures() {
-  releaseMyMemory();
-  assert(ResultGraph == 0 && "releaseMemory not called?");
-}
+SteensgaardDataStructures::~SteensgaardDataStructures() { }
 
 void
-SteensgaardDataStructures::releaseMyMemory() {
-  delete ResultGraph;
+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;
+	DataStructures::releaseMemory();
 }
 
 // print - Implement the Pass::print method...
@@ -133,6 +132,8 @@
   
   ResultGraph->removeDeadNodes(DSGraph::KeepUnreachableGlobals);
 
+	// Assign the result graph to globals graph. It should be the same.
+	GlobalsGraph = ResultGraph;
   print(DOUT, &M);
   return false;
 }





More information about the llvm-commits mailing list