Skip to content

Commit 8decdc4

Browse files
committed
Reenable tail calls for iOS 5.0 and later.
llvm-svn: 141370
1 parent 942bbce commit 8decdc4

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

llvm/lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,8 +1222,8 @@ ARMTargetLowering::LowerCall(SDValue Chain, SDValue Callee,
12221222
MachineFunction &MF = DAG.getMachineFunction();
12231223
bool IsStructRet = (Outs.empty()) ? false : Outs[0].Flags.isSRet();
12241224
bool IsSibCall = false;
1225-
// Temporarily disable tail calls so things don't break.
1226-
if (!EnableARMTailCalls)
1225+
// Disable tail calls if they're not supported.
1226+
if (!EnableARMTailCalls && !Subtarget->supportsTailCall())
12271227
isTailCall = false;
12281228
if (isTailCall) {
12291229
// Check if it's really possible to do a tail call.

llvm/lib/Target/ARM/ARMSubtarget.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ ARMSubtarget::ARMSubtarget(const std::string &TT, const std::string &CPU,
6060
, PostRAScheduler(false)
6161
, IsR9Reserved(ReserveR9)
6262
, UseMovt(false)
63+
, SupportsTailCall(false)
6364
, HasFP16(false)
6465
, HasD16(false)
6566
, HasHardwareDivide(false)
@@ -113,6 +114,8 @@ ARMSubtarget::ARMSubtarget(const std::string &TT, const std::string &CPU,
113114
else {
114115
IsR9Reserved = ReserveR9 | !HasV6Ops;
115116
UseMovt = DarwinUseMOVT && hasV6T2Ops();
117+
const Triple &T = getTargetTriple();
118+
SupportsTailCall = T.getOS() == Triple::IOS && !T.isOSVersionLT(5, 0);
116119
}
117120

118121
if (!isThumb() || hasThumb2())

llvm/lib/Target/ARM/ARMSubtarget.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ class ARMSubtarget : public ARMGenSubtargetInfo {
9393
/// imms (including global addresses).
9494
bool UseMovt;
9595

96+
/// SupportsTailCall - True if the OS supports tail call. The dynamic linker
97+
/// must be able to synthesize call stubs for interworking between ARM and
98+
/// Thumb.
99+
bool SupportsTailCall;
100+
96101
/// HasFP16 - True if subtarget supports half-precision FP (We support VFP+HF
97102
/// only so far)
98103
bool HasFP16;
@@ -234,6 +239,7 @@ class ARMSubtarget : public ARMGenSubtargetInfo {
234239
bool isR9Reserved() const { return IsR9Reserved; }
235240

236241
bool useMovt() const { return UseMovt && hasV6T2Ops(); }
242+
bool supportsTailCall() const { return SupportsTailCall; }
237243

238244
bool allowsUnalignedMem() const { return AllowsUnalignedMem; }
239245

llvm/test/CodeGen/ARM/call-tc.ll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
; RUN: llc < %s -mtriple=armv6-apple-darwin -mattr=+vfp2 -arm-tail-calls | FileCheck %s -check-prefix=CHECKV6
22
; RUN: llc < %s -mtriple=armv6-linux-gnueabi -relocation-model=pic -mattr=+vfp2 -arm-tail-calls | FileCheck %s -check-prefix=CHECKELF
33
; RUN: llc < %s -mtriple=thumbv7-apple-darwin -arm-tail-calls | FileCheck %s -check-prefix=CHECKT2D
4+
; RUN: llc < %s -mtriple=thumbv7-apple-ios5.0 | FileCheck %s -check-prefix=CHECKT2D
5+
6+
; Enable tailcall optimization for iOS 5.0
7+
; rdar://9120031
48

59
@t = weak global i32 ()* null ; <i32 ()**> [#uses=1]
610

0 commit comments

Comments
 (0)