1 ; RUN: llc < %s -mtriple=armv6-apple-ios5.0 -mattr=+vfp2 | FileCheck %s -check-prefix=CHECKV6
2 ; RUN: llc < %s -mtriple=thumbv7-apple-ios5.0 | FileCheck %s -check-prefix=CHECKT2D
3 ; RUN: llc < %s -mtriple=armv6-linux-gnueabi -relocation-model=pic -mattr=+vfp2 \
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)
16 call void @g( i32 1, i32 2, i32 3, i32 4 )
26 ; CHECKT2D-NEXT: bx r0
27 %tmp = load i32 ()** @t ; <i32 ()*> [#uses=1]
28 %tmp.upgrd.2 = tail call i32 %tmp( ) ; <i32> [#uses=0]
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 {
50 ; CHECKELF: b sin(PLT)
51 %0 = tail call double @sin(double %a) nounwind readonly ; <double> [#uses=1]
55 define float @t5(float %a) nounwind readonly ssp {
60 ; CHECKELF: b sinf(PLT)
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 {
72 ; CHECKV6: b ___divsi3
74 ; CHECKELF: b __aeabi_idiv(PLT)
79 ; Make sure the tail call instruction isn't deleted
81 declare void @foo() nounwind
83 define void @t7() nounwind {
86 ; CHECKT2D: blxeq _foo
87 ; CHECKT2D-NEXT: pop.w
88 ; CHECKT2D-NEXT: b.w _foo
89 br i1 undef, label %bb, label %bb1.lr.ph
92 tail call void @foo() nounwind
96 tail call void @foo() nounwind
100 ; Make sure codegenprep is duplicating ret instructions to enable tail calls.
102 define i32 @t8(i32 %x) nounwind ssp {
104 ; CHECKT2D-LABEL: t8:
107 %tobool = icmp eq i32 %and, 0
108 br i1 %tobool, label %if.end, label %if.then
110 if.then: ; preds = %entry
112 %call = tail call i32 @a(i32 %x) nounwind
115 if.end: ; preds = %entry
116 %and1 = and i32 %x, 2
117 %tobool2 = icmp eq i32 %and1, 0
118 br i1 %tobool2, label %if.end5, label %if.then3
120 if.then3: ; preds = %if.end
122 %call4 = tail call i32 @b(i32 %x) nounwind
125 if.end5: ; preds = %if.end
127 %call6 = tail call i32 @c(i32 %x) nounwind
130 return: ; preds = %if.end5, %if.then3, %if.then
131 %retval.0 = phi i32 [ %call, %if.then ], [ %call4, %if.then3 ], [ %call6, %if.end5 ]
143 ; Use the correct input chain for the tailcall node or else the call to
144 ; _ZN9MutexLockD1Ev would be lost.
145 %class.MutexLock = type { i8 }
147 @x = external global i32, align 4
149 define i32 @t9() nounwind {
150 ; CHECKT2D-LABEL: t9:
151 ; CHECKT2D: blx __ZN9MutexLockC1Ev
152 ; CHECKT2D: blx __ZN9MutexLockD1Ev
153 ; CHECKT2D: b.w ___divsi3
154 %lock = alloca %class.MutexLock, align 1
155 %1 = call %class.MutexLock* @_ZN9MutexLockC1Ev(%class.MutexLock* %lock)
156 %2 = load i32* @x, align 4
157 %3 = sdiv i32 1000, %2
158 %4 = call %class.MutexLock* @_ZN9MutexLockD1Ev(%class.MutexLock* %lock)
162 declare %class.MutexLock* @_ZN9MutexLockC1Ev(%class.MutexLock*) unnamed_addr nounwind align 2
164 declare %class.MutexLock* @_ZN9MutexLockD1Ev(%class.MutexLock*) unnamed_addr nounwind align 2
167 ; Correctly preserve the input chain for the tailcall node in the bitcast case,
168 ; otherwise the call to floorf is lost.
169 define float @libcall_tc_test2(float* nocapture %a, float %b) {
170 ; CHECKT2D-LABEL: libcall_tc_test2:
171 ; CHECKT2D: blx _floorf
172 ; CHECKT2D: b.w _truncf
173 %1 = load float* %a, align 4
174 %call = tail call float @floorf(float %1)
175 store float %call, float* %a, align 4
176 %call1 = tail call float @truncf(float %b)
180 declare float @floorf(float) readnone
181 declare float @truncf(float) readnone