1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-- -tailcallopt | FileCheck %s
4 ; With -tailcallopt, CodeGen guarantees a tail call optimization
7 declare fastcc i32 @tailcallee(i32 %a1, i32 %a2, i32 %a3, i32 %a4)
9 define dso_local fastcc i32 @tailcaller(i32 %in1, i32 %in2) nounwind {
10 ; CHECK-LABEL: tailcaller:
11 ; CHECK: # %bb.0: # %entry
12 ; CHECK-NEXT: subl $16, %esp
13 ; CHECK-NEXT: movl %ecx, {{[0-9]+}}(%esp)
14 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
15 ; CHECK-NEXT: movl %edx, {{[0-9]+}}(%esp)
16 ; CHECK-NEXT: movl %eax, {{[0-9]+}}(%esp)
17 ; CHECK-NEXT: addl $8, %esp
18 ; CHECK-NEXT: jmp tailcallee@PLT # TAILCALL
20 %tmp11 = tail call fastcc i32 @tailcallee(i32 %in1, i32 %in2, i32 %in1, i32 %in2)
24 declare fastcc ptr @alias_callee()
26 define fastcc noalias ptr @noalias_caller() nounwind {
27 ; CHECK-LABEL: noalias_caller:
29 ; CHECK-NEXT: jmp alias_callee@PLT # TAILCALL
30 %p = tail call fastcc ptr @alias_callee()
34 declare fastcc noalias ptr @noalias_callee()
36 define dso_local fastcc ptr @alias_caller() nounwind {
37 ; CHECK-LABEL: alias_caller:
39 ; CHECK-NEXT: jmp noalias_callee@PLT # TAILCALL
40 %p = tail call fastcc noalias ptr @noalias_callee()
44 declare fastcc i32 @i32_callee()
46 define dso_local fastcc i32 @ret_undef() nounwind {
47 ; CHECK-LABEL: ret_undef:
49 ; CHECK-NEXT: jmp i32_callee@PLT # TAILCALL
50 %p = tail call fastcc i32 @i32_callee()
54 declare fastcc void @does_not_return()
56 define dso_local fastcc i32 @noret() nounwind {
59 ; CHECK-NEXT: jmp does_not_return@PLT # TAILCALL
60 tail call fastcc void @does_not_return()
64 define dso_local fastcc void @void_test(i32, i32, i32, i32) {
65 ; CHECK-LABEL: void_test:
66 ; CHECK: # %bb.0: # %entry
67 ; CHECK-NEXT: pushl %esi
68 ; CHECK-NEXT: .cfi_def_cfa_offset 8
69 ; CHECK-NEXT: subl $8, %esp
70 ; CHECK-NEXT: .cfi_def_cfa_offset 16
71 ; CHECK-NEXT: .cfi_offset %esi, -8
72 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
73 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %esi
74 ; CHECK-NEXT: movl %esi, {{[0-9]+}}(%esp)
75 ; CHECK-NEXT: movl %eax, {{[0-9]+}}(%esp)
76 ; CHECK-NEXT: addl $8, %esp
77 ; CHECK-NEXT: .cfi_def_cfa_offset 8
78 ; CHECK-NEXT: popl %esi
79 ; CHECK-NEXT: .cfi_def_cfa_offset 4
80 ; CHECK-NEXT: jmp void_test # TAILCALL
82 tail call fastcc void @void_test( i32 %0, i32 %1, i32 %2, i32 %3)
86 define dso_local fastcc i1 @i1test(i32, i32, i32, i32) {
87 ; CHECK-LABEL: i1test:
88 ; CHECK: # %bb.0: # %entry
89 ; CHECK-NEXT: pushl %esi
90 ; CHECK-NEXT: .cfi_def_cfa_offset 8
91 ; CHECK-NEXT: subl $8, %esp
92 ; CHECK-NEXT: .cfi_def_cfa_offset 16
93 ; CHECK-NEXT: .cfi_offset %esi, -8
94 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
95 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %esi
96 ; CHECK-NEXT: movl %esi, {{[0-9]+}}(%esp)
97 ; CHECK-NEXT: movl %eax, {{[0-9]+}}(%esp)
98 ; CHECK-NEXT: addl $8, %esp
99 ; CHECK-NEXT: .cfi_def_cfa_offset 8
100 ; CHECK-NEXT: popl %esi
101 ; CHECK-NEXT: .cfi_def_cfa_offset 4
102 ; CHECK-NEXT: jmp i1test # TAILCALL
104 %4 = tail call fastcc i1 @i1test( i32 %0, i32 %1, i32 %2, i32 %3)