diff options
author | Nuno Lopes <nunoplopes@sapo.pt> | 2008-10-10 16:25:50 +0000 |
---|---|---|
committer | Nuno Lopes <nunoplopes@sapo.pt> | 2008-10-10 16:25:50 +0000 |
commit | 7cdd9ee088343026dd79b4b35da293a6d49d7044 (patch) | |
tree | 29727d9bd66ba1a7b3d45f6baa899b0d7684991d /lib/Transforms | |
parent | 2312022972ff86cecbf3cb510b3a63b61aa5e192 (diff) |
fix memleak by cleaning the global sets on pass exit
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57353 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/GVN.cpp | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp index 0e1900cbe0..2d0a99b482 100644 --- a/lib/Transforms/Scalar/GVN.cpp +++ b/lib/Transforms/Scalar/GVN.cpp @@ -739,6 +739,7 @@ namespace { bool performPRE(Function& F); Value* lookupNumber(BasicBlock* BB, uint32_t num); bool mergeBlockIntoPredecessor(BasicBlock* BB); + void cleanupGlobalSets(); }; char GVN::ID = 0; @@ -1129,7 +1130,9 @@ bool GVN::runOnFunction(Function& F) { changed |= PREChanged; } } - + + cleanupGlobalSets(); + return changed; } @@ -1332,16 +1335,9 @@ bool GVN::performPRE(Function& F) { // iterateOnFunction - Executes one iteration of GVN bool GVN::iterateOnFunction(Function &F) { - // Clean out global sets from any previous functions - VN.clear(); - phiMap.clear(); - - for (DenseMap<BasicBlock*, ValueNumberScope*>::iterator - I = localAvail.begin(), E = localAvail.end(); I != E; ++I) - delete I->second; - localAvail.clear(); - - DominatorTree &DT = getAnalysis<DominatorTree>(); + DominatorTree &DT = getAnalysis<DominatorTree>(); + + cleanupGlobalSets(); // Top-down walk of the dominator tree bool changed = false; @@ -1351,3 +1347,13 @@ bool GVN::iterateOnFunction(Function &F) { return changed; } + +void GVN::cleanupGlobalSets() { + VN.clear(); + phiMap.clear(); + + for (DenseMap<BasicBlock*, ValueNumberScope*>::iterator + I = localAvail.begin(), E = localAvail.end(); I != E; ++I) + delete I->second; + localAvail.clear(); +} |