1 ; RUN: llc < %s -march=x86 -mattr=+sse2 -asm-verbose=false | FileCheck %s -check-prefix=32
2 ; RUN: llc < %s -march=x86-64 -mattr=+sse2 -asm-verbose=false | FileCheck %s -check-prefix=64
3 ; Darwin 8 generates stubs, which don't match
6 define void @t1(i32 %x) nounwind ssp {
13 tail call void @foo() nounwind
19 define void @t2() nounwind ssp {
26 %0 = tail call i32 @foo2() nounwind
32 define void @t3() nounwind ssp {
39 %0 = tail call i32 @foo3() nounwind
45 define void @t4(void (i32)* nocapture %x) nounwind ssp {
49 ; FIXME: gcc can generate a tailcall for this. But it's tricky.
54 tail call void %x(i32 0) nounwind
58 define void @t5(void ()* nocapture %x) nounwind ssp {
67 tail call void %x() nounwind
71 define i32 @t6(i32 %x) nounwind ssp {
80 %0 = icmp slt i32 %x, 10
81 br i1 %0, label %bb, label %bb1
84 %1 = add nsw i32 %x, -1
85 %2 = tail call i32 @t6(i32 %1) nounwind ssp
89 %3 = tail call i32 @bar(i32 %x) nounwind
95 define i32 @t7(i32 %a, i32 %b, i32 %c) nounwind ssp {
102 %0 = tail call i32 @bar2(i32 %a, i32 %b, i32 %c) nounwind
106 declare i32 @bar2(i32, i32, i32)
108 define signext i16 @t8() nounwind ssp {
111 ; 32: call {{_?}}bar3
114 ; 64: callq {{_?}}bar3
115 %0 = tail call signext i16 @bar3() nounwind ; <i16> [#uses=1]
119 declare signext i16 @bar3()
121 define signext i16 @t9(i32 (i32)* nocapture %x) nounwind ssp {
128 %0 = bitcast i32 (i32)* %x to i16 (i32)*
129 %1 = tail call signext i16 %0(i32 0) nounwind
133 define void @t10() nounwind ssp {
140 %0 = tail call i32 @foo4() noreturn nounwind
146 define i32 @t11(i32 %x, i32 %y, i32 %z.0, i32 %z.1, i32 %z.2) nounwind ssp {
147 ; In 32-bit mode, it's emitting a bunch of dead loads that are not being
148 ; eliminated currently.
151 ; 32-NOT: subl ${{[0-9]+}}, %esp
154 ; 32-NOT: addl ${{[0-9]+}}, %esp
158 ; 64-NOT: subq ${{[0-9]+}}, %esp
159 ; 64-NOT: addq ${{[0-9]+}}, %esp
162 %0 = icmp eq i32 %x, 0
163 br i1 %0, label %bb6, label %bb
166 %1 = tail call i32 @foo5(i32 %x, i32 %y, i32 %z.0, i32 %z.1, i32 %z.2) nounwind
173 declare i32 @foo5(i32, i32, i32, i32, i32)
175 %struct.t = type { i32, i32, i32, i32, i32 }
177 define i32 @t12(i32 %x, i32 %y, %struct.t* byval align 4 %z) nounwind ssp {
179 ; 32-NOT: subl ${{[0-9]+}}, %esp
180 ; 32-NOT: addl ${{[0-9]+}}, %esp
184 ; 64-NOT: subq ${{[0-9]+}}, %esp
185 ; 64-NOT: addq ${{[0-9]+}}, %esp
188 %0 = icmp eq i32 %x, 0
189 br i1 %0, label %bb2, label %bb
192 %1 = tail call i32 @foo6(i32 %x, i32 %y, %struct.t* byval align 4 %z) nounwind
199 declare i32 @foo6(i32, i32, %struct.t* byval align 4)
202 %struct.ns = type { i32, i32 }
203 %struct.cp = type { float, float }
205 define %struct.ns* @t13(%struct.cp* %yy) nounwind ssp {
216 %0 = tail call fastcc %struct.ns* @foo7(%struct.cp* byval align 4 %yy, i8 signext 0) nounwind
221 ; llvm can't do sibcall for this in 32-bit mode (yet).
222 declare fastcc %struct.ns* @foo7(%struct.cp* byval align 4, i8 signext) nounwind ssp
224 %struct.__block_descriptor = type { i64, i64 }
225 %struct.__block_descriptor_withcopydispose = type { i64, i64, i8*, i8* }
226 %struct.__block_literal_1 = type { i8*, i32, i32, i8*, %struct.__block_descriptor* }
227 %struct.__block_literal_2 = type { i8*, i32, i32, i8*, %struct.__block_descriptor_withcopydispose*, void ()* }
229 define void @t14(%struct.__block_literal_2* nocapture %.block_descriptor) nounwind ssp {
233 ; 64-NOT: movq 16(%rdi)
235 %0 = getelementptr inbounds %struct.__block_literal_2* %.block_descriptor, i64 0, i32 5 ; <void ()**> [#uses=1]
236 %1 = load void ()** %0, align 8 ; <void ()*> [#uses=2]
237 %2 = bitcast void ()* %1 to %struct.__block_literal_1* ; <%struct.__block_literal_1*> [#uses=1]
238 %3 = getelementptr inbounds %struct.__block_literal_1* %2, i64 0, i32 3 ; <i8**> [#uses=1]
239 %4 = load i8** %3, align 8 ; <i8*> [#uses=1]
240 %5 = bitcast i8* %4 to void (i8*)* ; <void (i8*)*> [#uses=1]
241 %6 = bitcast void ()* %1 to i8* ; <i8*> [#uses=1]
242 tail call void %5(i8* %6) nounwind
247 %struct.foo = type { [4 x i32] }
249 define void @t15(%struct.foo* noalias sret %agg.result) nounwind {
257 tail call fastcc void @f(%struct.foo* noalias sret %agg.result) nounwind
261 declare void @f(%struct.foo* noalias sret) nounwind
263 define void @t16() nounwind ssp {
266 ; 32: call {{_?}}bar4
271 %0 = tail call double @bar4() nounwind
275 declare double @bar4()
278 define void @t17() nounwind ssp {
286 tail call void (...)* @bar5() nounwind
290 declare void @bar5(...)
293 define void @t18() nounwind ssp {
296 ; 32: call {{_?}}bar6
302 %0 = tail call double (...)* @bar6() nounwind
306 declare double @bar6(...)
308 define void @t19() alignstack(32) nounwind {
312 ; CHECK: call {{_?}}foo
313 tail call void @foo() nounwind
319 ; If caller / callee calling convention mismatch then check if the return
320 ; values are returned in the same registers.
323 define double @t20(double %x) nounwind {
326 ; 32: call {{_?}}foo20
330 ; 64: jmp {{_?}}foo20
331 %0 = tail call fastcc double @foo20(double %x) nounwind
335 declare fastcc double @foo20(double) nounwind