Use the transferSuccessors helper function.
authorDan Gohman <gohman@apple.com>
Thu, 19 Jun 2008 17:22:29 +0000 (17:22 +0000)
committerDan Gohman <gohman@apple.com>
Thu, 19 Jun 2008 17:22:29 +0000 (17:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52495 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/BranchFolding.cpp

index e67339ab3860066f1d86587615c327b36a7cb7ac..f629ae75f3aee9bf0eb2e163529b1960039e8235 100644 (file)
@@ -381,11 +381,7 @@ MachineBasicBlock *BranchFolder::SplitMBBAt(MachineBasicBlock &CurMBB,
   CurMBB.getParent()->getBasicBlockList().insert(++MBBI, NewMBB);
 
   // Move all the successors of this block to the specified block.
-  while (!CurMBB.succ_empty()) {
-    MachineBasicBlock *S = *(CurMBB.succ_end()-1);
-    NewMBB->addSuccessor(S);
-    CurMBB.removeSuccessor(S);
-  }
+  NewMBB->transferSuccessors(&CurMBB);
  
   // Add an edge from CurMBB to NewMBB for the fall-through.
   CurMBB.addSuccessor(NewMBB);