blob: 6dcd675280558d54366482d4e6b062dc81016af2 [file] [log] [blame]
Evan Chengf2d36d92010-04-30 06:00:56 +00001; 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
Dale Johannesena01818c2010-08-15 19:40:29 +00003; Darwin 8 generates stubs, which don't match
4; XFAIL: apple-darwin8
Evan Chengb1712452010-01-27 06:25:16 +00005
Evan Cheng7096ae42010-01-29 06:45:59 +00006define void @t1(i32 %x) nounwind ssp {
Evan Chengb1712452010-01-27 06:25:16 +00007entry:
Evan Chenga6bff982010-01-30 01:22:00 +00008; 32: t1:
9; 32: jmp {{_?}}foo
10
11; 64: t1:
12; 64: jmp {{_?}}foo
Evan Chengb1712452010-01-27 06:25:16 +000013 tail call void @foo() nounwind
14 ret void
15}
16
17declare void @foo()
Evan Cheng7096ae42010-01-29 06:45:59 +000018
19define void @t2() nounwind ssp {
20entry:
Evan Chenga6bff982010-01-30 01:22:00 +000021; 32: t2:
22; 32: jmp {{_?}}foo2
23
24; 64: t2:
25; 64: jmp {{_?}}foo2
Evan Cheng7096ae42010-01-29 06:45:59 +000026 %0 = tail call i32 @foo2() nounwind
27 ret void
28}
29
30declare i32 @foo2()
31
32define void @t3() nounwind ssp {
33entry:
Evan Chenga6bff982010-01-30 01:22:00 +000034; 32: t3:
35; 32: jmp {{_?}}foo3
36
37; 64: t3:
38; 64: jmp {{_?}}foo3
Evan Cheng7096ae42010-01-29 06:45:59 +000039 %0 = tail call i32 @foo3() nounwind
40 ret void
41}
42
43declare i32 @foo3()
Evan Chenga6bff982010-01-30 01:22:00 +000044
45define void @t4(void (i32)* nocapture %x) nounwind ssp {
46entry:
47; 32: t4:
Chris Lattner1eb1b682010-09-22 05:49:14 +000048; 32: calll *
Evan Chenga6bff982010-01-30 01:22:00 +000049; FIXME: gcc can generate a tailcall for this. But it's tricky.
50
51; 64: t4:
52; 64-NOT: call
53; 64: jmpq *
54 tail call void %x(i32 0) nounwind
55 ret void
56}
57
58define void @t5(void ()* nocapture %x) nounwind ssp {
59entry:
60; 32: t5:
61; 32-NOT: call
Evan Cheng1ad584e2010-03-20 03:17:05 +000062; 32: jmpl *4(%esp)
Evan Chenga6bff982010-01-30 01:22:00 +000063
64; 64: t5:
65; 64-NOT: call
Evan Cheng1ad584e2010-03-20 03:17:05 +000066; 64: jmpq *%rdi
Evan Chenga6bff982010-01-30 01:22:00 +000067 tail call void %x() nounwind
68 ret void
69}
Evan Cheng843bd692010-01-31 06:44:49 +000070
71define i32 @t6(i32 %x) nounwind ssp {
72entry:
73; 32: t6:
Chris Lattner1eb1b682010-09-22 05:49:14 +000074; 32: calll {{_?}}t6
Evan Cheng5f941932010-02-05 02:21:12 +000075; 32: jmp {{_?}}bar
Evan Cheng843bd692010-01-31 06:44:49 +000076
77; 64: t6:
Evan Cheng0a4fd462010-02-01 02:13:39 +000078; 64: jmp {{_?}}t6
Evan Cheng843bd692010-01-31 06:44:49 +000079; 64: jmp {{_?}}bar
80 %0 = icmp slt i32 %x, 10
81 br i1 %0, label %bb, label %bb1
82
83bb:
84 %1 = add nsw i32 %x, -1
85 %2 = tail call i32 @t6(i32 %1) nounwind ssp
86 ret i32 %2
87
88bb1:
89 %3 = tail call i32 @bar(i32 %x) nounwind
90 ret i32 %3
91}
92
93declare i32 @bar(i32)
Evan Chengb2c92902010-02-02 02:22:50 +000094
95define i32 @t7(i32 %a, i32 %b, i32 %c) nounwind ssp {
96entry:
97; 32: t7:
98; 32: jmp {{_?}}bar2
99
100; 64: t7:
101; 64: jmp {{_?}}bar2
102 %0 = tail call i32 @bar2(i32 %a, i32 %b, i32 %c) nounwind
103 ret i32 %0
104}
105
106declare i32 @bar2(i32, i32, i32)
Evan Cheng86809cc2010-02-03 03:28:02 +0000107
108define signext i16 @t8() nounwind ssp {
109entry:
110; 32: t8:
Chris Lattner1eb1b682010-09-22 05:49:14 +0000111; 32: calll {{_?}}bar3
Evan Cheng86809cc2010-02-03 03:28:02 +0000112
113; 64: t8:
Evan Cheng1f2fda92010-02-04 06:47:24 +0000114; 64: callq {{_?}}bar3
Evan Cheng86809cc2010-02-03 03:28:02 +0000115 %0 = tail call signext i16 @bar3() nounwind ; <i16> [#uses=1]
116 ret i16 %0
117}
118
119declare signext i16 @bar3()
120
121define signext i16 @t9(i32 (i32)* nocapture %x) nounwind ssp {
122entry:
123; 32: t9:
Chris Lattner1eb1b682010-09-22 05:49:14 +0000124; 32: calll *
Evan Cheng86809cc2010-02-03 03:28:02 +0000125
126; 64: t9:
127; 64: callq *
128 %0 = bitcast i32 (i32)* %x to i16 (i32)*
129 %1 = tail call signext i16 %0(i32 0) nounwind
130 ret i16 %1
131}
Evan Chengfebc8162010-02-03 03:55:59 +0000132
133define void @t10() nounwind ssp {
134entry:
135; 32: t10:
Chris Lattner1eb1b682010-09-22 05:49:14 +0000136; 32: calll
Evan Chengfebc8162010-02-03 03:55:59 +0000137
138; 64: t10:
139; 64: callq
140 %0 = tail call i32 @foo4() noreturn nounwind
141 unreachable
142}
143
144declare i32 @foo4()
Evan Cheng5f941932010-02-05 02:21:12 +0000145
146define 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.
149
150; 32: t11:
Evan Chengf22f9b32010-02-06 03:28:46 +0000151; 32-NOT: subl ${{[0-9]+}}, %esp
Evan Cheng00a99a32010-02-06 09:07:11 +0000152; 32: jne
153; 32-NOT: movl
Evan Chengf22f9b32010-02-06 03:28:46 +0000154; 32-NOT: addl ${{[0-9]+}}, %esp
Evan Cheng5f941932010-02-05 02:21:12 +0000155; 32: jmp {{_?}}foo5
156
157; 64: t11:
Evan Chengf22f9b32010-02-06 03:28:46 +0000158; 64-NOT: subq ${{[0-9]+}}, %esp
159; 64-NOT: addq ${{[0-9]+}}, %esp
Evan Cheng5f941932010-02-05 02:21:12 +0000160; 64: jmp {{_?}}foo5
161entry:
162 %0 = icmp eq i32 %x, 0
163 br i1 %0, label %bb6, label %bb
164
165bb:
166 %1 = tail call i32 @foo5(i32 %x, i32 %y, i32 %z.0, i32 %z.1, i32 %z.2) nounwind
167 ret i32 %1
168
169bb6:
170 ret i32 0
171}
172
173declare i32 @foo5(i32, i32, i32, i32, i32)
174
175%struct.t = type { i32, i32, i32, i32, i32 }
176
177define i32 @t12(i32 %x, i32 %y, %struct.t* byval align 4 %z) nounwind ssp {
178; 32: t12:
Evan Chengf22f9b32010-02-06 03:28:46 +0000179; 32-NOT: subl ${{[0-9]+}}, %esp
180; 32-NOT: addl ${{[0-9]+}}, %esp
Evan Cheng5f941932010-02-05 02:21:12 +0000181; 32: jmp {{_?}}foo6
182
183; 64: t12:
Evan Chengf22f9b32010-02-06 03:28:46 +0000184; 64-NOT: subq ${{[0-9]+}}, %esp
185; 64-NOT: addq ${{[0-9]+}}, %esp
Evan Cheng5f941932010-02-05 02:21:12 +0000186; 64: jmp {{_?}}foo6
187entry:
188 %0 = icmp eq i32 %x, 0
189 br i1 %0, label %bb2, label %bb
190
191bb:
192 %1 = tail call i32 @foo6(i32 %x, i32 %y, %struct.t* byval align 4 %z) nounwind
193 ret i32 %1
194
195bb2:
196 ret i32 0
197}
198
199declare i32 @foo6(i32, i32, %struct.t* byval align 4)
Evan Cheng4cae1332010-03-05 08:38:04 +0000200
201; rdar://r7717598
202%struct.ns = type { i32, i32 }
203%struct.cp = type { float, float }
204
205define %struct.ns* @t13(%struct.cp* %yy) nounwind ssp {
206; 32: t13:
207; 32-NOT: jmp
Chris Lattner1eb1b682010-09-22 05:49:14 +0000208; 32: calll
Evan Cheng4cae1332010-03-05 08:38:04 +0000209; 32: ret
210
211; 64: t13:
212; 64-NOT: jmp
Chris Lattner1eb1b682010-09-22 05:49:14 +0000213; 64: callq
Evan Cheng4cae1332010-03-05 08:38:04 +0000214; 64: ret
215entry:
216 %0 = tail call fastcc %struct.ns* @foo7(%struct.cp* byval align 4 %yy, i8 signext 0) nounwind
217 ret %struct.ns* %0
218}
219
Evan Cheng1ad584e2010-03-20 03:17:05 +0000220; rdar://6195379
221; llvm can't do sibcall for this in 32-bit mode (yet).
Evan Cheng4cae1332010-03-05 08:38:04 +0000222declare fastcc %struct.ns* @foo7(%struct.cp* byval align 4, i8 signext) nounwind ssp
Evan Cheng1ad584e2010-03-20 03:17:05 +0000223
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 ()* }
228
229define void @t14(%struct.__block_literal_2* nocapture %.block_descriptor) nounwind ssp {
230entry:
231; 64: t14:
232; 64: movq 32(%rdi)
233; 64-NOT: movq 16(%rdi)
234; 64: jmpq *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
243 ret void
244}
245
246; rdar://7726868
247%struct.foo = type { [4 x i32] }
248
249define void @t15(%struct.foo* noalias sret %agg.result) nounwind {
250; 32: t15:
Chris Lattner1eb1b682010-09-22 05:49:14 +0000251; 32: calll {{_?}}f
Evan Cheng1ad584e2010-03-20 03:17:05 +0000252; 32: ret $4
253
254; 64: t15:
255; 64: callq {{_?}}f
256; 64: ret
257 tail call fastcc void @f(%struct.foo* noalias sret %agg.result) nounwind
258 ret void
259}
260
261declare void @f(%struct.foo* noalias sret) nounwind
262
263define void @t16() nounwind ssp {
264entry:
265; 32: t16:
Chris Lattner1eb1b682010-09-22 05:49:14 +0000266; 32: calll {{_?}}bar4
Evan Cheng1ad584e2010-03-20 03:17:05 +0000267; 32: fstp
268
269; 64: t16:
270; 64: jmp {{_?}}bar4
271 %0 = tail call double @bar4() nounwind
272 ret void
273}
274
275declare double @bar4()
Evan Cheng3c262ee2010-03-26 02:13:13 +0000276
277; rdar://6283267
278define void @t17() nounwind ssp {
279entry:
280; 32: t17:
281; 32: jmp {{_?}}bar5
282
283; 64: t17:
284; 64: xorb %al, %al
285; 64: jmp {{_?}}bar5
286 tail call void (...)* @bar5() nounwind
287 ret void
288}
289
290declare void @bar5(...)
291
292; rdar://7774847
293define void @t18() nounwind ssp {
294entry:
295; 32: t18:
Chris Lattner1eb1b682010-09-22 05:49:14 +0000296; 32: calll {{_?}}bar6
Evan Cheng3c262ee2010-03-26 02:13:13 +0000297; 32: fstp %st(0)
298
299; 64: t18:
300; 64: xorb %al, %al
301; 64: jmp {{_?}}bar6
302 %0 = tail call double (...)* @bar6() nounwind
303 ret void
304}
305
306declare double @bar6(...)
Evan Cheng2c12cb42010-03-26 16:26:03 +0000307
308define void @t19() alignstack(32) nounwind {
309entry:
310; CHECK: t19:
311; CHECK: andl $-32
Chris Lattner1eb1b682010-09-22 05:49:14 +0000312; CHECK: calll {{_?}}foo
Evan Cheng2c12cb42010-03-26 16:26:03 +0000313 tail call void @foo() nounwind
314 ret void
315}
316
317declare void @foo()
Evan Cheng13617962010-04-30 01:12:32 +0000318
319; If caller / callee calling convention mismatch then check if the return
320; values are returned in the same registers.
321; rdar://7874780
322
323define double @t20(double %x) nounwind {
324entry:
325; 32: t20:
Chris Lattner1eb1b682010-09-22 05:49:14 +0000326; 32: calll {{_?}}foo20
Evan Cheng13617962010-04-30 01:12:32 +0000327; 32: fldl (%esp)
328
329; 64: t20:
330; 64: jmp {{_?}}foo20
331 %0 = tail call fastcc double @foo20(double %x) nounwind
332 ret double %0
333}
334
335declare fastcc double @foo20(double) nounwind