diff --git a/lib/Analysis/DataStructure/Local.cpp b/lib/Analysis/DataStructure/Local.cpp index ebac2690e70..27d5ce563aa 100644 --- a/lib/Analysis/DataStructure/Local.cpp +++ b/lib/Analysis/DataStructure/Local.cpp @@ -487,9 +487,12 @@ bool LocalDataStructures::run(Module &M) { // our memory... here... // void LocalDataStructures::releaseMemory() { - for (hash_map::iterator I = DSInfo.begin(), - E = DSInfo.end(); I != E; ++I) - delete I->second; + for (hash_map::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.