Fix <rdar://problem/9476260> by having tail calls always generate 32-bit branches

in Darwin Thumb2 code. Tail calls are already disabled on Thumb1.

llvm-svn: 131894
This commit is contained in:
Cameron Zwarich 2011-05-23 01:57:17 +00:00
parent bee56202ba
commit 5a416bda73
2 changed files with 11 additions and 6 deletions

View File

@ -1832,7 +1832,9 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
case ARM::tTAILJMPdND: {
MCInst TmpInst, TmpInst2;
LowerARMMachineInstrToMCInst(MI, TmpInst2, *this);
TmpInst.setOpcode(ARM::tB);
// The Darwin toolchain doesn't support tail call relocations of 16-bit
// branches.
TmpInst.setOpcode(Opc == ARM::tTAILJMPd ? ARM::t2B : ARM::tB);
TmpInst.addOperand(TmpInst2.getOperand(0));
OutStreamer.AddComment("TAILCALL");
OutStreamer.EmitInstruction(TmpInst);

View File

@ -1,6 +1,6 @@
; RUN: llc < %s -mtriple=armv6-apple-darwin -mattr=+vfp2 -arm-tail-calls | FileCheck %s -check-prefix=CHECKV6
; RUN: llc < %s -mtriple=armv6-linux-gnueabi -relocation-model=pic -mattr=+vfp2 -arm-tail-calls | FileCheck %s -check-prefix=CHECKELF
; RUN: llc < %s -mtriple=thumbv7-apple-darwin -arm-tail-calls | FileCheck %s -check-prefix=CHECKT2
; RUN: llc < %s -mtriple=thumbv7-apple-darwin -arm-tail-calls | FileCheck %s -check-prefix=CHECKT2D
@t = weak global i32 ()* null ; <i32 ()**> [#uses=1]
@ -26,6 +26,9 @@ define void @t3() {
; CHECKV6: b _t2 @ TAILCALL
; CHECKELF: t3:
; CHECKELF: b t2(PLT) @ TAILCALL
; CHECKT2D: t3:
; CHECKT2D: b.w _t2 @ TAILCALL
tail call void @t2( ) ; <i32> [#uses=0]
ret void
}
@ -71,10 +74,10 @@ declare void @foo() nounwind
define void @t7() nounwind {
entry:
; CHECKT2: t7:
; CHECKT2: blxeq _foo
; CHECKT2-NEXT: pop.w
; CHECKT2-NEXT: b _foo
; CHECKT2D: t7:
; CHECKT2D: blxeq _foo
; CHECKT2D-NEXT: pop.w
; CHECKT2D-NEXT: b.w _foo
br i1 undef, label %bb, label %bb1.lr.ph
bb1.lr.ph: