Testcase for r127630.
[oota-llvm.git] / test / CodeGen / ARM / call-tc.ll
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=CHECKT2
4
5 @t = weak global i32 ()* null           ; <i32 ()**> [#uses=1]
6
7 declare void @g(i32, i32, i32, i32)
8
9 define void @t1() {
10 ; CHECKELF: t1:
11 ; CHECKELF: bl g(PLT)
12         call void @g( i32 1, i32 2, i32 3, i32 4 )
13         ret void
14 }
15
16 define void @t2() {
17 ; CHECKV6: t2:
18 ; CHECKV6: bx r0 @ TAILCALL
19         %tmp = load i32 ()** @t         ; <i32 ()*> [#uses=1]
20         %tmp.upgrd.2 = tail call i32 %tmp( )            ; <i32> [#uses=0]
21         ret void
22 }
23
24 define void @t3() {
25 ; CHECKV6: t3:
26 ; CHECKV6: b _t2  @ TAILCALL
27 ; CHECKELF: t3:
28 ; CHECKELF: b t2(PLT) @ TAILCALL
29         tail call void @t2( )            ; <i32> [#uses=0]
30         ret void
31 }
32
33 ; Sibcall optimization of expanded libcalls. rdar://8707777
34 define double @t4(double %a) nounwind readonly ssp {
35 entry:
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
44 define float @t5(float %a) nounwind readonly ssp {
45 entry:
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
54 declare float @sinf(float) nounwind readonly
55
56 declare double @sin(double) nounwind readonly
57
58 define i32 @t6(i32 %a, i32 %b) nounwind readnone {
59 entry:
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 }
67
68 ; Make sure the tail call instruction isn't deleted
69 ; rdar://8309338
70 declare void @foo() nounwind
71
72 define void @t7() nounwind {
73 entry:
74 ; CHECKT2: t7:
75 ; CHECKT2: blxeq _foo
76 ; CHECKT2-NEXT: pop.w
77 ; CHECKT2-NEXT: b _foo
78   br i1 undef, label %bb, label %bb1.lr.ph
79
80 bb1.lr.ph:
81   tail call void @foo() nounwind
82   unreachable
83
84 bb:
85   tail call void @foo() nounwind
86   ret void
87 }