blob: c460f7a5bd02082f1a2a5695b99d95c4441fc7f0 [file] [log] [blame]
Evan Cheng3d2125c2010-11-30 23:55:39 +00001; 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
Cameron Zwarichd34d4292011-05-23 01:57:17 +00003; RUN: llc < %s -mtriple=thumbv7-apple-darwin -arm-tail-calls | FileCheck %s -check-prefix=CHECKT2D
Dale Johannesenc66cdf72010-06-18 19:00:18 +00004
5@t = weak global i32 ()* null ; <i32 ()**> [#uses=1]
6
7declare void @g(i32, i32, i32, i32)
8
Evan Cheng0110ac62010-06-19 01:01:32 +00009define void @t1() {
10; CHECKELF: t1:
Evan Cheng3d2125c2010-11-30 23:55:39 +000011; CHECKELF: bl g(PLT)
Dale Johannesenc66cdf72010-06-18 19:00:18 +000012 call void @g( i32 1, i32 2, i32 3, i32 4 )
13 ret void
14}
15
Evan Cheng0110ac62010-06-19 01:01:32 +000016define void @t2() {
Evan Cheng3d2125c2010-11-30 23:55:39 +000017; CHECKV6: t2:
18; CHECKV6: bx r0 @ TAILCALL
Cameron Zwarich106acd42011-05-25 04:45:27 +000019; CHECKT2D: t2:
20; CHECKT2D: ldr
21; CHECKT2D-NEXT: ldr
22; CHECKT2D-NEXT: bx r0 @ TAILCALL
Dale Johannesenc66cdf72010-06-18 19:00:18 +000023 %tmp = load i32 ()** @t ; <i32 ()*> [#uses=1]
24 %tmp.upgrd.2 = tail call i32 %tmp( ) ; <i32> [#uses=0]
25 ret void
26}
27
Evan Cheng3d2125c2010-11-30 23:55:39 +000028define void @t3() {
29; CHECKV6: t3:
30; CHECKV6: b _t2 @ TAILCALL
31; CHECKELF: t3:
32; CHECKELF: b t2(PLT) @ TAILCALL
Cameron Zwarichd34d4292011-05-23 01:57:17 +000033; CHECKT2D: t3:
34; CHECKT2D: b.w _t2 @ TAILCALL
35
Dale Johannesen7835f1f2010-07-08 01:18:23 +000036 tail call void @t2( ) ; <i32> [#uses=0]
37 ret void
38}
Evan Cheng3d2125c2010-11-30 23:55:39 +000039
40; Sibcall optimization of expanded libcalls. rdar://8707777
41define double @t4(double %a) nounwind readonly ssp {
42entry:
43; CHECKV6: t4:
44; CHECKV6: b _sin @ TAILCALL
45; CHECKELF: t4:
46; CHECKELF: b sin(PLT) @ TAILCALL
47 %0 = tail call double @sin(double %a) nounwind readonly ; <double> [#uses=1]
48 ret double %0
49}
50
51define float @t5(float %a) nounwind readonly ssp {
52entry:
53; CHECKV6: t5:
54; CHECKV6: b _sinf @ TAILCALL
55; CHECKELF: t5:
56; CHECKELF: b sinf(PLT) @ TAILCALL
57 %0 = tail call float @sinf(float %a) nounwind readonly ; <float> [#uses=1]
58 ret float %0
59}
60
61declare float @sinf(float) nounwind readonly
62
63declare double @sin(double) nounwind readonly
64
65define i32 @t6(i32 %a, i32 %b) nounwind readnone {
66entry:
67; CHECKV6: t6:
68; CHECKV6: b ___divsi3 @ TAILCALL
69; CHECKELF: t6:
70; CHECKELF: b __aeabi_idiv(PLT) @ TAILCALL
71 %0 = sdiv i32 %a, %b
72 ret i32 %0
73}
Evan Cheng7cfa6562011-01-25 01:28:33 +000074
75; Make sure the tail call instruction isn't deleted
76; rdar://8309338
77declare void @foo() nounwind
78
79define void @t7() nounwind {
80entry:
Cameron Zwarichd34d4292011-05-23 01:57:17 +000081; CHECKT2D: t7:
82; CHECKT2D: blxeq _foo
83; CHECKT2D-NEXT: pop.w
84; CHECKT2D-NEXT: b.w _foo
Evan Cheng7cfa6562011-01-25 01:28:33 +000085 br i1 undef, label %bb, label %bb1.lr.ph
86
87bb1.lr.ph:
88 tail call void @foo() nounwind
89 unreachable
90
91bb:
92 tail call void @foo() nounwind
93 ret void
94}