diff options
author | David Greene <greened@obbligato.org> | 2007-06-29 02:45:24 +0000 |
---|---|---|
committer | David Greene <greened@obbligato.org> | 2007-06-29 02:45:24 +0000 |
commit | 8a46d342d8cbca7c9c7be6c66007d41329babad0 (patch) | |
tree | eabf5286e6dbaaad09b1bf5847e705a640d2cd8c /lib/CodeGen/BranchFolding.cpp | |
parent | 6c631988c724b58a69c49af782d1eec79e46d29f (diff) |
Fix misue of iterator pointing to erased object. Uncovered by
_GLIBCXX_DEBUG.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37793 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/BranchFolding.cpp')
-rw-r--r-- | lib/CodeGen/BranchFolding.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/CodeGen/BranchFolding.cpp b/lib/CodeGen/BranchFolding.cpp index ad7d5fcc33..d0dcc708d0 100644 --- a/lib/CodeGen/BranchFolding.cpp +++ b/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); } } |