Do not delete the same graph multiple times when freeing memory if graphs are sharing
authorChris Lattner <sabre@nondot.org>
Mon, 30 Jun 2003 04:53:27 +0000 (04:53 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 30 Jun 2003 04:53:27 +0000 (04:53 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6998 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/DataStructure/Local.cpp

index ebac2690e709c1af6897d8ea9ce934a502db8cb5..27d5ce563aa70300554d3514a145102e97ee832b 100644 (file)
@@ -487,9 +487,12 @@ bool LocalDataStructures::run(Module &M) {
 // our memory... here...
 //
 void LocalDataStructures::releaseMemory() {
-  for (hash_map<const Function*, DSGraph*>::iterator I = DSInfo.begin(),
-         E = DSInfo.end(); I != E; ++I)
-    delete I->second;
+  for (hash_map<Function*, DSGraph*>::iterator I = DSInfo.begin(),
+         E = DSInfo.end(); I != E; ++I) {
+    I->second->getReturnNodes().erase(I->first);
+    if (I->second->getReturnNodes().empty())
+      delete I->second;
+  }
 
   // Empty map so next time memory is released, data structures are not
   // re-deleted.