1 ; RUN: llc < %s -mtriple=armv6-apple-darwin -mattr=+vfp2 -arm-tail-calls | FileCheck %s -check-prefix=CHECKV6 2 ; RUN: llc < %s -mtriple=armv6-linux-gnueabi -relocation-model=pic -mattr=+vfp2 -arm-tail-calls | FileCheck %s -check-prefix=CHECKELF 3 ; 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 8 9 @t = weak global i32 ()* null ; <i32 ()**> [#uses=1] 10 11 declare void @g(i32, i32, i32, i32) 12 13 define void @t1() { 14 ; CHECKELF: t1: 15 ; CHECKELF: bl g(PLT) 16 call void @g( i32 1, i32 2, i32 3, i32 4 ) 17 ret void 18 } 19 20 define void @t2() { 21 ; CHECKV6: t2: 22 ; CHECKV6: bx r0 23 ; CHECKT2D: t2: 24 ; CHECKT2D: ldr 25 ; CHECKT2D-NEXT: ldr 26 ; CHECKT2D-NEXT: bx r0 27 %tmp = load i32 ()** @t ; <i32 ()*> [#uses=1] 28 %tmp.upgrd.2 = tail call i32 %tmp( ) ; <i32> [#uses=0] 29 ret void 30 } 31 32 define void @t3() { 33 ; CHECKV6: t3: 34 ; CHECKV6: b _t2 35 ; CHECKELF: t3: 36 ; CHECKELF: b t2(PLT) 37 ; CHECKT2D: t3: 38 ; CHECKT2D: b.w _t2 39 40 tail call void @t2( ) ; <i32> [#uses=0] 41 ret void 42 } 43 44 ; Sibcall optimization of expanded libcalls. rdar://8707777 45 define double @t4(double %a) nounwind readonly ssp { 46 entry: 47 ; CHECKV6: t4: 48 ; CHECKV6: b _sin 49 ; CHECKELF: t4: 50 ; CHECKELF: b sin(PLT) 51 %0 = tail call double @sin(double %a) nounwind readonly ; <double> [#uses=1] 52 ret double %0 53 } 54 55 define float @t5(float %a) nounwind readonly ssp { 56 entry: 57 ; CHECKV6: t5: 58 ; CHECKV6: b _sinf 59 ; CHECKELF: t5: 60 ; CHECKELF: b sinf(PLT) 61 %0 = tail call float @sinf(float %a) nounwind readonly ; <float> [#uses=1] 62 ret float %0 63 } 64 65 declare float @sinf(float) nounwind readonly 66 67 declare double @sin(double) nounwind readonly 68 69 define i32 @t6(i32 %a, i32 %b) nounwind readnone { 70 entry: 71 ; CHECKV6: t6: 72 ; CHECKV6: b ___divsi3 73 ; CHECKELF: t6: 74 ; CHECKELF: b __aeabi_idiv(PLT) 75 %0 = sdiv i32 %a, %b 76 ret i32 %0 77 } 78 79 ; Make sure the tail call instruction isn't deleted 80 ; rdar://8309338 81 declare void @foo() nounwind 82 83 define void @t7() nounwind { 84 entry: 85 ; CHECKT2D: t7: 86 ; CHECKT2D: blxeq _foo 87 ; CHECKT2D-NEXT: pop.w 88 ; CHECKT2D-NEXT: b.w _foo 89 br i1 undef, label %bb, label %bb1.lr.ph 90 91 bb1.lr.ph: 92 tail call void @foo() nounwind 93 unreachable 94 95 bb: 96 tail call void @foo() nounwind 97 ret void 98 } 99