Use a worklist to prevent the iterator from becoming invalidated because of the ...
authorBill Wendling <isanbard@gmail.com>
Wed, 26 Oct 2011 07:16:18 +0000 (07:16 +0000)
committerBill Wendling <isanbard@gmail.com>
Wed, 26 Oct 2011 07:16:18 +0000 (07:16 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143018 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMISelLowering.cpp

index fa5f0be1d748546bdb46e671bf1b08e395a3f178..d7aca309807ed53724c8d4ac3094a808a9a249be 100644 (file)
@@ -5996,9 +5996,10 @@ EmitSjLjDispatchBlock(MachineInstr *MI, MachineBasicBlock *MBB) const {
 
     // Remove the landing pad successor from the invoke block and replace it
     // with the new dispatch block.
-    for (MachineBasicBlock::succ_iterator
-           SI = BB->succ_begin(), SE = BB->succ_end(); SI != SE; ++SI) {
-      MachineBasicBlock *SMBB = *SI;
+    SmallVector<MachineBasicBlock*, 4> Successors(BB->succ_begin(),
+                                                  BB->succ_end());
+    while (!Successors.empty()) {
+      MachineBasicBlock *SMBB = Successors.pop_back_val();
       if (SMBB->isLandingPad()) {
         BB->removeSuccessor(SMBB);
         MBBLPads.push_back(SMBB);