mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-12 22:28:22 +00:00
Rewrite a loop to avoid using iterators pointing to
elements that have been erased. Based on a patch by Nicolas Capens. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51485 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b737a64a85
commit
679860e31b
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user