Make tTAILJMPr/tTAILJMPrND emit a tBX without a preceding MOV of PC to LR. This
[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=CHECKT2D
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 ; CHECKT2D: t2:
20 ; CHECKT2D: ldr
21 ; CHECKT2D-NEXT: ldr
22 ; CHECKT2D-NEXT: bx r0 @ TAILCALL
23         %tmp = load i32 ()** @t         ; <i32 ()*> [#uses=1]
24         %tmp.upgrd.2 = tail call i32 %tmp( )            ; <i32> [#uses=0]
25         ret void
26 }
27
28 define void @t3() {
29 ; CHECKV6: t3:
30 ; CHECKV6: b _t2  @ TAILCALL
31 ; CHECKELF: t3:
32 ; CHECKELF: b t2(PLT) @ TAILCALL
33 ; CHECKT2D: t3:
34 ; CHECKT2D: b.w _t2  @ TAILCALL
35
36         tail call void @t2( )            ; <i32> [#uses=0]
37         ret void
38 }
39
40 ; Sibcall optimization of expanded libcalls. rdar://8707777
41 define double @t4(double %a) nounwind readonly ssp {
42 entry:
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
51 define float @t5(float %a) nounwind readonly ssp {
52 entry:
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
61 declare float @sinf(float) nounwind readonly
62
63 declare double @sin(double) nounwind readonly
64
65 define i32 @t6(i32 %a, i32 %b) nounwind readnone {
66 entry:
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 }
74
75 ; Make sure the tail call instruction isn't deleted
76 ; rdar://8309338
77 declare void @foo() nounwind
78
79 define void @t7() nounwind {
80 entry:
81 ; CHECKT2D: t7:
82 ; CHECKT2D: blxeq _foo
83 ; CHECKT2D-NEXT: pop.w
84 ; CHECKT2D-NEXT: b.w _foo
85   br i1 undef, label %bb, label %bb1.lr.ph
86
87 bb1.lr.ph:
88   tail call void @foo() nounwind
89   unreachable
90
91 bb:
92   tail call void @foo() nounwind
93   ret void
94 }