The IfConverter::MergeBlocks method appears to be used only to merge a basic
authorBob Wilson <bob.wilson@apple.com>
Wed, 13 May 2009 23:54:13 +0000 (23:54 +0000)
committerBob Wilson <bob.wilson@apple.com>
Wed, 13 May 2009 23:54:13 +0000 (23:54 +0000)
block with its unique predecessor.  Change the code to assert if that is not
the case, instead of trying to handle situations where the block has
multiple predecessors.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71744 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/IfConversion.cpp

index 1d0887f843d8c663a8a8aeae3c2ac9e04c6e8fc7..3cb3f74bb133aa5008555ca0f719b2b39c540736 100644 (file)
@@ -1187,15 +1187,10 @@ void IfConverter::MergeBlocks(BBInfo &ToBBI, BBInfo &FromBBI) {
   ToBBI.BB->splice(ToBBI.BB->end(),
                    FromBBI.BB, FromBBI.BB->begin(), FromBBI.BB->end());
 
-  // Redirect all branches to FromBB to ToBB.
-  std::vector<MachineBasicBlock *> Preds(FromBBI.BB->pred_begin(),
-                                         FromBBI.BB->pred_end());
-  for (unsigned i = 0, e = Preds.size(); i != e; ++i) {
-    MachineBasicBlock *Pred = Preds[i];
-    if (Pred == ToBBI.BB)
-      continue;
-    Pred->ReplaceUsesOfBlockWith(FromBBI.BB, ToBBI.BB);
-  }
+  // This only works when FromBBI has no predecessors except ToBBI.
+  assert(FromBBI.BB->pred_size() == 1 &&
+         *FromBBI.BB->pred_begin() == ToBBI.BB &&
+         "if-converter not merging block into its unique predecessor");
  
   std::vector<MachineBasicBlock *> Succs(FromBBI.BB->succ_begin(),
                                          FromBBI.BB->succ_end());