[llvm-commits] [llvm] r51485 - /llvm/trunk/lib/CodeGen/BranchFolding.cpp
Dale Johannesen
dalej at apple.com
Fri May 23 10:19:02 PDT 2008
Author: johannes
Date: Fri May 23 12:19:02 2008
New Revision: 51485
URL: http://llvm.org/viewvc/llvm-project?rev=51485&view=rev
Log:
Rewrite a loop to avoid using iterators pointing to
elements that have been erased. Based on a patch
by Nicolas Capens.
Modified:
llvm/trunk/lib/CodeGen/BranchFolding.cpp
Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=51485&r1=51484&r2=51485&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original)
+++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Fri May 23 12:19:02 2008
@@ -529,18 +529,20 @@
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
More information about the llvm-commits
mailing list