1 ; RUN: llc -fast-isel-sink-local-values -verify-machineinstrs -frame-pointer=all -enable-shrink-wrap=false < %s -mtriple=aarch64-apple-ios -disable-post-ra | FileCheck -allow-deprecated-dag-overlap --check-prefix=CHECK-APPLE --check-prefix=CHECK-APPLE-AARCH64 %s
2 ; RUN: llc -fast-isel-sink-local-values -verify-machineinstrs -frame-pointer=all -O0 -fast-isel < %s -mtriple=aarch64-apple-ios -disable-post-ra | FileCheck -allow-deprecated-dag-overlap --check-prefix=CHECK-O0 --check-prefix=CHECK-O0-AARCH64 %s
3 ; RUN: llc -fast-isel-sink-local-values -verify-machineinstrs -frame-pointer=all -enable-shrink-wrap=false < %s -mtriple=arm64_32-apple-ios -disable-post-ra | FileCheck -allow-deprecated-dag-overlap --check-prefix=CHECK-APPLE --check-prefix=CHECK-APPLE-ARM64_32 %s
4 ; RUN: llc -fast-isel-sink-local-values -verify-machineinstrs -O0 -fast-isel < %s -mtriple=arm64_32-apple-ios -disable-post-ra | FileCheck -allow-deprecated-dag-overlap --check-prefix=CHECK-O0 --check-prefix=CHECK-O0-ARM64_32 %s
6 declare i8* @malloc(i64)
7 declare void @free(i8*)
8 %swift_error = type {i64, i8}
10 ; This tests the basic usage of a swifterror parameter. "foo" is the function
11 ; that takes a swifterror parameter and "caller" is the caller of "foo".
12 define float @foo(%swift_error** swifterror %error_ptr_ref) {
13 ; CHECK-APPLE-LABEL: foo:
14 ; CHECK-APPLE: mov w0, #16
16 ; CHECK-APPLE: mov [[ID:w[0-9]+]], #1
17 ; CHECK-APPLE: strb [[ID]], [x0, #8]
18 ; CHECK-APPLE: mov x21, x0
19 ; CHECK-APPLE-NOT: x21
21 ; CHECK-O0-LABEL: foo:
22 ; CHECK-O0: mov w{{.*}}, #16
24 ; CHECK-O0: mov x1, x0
26 ; CHECK-O0: mov [[ID:w[0-9]+]], #1
27 ; CHECK-O0: strb [[ID]], [x0, #8]
28 ; CHECK-O0: mov x21, x1
30 %call = call i8* @malloc(i64 16)
31 %call.0 = bitcast i8* %call to %swift_error*
32 store %swift_error* %call.0, %swift_error** %error_ptr_ref
33 %tmp = getelementptr inbounds i8, i8* %call, i64 8
38 ; "caller" calls "foo" that takes a swifterror parameter.
39 define float @caller(i8* %error_ref) {
40 ; CHECK-APPLE-LABEL: caller:
41 ; CHECK-APPLE: mov [[ID:x[0-9]+]], x0
42 ; CHECK-APPLE: mov x21, xzr
43 ; CHECK-APPLE: bl {{.*}}foo
44 ; CHECK-APPLE: mov x0, x21
45 ; CHECK-APPLE-AARCH64: cbnz x21
46 ; CHECK-APPLE-ARM64_32: cbnz w0
47 ; Access part of the error object and save it to error_ref
48 ; CHECK-APPLE: ldrb [[CODE:w[0-9]+]], [x0, #8]
49 ; CHECK-APPLE: strb [[CODE]], [{{.*}}[[ID]]]
50 ; CHECK-APPLE: bl {{.*}}free
52 ; CHECK-O0-LABEL: caller:
54 ; CHECK-O0: bl {{.*}}foo
55 ; CHECK-O0: mov [[ID:x[0-9]+]], x21
56 ; CHECK-O0-AARCH64: cbnz x21
57 ; CHECK-O0-ARM64_32: cmp x21, #0
59 %error_ptr_ref = alloca swifterror %swift_error*
60 store %swift_error* null, %swift_error** %error_ptr_ref
61 %call = call float @foo(%swift_error** swifterror %error_ptr_ref)
62 %error_from_foo = load %swift_error*, %swift_error** %error_ptr_ref
63 %had_error_from_foo = icmp ne %swift_error* %error_from_foo, null
64 %tmp = bitcast %swift_error* %error_from_foo to i8*
65 br i1 %had_error_from_foo, label %handler, label %cont
67 %v1 = getelementptr inbounds %swift_error, %swift_error* %error_from_foo, i64 0, i32 1
69 store i8 %t, i8* %error_ref
72 call void @free(i8* %tmp)
76 ; "caller2" is the caller of "foo", it calls "foo" inside a loop.
77 define float @caller2(i8* %error_ref) {
78 ; CHECK-APPLE-LABEL: caller2:
79 ; CHECK-APPLE: mov [[ID:x[0-9]+]], x0
80 ; CHECK-APPLE: fmov [[CMP:s[0-9]+]], #1.0
81 ; CHECK-APPLE: mov x21, xzr
82 ; CHECK-APPLE: bl {{.*}}foo
83 ; CHECK-APPLE-AARCH64: cbnz x21
84 ; CHECK-APPLE-ARM64_32: cbnz w21
85 ; CHECK-APPLE: fcmp s0, [[CMP]]
87 ; Access part of the error object and save it to error_ref
88 ; CHECK-APPLE: ldrb [[CODE:w[0-9]+]], [x21, #8]
89 ; CHECK-APPLE: strb [[CODE]], [{{.*}}[[ID]]]
90 ; CHECK-APPLE: mov x0, x21
91 ; CHECK-APPLE: bl {{.*}}free
93 ; CHECK-O0-LABEL: caller2:
95 ; CHECK-O0: bl {{.*}}foo
96 ; CHECK-O0: mov [[ID:x[0-9]+]], x21
97 ; CHECK-O0-AARCH64: cbnz x21
98 ; CHECK-O0-ARM64_32: cmp x21, #0
100 %error_ptr_ref = alloca swifterror %swift_error*
103 store %swift_error* null, %swift_error** %error_ptr_ref
104 %call = call float @foo(%swift_error** swifterror %error_ptr_ref)
105 %error_from_foo = load %swift_error*, %swift_error** %error_ptr_ref
106 %had_error_from_foo = icmp ne %swift_error* %error_from_foo, null
107 %tmp = bitcast %swift_error* %error_from_foo to i8*
108 br i1 %had_error_from_foo, label %handler, label %cont
110 %cmp = fcmp ogt float %call, 1.000000e+00
111 br i1 %cmp, label %bb_end, label %bb_loop
113 %v1 = getelementptr inbounds %swift_error, %swift_error* %error_from_foo, i64 0, i32 1
114 %t = load i8, i8* %v1
115 store i8 %t, i8* %error_ref
118 call void @free(i8* %tmp)
122 ; "foo_if" is a function that takes a swifterror parameter, it sets swifterror
123 ; under a certain condition.
124 define float @foo_if(%swift_error** swifterror %error_ptr_ref, i32 %cc) {
125 ; CHECK-APPLE-LABEL: foo_if:
126 ; CHECK-APPLE: cbz w0
127 ; CHECK-APPLE: mov w0, #16
128 ; CHECK-APPLE: malloc
129 ; CHECK-APPLE: mov [[ID:w[0-9]+]], #1
130 ; CHECK-APPLE: strb [[ID]], [x0, #8]
131 ; CHECK-APPLE: mov x21, x0
132 ; CHECK-APPLE-NOT: x21
135 ; CHECK-O0-LABEL: foo_if:
137 ; CHECK-O0: str x21, [sp, [[SLOT:#[0-9]+]]]
139 ; CHECK-O0: mov w{{.*}}, #16
141 ; CHECK-O0: mov [[ID:x[0-9]+]], x0
142 ; CHECK-O0: mov [[ID2:w[0-9]+]], #1
143 ; CHECK-O0: strb [[ID2]], [x0, #8]
144 ; CHECK-O0: mov x21, [[ID]]
147 ; CHECK-O0: ldr [[ID3:x[0-9]+]], [sp, [[SLOT]]]
148 ; CHECK-O0: mov x21, [[ID3]]
151 %cond = icmp ne i32 %cc, 0
152 br i1 %cond, label %gen_error, label %normal
155 %call = call i8* @malloc(i64 16)
156 %call.0 = bitcast i8* %call to %swift_error*
157 store %swift_error* %call.0, %swift_error** %error_ptr_ref
158 %tmp = getelementptr inbounds i8, i8* %call, i64 8
166 ; "foo_loop" is a function that takes a swifterror parameter, it sets swifterror
167 ; under a certain condition inside a loop.
168 define float @foo_loop(%swift_error** swifterror %error_ptr_ref, i32 %cc, float %cc2) {
169 ; CHECK-APPLE-LABEL: foo_loop:
170 ; CHECK-APPLE: mov x0, x21
172 ; CHECK-APPLE: mov w0, #16
173 ; CHECK-APPLE: malloc
174 ; CHECK-APPLE: strb w{{.*}}, [x0, #8]
177 ; CHECK-APPLE: mov x21, x0
180 ; CHECK-O0-AARCH64-LABEL: foo_loop:
182 ; CHECK-O0-AARCH64: str x21, [sp, [[SLOT:#[0-9]+]]]
183 ; CHECK-O0-AARCH64: b [[BB1:[A-Za-z0-9_]*]]
184 ; CHECK-O0-AARCH64: [[BB1]]:
185 ; CHECK-O0-AARCH64: ldr x0, [sp, [[SLOT]]]
186 ; CHECK-O0-AARCH64: str x0, [sp, [[SLOT2:#[0-9]+]]]
187 ; CHECK-O0-AARCH64: cbz {{.*}}, [[BB2:[A-Za-z0-9_]*]]
188 ; CHECK-O0-AARCH64: mov w{{.*}}, #16
189 ; CHECK-O0-AARCH64: malloc
190 ; CHECK-O0-AARCH64: mov [[ID:x[0-9]+]], x0
191 ; CHECK-O0-AARCH64: strb w{{.*}}, [{{.*}}[[ID]], #8]
193 ; CHECK-O0-AARCH64: str x0, [sp, [[SLOT2]]]
194 ; CHECK-O0-AARCH64:[[BB2]]:
195 ; CHECK-O0-AARCH64: ldr x0, [sp, [[SLOT2]]]
196 ; CHECK-O0-AARCH64: fcmp
197 ; CHECK-O0-AARCH64: str x0, [sp]
198 ; CHECK-O0-AARCH64: b.le [[BB1]]
200 ; CHECK-O0-AARCH64: ldr [[ID3:x[0-9]+]], [sp]
201 ; CHECK-O0-AARCH64: mov x21, [[ID3]]
202 ; CHECK-O0-AARCH64: ret
204 ; CHECK-O0-ARM64_32-LABEL: foo_loop:
206 ; CHECK-O0-ARM64_32: str x21, [sp, [[SLOT:#[0-9]+]]]
207 ; CHECK-O0-ARM64_32: b [[BB1:[A-Za-z0-9_]*]]
208 ; CHECK-O0-ARM64_32: [[BB1]]:
209 ; CHECK-O0-ARM64_32: ldr x0, [sp, [[SLOT]]]
210 ; CHECK-O0-ARM64_32: str x0, [sp, [[SLOT2:#[0-9]+]]]
211 ; CHECK-O0-ARM64_32: cbz {{.*}}, [[BB2:[A-Za-z0-9_]*]]
212 ; CHECK-O0-ARM64_32: mov w{{.*}}, #16
213 ; CHECK-O0-ARM64_32: malloc
214 ; CHECK-O0-ARM64_32: mov {{.*}}, x0
215 ; CHECK-O0-ARM64_32: strb w{{.*}},
216 ; CHECK-O0-ARM64_32:[[BB2]]:
217 ; CHECK-O0-ARM64_32: ldr x0, [sp, [[SLOT2]]]
218 ; CHECK-O0-ARM64_32: fcmp
219 ; CHECK-O0-ARM64_32: str x0, [sp[[OFFSET:.*]]]
220 ; CHECK-O0-ARM64_32: b.le [[BB1]]
222 ; CHECK-O0-ARM64_32: ldr [[ID3:x[0-9]+]], [sp[[OFFSET]]]
223 ; CHECK-O0-ARM64_32: mov x21, [[ID3]]
224 ; CHECK-O0-ARM64_32: ret
230 %cond = icmp ne i32 %cc, 0
231 br i1 %cond, label %gen_error, label %bb_cont
234 %call = call i8* @malloc(i64 16)
235 %call.0 = bitcast i8* %call to %swift_error*
236 store %swift_error* %call.0, %swift_error** %error_ptr_ref
237 %tmp = getelementptr inbounds i8, i8* %call, i64 8
242 %cmp = fcmp ogt float %cc2, 1.000000e+00
243 br i1 %cmp, label %bb_end, label %bb_loop
248 %struct.S = type { i32, i32, i32, i32, i32, i32 }
250 ; "foo_sret" is a function that takes a swifterror parameter, it also has a sret
252 define void @foo_sret(%struct.S* sret %agg.result, i32 %val1, %swift_error** swifterror %error_ptr_ref) {
253 ; CHECK-APPLE-LABEL: foo_sret:
254 ; CHECK-APPLE: mov [[SRET:x[0-9]+]], x8
255 ; CHECK-APPLE: mov w0, #16
256 ; CHECK-APPLE: malloc
257 ; CHECK-APPLE: mov [[ID:w[0-9]+]], #1
258 ; CHECK-APPLE: strb [[ID]], [x0, #8]
259 ; CHECK-APPLE: str w{{.*}}, [{{.*}}[[SRET]], #4]
260 ; CHECK-APPLE: mov x21, x0
261 ; CHECK-APPLE-NOT: x21
263 ; CHECK-O0-LABEL: foo_sret:
264 ; CHECK-O0: mov w{{.*}}, #16
266 ; CHECK-O0-DAG: str x8
268 ; CHECK-O0: mov [[ID:w[0-9]+]], #1
269 ; CHECK-O0: strb [[ID]], [x0, #8]
271 ; CHECK-O0: ldr [[SRET:x[0-9]+]]
272 ; CHECK-O0: str w{{.*}}, [{{.*}}[[SRET]], #4]
276 %call = call i8* @malloc(i64 16)
277 %call.0 = bitcast i8* %call to %swift_error*
278 store %swift_error* %call.0, %swift_error** %error_ptr_ref
279 %tmp = getelementptr inbounds i8, i8* %call, i64 8
281 %v2 = getelementptr inbounds %struct.S, %struct.S* %agg.result, i32 0, i32 1
282 store i32 %val1, i32* %v2
286 ; "caller3" calls "foo_sret" that takes a swifterror parameter.
287 define float @caller3(i8* %error_ref) {
288 ; CHECK-APPLE-LABEL: caller3:
289 ; CHECK-APPLE: mov [[ID:x[0-9]+]], x0
290 ; CHECK-APPLE: mov x21, xzr
291 ; CHECK-APPLE: bl {{.*}}foo_sret
292 ; CHECK-APPLE: mov x0, x21
293 ; CHECK-APPLE-AARCH64: cbnz x21
294 ; CHECK-APPLE-ARM64_32: cbnz w0
295 ; Access part of the error object and save it to error_ref
296 ; CHECK-APPLE: ldrb [[CODE:w[0-9]+]], [x0, #8]
297 ; CHECK-APPLE: strb [[CODE]], [{{.*}}[[ID]]]
298 ; CHECK-APPLE: bl {{.*}}free
300 ; CHECK-O0-LABEL: caller3:
304 ; CHECK-O0: bl {{.*}}foo_sret
305 ; CHECK-O0: mov [[ID2:x[0-9]+]], x21
306 ; CHECK-O0-AARCH64: cbnz x21
307 ; CHECK-O0-ARM64_32: cmp x21, #0
308 ; Access part of the error object and save it to error_ref
310 ; CHECK-O0: ldrb [[CODE:w[0-9]+]]
311 ; CHECK-O0: ldr [[ID:x[0-9]+]]
312 ; CHECK-O0: strb [[CODE]], [{{.*}}[[ID]]]
313 ; CHECK-O0: bl {{.*}}free
315 %s = alloca %struct.S, align 8
316 %error_ptr_ref = alloca swifterror %swift_error*
317 store %swift_error* null, %swift_error** %error_ptr_ref
318 call void @foo_sret(%struct.S* sret %s, i32 1, %swift_error** swifterror %error_ptr_ref)
319 %error_from_foo = load %swift_error*, %swift_error** %error_ptr_ref
320 %had_error_from_foo = icmp ne %swift_error* %error_from_foo, null
321 %tmp = bitcast %swift_error* %error_from_foo to i8*
322 br i1 %had_error_from_foo, label %handler, label %cont
324 %v1 = getelementptr inbounds %swift_error, %swift_error* %error_from_foo, i64 0, i32 1
325 %t = load i8, i8* %v1
326 store i8 %t, i8* %error_ref
329 call void @free(i8* %tmp)
333 ; "foo_vararg" is a function that takes a swifterror parameter, it also has
334 ; variable number of arguments.
335 declare void @llvm.va_start(i8*) nounwind
336 define float @foo_vararg(%swift_error** swifterror %error_ptr_ref, ...) {
337 ; CHECK-APPLE-LABEL: foo_vararg:
338 ; CHECK-APPLE: mov w0, #16
339 ; CHECK-APPLE: malloc
342 ; CHECK-APPLE-AARCH64: ldr {{w[0-9]+}}, [{{.*}}[[TMP:x[0-9]+]], #16]
343 ; CHECK-APPLE-AARCH64: mov [[ID:w[0-9]+]], #1
344 ; CHECK-APPLE-AARCH64: add [[ARGS:x[0-9]+]], [[TMP]], #16
345 ; CHECK-APPLE-AARCH64: strb [[ID]], [x0, #8]
347 ; CHECK-APPLE-AARCH64: ldr {{w[0-9]+}}, [{{.*}}[[TMP]], #24]
349 ; CHECK-APPLE-AARCH64: ldr {{w[0-9]+}}, [{{.*}}[[TMP]], #32]
351 ; CHECK-APPLE-ARM64_32: mov [[ID:w[0-9]+]], #1
352 ; CHECK-APPLE-ARM64_32: add [[ARGS:x[0-9]+]], [[TMP:x[0-9]+]], #16
353 ; CHECK-APPLE-ARM64_32: strb [[ID]], [x0, #8]
357 %call = call i8* @malloc(i64 16)
358 %call.0 = bitcast i8* %call to %swift_error*
359 store %swift_error* %call.0, %swift_error** %error_ptr_ref
360 %tmp = getelementptr inbounds i8, i8* %call, i64 8
363 %args = alloca i8*, align 8
364 %a10 = alloca i32, align 4
365 %a11 = alloca i32, align 4
366 %a12 = alloca i32, align 4
367 %v10 = bitcast i8** %args to i8*
368 call void @llvm.va_start(i8* %v10)
369 %v11 = va_arg i8** %args, i32
370 store i32 %v11, i32* %a10, align 4
371 %v12 = va_arg i8** %args, i32
372 store i32 %v12, i32* %a11, align 4
373 %v13 = va_arg i8** %args, i32
374 store i32 %v13, i32* %a12, align 4
379 ; "caller4" calls "foo_vararg" that takes a swifterror parameter.
380 define float @caller4(i8* %error_ref) {
381 ; CHECK-APPLE-LABEL: caller4:
383 ; CHECK-APPLE-AARCH64: mov [[ID:x[0-9]+]], x0
384 ; CHECK-APPLE-AARCH64: stp {{x[0-9]+}}, {{x[0-9]+}}, [sp, #8]
385 ; CHECK-APPLE-AARCH64: str {{x[0-9]+}}, [sp]
387 ; CHECK-APPLE-AARCH64: mov x21, xzr
388 ; CHECK-APPLE-AARCH64: bl {{.*}}foo_vararg
389 ; CHECK-APPLE-AARCH64: mov x0, x21
390 ; CHECK-APPLE-AARCH64: cbnz x21
391 ; Access part of the error object and save it to error_ref
392 ; CHECK-APPLE-AARCH64: ldrb [[CODE:w[0-9]+]], [x0, #8]
393 ; CHECK-APPLE-AARCH64: strb [[CODE]], [{{.*}}[[ID]]]
394 ; CHECK-APPLE-AARCH64: bl {{.*}}free
396 %error_ptr_ref = alloca swifterror %swift_error*
397 store %swift_error* null, %swift_error** %error_ptr_ref
399 %a10 = alloca i32, align 4
400 %a11 = alloca i32, align 4
401 %a12 = alloca i32, align 4
402 store i32 10, i32* %a10, align 4
403 store i32 11, i32* %a11, align 4
404 store i32 12, i32* %a12, align 4
405 %v10 = load i32, i32* %a10, align 4
406 %v11 = load i32, i32* %a11, align 4
407 %v12 = load i32, i32* %a12, align 4
409 %call = call float (%swift_error**, ...) @foo_vararg(%swift_error** swifterror %error_ptr_ref, i32 %v10, i32 %v11, i32 %v12)
410 %error_from_foo = load %swift_error*, %swift_error** %error_ptr_ref
411 %had_error_from_foo = icmp ne %swift_error* %error_from_foo, null
412 %tmp = bitcast %swift_error* %error_from_foo to i8*
413 br i1 %had_error_from_foo, label %handler, label %cont
416 %v1 = getelementptr inbounds %swift_error, %swift_error* %error_from_foo, i64 0, i32 1
417 %t = load i8, i8* %v1
418 store i8 %t, i8* %error_ref
421 call void @free(i8* %tmp)
425 ; Check that we don't blow up on tail calling swifterror argument functions.
426 define float @tailcallswifterror(%swift_error** swifterror %error_ptr_ref) {
428 %0 = tail call float @tailcallswifterror(%swift_error** swifterror %error_ptr_ref)
431 define swiftcc float @tailcallswifterror_swiftcc(%swift_error** swifterror %error_ptr_ref) {
433 %0 = tail call swiftcc float @tailcallswifterror_swiftcc(%swift_error** swifterror %error_ptr_ref)
437 ; CHECK-APPLE-LABEL: swifterror_clobber
438 ; CHECK-APPLE: mov [[REG:x[0-9]+]], x21
440 ; CHECK-APPLE: mov x21, [[REG]]
441 define swiftcc void @swifterror_clobber(%swift_error** nocapture swifterror %err) {
442 call void asm sideeffect "nop", "~{x21}"()
446 ; CHECK-APPLE-LABEL: swifterror_reg_clobber
447 ; CHECK-APPLE: stp {{.*}}x21
449 ; CHECK-APPLE: ldp {{.*}}x21
450 define swiftcc void @swifterror_reg_clobber(%swift_error** nocapture %err) {
451 call void asm sideeffect "nop", "~{x21}"()
454 ; CHECK-APPLE-LABEL: params_in_reg
455 ; Save callee saved registers and swifterror since it will be clobbered by the first call to params_in_reg2.
456 ; CHECK-APPLE: stp x21, x28, [sp
457 ; CHECK-APPLE: stp x27, x26, [sp
458 ; CHECK-APPLE: stp x25, x24, [sp
459 ; CHECK-APPLE: stp x23, x22, [sp
460 ; CHECK-APPLE: stp x20, x19, [sp
461 ; CHECK-APPLE: stp x29, x30, [sp
462 ; CHECK-APPLE: str x20, [sp
463 ; Store argument registers.
464 ; CHECK-APPLE: mov x23, x7
465 ; CHECK-APPLE: mov x24, x6
466 ; CHECK-APPLE: mov x25, x5
467 ; CHECK-APPLE: mov x26, x4
468 ; CHECK-APPLE: mov x27, x3
469 ; CHECK-APPLE: mov x28, x2
470 ; CHECK-APPLE: mov x19, x1
471 ; CHECK-APPLE: mov x22, x0
473 ; CHECK-APPLE: mov w0, #1
474 ; CHECK-APPLE: mov w1, #2
475 ; CHECK-APPLE: mov w2, #3
476 ; CHECK-APPLE: mov w3, #4
477 ; CHECK-APPLE: mov w4, #5
478 ; CHECK-APPLE: mov w5, #6
479 ; CHECK-APPLE: mov w6, #7
480 ; CHECK-APPLE: mov w7, #8
481 ; CHECK-APPLE: mov x20, xzr
482 ; CHECK-APPLE: mov x21, xzr
483 ; CHECK-APPLE: bl _params_in_reg2
484 ; Restore original arguments for next call.
485 ; CHECK-APPLE: mov x0, x22
486 ; CHECK-APPLE: mov x1, x19
487 ; CHECK-APPLE: mov x2, x28
488 ; CHECK-APPLE: mov x3, x27
489 ; CHECK-APPLE: mov x4, x26
490 ; CHECK-APPLE: mov x5, x25
491 ; CHECK-APPLE: mov x6, x24
492 ; CHECK-APPLE: mov x7, x23
493 ; Restore original swiftself argument and swifterror %err.
494 ; CHECK-APPLE: ldp x20, x21, [sp
495 ; CHECK-APPLE: bl _params_in_reg2
496 ; Restore calle save registers but don't clober swifterror x21.
497 ; CHECK-APPLE-NOT: x21
498 ; CHECK-APPLE: ldp x29, x30, [sp
499 ; CHECK-APPLE-NOT: x21
500 ; CHECK-APPLE: ldp x20, x19, [sp
501 ; CHECK-APPLE-NOT: x21
502 ; CHECK-APPLE: ldp x23, x22, [sp
503 ; CHECK-APPLE-NOT: x21
504 ; CHECK-APPLE: ldp x25, x24, [sp
505 ; CHECK-APPLE-NOT: x21
506 ; CHECK-APPLE: ldp x27, x26, [sp
507 ; CHECK-APPLE-NOT: x21
508 ; CHECK-APPLE: ldr x28, [sp
509 ; CHECK-APPLE-NOT: x21
511 define swiftcc void @params_in_reg(i64, i64, i64, i64, i64, i64, i64, i64, i8* swiftself, %swift_error** nocapture swifterror %err) {
512 %error_ptr_ref = alloca swifterror %swift_error*, align 8
513 store %swift_error* null, %swift_error** %error_ptr_ref
514 call swiftcc void @params_in_reg2(i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i8* swiftself null, %swift_error** nocapture swifterror %error_ptr_ref)
515 call swiftcc void @params_in_reg2(i64 %0, i64 %1, i64 %2, i64 %3, i64 %4, i64 %5, i64 %6, i64 %7, i8* swiftself %8, %swift_error** nocapture swifterror %err)
518 declare swiftcc void @params_in_reg2(i64, i64, i64, i64, i64, i64, i64, i64, i8* swiftself, %swift_error** nocapture swifterror %err)
520 ; CHECK-APPLE-LABEL: params_and_return_in_reg
521 ; Store callee saved registers.
522 ; CHECK-APPLE: stp x20, x28, [sp, #24
523 ; CHECK-APPLE: stp x27, x26, [sp
524 ; CHECK-APPLE: stp x25, x24, [sp
525 ; CHECK-APPLE: stp x23, x22, [sp
526 ; CHECK-APPLE: stp x20, x19, [sp
527 ; CHECK-APPLE: stp x29, x30, [sp
528 ; Save original arguments.
529 ; CHECK-APPLE: mov x23, x21
530 ; CHECK-APPLE: str x7, [sp, #16]
531 ; CHECK-APPLE: mov x24, x6
532 ; CHECK-APPLE: mov x25, x5
533 ; CHECK-APPLE: mov x26, x4
534 ; CHECK-APPLE: mov x27, x3
535 ; CHECK-APPLE: mov x28, x2
536 ; CHECK-APPLE: mov x19, x1
537 ; CHECK-APPLE: mov x22, x0
538 ; Setup call arguments.
539 ; CHECK-APPLE: mov w0, #1
540 ; CHECK-APPLE: mov w1, #2
541 ; CHECK-APPLE: mov w2, #3
542 ; CHECK-APPLE: mov w3, #4
543 ; CHECK-APPLE: mov w4, #5
544 ; CHECK-APPLE: mov w5, #6
545 ; CHECK-APPLE: mov w6, #7
546 ; CHECK-APPLE: mov w7, #8
547 ; CHECK-APPLE: mov x20, xzr
548 ; CHECK-APPLE: mov x21, xzr
549 ; CHECK-APPLE: bl _params_in_reg2
550 ; Store swifterror %error_ptr_ref.
551 ; CHECK-APPLE: str x21, [sp, #8]
552 ; Setup call arguments from original arguments.
553 ; CHECK-APPLE: mov x0, x22
554 ; CHECK-APPLE: mov x1, x19
555 ; CHECK-APPLE: mov x2, x28
556 ; CHECK-APPLE: mov x3, x27
557 ; CHECK-APPLE: mov x4, x26
558 ; CHECK-APPLE: mov x5, x25
559 ; CHECK-APPLE: mov x6, x24
560 ; CHECK-APPLE: ldp x7, x20, [sp, #16]
561 ; CHECK-APPLE: mov x21, x23
562 ; CHECK-APPLE: bl _params_and_return_in_reg2
563 ; Store return values.
564 ; CHECK-APPLE: mov x19, x0
565 ; CHECK-APPLE: mov x22, x1
566 ; CHECK-APPLE: mov x24, x2
567 ; CHECK-APPLE: mov x25, x3
568 ; CHECK-APPLE: mov x26, x4
569 ; CHECK-APPLE: mov x27, x5
570 ; CHECK-APPLE: mov x28, x6
571 ; CHECK-APPLE: mov x23, x7
572 ; Save swifterror %err.
573 ; CHECK-APPLE: str x21, [sp, #24]
575 ; CHECK-APPLE: mov w0, #1
576 ; CHECK-APPLE: mov w1, #2
577 ; CHECK-APPLE: mov w2, #3
578 ; CHECK-APPLE: mov w3, #4
579 ; CHECK-APPLE: mov w4, #5
580 ; CHECK-APPLE: mov w5, #6
581 ; CHECK-APPLE: mov w6, #7
582 ; CHECK-APPLE: mov w7, #8
583 ; CHECK-APPLE: mov x20, xzr
584 ; ... setup call with swiferror %error_ptr_ref.
585 ; CHECK-APPLE: ldr x21, [sp, #8]
586 ; CHECK-APPLE: bl _params_in_reg2
587 ; Restore return values for return from this function.
588 ; CHECK-APPLE: mov x0, x19
589 ; CHECK-APPLE: mov x1, x22
590 ; CHECK-APPLE: mov x2, x24
591 ; CHECK-APPLE: mov x3, x25
592 ; CHECK-APPLE: mov x4, x26
593 ; CHECK-APPLE: mov x5, x27
594 ; CHECK-APPLE: mov x6, x28
595 ; CHECK-APPLE: mov x7, x23
596 ; Restore swifterror %err and callee save registers.
597 ; CHECK-APPLE: ldp x21, x28, [sp, #24
598 ; CHECK-APPLE: ldp x29, x30, [sp
599 ; CHECK-APPLE: ldp x20, x19, [sp
600 ; CHECK-APPLE: ldp x23, x22, [sp
601 ; CHECK-APPLE: ldp x25, x24, [sp
602 ; CHECK-APPLE: ldp x27, x26, [sp
604 define swiftcc { i64, i64, i64, i64, i64, i64, i64, i64 } @params_and_return_in_reg(i64, i64, i64, i64, i64, i64, i64, i64, i8* swiftself, %swift_error** nocapture swifterror %err) {
605 %error_ptr_ref = alloca swifterror %swift_error*, align 8
606 store %swift_error* null, %swift_error** %error_ptr_ref
607 call swiftcc void @params_in_reg2(i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i8* swiftself null, %swift_error** nocapture swifterror %error_ptr_ref)
608 %val = call swiftcc { i64, i64, i64, i64, i64, i64, i64, i64 } @params_and_return_in_reg2(i64 %0, i64 %1, i64 %2, i64 %3, i64 %4, i64 %5, i64 %6, i64 %7, i8* swiftself %8, %swift_error** nocapture swifterror %err)
609 call swiftcc void @params_in_reg2(i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i8* swiftself null, %swift_error** nocapture swifterror %error_ptr_ref)
610 ret { i64, i64, i64, i64, i64, i64, i64, i64 } %val
613 declare swiftcc { i64, i64, i64, i64, i64, i64, i64, i64 } @params_and_return_in_reg2(i64, i64, i64, i64, i64, i64, i64, i64, i8* swiftself, %swift_error** nocapture swifterror %err)
615 declare void @acallee(i8*)
617 ; Make sure we don't tail call if the caller returns a swifterror value. We
618 ; would have to move into the swifterror register before the tail call.
619 ; CHECK-APPLE: tailcall_from_swifterror:
620 ; CHECK-APPLE-NOT: b _acallee
621 ; CHECK-APPLE: bl _acallee
623 define swiftcc void @tailcall_from_swifterror(%swift_error** swifterror %error_ptr_ref) {
625 tail call void @acallee(i8* null)
629 declare swiftcc void @foo2(%swift_error** swifterror)
631 ; Make sure we properly assign registers during fast-isel.
632 ; CHECK-O0-LABEL: testAssign
633 ; CHECK-O0: mov [[TMP:x.*]], xzr
634 ; CHECK-O0: mov x21, [[TMP]]
636 ; CHECK-O0: str x21, [s[[STK:.*]]]
637 ; CHECK-O0: ldr x0, [s[[STK]]]
639 ; CHECK-APPLE-LABEL: testAssign
640 ; CHECK-APPLE: mov x21, xzr
641 ; CHECK-APPLE: bl _foo2
642 ; CHECK-APPLE: mov x0, x21
644 define swiftcc %swift_error* @testAssign(i8* %error_ref) {
646 %error_ptr = alloca swifterror %swift_error*
647 store %swift_error* null, %swift_error** %error_ptr
648 call swiftcc void @foo2(%swift_error** swifterror %error_ptr)
652 %error = load %swift_error*, %swift_error** %error_ptr
653 ret %swift_error* %error