1 ; RUN: llc < %s -mtriple=i686-linux -mattr=+sse2 -asm-verbose=false | FileCheck %s -check-prefix=32
2 ; RUN: llc < %s -mtriple=x86_64-linux -mattr=+sse2 -asm-verbose=false | FileCheck %s -check-prefix=64
4 define void @t1(i32 %x) nounwind ssp {
11 tail call void @foo() nounwind
17 define void @t2() nounwind ssp {
24 %0 = tail call i32 @foo2() nounwind
30 define void @t3() nounwind ssp {
37 %0 = tail call i32 @foo3() nounwind
43 define void @t4(void (i32)* nocapture %x) nounwind ssp {
47 ; FIXME: gcc can generate a tailcall for this. But it's tricky.
52 tail call void %x(i32 0) nounwind
56 define void @t5(void ()* nocapture %x) nounwind ssp {
65 tail call void %x() nounwind
69 define i32 @t6(i32 %x) nounwind ssp {
78 %0 = icmp slt i32 %x, 10
79 br i1 %0, label %bb, label %bb1
82 %1 = add nsw i32 %x, -1
83 %2 = tail call i32 @t6(i32 %1) nounwind ssp
87 %3 = tail call i32 @bar(i32 %x) nounwind
93 define i32 @t7(i32 %a, i32 %b, i32 %c) nounwind ssp {
100 %0 = tail call i32 @bar2(i32 %a, i32 %b, i32 %c) nounwind
104 declare i32 @bar2(i32, i32, i32)
106 define signext i16 @t8() nounwind ssp {
109 ; 32: calll {{_?}}bar3
112 ; 64: callq {{_?}}bar3
113 %0 = tail call signext i16 @bar3() nounwind ; <i16> [#uses=1]
117 declare signext i16 @bar3()
119 define signext i16 @t9(i32 (i32)* nocapture %x) nounwind ssp {
126 %0 = bitcast i32 (i32)* %x to i16 (i32)*
127 %1 = tail call signext i16 %0(i32 0) nounwind
131 define void @t10() nounwind ssp {
138 %0 = tail call i32 @foo4() noreturn nounwind
144 define i32 @t11(i32 %x, i32 %y, i32 %z.0, i32 %z.1, i32 %z.2) nounwind ssp {
145 ; In 32-bit mode, it's emitting a bunch of dead loads that are not being
146 ; eliminated currently.
149 ; 32-NOT: subl ${{[0-9]+}}, %esp
152 ; 32-NOT: addl ${{[0-9]+}}, %esp
156 ; 64-NOT: subq ${{[0-9]+}}, %esp
157 ; 64-NOT: addq ${{[0-9]+}}, %esp
160 %0 = icmp eq i32 %x, 0
161 br i1 %0, label %bb6, label %bb
164 %1 = tail call i32 @foo5(i32 %x, i32 %y, i32 %z.0, i32 %z.1, i32 %z.2) nounwind
171 declare i32 @foo5(i32, i32, i32, i32, i32)
173 %struct.t = type { i32, i32, i32, i32, i32 }
175 define i32 @t12(i32 %x, i32 %y, %struct.t* byval align 4 %z) nounwind ssp {
177 ; 32-NOT: subl ${{[0-9]+}}, %esp
178 ; 32-NOT: addl ${{[0-9]+}}, %esp
182 ; 64-NOT: subq ${{[0-9]+}}, %esp
183 ; 64-NOT: addq ${{[0-9]+}}, %esp
186 %0 = icmp eq i32 %x, 0
187 br i1 %0, label %bb2, label %bb
190 %1 = tail call i32 @foo6(i32 %x, i32 %y, %struct.t* byval align 4 %z) nounwind
197 declare i32 @foo6(i32, i32, %struct.t* byval align 4)
200 %struct.ns = type { i32, i32 }
201 %struct.cp = type { float, float }
203 define %struct.ns* @t13(%struct.cp* %yy) nounwind ssp {
214 %0 = tail call fastcc %struct.ns* @foo7(%struct.cp* byval align 4 %yy, i8 signext 0) nounwind
219 ; llvm can't do sibcall for this in 32-bit mode (yet).
220 declare fastcc %struct.ns* @foo7(%struct.cp* byval align 4, i8 signext) nounwind ssp
222 %struct.__block_descriptor = type { i64, i64 }
223 %struct.__block_descriptor_withcopydispose = type { i64, i64, i8*, i8* }
224 %struct.__block_literal_1 = type { i8*, i32, i32, i8*, %struct.__block_descriptor* }
225 %struct.__block_literal_2 = type { i8*, i32, i32, i8*, %struct.__block_descriptor_withcopydispose*, void ()* }
227 define void @t14(%struct.__block_literal_2* nocapture %.block_descriptor) nounwind ssp {
231 ; 64-NOT: movq 16(%rdi)
233 %0 = getelementptr inbounds %struct.__block_literal_2* %.block_descriptor, i64 0, i32 5 ; <void ()**> [#uses=1]
234 %1 = load void ()** %0, align 8 ; <void ()*> [#uses=2]
235 %2 = bitcast void ()* %1 to %struct.__block_literal_1* ; <%struct.__block_literal_1*> [#uses=1]
236 %3 = getelementptr inbounds %struct.__block_literal_1* %2, i64 0, i32 3 ; <i8**> [#uses=1]
237 %4 = load i8** %3, align 8 ; <i8*> [#uses=1]
238 %5 = bitcast i8* %4 to void (i8*)* ; <void (i8*)*> [#uses=1]
239 %6 = bitcast void ()* %1 to i8* ; <i8*> [#uses=1]
240 tail call void %5(i8* %6) nounwind
245 %struct.foo = type { [4 x i32] }
247 define void @t15(%struct.foo* noalias sret %agg.result) nounwind {
255 tail call fastcc void @f(%struct.foo* noalias sret %agg.result) nounwind
259 declare void @f(%struct.foo* noalias sret) nounwind
261 define void @t16() nounwind ssp {
264 ; 32: calll {{_?}}bar4
269 %0 = tail call double @bar4() nounwind
273 declare double @bar4()
276 define void @t17() nounwind ssp {
284 tail call void (...)* @bar5() nounwind
288 declare void @bar5(...)
291 define void @t18() nounwind ssp {
294 ; 32: calll {{_?}}bar6
300 %0 = tail call double (...)* @bar6() nounwind
304 declare double @bar6(...)
306 define void @t19() alignstack(32) nounwind {
310 ; CHECK: calll {{_?}}foo
311 tail call void @foo() nounwind
317 ; If caller / callee calling convention mismatch then check if the return
318 ; values are returned in the same registers.
321 define double @t20(double %x) nounwind {
324 ; 32: calll {{_?}}foo20
328 ; 64: jmp {{_?}}foo20
329 %0 = tail call fastcc double @foo20(double %x) nounwind
333 declare fastcc double @foo20(double) nounwind