summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/BranchFolding.cpp
diff options
context:
space:
mode:
authorDavid Greene <greened@obbligato.org>2007-06-29 02:45:24 +0000
committerDavid Greene <greened@obbligato.org>2007-06-29 02:45:24 +0000
commit451d1a6ecd3e4d56abf17ec25c818c2fe3c25984 (patch)
tree87032df7deac842e4fac562253e715409a861efb /llvm/lib/CodeGen/BranchFolding.cpp
parent9feb7f5846cce0d40db9e4689f8178f5fa570bc3 (diff)
downloadbcm5719-llvm-451d1a6ecd3e4d56abf17ec25c818c2fe3c25984.tar.gz
bcm5719-llvm-451d1a6ecd3e4d56abf17ec25c818c2fe3c25984.zip
Fix misue of iterator pointing to erased object. Uncovered by
_GLIBCXX_DEBUG. llvm-svn: 37793
Diffstat (limited to 'llvm/lib/CodeGen/BranchFolding.cpp')
-rw-r--r--llvm/lib/CodeGen/BranchFolding.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp
index ad7d5fcc332..d0dcc708d06 100644
--- a/llvm/lib/CodeGen/BranchFolding.cpp
+++ b/llvm/lib/CodeGen/BranchFolding.cpp
@@ -978,17 +978,18 @@ void BranchFolder::OptimizeBlock(MachineBasicBlock *MBB) {
}
// Iterate through all the predecessors, revectoring each in-turn.
- MachineBasicBlock::pred_iterator PI = MBB->pred_begin();
+ size_t PI = 0;
bool DidChange = false;
bool HasBranchToSelf = false;
- while (PI != MBB->pred_end()) {
- if (*PI == MBB) {
+ while(PI != MBB->pred_size()) {
+ MachineBasicBlock *PMBB = *(MBB->pred_begin() + PI);
+ if (PMBB == MBB) {
// If this block has an uncond branch to itself, leave it.
++PI;
HasBranchToSelf = true;
} else {
DidChange = true;
- (*PI)->ReplaceUsesOfBlockWith(MBB, CurTBB);
+ PMBB->ReplaceUsesOfBlockWith(MBB, CurTBB);
}
}
OpenPOWER on IntegriCloud