llvm::SplitEdge should refuse to split an edge from an indirectbr.
authorChris Lattner <sabre@nondot.org>
Sat, 31 Oct 2009 22:04:43 +0000 (22:04 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 31 Oct 2009 22:04:43 +0000 (22:04 +0000)
Fix CodeGenPrepare to not try to split edges from indirectbr.

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

lib/Transforms/Scalar/CodeGenPrepare.cpp
lib/Transforms/Utils/BasicBlockUtils.cpp

index 42209b8cbe2d5be2410a97408a358ed2d06a2a8d..9ca90c333af9238ea8cbb16d80060a80aa3ec682 100644 (file)
@@ -318,6 +318,7 @@ static void SplitEdgeNicely(TerminatorInst *TI, unsigned SuccNum,
     if (Invoke->getSuccessor(1) == Dest)
       return;
   }
+  
 
   // As a hack, never split backedges of loops.  Even though the copy for any
   // PHIs inserted on the backedge would be dead for exits from the loop, we
@@ -852,7 +853,7 @@ bool CodeGenPrepare::OptimizeBlock(BasicBlock &BB) {
 
   // Split all critical edges where the dest block has a PHI.
   TerminatorInst *BBTI = BB.getTerminator();
-  if (BBTI->getNumSuccessors() > 1) {
+  if (BBTI->getNumSuccessors() > 1 && !isa<IndirectBrInst>(BBTI)) {
     for (unsigned i = 0, e = BBTI->getNumSuccessors(); i != e; ++i) {
       BasicBlock *SuccBB = BBTI->getSuccessor(i);
       if (isa<PHINode>(SuccBB->begin()) && isCriticalEdge(BBTI, i, true))
index f3c175469ac1a7b3f27db050376640facdc8faaf..1f9a2031f3b524feb95c203675027c8c5313a7da 100644 (file)
@@ -271,6 +271,8 @@ void llvm::RemoveSuccessor(TerminatorInst *TI, unsigned SuccNum) {
 /// SplitEdge -  Split the edge connecting specified block. Pass P must 
 /// not be NULL. 
 BasicBlock *llvm::SplitEdge(BasicBlock *BB, BasicBlock *Succ, Pass *P) {
+  assert(!isa<IndirectBrInst>(BB->getTerminator()) &&
+         "Cannot split an edge from an IndirectBrInst");
   TerminatorInst *LatchTerm = BB->getTerminator();
   unsigned SuccNum = 0;
 #ifndef NDEBUG