1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -verify-machineinstrs < %s -mtriple=i686-linux -mcpu=core2 -mattr=+sse2 | FileCheck %s --check-prefix=X86
3 ; RUN: llc -verify-machineinstrs < %s -mtriple=x86_64-linux -mcpu=core2 -mattr=+sse2 | FileCheck %s --check-prefix=X64
4 ; RUN: llc -verify-machineinstrs < %s -mtriple=x86_64-linux-gnux32 -mcpu=core2 -mattr=+sse2 | FileCheck %s --check-prefix=X32
6 define dso_local void @t1(i32 %x) nounwind ssp {
9 ; X86-NEXT: jmp foo # TAILCALL
13 ; X64-NEXT: jmp foo # TAILCALL
17 ; X32-NEXT: jmp foo # TAILCALL
18 tail call void @foo() nounwind
22 declare dso_local void @foo()
24 define dso_local void @t2() nounwind ssp {
27 ; X86-NEXT: jmp foo2 # TAILCALL
31 ; X64-NEXT: jmp foo2 # TAILCALL
35 ; X32-NEXT: jmp foo2 # TAILCALL
36 %t0 = tail call i32 @foo2() nounwind
40 declare dso_local i32 @foo2()
42 define dso_local void @t3() nounwind ssp {
45 ; X86-NEXT: jmp foo3 # TAILCALL
49 ; X64-NEXT: jmp foo3 # TAILCALL
53 ; X32-NEXT: jmp foo3 # TAILCALL
54 %t0 = tail call i32 @foo3() nounwind
58 declare dso_local i32 @foo3()
60 define dso_local void @t4(void (i32)* nocapture %x) nounwind ssp {
63 ; X86-NEXT: subl $12, %esp
64 ; X86-NEXT: movl $0, (%esp)
65 ; X86-NEXT: calll *{{[0-9]+}}(%esp)
66 ; X86-NEXT: addl $12, %esp
71 ; X64-NEXT: movq %rdi, %rax
72 ; X64-NEXT: xorl %edi, %edi
73 ; X64-NEXT: jmpq *%rax # TAILCALL
77 ; X32-NEXT: movq %rdi, %rax
78 ; X32-NEXT: xorl %edi, %edi
79 ; X32-NEXT: jmpq *%rax # TAILCALL
80 tail call void %x(i32 0) nounwind
84 define dso_local void @t5(void ()* nocapture %x) nounwind ssp {
87 ; X86-NEXT: jmpl *{{[0-9]+}}(%esp) # TAILCALL
91 ; X64-NEXT: jmpq *%rdi # TAILCALL
95 ; X32-NEXT: jmpq *%rdi # TAILCALL
96 tail call void %x() nounwind
100 ; Basically the same test as t5, except pass the function pointer on the stack
103 define dso_local void @t5_x64(i32, i32, i32, i32, i32, i32, void ()* nocapture %x) nounwind ssp {
106 ; X86-NEXT: jmpl *{{[0-9]+}}(%esp) # TAILCALL
110 ; X64-NEXT: jmpq *{{[0-9]+}}(%rsp) # TAILCALL
114 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
115 ; X32-NEXT: jmpq *%rax # TAILCALL
116 tail call void %x() nounwind
121 define dso_local i32 @t6(i32 %x) nounwind ssp {
124 ; X86-NEXT: subl $12, %esp
125 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
126 ; X86-NEXT: cmpl $9, %eax
127 ; X86-NEXT: jg .LBB6_2
128 ; X86-NEXT: # %bb.1: # %bb
129 ; X86-NEXT: decl %eax
130 ; X86-NEXT: movl %eax, (%esp)
132 ; X86-NEXT: addl $12, %esp
134 ; X86-NEXT: .LBB6_2: # %bb1
135 ; X86-NEXT: addl $12, %esp
136 ; X86-NEXT: jmp bar # TAILCALL
140 ; X64-NEXT: cmpl $9, %edi
141 ; X64-NEXT: jg .LBB6_2
142 ; X64-NEXT: # %bb.1: # %bb
143 ; X64-NEXT: decl %edi
144 ; X64-NEXT: jmp t6 # TAILCALL
145 ; X64-NEXT: .LBB6_2: # %bb1
146 ; X64-NEXT: jmp bar # TAILCALL
150 ; X32-NEXT: cmpl $9, %edi
151 ; X32-NEXT: jg .LBB6_2
152 ; X32-NEXT: # %bb.1: # %bb
153 ; X32-NEXT: decl %edi
154 ; X32-NEXT: jmp t6 # TAILCALL
155 ; X32-NEXT: .LBB6_2: # %bb1
156 ; X32-NEXT: jmp bar # TAILCALL
157 %t0 = icmp slt i32 %x, 10
158 br i1 %t0, label %bb, label %bb1
161 %t1 = add nsw i32 %x, -1
162 %t2 = tail call i32 @t6(i32 %t1) nounwind ssp
166 %t3 = tail call i32 @bar(i32 %x) nounwind
170 declare dso_local i32 @bar(i32)
172 define dso_local i32 @t7(i32 %a, i32 %b, i32 %c) nounwind ssp {
175 ; X86-NEXT: jmp bar2 # TAILCALL
179 ; X64-NEXT: jmp bar2 # TAILCALL
183 ; X32-NEXT: jmp bar2 # TAILCALL
184 %t0 = tail call i32 @bar2(i32 %a, i32 %b, i32 %c) nounwind
188 declare dso_local i32 @bar2(i32, i32, i32)
190 define signext i16 @t8() nounwind ssp {
192 ; X86: # %bb.0: # %entry
193 ; X86-NEXT: jmp bar3 # TAILCALL
196 ; X64: # %bb.0: # %entry
197 ; X64-NEXT: jmp bar3 # TAILCALL
200 ; X32: # %bb.0: # %entry
201 ; X32-NEXT: jmp bar3 # TAILCALL
203 %0 = tail call signext i16 @bar3() nounwind ; <i16> [#uses=1]
207 declare dso_local signext i16 @bar3()
209 define signext i16 @t9(i32 (i32)* nocapture %x) nounwind ssp {
211 ; X86: # %bb.0: # %entry
212 ; X86-NEXT: subl $12, %esp
213 ; X86-NEXT: movl $0, (%esp)
214 ; X86-NEXT: calll *{{[0-9]+}}(%esp)
215 ; X86-NEXT: addl $12, %esp
219 ; X64: # %bb.0: # %entry
220 ; X64-NEXT: movq %rdi, %rax
221 ; X64-NEXT: xorl %edi, %edi
222 ; X64-NEXT: jmpq *%rax # TAILCALL
225 ; X32: # %bb.0: # %entry
226 ; X32-NEXT: movq %rdi, %rax
227 ; X32-NEXT: xorl %edi, %edi
228 ; X32-NEXT: jmpq *%rax # TAILCALL
230 %0 = bitcast i32 (i32)* %x to i16 (i32)*
231 %1 = tail call signext i16 %0(i32 0) nounwind
235 define dso_local void @t10() nounwind ssp {
237 ; X86: # %bb.0: # %entry
238 ; X86-NEXT: subl $12, %esp
239 ; X86-NEXT: calll foo4
242 ; X64: # %bb.0: # %entry
243 ; X64-NEXT: pushq %rax
244 ; X64-NEXT: callq foo4
247 ; X32: # %bb.0: # %entry
248 ; X32-NEXT: pushq %rax
249 ; X32-NEXT: callq foo4
251 %0 = tail call i32 @foo4() noreturn nounwind
255 declare dso_local i32 @foo4()
257 ; In 32-bit mode, it's emitting a bunch of dead loads that are not being
258 ; eliminated currently.
260 define dso_local i32 @t11(i32 %x, i32 %y, i32 %z.0, i32 %z.1, i32 %z.2) nounwind ssp {
262 ; X86: # %bb.0: # %entry
263 ; X86-NEXT: cmpl $0, {{[0-9]+}}(%esp)
264 ; X86-NEXT: je .LBB11_1
265 ; X86-NEXT: # %bb.2: # %bb
266 ; X86-NEXT: jmp foo5 # TAILCALL
267 ; X86-NEXT: .LBB11_1: # %bb6
268 ; X86-NEXT: xorl %eax, %eax
272 ; X64: # %bb.0: # %entry
273 ; X64-NEXT: testl %edi, %edi
274 ; X64-NEXT: je .LBB11_1
275 ; X64-NEXT: # %bb.2: # %bb
276 ; X64-NEXT: jmp foo5 # TAILCALL
277 ; X64-NEXT: .LBB11_1: # %bb6
278 ; X64-NEXT: xorl %eax, %eax
282 ; X32: # %bb.0: # %entry
283 ; X32-NEXT: testl %edi, %edi
284 ; X32-NEXT: je .LBB11_1
285 ; X32-NEXT: # %bb.2: # %bb
286 ; X32-NEXT: jmp foo5 # TAILCALL
287 ; X32-NEXT: .LBB11_1: # %bb6
288 ; X32-NEXT: xorl %eax, %eax
291 %0 = icmp eq i32 %x, 0
292 br i1 %0, label %bb6, label %bb
295 %1 = tail call i32 @foo5(i32 %x, i32 %y, i32 %z.0, i32 %z.1, i32 %z.2) nounwind
302 declare dso_local i32 @foo5(i32, i32, i32, i32, i32)
304 %struct.t = type { i32, i32, i32, i32, i32 }
306 define dso_local i32 @t12(i32 %x, i32 %y, %struct.t* byval(%struct.t) align 4 %z) nounwind ssp {
308 ; X86: # %bb.0: # %entry
309 ; X86-NEXT: cmpl $0, {{[0-9]+}}(%esp)
310 ; X86-NEXT: je .LBB12_1
311 ; X86-NEXT: # %bb.2: # %bb
312 ; X86-NEXT: jmp foo6 # TAILCALL
313 ; X86-NEXT: .LBB12_1: # %bb2
314 ; X86-NEXT: xorl %eax, %eax
318 ; X64: # %bb.0: # %entry
319 ; X64-NEXT: testl %edi, %edi
320 ; X64-NEXT: je .LBB12_1
321 ; X64-NEXT: # %bb.2: # %bb
322 ; X64-NEXT: jmp foo6 # TAILCALL
323 ; X64-NEXT: .LBB12_1: # %bb2
324 ; X64-NEXT: xorl %eax, %eax
328 ; X32: # %bb.0: # %entry
329 ; X32-NEXT: testl %edi, %edi
330 ; X32-NEXT: je .LBB12_1
331 ; X32-NEXT: # %bb.2: # %bb
332 ; X32-NEXT: jmp foo6 # TAILCALL
333 ; X32-NEXT: .LBB12_1: # %bb2
334 ; X32-NEXT: xorl %eax, %eax
337 %0 = icmp eq i32 %x, 0
338 br i1 %0, label %bb2, label %bb
341 %1 = tail call i32 @foo6(i32 %x, i32 %y, %struct.t* byval(%struct.t) align 4 %z) nounwind
348 declare dso_local i32 @foo6(i32, i32, %struct.t* byval(%struct.t) align 4)
351 %struct.ns = type { i32, i32 }
352 %struct.cp = type { float, float, float, float, float }
354 define %struct.ns* @t13(%struct.cp* %yy) nounwind ssp {
356 ; X86: # %bb.0: # %entry
357 ; X86-NEXT: subl $28, %esp
358 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
359 ; X86-NEXT: movl 16(%eax), %ecx
360 ; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
361 ; X86-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
362 ; X86-NEXT: movsd {{.*#+}} xmm1 = mem[0],zero
363 ; X86-NEXT: movsd %xmm1, {{[0-9]+}}(%esp)
364 ; X86-NEXT: movsd %xmm0, (%esp)
365 ; X86-NEXT: xorl %ecx, %ecx
366 ; X86-NEXT: calll foo7
367 ; X86-NEXT: addl $28, %esp
371 ; X64: # %bb.0: # %entry
372 ; X64-NEXT: pushq %rax
373 ; X64-NEXT: subq $8, %rsp
374 ; X64-NEXT: movl 16(%rdi), %eax
375 ; X64-NEXT: movq (%rdi), %rcx
376 ; X64-NEXT: movq 8(%rdi), %rdx
377 ; X64-NEXT: xorl %edi, %edi
378 ; X64-NEXT: pushq %rax
379 ; X64-NEXT: pushq %rdx
380 ; X64-NEXT: pushq %rcx
381 ; X64-NEXT: callq foo7
382 ; X64-NEXT: addq $32, %rsp
383 ; X64-NEXT: popq %rcx
387 ; X32: # %bb.0: # %entry
388 ; X32-NEXT: pushq %rax
389 ; X32-NEXT: subl $8, %esp
390 ; X32-NEXT: movl 16(%edi), %eax
391 ; X32-NEXT: movq (%edi), %rcx
392 ; X32-NEXT: movq 8(%edi), %rdx
393 ; X32-NEXT: xorl %edi, %edi
394 ; X32-NEXT: pushq %rax
395 ; X32-NEXT: pushq %rdx
396 ; X32-NEXT: pushq %rcx
397 ; X32-NEXT: callq foo7
398 ; X32-NEXT: addl $32, %esp
399 ; X32-NEXT: movl %eax, %eax
400 ; X32-NEXT: popq %rcx
403 %0 = tail call fastcc %struct.ns* @foo7(%struct.cp* byval(%struct.cp) align 4 %yy, i8 signext 0) nounwind
408 ; llvm can't do sibcall for this in 32-bit mode (yet).
409 declare dso_local fastcc %struct.ns* @foo7(%struct.cp* byval(%struct.cp) align 4, i8 signext) nounwind ssp
411 %struct.__block_descriptor = type { i64, i64 }
412 %struct.__block_descriptor_withcopydispose = type { i64, i64, i8*, i8* }
413 %struct.__block_literal_1 = type { i8*, i32, i32, i8*, %struct.__block_descriptor* }
414 %struct.__block_literal_2 = type { i8*, i32, i32, i8*, %struct.__block_descriptor_withcopydispose*, void ()* }
416 define dso_local void @t14(%struct.__block_literal_2* nocapture %.block_descriptor) nounwind ssp {
418 ; X86: # %bb.0: # %entry
419 ; X86-NEXT: subl $12, %esp
420 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
421 ; X86-NEXT: movl 20(%eax), %eax
422 ; X86-NEXT: movl %eax, (%esp)
423 ; X86-NEXT: calll *12(%eax)
424 ; X86-NEXT: addl $12, %esp
428 ; X64: # %bb.0: # %entry
429 ; X64-NEXT: movq 32(%rdi), %rdi
430 ; X64-NEXT: jmpq *16(%rdi) # TAILCALL
433 ; X32: # %bb.0: # %entry
434 ; X32-NEXT: movl 20(%edi), %edi
435 ; X32-NEXT: movl 12(%edi), %eax
436 ; X32-NEXT: jmpq *%rax # TAILCALL
438 %0 = getelementptr inbounds %struct.__block_literal_2, %struct.__block_literal_2* %.block_descriptor, i64 0, i32 5 ; <void ()**> [#uses=1]
439 %1 = load void ()*, void ()** %0, align 8 ; <void ()*> [#uses=2]
440 %2 = bitcast void ()* %1 to %struct.__block_literal_1* ; <%struct.__block_literal_1*> [#uses=1]
441 %3 = getelementptr inbounds %struct.__block_literal_1, %struct.__block_literal_1* %2, i64 0, i32 3 ; <i8**> [#uses=1]
442 %4 = load i8*, i8** %3, align 8 ; <i8*> [#uses=1]
443 %5 = bitcast i8* %4 to void (i8*)* ; <void (i8*)*> [#uses=1]
444 %6 = bitcast void ()* %1 to i8* ; <i8*> [#uses=1]
445 tail call void %5(i8* %6) nounwind
450 %struct.foo = type { [4 x i32] }
452 define dso_local void @t15(%struct.foo* noalias sret(%struct.foo) %agg.result) nounwind {
455 ; X86-NEXT: pushl %esi
456 ; X86-NEXT: subl $8, %esp
457 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
458 ; X86-NEXT: movl %esi, %ecx
460 ; X86-NEXT: movl %esi, %eax
461 ; X86-NEXT: addl $8, %esp
462 ; X86-NEXT: popl %esi
467 ; X64-NEXT: pushq %rbx
468 ; X64-NEXT: movq %rdi, %rbx
470 ; X64-NEXT: movq %rbx, %rax
471 ; X64-NEXT: popq %rbx
476 ; X32-NEXT: pushq %rbx
477 ; X32-NEXT: movq %rdi, %rbx
479 ; X32-NEXT: movl %ebx, %eax
480 ; X32-NEXT: popq %rbx
482 tail call fastcc void @f(%struct.foo* noalias sret(%struct.foo) %agg.result) nounwind
486 declare dso_local void @f(%struct.foo* noalias sret(%struct.foo)) nounwind
488 define dso_local void @t16() nounwind ssp {
490 ; X86: # %bb.0: # %entry
491 ; X86-NEXT: subl $12, %esp
492 ; X86-NEXT: calll bar4
493 ; X86-NEXT: fstp %st(0)
494 ; X86-NEXT: addl $12, %esp
498 ; X64: # %bb.0: # %entry
499 ; X64-NEXT: jmp bar4 # TAILCALL
502 ; X32: # %bb.0: # %entry
503 ; X32-NEXT: jmp bar4 # TAILCALL
505 %0 = tail call double @bar4() nounwind
509 declare dso_local double @bar4()
512 define dso_local void @t17() nounwind ssp {
514 ; X86: # %bb.0: # %entry
515 ; X86-NEXT: jmp bar5 # TAILCALL
518 ; X64: # %bb.0: # %entry
519 ; X64-NEXT: xorl %eax, %eax
520 ; X64-NEXT: jmp bar5 # TAILCALL
523 ; X32: # %bb.0: # %entry
524 ; X32-NEXT: xorl %eax, %eax
525 ; X32-NEXT: jmp bar5 # TAILCALL
527 tail call void (...) @bar5() nounwind
531 declare dso_local void @bar5(...)
534 define dso_local void @t18() nounwind ssp {
536 ; X86: # %bb.0: # %entry
537 ; X86-NEXT: subl $12, %esp
538 ; X86-NEXT: calll bar6
539 ; X86-NEXT: fstp %st(0)
540 ; X86-NEXT: addl $12, %esp
544 ; X64: # %bb.0: # %entry
545 ; X64-NEXT: xorl %eax, %eax
546 ; X64-NEXT: jmp bar6 # TAILCALL
549 ; X32: # %bb.0: # %entry
550 ; X32-NEXT: xorl %eax, %eax
551 ; X32-NEXT: jmp bar6 # TAILCALL
553 %0 = tail call double (...) @bar6() nounwind
557 declare dso_local double @bar6(...)
559 define dso_local void @t19() alignstack(32) nounwind {
561 ; X86: # %bb.0: # %entry
562 ; X86-NEXT: pushl %ebp
563 ; X86-NEXT: movl %esp, %ebp
564 ; X86-NEXT: andl $-32, %esp
565 ; X86-NEXT: subl $32, %esp
566 ; X86-NEXT: calll foo
567 ; X86-NEXT: movl %ebp, %esp
568 ; X86-NEXT: popl %ebp
572 ; X64: # %bb.0: # %entry
573 ; X64-NEXT: pushq %rbp
574 ; X64-NEXT: movq %rsp, %rbp
575 ; X64-NEXT: andq $-32, %rsp
576 ; X64-NEXT: subq $32, %rsp
577 ; X64-NEXT: callq foo
578 ; X64-NEXT: movq %rbp, %rsp
579 ; X64-NEXT: popq %rbp
583 ; X32: # %bb.0: # %entry
584 ; X32-NEXT: pushq %rbp
585 ; X32-NEXT: movl %esp, %ebp
586 ; X32-NEXT: andl $-32, %esp
587 ; X32-NEXT: subl $32, %esp
588 ; X32-NEXT: callq foo
589 ; X32-NEXT: movl %ebp, %esp
590 ; X32-NEXT: popq %rbp
593 tail call void @foo() nounwind
597 ; If caller / callee calling convention mismatch then check if the return
598 ; values are returned in the same registers.
601 define dso_local double @t20(double %x) nounwind {
603 ; X86: # %bb.0: # %entry
604 ; X86-NEXT: subl $12, %esp
605 ; X86-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
606 ; X86-NEXT: calll foo20
607 ; X86-NEXT: movsd %xmm0, (%esp)
608 ; X86-NEXT: fldl (%esp)
609 ; X86-NEXT: addl $12, %esp
613 ; X64: # %bb.0: # %entry
614 ; X64-NEXT: jmp foo20 # TAILCALL
617 ; X32: # %bb.0: # %entry
618 ; X32-NEXT: jmp foo20 # TAILCALL
620 %0 = tail call fastcc double @foo20(double %x) nounwind
624 declare dso_local fastcc double @foo20(double) nounwind
627 define fastcc void @t21_sret_to_sret(%struct.foo* noalias sret(%struct.foo) %agg.result) nounwind {
628 ; X86-LABEL: t21_sret_to_sret:
630 ; X86-NEXT: pushl %esi
631 ; X86-NEXT: subl $8, %esp
632 ; X86-NEXT: movl %ecx, %esi
633 ; X86-NEXT: calll t21_f_sret
634 ; X86-NEXT: movl %esi, %eax
635 ; X86-NEXT: addl $8, %esp
636 ; X86-NEXT: popl %esi
639 ; X64-LABEL: t21_sret_to_sret:
641 ; X64-NEXT: pushq %rbx
642 ; X64-NEXT: movq %rdi, %rbx
643 ; X64-NEXT: callq t21_f_sret
644 ; X64-NEXT: movq %rbx, %rax
645 ; X64-NEXT: popq %rbx
648 ; X32-LABEL: t21_sret_to_sret:
650 ; X32-NEXT: pushq %rbx
651 ; X32-NEXT: movq %rdi, %rbx
652 ; X32-NEXT: callq t21_f_sret
653 ; X32-NEXT: movl %ebx, %eax
654 ; X32-NEXT: popq %rbx
656 tail call fastcc void @t21_f_sret(%struct.foo* noalias sret(%struct.foo) %agg.result) nounwind
660 define fastcc void @t21_sret_to_sret_alloca(%struct.foo* noalias sret(%struct.foo) %agg.result) nounwind {
661 ; X86-LABEL: t21_sret_to_sret_alloca:
663 ; X86-NEXT: pushl %esi
664 ; X86-NEXT: subl $24, %esp
665 ; X86-NEXT: movl %ecx, %esi
666 ; X86-NEXT: leal {{[0-9]+}}(%esp), %ecx
667 ; X86-NEXT: calll t21_f_sret
668 ; X86-NEXT: movl %esi, %eax
669 ; X86-NEXT: addl $24, %esp
670 ; X86-NEXT: popl %esi
673 ; X64-LABEL: t21_sret_to_sret_alloca:
675 ; X64-NEXT: pushq %rbx
676 ; X64-NEXT: subq $16, %rsp
677 ; X64-NEXT: movq %rdi, %rbx
678 ; X64-NEXT: movq %rsp, %rdi
679 ; X64-NEXT: callq t21_f_sret
680 ; X64-NEXT: movq %rbx, %rax
681 ; X64-NEXT: addq $16, %rsp
682 ; X64-NEXT: popq %rbx
685 ; X32-LABEL: t21_sret_to_sret_alloca:
687 ; X32-NEXT: pushq %rbx
688 ; X32-NEXT: subl $16, %esp
689 ; X32-NEXT: movq %rdi, %rbx
690 ; X32-NEXT: movl %esp, %edi
691 ; X32-NEXT: callq t21_f_sret
692 ; X32-NEXT: movl %ebx, %eax
693 ; X32-NEXT: addl $16, %esp
694 ; X32-NEXT: popq %rbx
696 %a = alloca %struct.foo, align 8
697 tail call fastcc void @t21_f_sret(%struct.foo* noalias sret(%struct.foo) %a) nounwind
701 define fastcc void @t21_sret_to_sret_more_args(%struct.foo* noalias sret(%struct.foo) %agg.result, i32 %a, i32 %b) nounwind {
702 ; X86-LABEL: t21_sret_to_sret_more_args:
704 ; X86-NEXT: pushl %esi
705 ; X86-NEXT: subl $8, %esp
706 ; X86-NEXT: movl %ecx, %esi
707 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
708 ; X86-NEXT: movl %eax, (%esp)
709 ; X86-NEXT: calll f_sret@PLT
710 ; X86-NEXT: movl %esi, %eax
711 ; X86-NEXT: addl $8, %esp
712 ; X86-NEXT: popl %esi
715 ; X64-LABEL: t21_sret_to_sret_more_args:
717 ; X64-NEXT: pushq %rbx
718 ; X64-NEXT: movq %rdi, %rbx
719 ; X64-NEXT: callq f_sret@PLT
720 ; X64-NEXT: movq %rbx, %rax
721 ; X64-NEXT: popq %rbx
724 ; X32-LABEL: t21_sret_to_sret_more_args:
726 ; X32-NEXT: pushq %rbx
727 ; X32-NEXT: movq %rdi, %rbx
728 ; X32-NEXT: callq f_sret@PLT
729 ; X32-NEXT: movl %ebx, %eax
730 ; X32-NEXT: popq %rbx
732 tail call fastcc void @f_sret(%struct.foo* noalias sret(%struct.foo) %agg.result, i32 %a, i32 %b) nounwind
736 define fastcc void @t21_sret_to_sret_second_arg_sret(%struct.foo* noalias %agg.result, %struct.foo* noalias sret(%struct.foo) %ret) nounwind {
737 ; X86-LABEL: t21_sret_to_sret_second_arg_sret:
739 ; X86-NEXT: pushl %esi
740 ; X86-NEXT: subl $8, %esp
741 ; X86-NEXT: movl %edx, %esi
742 ; X86-NEXT: movl %edx, %ecx
743 ; X86-NEXT: calll t21_f_sret
744 ; X86-NEXT: movl %esi, %eax
745 ; X86-NEXT: addl $8, %esp
746 ; X86-NEXT: popl %esi
749 ; X64-LABEL: t21_sret_to_sret_second_arg_sret:
751 ; X64-NEXT: pushq %rbx
752 ; X64-NEXT: movq %rsi, %rbx
753 ; X64-NEXT: movq %rsi, %rdi
754 ; X64-NEXT: callq t21_f_sret
755 ; X64-NEXT: movq %rbx, %rax
756 ; X64-NEXT: popq %rbx
759 ; X32-LABEL: t21_sret_to_sret_second_arg_sret:
761 ; X32-NEXT: pushq %rbx
762 ; X32-NEXT: movq %rsi, %rbx
763 ; X32-NEXT: movq %rsi, %rdi
764 ; X32-NEXT: callq t21_f_sret
765 ; X32-NEXT: movl %ebx, %eax
766 ; X32-NEXT: popq %rbx
768 tail call fastcc void @t21_f_sret(%struct.foo* noalias sret(%struct.foo) %ret) nounwind
772 define fastcc void @t21_sret_to_sret_more_args2(%struct.foo* noalias sret(%struct.foo) %agg.result, i32 %a, i32 %b) nounwind {
773 ; X86-LABEL: t21_sret_to_sret_more_args2:
775 ; X86-NEXT: pushl %esi
776 ; X86-NEXT: subl $8, %esp
777 ; X86-NEXT: movl %ecx, %esi
778 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
779 ; X86-NEXT: movl %edx, (%esp)
780 ; X86-NEXT: movl %eax, %edx
781 ; X86-NEXT: calll f_sret@PLT
782 ; X86-NEXT: movl %esi, %eax
783 ; X86-NEXT: addl $8, %esp
784 ; X86-NEXT: popl %esi
787 ; X64-LABEL: t21_sret_to_sret_more_args2:
789 ; X64-NEXT: pushq %rbx
790 ; X64-NEXT: movl %esi, %eax
791 ; X64-NEXT: movq %rdi, %rbx
792 ; X64-NEXT: movl %edx, %esi
793 ; X64-NEXT: movl %eax, %edx
794 ; X64-NEXT: callq f_sret@PLT
795 ; X64-NEXT: movq %rbx, %rax
796 ; X64-NEXT: popq %rbx
799 ; X32-LABEL: t21_sret_to_sret_more_args2:
801 ; X32-NEXT: pushq %rbx
802 ; X32-NEXT: movl %esi, %eax
803 ; X32-NEXT: movq %rdi, %rbx
804 ; X32-NEXT: movl %edx, %esi
805 ; X32-NEXT: movl %eax, %edx
806 ; X32-NEXT: callq f_sret@PLT
807 ; X32-NEXT: movl %ebx, %eax
808 ; X32-NEXT: popq %rbx
810 tail call fastcc void @f_sret(%struct.foo* noalias sret(%struct.foo) %agg.result, i32 %b, i32 %a) nounwind
815 define fastcc void @t21_sret_to_sret_args_mismatch(%struct.foo* noalias sret(%struct.foo) %agg.result, %struct.foo* noalias %ret) nounwind {
816 ; X86-LABEL: t21_sret_to_sret_args_mismatch:
818 ; X86-NEXT: pushl %esi
819 ; X86-NEXT: subl $8, %esp
820 ; X86-NEXT: movl %ecx, %esi
821 ; X86-NEXT: movl %edx, %ecx
822 ; X86-NEXT: calll t21_f_sret
823 ; X86-NEXT: movl %esi, %eax
824 ; X86-NEXT: addl $8, %esp
825 ; X86-NEXT: popl %esi
828 ; X64-LABEL: t21_sret_to_sret_args_mismatch:
830 ; X64-NEXT: pushq %rbx
831 ; X64-NEXT: movq %rdi, %rbx
832 ; X64-NEXT: movq %rsi, %rdi
833 ; X64-NEXT: callq t21_f_sret
834 ; X64-NEXT: movq %rbx, %rax
835 ; X64-NEXT: popq %rbx
838 ; X32-LABEL: t21_sret_to_sret_args_mismatch:
840 ; X32-NEXT: pushq %rbx
841 ; X32-NEXT: movq %rdi, %rbx
842 ; X32-NEXT: movq %rsi, %rdi
843 ; X32-NEXT: callq t21_f_sret
844 ; X32-NEXT: movl %ebx, %eax
845 ; X32-NEXT: popq %rbx
847 tail call fastcc void @t21_f_sret(%struct.foo* noalias sret(%struct.foo) %ret) nounwind
851 define fastcc void @t21_sret_to_sret_args_mismatch2(%struct.foo* noalias sret(%struct.foo) %agg.result, %struct.foo* noalias %ret) nounwind {
852 ; X86-LABEL: t21_sret_to_sret_args_mismatch2:
854 ; X86-NEXT: pushl %esi
855 ; X86-NEXT: subl $8, %esp
856 ; X86-NEXT: movl %ecx, %esi
857 ; X86-NEXT: movl %edx, %ecx
858 ; X86-NEXT: calll t21_f_sret
859 ; X86-NEXT: movl %esi, %eax
860 ; X86-NEXT: addl $8, %esp
861 ; X86-NEXT: popl %esi
864 ; X64-LABEL: t21_sret_to_sret_args_mismatch2:
866 ; X64-NEXT: pushq %rbx
867 ; X64-NEXT: movq %rdi, %rbx
868 ; X64-NEXT: movq %rsi, %rdi
869 ; X64-NEXT: callq t21_f_sret
870 ; X64-NEXT: movq %rbx, %rax
871 ; X64-NEXT: popq %rbx
874 ; X32-LABEL: t21_sret_to_sret_args_mismatch2:
876 ; X32-NEXT: pushq %rbx
877 ; X32-NEXT: movq %rdi, %rbx
878 ; X32-NEXT: movq %rsi, %rdi
879 ; X32-NEXT: callq t21_f_sret
880 ; X32-NEXT: movl %ebx, %eax
881 ; X32-NEXT: popq %rbx
883 tail call fastcc void @t21_f_sret(%struct.foo* noalias sret(%struct.foo) %ret) nounwind
887 define fastcc void @t21_sret_to_sret_arg_mismatch(%struct.foo* noalias sret(%struct.foo) %agg.result) nounwind {
888 ; X86-LABEL: t21_sret_to_sret_arg_mismatch:
890 ; X86-NEXT: pushl %esi
891 ; X86-NEXT: subl $8, %esp
892 ; X86-NEXT: movl %ecx, %esi
893 ; X86-NEXT: calll ret_struct@PLT
894 ; X86-NEXT: movl %eax, %ecx
895 ; X86-NEXT: calll t21_f_sret
896 ; X86-NEXT: movl %esi, %eax
897 ; X86-NEXT: addl $8, %esp
898 ; X86-NEXT: popl %esi
901 ; X64-LABEL: t21_sret_to_sret_arg_mismatch:
903 ; X64-NEXT: pushq %rbx
904 ; X64-NEXT: movq %rdi, %rbx
905 ; X64-NEXT: callq ret_struct@PLT
906 ; X64-NEXT: movq %rax, %rdi
907 ; X64-NEXT: callq t21_f_sret
908 ; X64-NEXT: movq %rbx, %rax
909 ; X64-NEXT: popq %rbx
912 ; X32-LABEL: t21_sret_to_sret_arg_mismatch:
914 ; X32-NEXT: pushq %rbx
915 ; X32-NEXT: movq %rdi, %rbx
916 ; X32-NEXT: callq ret_struct@PLT
917 ; X32-NEXT: movl %eax, %edi
918 ; X32-NEXT: callq t21_f_sret
919 ; X32-NEXT: movl %ebx, %eax
920 ; X32-NEXT: popq %rbx
922 %a = call fastcc %struct.foo* @ret_struct()
923 tail call fastcc void @t21_f_sret(%struct.foo* noalias sret(%struct.foo) %a) nounwind
927 define fastcc void @t21_sret_to_sret_structs_mismatch(%struct.foo* noalias sret(%struct.foo) %agg.result, %struct.foo* noalias %a) nounwind {
928 ; X86-LABEL: t21_sret_to_sret_structs_mismatch:
930 ; X86-NEXT: pushl %edi
931 ; X86-NEXT: pushl %esi
932 ; X86-NEXT: pushl %eax
933 ; X86-NEXT: movl %edx, %esi
934 ; X86-NEXT: movl %ecx, %edi
935 ; X86-NEXT: calll ret_struct@PLT
936 ; X86-NEXT: movl %esi, %ecx
937 ; X86-NEXT: movl %eax, %edx
938 ; X86-NEXT: calll t21_f_sret2
939 ; X86-NEXT: movl %edi, %eax
940 ; X86-NEXT: addl $4, %esp
941 ; X86-NEXT: popl %esi
942 ; X86-NEXT: popl %edi
945 ; X64-LABEL: t21_sret_to_sret_structs_mismatch:
947 ; X64-NEXT: pushq %r14
948 ; X64-NEXT: pushq %rbx
949 ; X64-NEXT: pushq %rax
950 ; X64-NEXT: movq %rsi, %rbx
951 ; X64-NEXT: movq %rdi, %r14
952 ; X64-NEXT: callq ret_struct@PLT
953 ; X64-NEXT: movq %rbx, %rdi
954 ; X64-NEXT: movq %rax, %rsi
955 ; X64-NEXT: callq t21_f_sret2
956 ; X64-NEXT: movq %r14, %rax
957 ; X64-NEXT: addq $8, %rsp
958 ; X64-NEXT: popq %rbx
959 ; X64-NEXT: popq %r14
962 ; X32-LABEL: t21_sret_to_sret_structs_mismatch:
964 ; X32-NEXT: pushq %r14
965 ; X32-NEXT: pushq %rbx
966 ; X32-NEXT: pushq %rax
967 ; X32-NEXT: movq %rsi, %rbx
968 ; X32-NEXT: movq %rdi, %r14
969 ; X32-NEXT: callq ret_struct@PLT
970 ; X32-NEXT: movl %eax, %esi
971 ; X32-NEXT: movq %rbx, %rdi
972 ; X32-NEXT: callq t21_f_sret2
973 ; X32-NEXT: movl %r14d, %eax
974 ; X32-NEXT: addl $8, %esp
975 ; X32-NEXT: popq %rbx
976 ; X32-NEXT: popq %r14
978 %b = call fastcc %struct.foo* @ret_struct()
979 tail call fastcc void @t21_f_sret2(%struct.foo* noalias sret(%struct.foo) %a, %struct.foo* noalias %b) nounwind
983 declare ccc %struct.foo* @ret_struct() nounwind
986 define fastcc void @t21_sret_to_non_sret(%struct.foo* noalias sret(%struct.foo) %agg.result) nounwind {
987 ; X86-LABEL: t21_sret_to_non_sret:
989 ; X86-NEXT: pushl %esi
990 ; X86-NEXT: subl $8, %esp
991 ; X86-NEXT: movl %ecx, %esi
992 ; X86-NEXT: calll t21_f_non_sret
993 ; X86-NEXT: movl %esi, %eax
994 ; X86-NEXT: addl $8, %esp
995 ; X86-NEXT: popl %esi
998 ; X64-LABEL: t21_sret_to_non_sret:
1000 ; X64-NEXT: pushq %rbx
1001 ; X64-NEXT: movq %rdi, %rbx
1002 ; X64-NEXT: callq t21_f_non_sret
1003 ; X64-NEXT: movq %rbx, %rax
1004 ; X64-NEXT: popq %rbx
1007 ; X32-LABEL: t21_sret_to_non_sret:
1009 ; X32-NEXT: pushq %rbx
1010 ; X32-NEXT: movq %rdi, %rbx
1011 ; X32-NEXT: callq t21_f_non_sret
1012 ; X32-NEXT: movl %ebx, %eax
1013 ; X32-NEXT: popq %rbx
1015 tail call fastcc void @t21_f_non_sret(%struct.foo* %agg.result) nounwind
1020 define ccc void @t22_non_sret_to_sret(%struct.foo* %agg.result) nounwind {
1021 ; X86-LABEL: t22_non_sret_to_sret:
1023 ; X86-NEXT: subl $12, %esp
1024 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1025 ; X86-NEXT: movl %eax, (%esp)
1026 ; X86-NEXT: calll t22_f_sret@PLT
1027 ; X86-NEXT: addl $8, %esp
1030 ; X64-LABEL: t22_non_sret_to_sret:
1032 ; X64-NEXT: pushq %rax
1033 ; X64-NEXT: callq t22_f_sret@PLT
1034 ; X64-NEXT: popq %rax
1037 ; X32-LABEL: t22_non_sret_to_sret:
1039 ; X32-NEXT: pushq %rax
1040 ; X32-NEXT: callq t22_f_sret@PLT
1041 ; X32-NEXT: popq %rax
1043 tail call ccc void @t22_f_sret(%struct.foo* noalias sret(%struct.foo) %agg.result) nounwind
1047 declare dso_local fastcc void @t21_f_sret(%struct.foo* noalias sret(%struct.foo)) nounwind
1048 declare dso_local fastcc void @t21_f_sret2(%struct.foo* noalias sret(%struct.foo), %struct.foo* noalias) nounwind
1049 declare dso_local fastcc void @t21_f_non_sret(%struct.foo*) nounwind
1051 declare ccc void @t22_f_sret(%struct.foo* noalias sret(%struct.foo)) nounwind
1053 declare ccc void @f_sret(%struct.foo* noalias sret(%struct.foo), i32, i32) nounwind