[llvm-commits] CVS: llvm/lib/CodeGen/BranchFolding.cpp

David Greene greened at obbligato.org
Thu Jun 28 19:45:46 PDT 2007



Changes in directory llvm/lib/CodeGen:

BranchFolding.cpp updated: 1.68 -> 1.69
---
Log message:

Fix misue of iterator pointing to erased object.  Uncovered by
_GLIBCXX_DEBUG.


---
Diffs of the changes:  (+5 -4)

 BranchFolding.cpp |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)


Index: llvm/lib/CodeGen/BranchFolding.cpp
diff -u llvm/lib/CodeGen/BranchFolding.cpp:1.68 llvm/lib/CodeGen/BranchFolding.cpp:1.69
--- llvm/lib/CodeGen/BranchFolding.cpp:1.68	Mon Jun 18 17:43:31 2007
+++ llvm/lib/CodeGen/BranchFolding.cpp	Thu Jun 28 21:45:24 2007
@@ -978,17 +978,18 @@
           }
 
           // 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);
             }
           }
 






More information about the llvm-commits mailing list