1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=x86_64-unknown-unknown -O0 < %s | FileCheck --check-prefixes=CHECK,CHECK-O0 %s
3 ; RUN: llc -mtriple=x86_64-unknown-unknown -O3 < %s | FileCheck --check-prefixes=CHECK,CHECK-O3 %s
5 declare void @external()
6 declare void @no_csr() "no_callee_saved_registers"
8 define void @normal() {
11 ; CHECK-NEXT: pushq %rax
12 ; CHECK-NEXT: .cfi_def_cfa_offset 16
13 ; CHECK-NEXT: callq external@PLT
14 ; CHECK-NEXT: popq %rax
15 ; CHECK-NEXT: .cfi_def_cfa_offset 8
21 ; Calling a routine with no CSRs means the caller has to spill a bunch
22 define void @test1() {
25 ; CHECK-NEXT: pushq %rbp
26 ; CHECK-NEXT: .cfi_def_cfa_offset 16
27 ; CHECK-NEXT: pushq %r15
28 ; CHECK-NEXT: .cfi_def_cfa_offset 24
29 ; CHECK-NEXT: pushq %r14
30 ; CHECK-NEXT: .cfi_def_cfa_offset 32
31 ; CHECK-NEXT: pushq %r13
32 ; CHECK-NEXT: .cfi_def_cfa_offset 40
33 ; CHECK-NEXT: pushq %r12
34 ; CHECK-NEXT: .cfi_def_cfa_offset 48
35 ; CHECK-NEXT: pushq %rbx
36 ; CHECK-NEXT: .cfi_def_cfa_offset 56
37 ; CHECK-NEXT: pushq %rax
38 ; CHECK-NEXT: .cfi_def_cfa_offset 64
39 ; CHECK-NEXT: .cfi_offset %rbx, -56
40 ; CHECK-NEXT: .cfi_offset %r12, -48
41 ; CHECK-NEXT: .cfi_offset %r13, -40
42 ; CHECK-NEXT: .cfi_offset %r14, -32
43 ; CHECK-NEXT: .cfi_offset %r15, -24
44 ; CHECK-NEXT: .cfi_offset %rbp, -16
45 ; CHECK-NEXT: callq external@PLT
46 ; CHECK-NEXT: addq $8, %rsp
47 ; CHECK-NEXT: .cfi_def_cfa_offset 56
48 ; CHECK-NEXT: popq %rbx
49 ; CHECK-NEXT: .cfi_def_cfa_offset 48
50 ; CHECK-NEXT: popq %r12
51 ; CHECK-NEXT: .cfi_def_cfa_offset 40
52 ; CHECK-NEXT: popq %r13
53 ; CHECK-NEXT: .cfi_def_cfa_offset 32
54 ; CHECK-NEXT: popq %r14
55 ; CHECK-NEXT: .cfi_def_cfa_offset 24
56 ; CHECK-NEXT: popq %r15
57 ; CHECK-NEXT: .cfi_def_cfa_offset 16
58 ; CHECK-NEXT: popq %rbp
59 ; CHECK-NEXT: .cfi_def_cfa_offset 8
61 call void @external() "no_callee_saved_registers"
65 ; Same as test1, but on callee, not callsite
66 define void @test2() {
69 ; CHECK-NEXT: pushq %rbp
70 ; CHECK-NEXT: .cfi_def_cfa_offset 16
71 ; CHECK-NEXT: pushq %r15
72 ; CHECK-NEXT: .cfi_def_cfa_offset 24
73 ; CHECK-NEXT: pushq %r14
74 ; CHECK-NEXT: .cfi_def_cfa_offset 32
75 ; CHECK-NEXT: pushq %r13
76 ; CHECK-NEXT: .cfi_def_cfa_offset 40
77 ; CHECK-NEXT: pushq %r12
78 ; CHECK-NEXT: .cfi_def_cfa_offset 48
79 ; CHECK-NEXT: pushq %rbx
80 ; CHECK-NEXT: .cfi_def_cfa_offset 56
81 ; CHECK-NEXT: pushq %rax
82 ; CHECK-NEXT: .cfi_def_cfa_offset 64
83 ; CHECK-NEXT: .cfi_offset %rbx, -56
84 ; CHECK-NEXT: .cfi_offset %r12, -48
85 ; CHECK-NEXT: .cfi_offset %r13, -40
86 ; CHECK-NEXT: .cfi_offset %r14, -32
87 ; CHECK-NEXT: .cfi_offset %r15, -24
88 ; CHECK-NEXT: .cfi_offset %rbp, -16
89 ; CHECK-NEXT: callq no_csr@PLT
90 ; CHECK-NEXT: addq $8, %rsp
91 ; CHECK-NEXT: .cfi_def_cfa_offset 56
92 ; CHECK-NEXT: popq %rbx
93 ; CHECK-NEXT: .cfi_def_cfa_offset 48
94 ; CHECK-NEXT: popq %r12
95 ; CHECK-NEXT: .cfi_def_cfa_offset 40
96 ; CHECK-NEXT: popq %r13
97 ; CHECK-NEXT: .cfi_def_cfa_offset 32
98 ; CHECK-NEXT: popq %r14
99 ; CHECK-NEXT: .cfi_def_cfa_offset 24
100 ; CHECK-NEXT: popq %r15
101 ; CHECK-NEXT: .cfi_def_cfa_offset 16
102 ; CHECK-NEXT: popq %rbp
103 ; CHECK-NEXT: .cfi_def_cfa_offset 8
109 ; on an invoke instead
110 define i32 @test3() personality ptr undef {
111 ; CHECK-O0-LABEL: test3:
112 ; CHECK-O0: # %bb.0: # %entry
113 ; CHECK-O0-NEXT: pushq %rbp
114 ; CHECK-O0-NEXT: .cfi_def_cfa_offset 16
115 ; CHECK-O0-NEXT: pushq %r15
116 ; CHECK-O0-NEXT: .cfi_def_cfa_offset 24
117 ; CHECK-O0-NEXT: pushq %r14
118 ; CHECK-O0-NEXT: .cfi_def_cfa_offset 32
119 ; CHECK-O0-NEXT: pushq %r13
120 ; CHECK-O0-NEXT: .cfi_def_cfa_offset 40
121 ; CHECK-O0-NEXT: pushq %r12
122 ; CHECK-O0-NEXT: .cfi_def_cfa_offset 48
123 ; CHECK-O0-NEXT: pushq %rbx
124 ; CHECK-O0-NEXT: .cfi_def_cfa_offset 56
125 ; CHECK-O0-NEXT: pushq %rax
126 ; CHECK-O0-NEXT: .cfi_def_cfa_offset 64
127 ; CHECK-O0-NEXT: .cfi_offset %rbx, -56
128 ; CHECK-O0-NEXT: .cfi_offset %r12, -48
129 ; CHECK-O0-NEXT: .cfi_offset %r13, -40
130 ; CHECK-O0-NEXT: .cfi_offset %r14, -32
131 ; CHECK-O0-NEXT: .cfi_offset %r15, -24
132 ; CHECK-O0-NEXT: .cfi_offset %rbp, -16
133 ; CHECK-O0-NEXT: .Ltmp0:
134 ; CHECK-O0-NEXT: callq no_csr@PLT
135 ; CHECK-O0-NEXT: .Ltmp1:
136 ; CHECK-O0-NEXT: jmp .LBB3_1
137 ; CHECK-O0-NEXT: .LBB3_1: # %invoke.cont
138 ; CHECK-O0-NEXT: movl $1, %eax
139 ; CHECK-O0-NEXT: addq $8, %rsp
140 ; CHECK-O0-NEXT: .cfi_def_cfa_offset 56
141 ; CHECK-O0-NEXT: popq %rbx
142 ; CHECK-O0-NEXT: .cfi_def_cfa_offset 48
143 ; CHECK-O0-NEXT: popq %r12
144 ; CHECK-O0-NEXT: .cfi_def_cfa_offset 40
145 ; CHECK-O0-NEXT: popq %r13
146 ; CHECK-O0-NEXT: .cfi_def_cfa_offset 32
147 ; CHECK-O0-NEXT: popq %r14
148 ; CHECK-O0-NEXT: .cfi_def_cfa_offset 24
149 ; CHECK-O0-NEXT: popq %r15
150 ; CHECK-O0-NEXT: .cfi_def_cfa_offset 16
151 ; CHECK-O0-NEXT: popq %rbp
152 ; CHECK-O0-NEXT: .cfi_def_cfa_offset 8
153 ; CHECK-O0-NEXT: retq
154 ; CHECK-O0-NEXT: .LBB3_2: # %lpad
155 ; CHECK-O0-NEXT: .cfi_def_cfa_offset 64
156 ; CHECK-O0-NEXT: .Ltmp2:
157 ; CHECK-O0-NEXT: xorl %eax, %eax
158 ; CHECK-O0-NEXT: addq $8, %rsp
159 ; CHECK-O0-NEXT: .cfi_def_cfa_offset 56
160 ; CHECK-O0-NEXT: popq %rbx
161 ; CHECK-O0-NEXT: .cfi_def_cfa_offset 48
162 ; CHECK-O0-NEXT: popq %r12
163 ; CHECK-O0-NEXT: .cfi_def_cfa_offset 40
164 ; CHECK-O0-NEXT: popq %r13
165 ; CHECK-O0-NEXT: .cfi_def_cfa_offset 32
166 ; CHECK-O0-NEXT: popq %r14
167 ; CHECK-O0-NEXT: .cfi_def_cfa_offset 24
168 ; CHECK-O0-NEXT: popq %r15
169 ; CHECK-O0-NEXT: .cfi_def_cfa_offset 16
170 ; CHECK-O0-NEXT: popq %rbp
171 ; CHECK-O0-NEXT: .cfi_def_cfa_offset 8
172 ; CHECK-O0-NEXT: retq
174 ; CHECK-O3-LABEL: test3:
175 ; CHECK-O3: # %bb.0: # %entry
176 ; CHECK-O3-NEXT: pushq %rbp
177 ; CHECK-O3-NEXT: .cfi_def_cfa_offset 16
178 ; CHECK-O3-NEXT: pushq %r15
179 ; CHECK-O3-NEXT: .cfi_def_cfa_offset 24
180 ; CHECK-O3-NEXT: pushq %r14
181 ; CHECK-O3-NEXT: .cfi_def_cfa_offset 32
182 ; CHECK-O3-NEXT: pushq %r13
183 ; CHECK-O3-NEXT: .cfi_def_cfa_offset 40
184 ; CHECK-O3-NEXT: pushq %r12
185 ; CHECK-O3-NEXT: .cfi_def_cfa_offset 48
186 ; CHECK-O3-NEXT: pushq %rbx
187 ; CHECK-O3-NEXT: .cfi_def_cfa_offset 56
188 ; CHECK-O3-NEXT: pushq %rax
189 ; CHECK-O3-NEXT: .cfi_def_cfa_offset 64
190 ; CHECK-O3-NEXT: .cfi_offset %rbx, -56
191 ; CHECK-O3-NEXT: .cfi_offset %r12, -48
192 ; CHECK-O3-NEXT: .cfi_offset %r13, -40
193 ; CHECK-O3-NEXT: .cfi_offset %r14, -32
194 ; CHECK-O3-NEXT: .cfi_offset %r15, -24
195 ; CHECK-O3-NEXT: .cfi_offset %rbp, -16
196 ; CHECK-O3-NEXT: .Ltmp0:
197 ; CHECK-O3-NEXT: callq no_csr@PLT
198 ; CHECK-O3-NEXT: .Ltmp1:
199 ; CHECK-O3-NEXT: # %bb.1: # %invoke.cont
200 ; CHECK-O3-NEXT: movl $1, %eax
201 ; CHECK-O3-NEXT: .LBB3_2: # %invoke.cont
202 ; CHECK-O3-NEXT: addq $8, %rsp
203 ; CHECK-O3-NEXT: .cfi_def_cfa_offset 56
204 ; CHECK-O3-NEXT: popq %rbx
205 ; CHECK-O3-NEXT: .cfi_def_cfa_offset 48
206 ; CHECK-O3-NEXT: popq %r12
207 ; CHECK-O3-NEXT: .cfi_def_cfa_offset 40
208 ; CHECK-O3-NEXT: popq %r13
209 ; CHECK-O3-NEXT: .cfi_def_cfa_offset 32
210 ; CHECK-O3-NEXT: popq %r14
211 ; CHECK-O3-NEXT: .cfi_def_cfa_offset 24
212 ; CHECK-O3-NEXT: popq %r15
213 ; CHECK-O3-NEXT: .cfi_def_cfa_offset 16
214 ; CHECK-O3-NEXT: popq %rbp
215 ; CHECK-O3-NEXT: .cfi_def_cfa_offset 8
216 ; CHECK-O3-NEXT: retq
217 ; CHECK-O3-NEXT: .LBB3_3: # %lpad
218 ; CHECK-O3-NEXT: .cfi_def_cfa_offset 64
219 ; CHECK-O3-NEXT: .Ltmp2:
220 ; CHECK-O3-NEXT: xorl %eax, %eax
221 ; CHECK-O3-NEXT: jmp .LBB3_2
223 invoke void @no_csr()
224 to label %invoke.cont unwind label %lpad
230 %0 = landingpad { ptr, i32 }
235 define void @no_csr_func() "no_callee_saved_registers" {
236 ; CHECK-LABEL: no_csr_func:
238 ; CHECK-NEXT: pushq %rax
239 ; CHECK-NEXT: .cfi_def_cfa_offset 16
240 ; CHECK-NEXT: callq external@PLT
241 ; CHECK-NEXT: popq %rax
242 ; CHECK-NEXT: .cfi_def_cfa_offset 8
244 call void @external()