When comparing DominanceFrontier's, advance iterators

before erasing nodes, not after.  Otherwise dom frontier
checking reads from freed memory.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72168 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan Sands 2009-05-20 15:12:01 +00:00
parent 9b2818d207
commit 0a8fe7a245

View File

@ -968,8 +968,8 @@ public:
tmpSet.insert(*I);
for (DomSetType::const_iterator I = DS1.begin(),
E = DS1.end(); I != E; ++I) {
BasicBlock *Node = *I;
E = DS1.end(); I != E; ) {
BasicBlock *Node = *I++;
if (tmpSet.erase(Node) == 0)
// Node is in DS1 but not in DS2.
@ -993,7 +993,7 @@ public:
tmpFrontiers.insert(std::make_pair(I->first, I->second));
for (DomSetMapType::iterator I = tmpFrontiers.begin(),
E = tmpFrontiers.end(); I != E; ++I) {
E = tmpFrontiers.end(); I != E; ) {
BasicBlock *Node = I->first;
const_iterator DFI = find(Node);
if (DFI == end())
@ -1002,6 +1002,7 @@ public:
if (compareDomSet(I->second, DFI->second))
return true;
++I;
tmpFrontiers.erase(Node);
}