Use MachineBasicBlock::transferSuccessors.
authorDan Gohman <gohman@apple.com>
Sat, 21 Jun 2008 20:21:19 +0000 (20:21 +0000)
committerDan Gohman <gohman@apple.com>
Sat, 21 Jun 2008 20:21:19 +0000 (20:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52594 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/Alpha/AlphaISelLowering.cpp
lib/Target/PowerPC/PPCISelLowering.cpp
lib/Target/Sparc/SparcISelLowering.cpp

index 86fc4886fdb93719460755bf6cc2120c95bba69f..dd001b4f168779826ea9a0dd39e5fdaf01b8c7bf 100644 (file)
@@ -662,11 +662,7 @@ AlphaTargetLowering::EmitInstrWithCustomInserter(MachineInstr *MI,
   MachineBasicBlock *llscMBB = new MachineBasicBlock(LLVM_BB);
   MachineBasicBlock *sinkMBB = new MachineBasicBlock(LLVM_BB);
 
-  for(MachineBasicBlock::succ_iterator i = thisMBB->succ_begin(), 
-        e = thisMBB->succ_end(); i != e; ++i)
-    sinkMBB->addSuccessor(*i);
-  while(!thisMBB->succ_empty())
-    thisMBB->removeSuccessor(thisMBB->succ_begin());
+  sinkMBB->transferSuccessors(thisMBB);
 
   MachineFunction *F = BB->getParent();
   F->getBasicBlockList().insert(It, llscMBB);
index beb03d0e5980fed72e63cbc3de58c1786b1dc053..000cfc3f2cd45082d5f79bae8626b484720eac9b 100644 (file)
@@ -4018,15 +4018,10 @@ PPCTargetLowering::EmitInstrWithCustomInserter(MachineInstr *MI,
   MachineFunction *F = BB->getParent();
   F->getBasicBlockList().insert(It, copy0MBB);
   F->getBasicBlockList().insert(It, sinkMBB);
-  // Update machine-CFG edges by first adding all successors of the current
+  // Update machine-CFG edges by transferring all successors of the current
   // block to the new block which will contain the Phi node for the select.
-  for(MachineBasicBlock::succ_iterator i = BB->succ_begin(), 
-      e = BB->succ_end(); i != e; ++i)
-    sinkMBB->addSuccessor(*i);
-  // Next, remove all successors of the current block, and add the true
-  // and fallthrough blocks as its successors.
-  while(!BB->succ_empty())
-    BB->removeSuccessor(BB->succ_begin());
+  sinkMBB->transferSuccessors(BB);
+  // Next, add the true and fallthrough blocks as its successors.
   BB->addSuccessor(copy0MBB);
   BB->addSuccessor(sinkMBB);
   
index 89172fcb5278b93437af24673b2031bf8c0e2291..5c0617438c4becbf94557f5ec663c5ac2db5fa5b 100644 (file)
@@ -920,15 +920,10 @@ SparcTargetLowering::EmitInstrWithCustomInserter(MachineInstr *MI,
   MachineFunction *F = BB->getParent();
   F->getBasicBlockList().insert(It, copy0MBB);
   F->getBasicBlockList().insert(It, sinkMBB);
-  // Update machine-CFG edges by first adding all successors of the current
+  // Update machine-CFG edges by transferring all successors of the current
   // block to the new block which will contain the Phi node for the select.
-  for(MachineBasicBlock::succ_iterator i = BB->succ_begin(), 
-      e = BB->succ_end(); i != e; ++i)
-    sinkMBB->addSuccessor(*i);
-  // Next, remove all successors of the current block, and add the true
-  // and fallthrough blocks as its successors.
-  while(!BB->succ_empty())
-    BB->removeSuccessor(BB->succ_begin());
+  sinkMBB->transferSuccessors(BB);
+  // Next, add the true and fallthrough blocks as its successors.
   BB->addSuccessor(copy0MBB);
   BB->addSuccessor(sinkMBB);