[llvm-commits] [llvm] r39782 - in /llvm/trunk/lib/Target/ARM: ARMConstantIslandPass.cpp ARMInstrInfo.cpp

Dale Johannesen dalej at apple.com
Thu Jul 12 09:45:36 PDT 2007


Author: johannes
Date: Thu Jul 12 11:45:35 2007
New Revision: 39782

URL: http://llvm.org/viewvc/llvm-project?rev=39782&view=rev
Log:
ARM:  make branch folder remove unconditional branches
following jump tables that it earlier inserted.  This
would be OK on other targets but is needed for correctness
only on ARM (constant islands needs to find jump tables).


Modified:
    llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp
    llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp

Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=39782&r1=39781&r2=39782&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Thu Jul 12 11:45:35 2007
@@ -740,14 +740,11 @@
             delta -= 2;
           }
         }
-        // Thumb jump tables require padding.  They can be at the end, or
-        // followed by an unconditional branch.
+        // Thumb jump tables require padding.  They should be at the end;
+        // following unconditional branches are removed by AnalyzeBranch.
         MachineInstr *ThumbJTMI = NULL;
         if (prior(MBB->end())->getOpcode() == ARM::tBR_JTr)
           ThumbJTMI = prior(MBB->end());
-        else if (prior(MBB->end()) != MBB->begin() &&
-                prior(prior(MBB->end()))->getOpcode() == ARM::tBR_JTr)
-          ThumbJTMI = prior(prior(MBB->end()));
         if (ThumbJTMI) {
           unsigned newMIOffset = GetOffsetOf(ThumbJTMI);
           unsigned oldMIOffset = newMIOffset - delta;

Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp?rev=39782&r1=39781&r2=39782&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp Thu Jul 12 11:45:35 2007
@@ -350,8 +350,8 @@
     return false;
   }
   
-  // If the block ends with two B's or tB's, handle it.  The second one is not
-  // executed, so remove it.
+  // If the block ends with two unconditional branches, handle it.  The second 
+  // one is not executed, so remove it.
   if ((SecondLastOpc == ARM::B || SecondLastOpc==ARM::tB) &&
       (LastOpc == ARM::B || LastOpc == ARM::tB)) {
     TBB = SecondLastInst->getOperand(0).getMachineBasicBlock();
@@ -360,6 +360,17 @@
     return false;
   }
 
+  // Likewise if it ends with a branch table followed by an unconditional branch.
+  // The branch folder can create these, and we must get rid of them for
+  // correctness of Thumb constant islands.
+  if ((SecondLastOpc == ARM::BR_JTr || SecondLastOpc==ARM::BR_JTm ||
+       SecondLastOpc == ARM::BR_JTadd || SecondLastOpc==ARM::tBR_JTr) &&
+      (LastOpc == ARM::B || LastOpc == ARM::tB)) {
+    I = LastInst;
+    I->eraseFromParent();
+    return true;
+  } 
+
   // Otherwise, can't handle this.
   return true;
 }





More information about the llvm-commits mailing list