1 ; RUN: llc < %s -mtriple=armv6-apple-ios5.0 -mattr=+vfp2 -arm-atomic-cfg-tidy=0 | FileCheck %s -check-prefix=CHECKV6
2 ; RUN: llc < %s -mtriple=thumbv7-apple-ios5.0 -arm-atomic-cfg-tidy=0 | FileCheck %s -check-prefix=CHECKT2D
3 ; RUN: llc < %s -mtriple=armv6-linux-gnueabi -relocation-model=pic -mattr=+vfp2 -arm-atomic-cfg-tidy=0 \
4 ; RUN: | FileCheck %s -check-prefix=CHECKELF
6 ; Enable tailcall optimization for iOS 5.0
9 @t = weak global i32 ()* null ; <i32 ()**> [#uses=1]
11 declare void @g(i32, i32, i32, i32)
13 define void @t1() "no-frame-pointer-elim"="true" {
16 call void @g( i32 1, i32 2, i32 3, i32 4 )
20 define void @t2() "no-frame-pointer-elim"="true" {
26 ; CHECKT2D-NEXT: bx r0
27 %tmp = load i32 ()*, i32 ()** @t ; <i32 ()*> [#uses=1]
28 %tmp.upgrd.2 = tail call i32 %tmp( ) ; <i32> [#uses=0]
32 define void @t3() "no-frame-pointer-elim"="true" {
40 tail call void @t2( ) ; <i32> [#uses=0]
44 ; Sibcall optimization of expanded libcalls. rdar://8707777
45 define double @t4(double %a) nounwind readonly ssp "no-frame-pointer-elim"="true" {
51 %0 = tail call double @sin(double %a) nounwind readonly ; <double> [#uses=1]
55 define float @t5(float %a) nounwind readonly ssp "no-frame-pointer-elim"="true" {
61 %0 = tail call float @sinf(float %a) nounwind readonly ; <float> [#uses=1]
65 declare float @sinf(float) nounwind readonly
67 declare double @sin(double) nounwind readonly
69 define i32 @t6(i32 %a, i32 %b) nounwind readnone "no-frame-pointer-elim"="true" {
72 ; CHECKV6: b ___divsi3
74 ; CHECKELF: b __aeabi_idiv
79 ; Make sure the tail call instruction isn't deleted
81 declare void @foo() nounwind
83 define void @t7() nounwind "no-frame-pointer-elim"="true" {
87 ; CHECKT2D-NEXT: bne.w _foo
89 ; CHECKT2D-NEXT: mov r7, sp
90 ; CHECKT2D-NEXT: bl _foo
91 br i1 undef, label %bb, label %bb1.lr.ph
94 tail call void @foo() nounwind
98 tail call void @foo() nounwind
102 ; Make sure codegenprep is duplicating ret instructions to enable tail calls.
104 define i32 @t8(i32 %x) nounwind ssp "no-frame-pointer-elim"="true" {
106 ; CHECKT2D-LABEL: t8:
109 %tobool = icmp eq i32 %and, 0
110 br i1 %tobool, label %if.end, label %if.then
112 if.then: ; preds = %entry
114 %call = tail call i32 @a(i32 %x) nounwind
117 if.end: ; preds = %entry
118 %and1 = and i32 %x, 2
119 %tobool2 = icmp eq i32 %and1, 0
120 br i1 %tobool2, label %if.end5, label %if.then3
122 if.then3: ; preds = %if.end
124 %call4 = tail call i32 @b(i32 %x) nounwind
127 if.end5: ; preds = %if.end
129 %call6 = tail call i32 @c(i32 %x) nounwind
132 return: ; preds = %if.end5, %if.then3, %if.then
133 %retval.0 = phi i32 [ %call, %if.then ], [ %call4, %if.then3 ], [ %call6, %if.end5 ]
145 ; Use the correct input chain for the tailcall node or else the call to
146 ; _ZN9MutexLockD1Ev would be lost.
147 %class.MutexLock = type { i8 }
149 @x = external global i32, align 4
151 define i32 @t9() nounwind "no-frame-pointer-elim"="true" {
152 ; CHECKT2D-LABEL: t9:
153 ; CHECKT2D: bl __ZN9MutexLockC1Ev
154 ; CHECKT2D: bl __ZN9MutexLockD1Ev
155 ; CHECKT2D: b.w ___divsi3
156 %lock = alloca %class.MutexLock, align 1
157 %1 = call %class.MutexLock* @_ZN9MutexLockC1Ev(%class.MutexLock* %lock)
158 %2 = load i32, i32* @x, align 4
159 %3 = sdiv i32 1000, %2
160 %4 = call %class.MutexLock* @_ZN9MutexLockD1Ev(%class.MutexLock* %lock)
164 declare %class.MutexLock* @_ZN9MutexLockC1Ev(%class.MutexLock*) unnamed_addr nounwind align 2
166 declare %class.MutexLock* @_ZN9MutexLockD1Ev(%class.MutexLock*) unnamed_addr nounwind align 2
169 ; Correctly preserve the input chain for the tailcall node in the bitcast case,
170 ; otherwise the call to floorf is lost.
171 define float @libcall_tc_test2(float* nocapture %a, float %b) "no-frame-pointer-elim"="true" {
172 ; CHECKT2D-LABEL: libcall_tc_test2:
173 ; CHECKT2D: bl _floorf
174 ; CHECKT2D: b.w _truncf
175 %1 = load float, float* %a, align 4
176 %call = tail call float @floorf(float %1)
177 store float %call, float* %a, align 4
178 %call1 = tail call float @truncf(float %b)
182 declare float @floorf(float) readnone
183 declare float @truncf(float) readnone