summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/ARM/ARMInstrInfo.cpp
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2007-07-12 16:45:35 +0000
committerDale Johannesen <dalej@apple.com>2007-07-12 16:45:35 +0000
commit85ee72f7ba48a1657b4443f3326267c7544b3468 (patch)
treeceddb59343bf1c6f024086670a9f709e4cfc63ed /llvm/lib/Target/ARM/ARMInstrInfo.cpp
parentffc337b1e168d8f6daa2a077e3ea5177ca36699d (diff)
downloadbcm5719-llvm-85ee72f7ba48a1657b4443f3326267c7544b3468.tar.gz
bcm5719-llvm-85ee72f7ba48a1657b4443f3326267c7544b3468.zip
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). llvm-svn: 39782
Diffstat (limited to 'llvm/lib/Target/ARM/ARMInstrInfo.cpp')
-rw-r--r--llvm/lib/Target/ARM/ARMInstrInfo.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/llvm/lib/Target/ARM/ARMInstrInfo.cpp b/llvm/lib/Target/ARM/ARMInstrInfo.cpp
index f4b4dbe2e3a..b404ec078e5 100644
--- a/llvm/lib/Target/ARM/ARMInstrInfo.cpp
+++ b/llvm/lib/Target/ARM/ARMInstrInfo.cpp
@@ -350,8 +350,8 @@ bool ARMInstrInfo::AnalyzeBranch(MachineBasicBlock &MBB,MachineBasicBlock *&TBB,
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 @@ bool ARMInstrInfo::AnalyzeBranch(MachineBasicBlock &MBB,MachineBasicBlock *&TBB,
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;
}
OpenPOWER on IntegriCloud