blob: a77aba037be5fd5bc982a6e6ef440750771b8789 [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
Evan Cheng7cfa6562011-01-25 01:28:33 +00003; RUN: llc < %s -mtriple=thumbv7-apple-darwin -arm-tail-calls | FileCheck %s -check-prefix=CHECKT2
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
Dale Johannesenc66cdf72010-06-18 19:00:18 +000019 %tmp = load i32 ()** @t ; <i32 ()*> [#uses=1]
20 %tmp.upgrd.2 = tail call i32 %tmp( ) ; <i32> [#uses=0]
21 ret void
22}
23
Evan Cheng3d2125c2010-11-30 23:55:39 +000024define void @t3() {
25; CHECKV6: t3:
26; CHECKV6: b _t2 @ TAILCALL
27; CHECKELF: t3:
28; CHECKELF: b t2(PLT) @ TAILCALL
Dale Johannesen7835f1f2010-07-08 01:18:23 +000029 tail call void @t2( ) ; <i32> [#uses=0]
30 ret void
31}
Evan Cheng3d2125c2010-11-30 23:55:39 +000032
33; Sibcall optimization of expanded libcalls. rdar://8707777
34define double @t4(double %a) nounwind readonly ssp {
35entry:
36; CHECKV6: t4:
37; CHECKV6: b _sin @ TAILCALL
38; CHECKELF: t4:
39; CHECKELF: b sin(PLT) @ TAILCALL
40 %0 = tail call double @sin(double %a) nounwind readonly ; <double> [#uses=1]
41 ret double %0
42}
43
44define float @t5(float %a) nounwind readonly ssp {
45entry:
46; CHECKV6: t5:
47; CHECKV6: b _sinf @ TAILCALL
48; CHECKELF: t5:
49; CHECKELF: b sinf(PLT) @ TAILCALL
50 %0 = tail call float @sinf(float %a) nounwind readonly ; <float> [#uses=1]
51 ret float %0
52}
53
54declare float @sinf(float) nounwind readonly
55
56declare double @sin(double) nounwind readonly
57
58define i32 @t6(i32 %a, i32 %b) nounwind readnone {
59entry:
60; CHECKV6: t6:
61; CHECKV6: b ___divsi3 @ TAILCALL
62; CHECKELF: t6:
63; CHECKELF: b __aeabi_idiv(PLT) @ TAILCALL
64 %0 = sdiv i32 %a, %b
65 ret i32 %0
66}
Evan Cheng7cfa6562011-01-25 01:28:33 +000067
68; Make sure the tail call instruction isn't deleted
69; rdar://8309338
70declare void @foo() nounwind
71
72define void @t7() nounwind {
73entry:
74; CHECKT2: t7:
75; CHECKT2: blxeq _foo
76; CHECKT2-NEXT: pop.w
77; CHECKT2-NEXT: b.w _foo
78 br i1 undef, label %bb, label %bb1.lr.ph
79
80bb1.lr.ph:
81 tail call void @foo() nounwind
82 unreachable
83
84bb:
85 tail call void @foo() nounwind
86 ret void
87}