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 %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 %s
4 declare i8* @malloc(i64)
5 declare void @free(i8*)
6 %swift_error = type {i64, i8}
8 ; This tests the basic usage of a swifterror parameter. "foo" is the function
9 ; that takes a swifterror parameter and "caller" is the caller of "foo".
10 define float @foo(%swift_error** swifterror %error_ptr_ref) {
11 ; CHECK-APPLE-LABEL: foo:
12 ; CHECK-APPLE: mov w0, #16
14 ; CHECK-APPLE: mov [[ID:w[0-9]+]], #1
15 ; CHECK-APPLE: strb [[ID]], [x0, #8]
16 ; CHECK-APPLE: mov x21, x0
17 ; CHECK-APPLE-NOT: x21
19 ; CHECK-O0-LABEL: foo:
20 ; CHECK-O0: mov w{{.*}}, #16
22 ; CHECK-O0: mov x1, x0
24 ; CHECK-O0: mov [[ID:w[0-9]+]], #1
25 ; CHECK-O0: strb [[ID]], [x0, #8]
26 ; CHECK-O0: mov x21, x1
28 %call = call i8* @malloc(i64 16)
29 %call.0 = bitcast i8* %call to %swift_error*
30 store %swift_error* %call.0, %swift_error** %error_ptr_ref
31 %tmp = getelementptr inbounds i8, i8* %call, i64 8
36 ; "caller" calls "foo" that takes a swifterror parameter.
37 define float @caller(i8* %error_ref) {
38 ; CHECK-APPLE-LABEL: caller:
39 ; CHECK-APPLE: mov [[ID:x[0-9]+]], x0
40 ; CHECK-APPLE: mov x21, xzr
41 ; CHECK-APPLE: bl {{.*}}foo
42 ; CHECK-APPLE: mov x0, x21
43 ; CHECK-APPLE: cbnz x21
44 ; Access part of the error object and save it to error_ref
45 ; CHECK-APPLE: ldrb [[CODE:w[0-9]+]], [x0, #8]
46 ; CHECK-APPLE: strb [[CODE]], [{{.*}}[[ID]]]
47 ; CHECK-APPLE: bl {{.*}}free
49 ; CHECK-O0-LABEL: caller:
51 ; CHECK-O0: bl {{.*}}foo
52 ; CHECK-O0: mov [[ID:x[0-9]+]], x21
55 %error_ptr_ref = alloca swifterror %swift_error*
56 store %swift_error* null, %swift_error** %error_ptr_ref
57 %call = call float @foo(%swift_error** swifterror %error_ptr_ref)
58 %error_from_foo = load %swift_error*, %swift_error** %error_ptr_ref
59 %had_error_from_foo = icmp ne %swift_error* %error_from_foo, null
60 %tmp = bitcast %swift_error* %error_from_foo to i8*
61 br i1 %had_error_from_foo, label %handler, label %cont
63 %v1 = getelementptr inbounds %swift_error, %swift_error* %error_from_foo, i64 0, i32 1
65 store i8 %t, i8* %error_ref
68 call void @free(i8* %tmp)
72 ; "caller2" is the caller of "foo", it calls "foo" inside a loop.
73 define float @caller2(i8* %error_ref) {
74 ; CHECK-APPLE-LABEL: caller2:
75 ; CHECK-APPLE: mov [[ID:x[0-9]+]], x0
76 ; CHECK-APPLE: fmov [[CMP:s[0-9]+]], #1.0
77 ; CHECK-APPLE: mov x21, xzr
78 ; CHECK-APPLE: bl {{.*}}foo
79 ; CHECK-APPLE: cbnz x21
80 ; CHECK-APPLE: fcmp s0, [[CMP]]
82 ; Access part of the error object and save it to error_ref
83 ; CHECK-APPLE: ldrb [[CODE:w[0-9]+]], [x21, #8]
84 ; CHECK-APPLE: strb [[CODE]], [{{.*}}[[ID]]]
85 ; CHECK-APPLE: mov x0, x21
86 ; CHECK-APPLE: bl {{.*}}free
88 ; CHECK-O0-LABEL: caller2:
90 ; CHECK-O0: bl {{.*}}foo
91 ; CHECK-O0: mov [[ID:x[0-9]+]], x21
94 %error_ptr_ref = alloca swifterror %swift_error*
97 store %swift_error* null, %swift_error** %error_ptr_ref
98 %call = call float @foo(%swift_error** swifterror %error_ptr_ref)
99 %error_from_foo = load %swift_error*, %swift_error** %error_ptr_ref
100 %had_error_from_foo = icmp ne %swift_error* %error_from_foo, null
101 %tmp = bitcast %swift_error* %error_from_foo to i8*
102 br i1 %had_error_from_foo, label %handler, label %cont
104 %cmp = fcmp ogt float %call, 1.000000e+00
105 br i1 %cmp, label %bb_end, label %bb_loop
107 %v1 = getelementptr inbounds %swift_error, %swift_error* %error_from_foo, i64 0, i32 1
108 %t = load i8, i8* %v1
109 store i8 %t, i8* %error_ref
112 call void @free(i8* %tmp)
116 ; "foo_if" is a function that takes a swifterror parameter, it sets swifterror
117 ; under a certain condition.
118 define float @foo_if(%swift_error** swifterror %error_ptr_ref, i32 %cc) {
119 ; CHECK-APPLE-LABEL: foo_if:
120 ; CHECK-APPLE: cbz w0
121 ; CHECK-APPLE: mov w0, #16
122 ; CHECK-APPLE: malloc
123 ; CHECK-APPLE: mov [[ID:w[0-9]+]], #1
124 ; CHECK-APPLE: strb [[ID]], [x0, #8]
125 ; CHECK-APPLE: mov x21, x0
126 ; CHECK-APPLE-NOT: x21
129 ; CHECK-O0-LABEL: foo_if:
131 ; CHECK-O0: str x21, [sp, [[SLOT:#[0-9]+]]]
133 ; CHECK-O0: mov w{{.*}}, #16
135 ; CHECK-O0: mov [[ID:x[0-9]+]], x0
136 ; CHECK-O0: mov [[ID2:w[0-9]+]], #1
137 ; CHECK-O0: strb [[ID2]], [x0, #8]
138 ; CHECK-O0: mov x21, [[ID]]
141 ; CHECK-O0: ldr [[ID3:x[0-9]+]], [sp, [[SLOT]]]
142 ; CHECK-O0: mov x21, [[ID3]]
145 %cond = icmp ne i32 %cc, 0
146 br i1 %cond, label %gen_error, label %normal
149 %call = call i8* @malloc(i64 16)
150 %call.0 = bitcast i8* %call to %swift_error*
151 store %swift_error* %call.0, %swift_error** %error_ptr_ref
152 %tmp = getelementptr inbounds i8, i8* %call, i64 8
160 ; "foo_loop" is a function that takes a swifterror parameter, it sets swifterror
161 ; under a certain condition inside a loop.
162 define float @foo_loop(%swift_error** swifterror %error_ptr_ref, i32 %cc, float %cc2) {
163 ; CHECK-APPLE-LABEL: foo_loop:
164 ; CHECK-APPLE: mov x0, x21
166 ; CHECK-APPLE: mov w0, #16
167 ; CHECK-APPLE: malloc
168 ; CHECK-APPLE: strb w{{.*}}, [x0, #8]
171 ; CHECK-APPLE: mov x21, x0
174 ; CHECK-O0-LABEL: foo_loop:
176 ; CHECK-O0: str x21, [sp, [[SLOT:#[0-9]+]]]
177 ; CHECK-O0: b [[BB1:[A-Za-z0-9_]*]]
179 ; CHECK-O0: ldr x0, [sp, [[SLOT]]]
180 ; CHECK-O0: str x0, [sp, [[SLOT2:#[0-9]+]]]
181 ; CHECK-O0: cbz {{.*}}, [[BB2:[A-Za-z0-9_]*]]
182 ; CHECK-O0: mov w{{.*}}, #16
184 ; CHECK-O0: mov [[ID:x[0-9]+]], x0
185 ; CHECK-O0: strb w{{.*}}, [{{.*}}[[ID]], #8]
187 ; CHECK-O0: str x0, [sp, [[SLOT2]]]
189 ; CHECK-O0: ldr x0, [sp, [[SLOT2]]]
191 ; CHECK-O0: str x0, [sp]
192 ; CHECK-O0: b.le [[BB1]]
194 ; CHECK-O0: ldr [[ID3:x[0-9]+]], [sp]
195 ; CHECK-O0: mov x21, [[ID3]]
201 %cond = icmp ne i32 %cc, 0
202 br i1 %cond, label %gen_error, label %bb_cont
205 %call = call i8* @malloc(i64 16)
206 %call.0 = bitcast i8* %call to %swift_error*
207 store %swift_error* %call.0, %swift_error** %error_ptr_ref
208 %tmp = getelementptr inbounds i8, i8* %call, i64 8
213 %cmp = fcmp ogt float %cc2, 1.000000e+00
214 br i1 %cmp, label %bb_end, label %bb_loop
219 %struct.S = type { i32, i32, i32, i32, i32, i32 }
221 ; "foo_sret" is a function that takes a swifterror parameter, it also has a sret
223 define void @foo_sret(%struct.S* sret %agg.result, i32 %val1, %swift_error** swifterror %error_ptr_ref) {
224 ; CHECK-APPLE-LABEL: foo_sret:
225 ; CHECK-APPLE: mov [[SRET:x[0-9]+]], x8
226 ; CHECK-APPLE: mov w0, #16
227 ; CHECK-APPLE: malloc
228 ; CHECK-APPLE: mov [[ID:w[0-9]+]], #1
229 ; CHECK-APPLE: strb [[ID]], [x0, #8]
230 ; CHECK-APPLE: str w{{.*}}, [{{.*}}[[SRET]], #4]
231 ; CHECK-APPLE: mov x21, x0
232 ; CHECK-APPLE-NOT: x21
234 ; CHECK-O0-LABEL: foo_sret:
235 ; CHECK-O0: mov w{{.*}}, #16
237 ; CHECK-O0-DAG: str x8
239 ; CHECK-O0: mov [[ID:w[0-9]+]], #1
240 ; CHECK-O0: strb [[ID]], [x0, #8]
242 ; CHECK-O0: ldr [[SRET:x[0-9]+]]
243 ; CHECK-O0: str w{{.*}}, [{{.*}}[[SRET]], #4]
247 %call = call i8* @malloc(i64 16)
248 %call.0 = bitcast i8* %call to %swift_error*
249 store %swift_error* %call.0, %swift_error** %error_ptr_ref
250 %tmp = getelementptr inbounds i8, i8* %call, i64 8
252 %v2 = getelementptr inbounds %struct.S, %struct.S* %agg.result, i32 0, i32 1
253 store i32 %val1, i32* %v2
257 ; "caller3" calls "foo_sret" that takes a swifterror parameter.
258 define float @caller3(i8* %error_ref) {
259 ; CHECK-APPLE-LABEL: caller3:
260 ; CHECK-APPLE: mov [[ID:x[0-9]+]], x0
261 ; CHECK-APPLE: mov x21, xzr
262 ; CHECK-APPLE: bl {{.*}}foo_sret
263 ; CHECK-APPLE: mov x0, x21
264 ; CHECK-APPLE: cbnz x21
265 ; Access part of the error object and save it to error_ref
266 ; CHECK-APPLE: ldrb [[CODE:w[0-9]+]], [x0, #8]
267 ; CHECK-APPLE: strb [[CODE]], [{{.*}}[[ID]]]
268 ; CHECK-APPLE: bl {{.*}}free
270 ; CHECK-O0-LABEL: caller3:
274 ; CHECK-O0: bl {{.*}}foo_sret
275 ; CHECK-O0: mov [[ID2:x[0-9]+]], x21
277 ; Access part of the error object and save it to error_ref
279 ; CHECK-O0: ldrb [[CODE:w[0-9]+]]
280 ; CHECK-O0: ldr [[ID:x[0-9]+]]
281 ; CHECK-O0: strb [[CODE]], [{{.*}}[[ID]]]
282 ; CHECK-O0: bl {{.*}}free
284 %s = alloca %struct.S, align 8
285 %error_ptr_ref = alloca swifterror %swift_error*
286 store %swift_error* null, %swift_error** %error_ptr_ref
287 call void @foo_sret(%struct.S* sret %s, i32 1, %swift_error** swifterror %error_ptr_ref)
288 %error_from_foo = load %swift_error*, %swift_error** %error_ptr_ref
289 %had_error_from_foo = icmp ne %swift_error* %error_from_foo, null
290 %tmp = bitcast %swift_error* %error_from_foo to i8*
291 br i1 %had_error_from_foo, label %handler, label %cont
293 %v1 = getelementptr inbounds %swift_error, %swift_error* %error_from_foo, i64 0, i32 1
294 %t = load i8, i8* %v1
295 store i8 %t, i8* %error_ref
298 call void @free(i8* %tmp)
302 ; "foo_vararg" is a function that takes a swifterror parameter, it also has
303 ; variable number of arguments.
304 declare void @llvm.va_start(i8*) nounwind
305 define float @foo_vararg(%swift_error** swifterror %error_ptr_ref, ...) {
306 ; CHECK-APPLE-LABEL: foo_vararg:
307 ; CHECK-APPLE: mov w0, #16
308 ; CHECK-APPLE: malloc
309 ; CHECK-APPLE-DAG: mov [[ID:w[0-9]+]], #1
310 ; CHECK-APPLE-DAG: add [[ARGS:x[0-9]+]], [[TMP:x[0-9]+]], #16
311 ; CHECK-APPLE-DAG: strb [[ID]], [x0, #8]
314 ; CHECK-APPLE-DAG: ldr {{w[0-9]+}}, [{{.*}}[[TMP]], #16]
316 ; CHECK-APPLE-DAG: ldr {{w[0-9]+}}, [{{.*}}[[TMP]], #24]
317 ; CHECK-APPLE-DAG: add {{x[0-9]+}}, {{x[0-9]+}}, #16
319 ; CHECK-APPLE-DAG: ldr {{w[0-9]+}}, [{{.*}}[[TMP]], #32]
321 ; CHECK-APPLE: mov x21, x0
322 ; CHECK-APPLE-NOT: x21
324 %call = call i8* @malloc(i64 16)
325 %call.0 = bitcast i8* %call to %swift_error*
326 store %swift_error* %call.0, %swift_error** %error_ptr_ref
327 %tmp = getelementptr inbounds i8, i8* %call, i64 8
330 %args = alloca i8*, align 8
331 %a10 = alloca i32, align 4
332 %a11 = alloca i32, align 4
333 %a12 = alloca i32, align 4
334 %v10 = bitcast i8** %args to i8*
335 call void @llvm.va_start(i8* %v10)
336 %v11 = va_arg i8** %args, i32
337 store i32 %v11, i32* %a10, align 4
338 %v12 = va_arg i8** %args, i32
339 store i32 %v12, i32* %a11, align 4
340 %v13 = va_arg i8** %args, i32
341 store i32 %v13, i32* %a12, align 4
346 ; "caller4" calls "foo_vararg" that takes a swifterror parameter.
347 define float @caller4(i8* %error_ref) {
348 ; CHECK-APPLE-LABEL: caller4:
350 ; CHECK-APPLE: mov [[ID:x[0-9]+]], x0
351 ; CHECK-APPLE: stp {{x[0-9]+}}, {{x[0-9]+}}, [sp, #8]
352 ; CHECK-APPLE: str {{x[0-9]+}}, [sp]
354 ; CHECK-APPLE: mov x21, xzr
355 ; CHECK-APPLE: bl {{.*}}foo_vararg
356 ; CHECK-APPLE: mov x0, x21
357 ; CHECK-APPLE: cbnz x21
358 ; Access part of the error object and save it to error_ref
359 ; CHECK-APPLE: ldrb [[CODE:w[0-9]+]], [x0, #8]
360 ; CHECK-APPLE: strb [[CODE]], [{{.*}}[[ID]]]
361 ; CHECK-APPLE: bl {{.*}}free
363 %error_ptr_ref = alloca swifterror %swift_error*
364 store %swift_error* null, %swift_error** %error_ptr_ref
366 %a10 = alloca i32, align 4
367 %a11 = alloca i32, align 4
368 %a12 = alloca i32, align 4
369 store i32 10, i32* %a10, align 4
370 store i32 11, i32* %a11, align 4
371 store i32 12, i32* %a12, align 4
372 %v10 = load i32, i32* %a10, align 4
373 %v11 = load i32, i32* %a11, align 4
374 %v12 = load i32, i32* %a12, align 4
376 %call = call float (%swift_error**, ...) @foo_vararg(%swift_error** swifterror %error_ptr_ref, i32 %v10, i32 %v11, i32 %v12)
377 %error_from_foo = load %swift_error*, %swift_error** %error_ptr_ref
378 %had_error_from_foo = icmp ne %swift_error* %error_from_foo, null
379 %tmp = bitcast %swift_error* %error_from_foo to i8*
380 br i1 %had_error_from_foo, label %handler, label %cont
383 %v1 = getelementptr inbounds %swift_error, %swift_error* %error_from_foo, i64 0, i32 1
384 %t = load i8, i8* %v1
385 store i8 %t, i8* %error_ref
388 call void @free(i8* %tmp)
392 ; Check that we don't blow up on tail calling swifterror argument functions.
393 define float @tailcallswifterror(%swift_error** swifterror %error_ptr_ref) {
395 %0 = tail call float @tailcallswifterror(%swift_error** swifterror %error_ptr_ref)
398 define swiftcc float @tailcallswifterror_swiftcc(%swift_error** swifterror %error_ptr_ref) {
400 %0 = tail call swiftcc float @tailcallswifterror_swiftcc(%swift_error** swifterror %error_ptr_ref)
404 ; CHECK-APPLE-LABEL: swifterror_clobber
405 ; CHECK-APPLE: mov [[REG:x[0-9]+]], x21
407 ; CHECK-APPLE: mov x21, [[REG]]
408 define swiftcc void @swifterror_clobber(%swift_error** nocapture swifterror %err) {
409 call void asm sideeffect "nop", "~{x21}"()
413 ; CHECK-APPLE-LABEL: swifterror_reg_clobber
414 ; CHECK-APPLE: stp {{.*}}x21
416 ; CHECK-APPLE: ldp {{.*}}x21
417 define swiftcc void @swifterror_reg_clobber(%swift_error** nocapture %err) {
418 call void asm sideeffect "nop", "~{x21}"()
421 ; CHECK-APPLE-LABEL: params_in_reg
422 ; Save callee saved registers and swifterror since it will be clobbered by the first call to params_in_reg2.
423 ; CHECK-APPLE: stp x21, x28, [sp
424 ; CHECK-APPLE: stp x27, x26, [sp
425 ; CHECK-APPLE: stp x25, x24, [sp
426 ; CHECK-APPLE: stp x23, x22, [sp
427 ; CHECK-APPLE: stp x20, x19, [sp
428 ; CHECK-APPLE: stp x29, x30, [sp
429 ; CHECK-APPLE: str x20, [sp
430 ; Store argument registers.
431 ; CHECK-APPLE: mov x23, x7
432 ; CHECK-APPLE: mov x24, x6
433 ; CHECK-APPLE: mov x25, x5
434 ; CHECK-APPLE: mov x26, x4
435 ; CHECK-APPLE: mov x27, x3
436 ; CHECK-APPLE: mov x28, x2
437 ; CHECK-APPLE: mov x19, x1
438 ; CHECK-APPLE: mov x22, x0
440 ; CHECK-APPLE: mov w0, #1
441 ; CHECK-APPLE: mov w1, #2
442 ; CHECK-APPLE: mov w2, #3
443 ; CHECK-APPLE: mov w3, #4
444 ; CHECK-APPLE: mov w4, #5
445 ; CHECK-APPLE: mov w5, #6
446 ; CHECK-APPLE: mov w6, #7
447 ; CHECK-APPLE: mov w7, #8
448 ; CHECK-APPLE: mov x20, xzr
449 ; CHECK-APPLE: mov x21, xzr
450 ; CHECK-APPLE: bl _params_in_reg2
451 ; Restore original arguments for next call.
452 ; CHECK-APPLE: mov x0, x22
453 ; CHECK-APPLE: mov x1, x19
454 ; CHECK-APPLE: mov x2, x28
455 ; CHECK-APPLE: mov x3, x27
456 ; CHECK-APPLE: mov x4, x26
457 ; CHECK-APPLE: mov x5, x25
458 ; CHECK-APPLE: mov x6, x24
459 ; CHECK-APPLE: mov x7, x23
460 ; Restore original swiftself argument and swifterror %err.
461 ; CHECK-APPLE: ldp x20, x21, [sp
462 ; CHECK-APPLE: bl _params_in_reg2
463 ; Restore calle save registers but don't clober swifterror x21.
464 ; CHECK-APPLE-NOT: x21
465 ; CHECK-APPLE: ldp x29, x30, [sp
466 ; CHECK-APPLE-NOT: x21
467 ; CHECK-APPLE: ldp x20, x19, [sp
468 ; CHECK-APPLE-NOT: x21
469 ; CHECK-APPLE: ldp x23, x22, [sp
470 ; CHECK-APPLE-NOT: x21
471 ; CHECK-APPLE: ldp x25, x24, [sp
472 ; CHECK-APPLE-NOT: x21
473 ; CHECK-APPLE: ldp x27, x26, [sp
474 ; CHECK-APPLE-NOT: x21
475 ; CHECK-APPLE: ldr x28, [sp
476 ; CHECK-APPLE-NOT: x21
478 define swiftcc void @params_in_reg(i64, i64, i64, i64, i64, i64, i64, i64, i8* swiftself, %swift_error** nocapture swifterror %err) {
479 %error_ptr_ref = alloca swifterror %swift_error*, align 8
480 store %swift_error* null, %swift_error** %error_ptr_ref
481 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)
482 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)
485 declare swiftcc void @params_in_reg2(i64, i64, i64, i64, i64, i64, i64, i64, i8* swiftself, %swift_error** nocapture swifterror %err)
487 ; CHECK-APPLE-LABEL: params_and_return_in_reg
488 ; Store callee saved registers.
489 ; CHECK-APPLE: stp x20, x28, [sp, #24
490 ; CHECK-APPLE: stp x27, x26, [sp
491 ; CHECK-APPLE: stp x25, x24, [sp
492 ; CHECK-APPLE: stp x23, x22, [sp
493 ; CHECK-APPLE: stp x20, x19, [sp
494 ; CHECK-APPLE: stp x29, x30, [sp
495 ; Save original arguments.
496 ; CHECK-APPLE: mov x23, x21
497 ; CHECK-APPLE: str x7, [sp, #16]
498 ; CHECK-APPLE: mov x24, x6
499 ; CHECK-APPLE: mov x25, x5
500 ; CHECK-APPLE: mov x26, x4
501 ; CHECK-APPLE: mov x27, x3
502 ; CHECK-APPLE: mov x28, x2
503 ; CHECK-APPLE: mov x19, x1
504 ; CHECK-APPLE: mov x22, x0
505 ; Setup call arguments.
506 ; CHECK-APPLE: mov w0, #1
507 ; CHECK-APPLE: mov w1, #2
508 ; CHECK-APPLE: mov w2, #3
509 ; CHECK-APPLE: mov w3, #4
510 ; CHECK-APPLE: mov w4, #5
511 ; CHECK-APPLE: mov w5, #6
512 ; CHECK-APPLE: mov w6, #7
513 ; CHECK-APPLE: mov w7, #8
514 ; CHECK-APPLE: mov x20, xzr
515 ; CHECK-APPLE: mov x21, xzr
516 ; CHECK-APPLE: bl _params_in_reg2
517 ; Store swifterror %error_ptr_ref.
518 ; CHECK-APPLE: str x21, [sp, #8]
519 ; Setup call arguments from original arguments.
520 ; CHECK-APPLE: mov x0, x22
521 ; CHECK-APPLE: mov x1, x19
522 ; CHECK-APPLE: mov x2, x28
523 ; CHECK-APPLE: mov x3, x27
524 ; CHECK-APPLE: mov x4, x26
525 ; CHECK-APPLE: mov x5, x25
526 ; CHECK-APPLE: mov x6, x24
527 ; CHECK-APPLE: ldp x7, x20, [sp, #16]
528 ; CHECK-APPLE: mov x21, x23
529 ; CHECK-APPLE: bl _params_and_return_in_reg2
530 ; Store return values.
531 ; CHECK-APPLE: mov x19, x0
532 ; CHECK-APPLE: mov x22, x1
533 ; CHECK-APPLE: mov x24, x2
534 ; CHECK-APPLE: mov x25, x3
535 ; CHECK-APPLE: mov x26, x4
536 ; CHECK-APPLE: mov x27, x5
537 ; CHECK-APPLE: mov x28, x6
538 ; CHECK-APPLE: mov x23, x7
539 ; Save swifterror %err.
540 ; CHECK-APPLE: str x21, [sp, #24]
542 ; CHECK-APPLE: mov w0, #1
543 ; CHECK-APPLE: mov w1, #2
544 ; CHECK-APPLE: mov w2, #3
545 ; CHECK-APPLE: mov w3, #4
546 ; CHECK-APPLE: mov w4, #5
547 ; CHECK-APPLE: mov w5, #6
548 ; CHECK-APPLE: mov w6, #7
549 ; CHECK-APPLE: mov w7, #8
550 ; CHECK-APPLE: mov x20, xzr
551 ; ... setup call with swiferror %error_ptr_ref.
552 ; CHECK-APPLE: ldr x21, [sp, #8]
553 ; CHECK-APPLE: bl _params_in_reg2
554 ; Restore return values for return from this function.
555 ; CHECK-APPLE: mov x0, x19
556 ; CHECK-APPLE: mov x1, x22
557 ; CHECK-APPLE: mov x2, x24
558 ; CHECK-APPLE: mov x3, x25
559 ; CHECK-APPLE: mov x4, x26
560 ; CHECK-APPLE: mov x5, x27
561 ; CHECK-APPLE: mov x6, x28
562 ; CHECK-APPLE: mov x7, x23
563 ; Restore swifterror %err and callee save registers.
564 ; CHECK-APPLE: ldp x21, x28, [sp, #24
565 ; CHECK-APPLE: ldp x29, x30, [sp
566 ; CHECK-APPLE: ldp x20, x19, [sp
567 ; CHECK-APPLE: ldp x23, x22, [sp
568 ; CHECK-APPLE: ldp x25, x24, [sp
569 ; CHECK-APPLE: ldp x27, x26, [sp
571 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) {
572 %error_ptr_ref = alloca swifterror %swift_error*, align 8
573 store %swift_error* null, %swift_error** %error_ptr_ref
574 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)
575 %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)
576 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)
577 ret { i64, i64, i64, i64, i64, i64, i64, i64 } %val
580 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)
582 declare void @acallee(i8*)
584 ; Make sure we don't tail call if the caller returns a swifterror value. We
585 ; would have to move into the swifterror register before the tail call.
586 ; CHECK-APPLE: tailcall_from_swifterror:
587 ; CHECK-APPLE-NOT: b _acallee
588 ; CHECK-APPLE: bl _acallee
590 define swiftcc void @tailcall_from_swifterror(%swift_error** swifterror %error_ptr_ref) {
592 tail call void @acallee(i8* null)
596 declare swiftcc void @foo2(%swift_error** swifterror)
598 ; Make sure we properly assign registers during fast-isel.
599 ; CHECK-O0-LABEL: testAssign
600 ; CHECK-O0: mov [[TMP:x.*]], xzr
601 ; CHECK-O0: mov x21, [[TMP]]
603 ; CHECK-O0: str x21, [s[[STK:.*]]]
604 ; CHECK-O0: ldr x0, [s[[STK]]]
606 ; CHECK-APPLE-LABEL: testAssign
607 ; CHECK-APPLE: mov x21, xzr
608 ; CHECK-APPLE: bl _foo2
609 ; CHECK-APPLE: mov x0, x21
611 define swiftcc %swift_error* @testAssign(i8* %error_ref) {
613 %error_ptr = alloca swifterror %swift_error*
614 store %swift_error* null, %swift_error** %error_ptr
615 call swiftcc void @foo2(%swift_error** swifterror %error_ptr)
619 %error = load %swift_error*, %swift_error** %error_ptr
620 ret %swift_error* %error