Fix a memory leak.
authorEvan Cheng <evan.cheng@apple.com>
Thu, 6 Sep 2007 01:07:24 +0000 (01:07 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Thu, 6 Sep 2007 01:07:24 +0000 (01:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41739 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/LiveInterval.cpp
lib/CodeGen/LiveIntervalAnalysis.cpp

index 4d38f0adcfa241abd7a17a8015e3dd07540a618c..9b4872d830847939cda0c9cc6c8c79bde05fddfe 100644 (file)
@@ -476,7 +476,9 @@ void LiveInterval::MergeValueNumberInto(VNInfo *V1, VNInfo *V2) {
   // ~1U so it can be nuked later.
   if (V1->id == getNumValNums()-1) {
     do {
+      VNInfo *VNI = valnos.back();
       valnos.pop_back();
+      VNI->~VNInfo();
     } while (valnos.back()->def == ~1U);
   } else {
     V1->def = ~1U;
index 2f93b76948547bf87318ef7cea0c97c9bb131626..3d324b7bfc660fb3fa709201c281aa416d0b2725 100644 (file)
@@ -62,10 +62,11 @@ void LiveIntervals::getAnalysisUsage(AnalysisUsage &AU) const {
 }
 
 void LiveIntervals::releaseMemory() {
-  VNInfoAllocator.Reset();
   mi2iMap_.clear();
   i2miMap_.clear();
   r2iMap_.clear();
+  // Release VNInfo memroy regions after all VNInfo objects are dtor'd.
+  VNInfoAllocator.Reset();
   for (unsigned i = 0, e = ClonedMIs.size(); i != e; ++i)
     delete ClonedMIs[i];
 }