1 ; RUN: llc < %s -mtriple=i686-linux -mcpu=core2 -mattr=+sse2 -asm-verbose=false | FileCheck %s -check-prefix=32
2 ; RUN: llc < %s -mtriple=x86_64-linux -mcpu=core2 -mattr=+sse2 -asm-verbose=false | FileCheck %s -check-prefix=64
3 ; RUN: llc < %s -mtriple=x86_64-linux-gnux32 -mcpu=core2 -mattr=+sse2 -asm-verbose=false | FileCheck %s -check-prefix=X32ABI
5 define void @t1(i32 %x) nounwind ssp {
14 ; X32ABI: jmp {{_?}}foo
15 tail call void @foo() nounwind
21 define void @t2() nounwind ssp {
30 ; X32ABI: jmp {{_?}}foo2
31 %0 = tail call i32 @foo2() nounwind
37 define void @t3() nounwind ssp {
46 ; X32ABI: jmp {{_?}}foo3
47 %0 = tail call i32 @foo3() nounwind
53 define void @t4(void (i32)* nocapture %x) nounwind ssp {
57 ; FIXME: gcc can generate a tailcall for this. But it's tricky.
66 tail call void %x(i32 0) nounwind
70 define void @t5(void ()* nocapture %x) nounwind ssp {
82 ; FIXME: This isn't needed since x32 psABI specifies that callers must
83 ; zero-extend pointers passed in registers.
84 ; X32ABI: movl %edi, %eax
86 tail call void %x() nounwind
90 define i32 @t6(i32 %x) nounwind ssp {
101 ; X32ABI: jmp {{_?}}t6
102 ; X32ABI: jmp {{_?}}bar
103 %0 = icmp slt i32 %x, 10
104 br i1 %0, label %bb, label %bb1
107 %1 = add nsw i32 %x, -1
108 %2 = tail call i32 @t6(i32 %1) nounwind ssp
112 %3 = tail call i32 @bar(i32 %x) nounwind
116 declare i32 @bar(i32)
118 define i32 @t7(i32 %a, i32 %b, i32 %c) nounwind ssp {
127 ; X32ABI: jmp {{_?}}bar2
128 %0 = tail call i32 @bar2(i32 %a, i32 %b, i32 %c) nounwind
132 declare i32 @bar2(i32, i32, i32)
134 define signext i16 @t8() nounwind ssp {
143 ; X32ABI: jmp {{_?}}bar3
144 %0 = tail call signext i16 @bar3() nounwind ; <i16> [#uses=1]
148 declare signext i16 @bar3()
150 define signext i16 @t9(i32 (i32)* nocapture %x) nounwind ssp {
160 %0 = bitcast i32 (i32)* %x to i16 (i32)*
161 %1 = tail call signext i16 %0(i32 0) nounwind
165 define void @t10() nounwind ssp {
175 %0 = tail call i32 @foo4() noreturn nounwind
181 define i32 @t11(i32 %x, i32 %y, i32 %z.0, i32 %z.1, i32 %z.2) nounwind ssp {
182 ; In 32-bit mode, it's emitting a bunch of dead loads that are not being
183 ; eliminated currently.
186 ; 32-NOT: subl ${{[0-9]+}}, %esp
189 ; 32-NOT: addl ${{[0-9]+}}, %esp
193 ; 64-NOT: subq ${{[0-9]+}}, %rsp
194 ; 64-NOT: addq ${{[0-9]+}}, %rsp
198 ; X32ABI-NOT: subl ${{[0-9]+}}, %esp
199 ; X32ABI-NOT: addl ${{[0-9]+}}, %esp
200 ; X32ABI: jmp {{_?}}foo5
202 %0 = icmp eq i32 %x, 0
203 br i1 %0, label %bb6, label %bb
206 %1 = tail call i32 @foo5(i32 %x, i32 %y, i32 %z.0, i32 %z.1, i32 %z.2) nounwind
213 declare i32 @foo5(i32, i32, i32, i32, i32)
215 %struct.t = type { i32, i32, i32, i32, i32 }
217 define i32 @t12(i32 %x, i32 %y, %struct.t* byval align 4 %z) nounwind ssp {
219 ; 32-NOT: subl ${{[0-9]+}}, %esp
220 ; 32-NOT: addl ${{[0-9]+}}, %esp
224 ; 64-NOT: subq ${{[0-9]+}}, %rsp
225 ; 64-NOT: addq ${{[0-9]+}}, %rsp
229 ; X32ABI-NOT: subl ${{[0-9]+}}, %esp
230 ; X32ABI-NOT: addl ${{[0-9]+}}, %esp
231 ; X32ABI: jmp {{_?}}foo6
233 %0 = icmp eq i32 %x, 0
234 br i1 %0, label %bb2, label %bb
237 %1 = tail call i32 @foo6(i32 %x, i32 %y, %struct.t* byval align 4 %z) nounwind
244 declare i32 @foo6(i32, i32, %struct.t* byval align 4)
247 %struct.ns = type { i32, i32 }
248 %struct.cp = type { float, float, float, float, float }
250 define %struct.ns* @t13(%struct.cp* %yy) nounwind ssp {
266 %0 = tail call fastcc %struct.ns* @foo7(%struct.cp* byval align 4 %yy, i8 signext 0) nounwind
271 ; llvm can't do sibcall for this in 32-bit mode (yet).
272 declare fastcc %struct.ns* @foo7(%struct.cp* byval align 4, i8 signext) nounwind ssp
274 %struct.__block_descriptor = type { i64, i64 }
275 %struct.__block_descriptor_withcopydispose = type { i64, i64, i8*, i8* }
276 %struct.__block_literal_1 = type { i8*, i32, i32, i8*, %struct.__block_descriptor* }
277 %struct.__block_literal_2 = type { i8*, i32, i32, i8*, %struct.__block_descriptor_withcopydispose*, void ()* }
279 define void @t14(%struct.__block_literal_2* nocapture %.block_descriptor) nounwind ssp {
283 ; 64-NOT: movq 16(%rdi)
284 ; 64: jmpq *16({{%rdi|%rax}})
287 ; X32ABI: movl 20(%edi), %edi
288 ; X32ABI-NEXT: movl 12(%edi), %eax
289 ; X32ABI-NEXT: jmpq *%rax
290 %0 = getelementptr inbounds %struct.__block_literal_2, %struct.__block_literal_2* %.block_descriptor, i64 0, i32 5 ; <void ()**> [#uses=1]
291 %1 = load void ()*, void ()** %0, align 8 ; <void ()*> [#uses=2]
292 %2 = bitcast void ()* %1 to %struct.__block_literal_1* ; <%struct.__block_literal_1*> [#uses=1]
293 %3 = getelementptr inbounds %struct.__block_literal_1, %struct.__block_literal_1* %2, i64 0, i32 3 ; <i8**> [#uses=1]
294 %4 = load i8*, i8** %3, align 8 ; <i8*> [#uses=1]
295 %5 = bitcast i8* %4 to void (i8*)* ; <void (i8*)*> [#uses=1]
296 %6 = bitcast void ()* %1 to i8* ; <i8*> [#uses=1]
297 tail call void %5(i8* %6) nounwind
302 %struct.foo = type { [4 x i32] }
304 define void @t15(%struct.foo* noalias sret %agg.result) nounwind {
314 ; X32ABI: callq {{_?}}f
316 tail call fastcc void @f(%struct.foo* noalias sret %agg.result) nounwind
320 declare void @f(%struct.foo* noalias sret) nounwind
322 define void @t16() nounwind ssp {
325 ; 32: calll {{_?}}bar4
332 ; X32ABI: jmp {{_?}}bar4
333 %0 = tail call double @bar4() nounwind
337 declare double @bar4()
340 define void @t17() nounwind ssp {
346 ; 64: xorl %eax, %eax
350 ; X32ABI: xorl %eax, %eax
351 ; X32ABI: jmp {{_?}}bar5
352 tail call void (...) @bar5() nounwind
356 declare void @bar5(...)
359 define void @t18() nounwind ssp {
362 ; 32: calll {{_?}}bar6
366 ; 64: xorl %eax, %eax
370 ; X32ABI: xorl %eax, %eax
371 ; X32ABI: jmp {{_?}}bar6
372 %0 = tail call double (...) @bar6() nounwind
376 declare double @bar6(...)
378 define void @t19() alignstack(32) nounwind {
382 ; CHECK: calll {{_?}}foo
386 ; X32ABI: callq {{_?}}foo
387 tail call void @foo() nounwind
391 ; If caller / callee calling convention mismatch then check if the return
392 ; values are returned in the same registers.
395 define double @t20(double %x) nounwind {
398 ; 32: calll {{_?}}foo20
402 ; 64: jmp {{_?}}foo20
405 ; X32ABI: jmp {{_?}}foo20
406 %0 = tail call fastcc double @foo20(double %x) nounwind
410 declare fastcc double @foo20(double) nounwind