1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00

Rewrite a loop to avoid using iterators pointing to

elements that have been erased.  Based on a patch
by Nicolas Capens.

llvm-svn: 51485
This commit is contained in:
Dale Johannesen 2008-05-23 17:19:02 +00:00
parent 19aa4b76fc
commit 3d9a178ff9

View File

@ -529,18 +529,20 @@ unsigned BranchFolder::ComputeSameTails(unsigned CurHash,
void BranchFolder::RemoveBlocksWithHash(unsigned CurHash,
MachineBasicBlock* SuccBB,
MachineBasicBlock* PredBB) {
for (MPIterator CurMPIter = prior(MergePotentials.end()),
B = MergePotentials.begin();
MPIterator CurMPIter, B;
for (CurMPIter = prior(MergePotentials.end()), B = MergePotentials.begin();
CurMPIter->first==CurHash;
--CurMPIter) {
// Put the unconditional branch back, if we need one.
MachineBasicBlock *CurMBB = CurMPIter->second;
if (SuccBB && CurMBB != PredBB)
FixTail(CurMBB, SuccBB, TII);
MergePotentials.erase(CurMPIter);
if (CurMPIter==B)
if (CurMPIter==B)
break;
}
if (CurMPIter->first!=CurHash)
CurMPIter++;
MergePotentials.erase(CurMPIter, MergePotentials.end());
}
/// CreateCommonTailOnlyBlock - None of the blocks to be tail-merged consist