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
This commit is contained in:
Nuno Lopes 2008-10-10 16:25:50 +00:00
parent 2312022972
commit 7cdd9ee088

View File

@ -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();
}