1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s -check-prefix=X64
3 ; RUN: llc < %s -mtriple=i686-unknown-unknown | FileCheck %s -check-prefix=X32
5 ; With -tailcallopt, CodeGen guarantees a tail call optimization
8 declare dso_local tailcc i32 @tailcallee(i32 %a1, i32 %a2, i32 %a3, i32 %a4)
10 define dso_local tailcc i32 @tailcaller(i32 %in1, i32 %in2) nounwind {
11 ; X64-LABEL: tailcaller:
12 ; X64: # %bb.0: # %entry
13 ; X64-NEXT: pushq %rax
14 ; X64-NEXT: movl %edi, %edx
15 ; X64-NEXT: movl %esi, %ecx
17 ; X64-NEXT: jmp tailcallee # TAILCALL
19 ; X32-LABEL: tailcaller:
20 ; X32: # %bb.0: # %entry
21 ; X32-NEXT: subl $16, %esp
22 ; X32-NEXT: movl %ecx, {{[0-9]+}}(%esp)
23 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
24 ; X32-NEXT: movl %edx, {{[0-9]+}}(%esp)
25 ; X32-NEXT: movl %eax, {{[0-9]+}}(%esp)
26 ; X32-NEXT: addl $8, %esp
27 ; X32-NEXT: jmp tailcallee # TAILCALL
29 %tmp11 = tail call tailcc i32 @tailcallee(i32 %in1, i32 %in2, i32 %in1, i32 %in2)
33 declare dso_local tailcc ptr @alias_callee()
35 define tailcc noalias ptr @noalias_caller() nounwind {
36 ; X64-LABEL: noalias_caller:
38 ; X64-NEXT: pushq %rax
40 ; X64-NEXT: jmp alias_callee # TAILCALL
42 ; X32-LABEL: noalias_caller:
44 ; X32-NEXT: jmp alias_callee # TAILCALL
45 %p = tail call tailcc ptr @alias_callee()
49 declare dso_local tailcc noalias ptr @noalias_callee()
51 define dso_local tailcc ptr @alias_caller() nounwind {
52 ; X64-LABEL: alias_caller:
54 ; X64-NEXT: pushq %rax
56 ; X64-NEXT: jmp noalias_callee # TAILCALL
58 ; X32-LABEL: alias_caller:
60 ; X32-NEXT: jmp noalias_callee # TAILCALL
61 %p = tail call tailcc noalias ptr @noalias_callee()
65 declare dso_local tailcc i32 @i32_callee()
67 define dso_local tailcc i32 @ret_undef() nounwind {
68 ; X64-LABEL: ret_undef:
70 ; X64-NEXT: pushq %rax
72 ; X64-NEXT: jmp i32_callee # TAILCALL
74 ; X32-LABEL: ret_undef:
76 ; X32-NEXT: jmp i32_callee # TAILCALL
77 %p = tail call tailcc i32 @i32_callee()
81 declare dso_local tailcc void @does_not_return()
83 define dso_local tailcc i32 @noret() nounwind {
86 ; X64-NEXT: pushq %rax
88 ; X64-NEXT: jmp does_not_return # TAILCALL
92 ; X32-NEXT: jmp does_not_return # TAILCALL
93 tail call tailcc void @does_not_return()
97 define dso_local tailcc void @void_test(i32, i32, i32, i32) {
98 ; X64-LABEL: void_test:
99 ; X64: # %bb.0: # %entry
100 ; X64-NEXT: pushq %rax
101 ; X64-NEXT: .cfi_def_cfa_offset 16
102 ; X64-NEXT: popq %rax
103 ; X64-NEXT: .cfi_def_cfa_offset 8
104 ; X64-NEXT: jmp void_test # TAILCALL
106 ; X32-LABEL: void_test:
107 ; X32: # %bb.0: # %entry
108 ; X32-NEXT: pushl %esi
109 ; X32-NEXT: .cfi_def_cfa_offset 8
110 ; X32-NEXT: subl $8, %esp
111 ; X32-NEXT: .cfi_def_cfa_offset 16
112 ; X32-NEXT: .cfi_offset %esi, -8
113 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
114 ; X32-NEXT: movl {{[0-9]+}}(%esp), %esi
115 ; X32-NEXT: movl %esi, {{[0-9]+}}(%esp)
116 ; X32-NEXT: movl %eax, {{[0-9]+}}(%esp)
117 ; X32-NEXT: addl $8, %esp
118 ; X32-NEXT: .cfi_def_cfa_offset 8
119 ; X32-NEXT: popl %esi
120 ; X32-NEXT: .cfi_def_cfa_offset 4
121 ; X32-NEXT: jmp void_test # TAILCALL
123 tail call tailcc void @void_test( i32 %0, i32 %1, i32 %2, i32 %3)
127 define dso_local tailcc i1 @i1test(i32, i32, i32, i32) {
129 ; X64: # %bb.0: # %entry
130 ; X64-NEXT: pushq %rax
131 ; X64-NEXT: .cfi_def_cfa_offset 16
132 ; X64-NEXT: popq %rax
133 ; X64-NEXT: .cfi_def_cfa_offset 8
134 ; X64-NEXT: jmp i1test # TAILCALL
137 ; X32: # %bb.0: # %entry
138 ; X32-NEXT: pushl %esi
139 ; X32-NEXT: .cfi_def_cfa_offset 8
140 ; X32-NEXT: subl $8, %esp
141 ; X32-NEXT: .cfi_def_cfa_offset 16
142 ; X32-NEXT: .cfi_offset %esi, -8
143 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
144 ; X32-NEXT: movl {{[0-9]+}}(%esp), %esi
145 ; X32-NEXT: movl %esi, {{[0-9]+}}(%esp)
146 ; X32-NEXT: movl %eax, {{[0-9]+}}(%esp)
147 ; X32-NEXT: addl $8, %esp
148 ; X32-NEXT: .cfi_def_cfa_offset 8
149 ; X32-NEXT: popl %esi
150 ; X32-NEXT: .cfi_def_cfa_offset 4
151 ; X32-NEXT: jmp i1test # TAILCALL
153 %4 = tail call tailcc i1 @i1test( i32 %0, i32 %1, i32 %2, i32 %3)