Analyze has to be before checking the condition, obviously. Properly construct an...
authorJim Grosbach <grosbach@apple.com>
Mon, 16 Nov 2009 17:10:56 +0000 (17:10 +0000)
committerJim Grosbach <grosbach@apple.com>
Mon, 16 Nov 2009 17:10:56 +0000 (17:10 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@88917 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMConstantIslandPass.cpp

index 8279888dfacf71426585a367301fab8f1ad01e5e..4925a20455c89d3b8c80ab4094fffe85ef1da9c9 100644 (file)
@@ -1772,13 +1772,15 @@ AdjustJTTargetBlockForward(MachineBasicBlock *BB, MachineBasicBlock *JTBB)
   int Size = BBSizes[BBI];
   MachineBasicBlock *TBB = 0, *FBB = 0;
   SmallVector<MachineOperand, 4> Cond;
-  // If the block is small and ends in an unconditional branch, move it.
-  if (Size < 50 && Cond.empty()) {
-    // If the block terminator isn't analyzable, don't try to move the block
-    if (TII->AnalyzeBranch(*BB, TBB, FBB, Cond))
-      return NULL;
 
-    MachineFunction::iterator OldPrior = prior(BB);
+  // If the block terminator isn't analyzable, don't try to move the block
+  if (TII->AnalyzeBranch(*BB, TBB, FBB, Cond))
+    return NULL;
+
+  // If the block is small and ends in an unconditional branch, move it.
+  if (Size < 50 && Cond.empty() && BB != MF.begin()) {
+    MachineFunction::iterator BBi = BB;
+    MachineFunction::iterator OldPrior = prior(BBi);
     BB->moveAfter(JTBB);
     OldPrior->updateTerminator();
     BB->updateTerminator();