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: orr w0, wzr, #0x10
14 ; CHECK-APPLE: orr [[ID:w[0-9]+]], wzr, #0x1
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: orr w{{.*}}, wzr, #0x10
22 ; CHECK-O0: mov x21, x0
24 ; CHECK-O0: orr [[ID:w[0-9]+]], wzr, #0x1
26 ; CHECK-O0: strb [[ID]], [x0, #8]
29 %call = call i8* @malloc(i64 16)
30 %call.0 = bitcast i8* %call to %swift_error*
31 store %swift_error* %call.0, %swift_error** %error_ptr_ref
32 %tmp = getelementptr inbounds i8, i8* %call, i64 8
37 ; "caller" calls "foo" that takes a swifterror parameter.
38 define float @caller(i8* %error_ref) {
39 ; CHECK-APPLE-LABEL: caller:
40 ; CHECK-APPLE: mov [[ID:x[0-9]+]], x0
41 ; CHECK-APPLE: mov x21, xzr
42 ; CHECK-APPLE: bl {{.*}}foo
43 ; CHECK-APPLE: mov x0, x21
44 ; CHECK-APPLE: cbnz x21
45 ; Access part of the error object and save it to error_ref
46 ; CHECK-APPLE: ldrb [[CODE:w[0-9]+]], [x0, #8]
47 ; CHECK-APPLE: strb [[CODE]], [{{.*}}[[ID]]]
48 ; CHECK-APPLE: bl {{.*}}free
50 ; CHECK-O0-LABEL: caller:
52 ; CHECK-O0: bl {{.*}}foo
53 ; CHECK-O0: mov [[ID:x[0-9]+]], x21
56 %error_ptr_ref = alloca swifterror %swift_error*
57 store %swift_error* null, %swift_error** %error_ptr_ref
58 %call = call float @foo(%swift_error** swifterror %error_ptr_ref)
59 %error_from_foo = load %swift_error*, %swift_error** %error_ptr_ref
60 %had_error_from_foo = icmp ne %swift_error* %error_from_foo, null
61 %tmp = bitcast %swift_error* %error_from_foo to i8*
62 br i1 %had_error_from_foo, label %handler, label %cont
64 %v1 = getelementptr inbounds %swift_error, %swift_error* %error_from_foo, i64 0, i32 1
66 store i8 %t, i8* %error_ref
69 call void @free(i8* %tmp)
73 ; "caller2" is the caller of "foo", it calls "foo" inside a loop.
74 define float @caller2(i8* %error_ref) {
75 ; CHECK-APPLE-LABEL: caller2:
76 ; CHECK-APPLE: mov [[ID:x[0-9]+]], x0
77 ; CHECK-APPLE: fmov [[CMP:s[0-9]+]], #1.0
78 ; CHECK-APPLE: mov x21, xzr
79 ; CHECK-APPLE: bl {{.*}}foo
80 ; CHECK-APPLE: cbnz x21
81 ; CHECK-APPLE: fcmp s0, [[CMP]]
83 ; Access part of the error object and save it to error_ref
84 ; CHECK-APPLE: ldrb [[CODE:w[0-9]+]], [x21, #8]
85 ; CHECK-APPLE: strb [[CODE]], [{{.*}}[[ID]]]
86 ; CHECK-APPLE: mov x0, x21
87 ; CHECK-APPLE: bl {{.*}}free
89 ; CHECK-O0-LABEL: caller2:
91 ; CHECK-O0: bl {{.*}}foo
92 ; CHECK-O0: mov [[ID:x[0-9]+]], x21
95 %error_ptr_ref = alloca swifterror %swift_error*
98 store %swift_error* null, %swift_error** %error_ptr_ref
99 %call = call float @foo(%swift_error** swifterror %error_ptr_ref)
100 %error_from_foo = load %swift_error*, %swift_error** %error_ptr_ref
101 %had_error_from_foo = icmp ne %swift_error* %error_from_foo, null
102 %tmp = bitcast %swift_error* %error_from_foo to i8*
103 br i1 %had_error_from_foo, label %handler, label %cont
105 %cmp = fcmp ogt float %call, 1.000000e+00
106 br i1 %cmp, label %bb_end, label %bb_loop
108 %v1 = getelementptr inbounds %swift_error, %swift_error* %error_from_foo, i64 0, i32 1
109 %t = load i8, i8* %v1
110 store i8 %t, i8* %error_ref
113 call void @free(i8* %tmp)
117 ; "foo_if" is a function that takes a swifterror parameter, it sets swifterror
118 ; under a certain condition.
119 define float @foo_if(%swift_error** swifterror %error_ptr_ref, i32 %cc) {
120 ; CHECK-APPLE-LABEL: foo_if:
121 ; CHECK-APPLE: cbz w0
122 ; CHECK-APPLE: orr w0, wzr, #0x10
123 ; CHECK-APPLE: malloc
124 ; CHECK-APPLE: orr [[ID:w[0-9]+]], wzr, #0x1
125 ; CHECK-APPLE: strb [[ID]], [x0, #8]
126 ; CHECK-APPLE: mov x21, x0
127 ; CHECK-APPLE-NOT: x21
130 ; CHECK-O0-LABEL: foo_if:
132 ; CHECK-O0: str x21, [sp, [[SLOT:#[0-9]+]]]
134 ; CHECK-O0: orr w{{.*}}, wzr, #0x10
136 ; CHECK-O0: mov [[ID:x[0-9]+]], x0
137 ; CHECK-O0: orr [[ID2:w[0-9]+]], wzr, #0x1
138 ; CHECK-O0: strb [[ID2]], [x0, #8]
139 ; CHECK-O0: mov x21, [[ID]]
142 ; CHECK-O0: ldr [[ID3:x[0-9]+]], [sp, [[SLOT]]]
143 ; CHECK-O0: mov x21, [[ID3]]
146 %cond = icmp ne i32 %cc, 0
147 br i1 %cond, label %gen_error, label %normal
150 %call = call i8* @malloc(i64 16)
151 %call.0 = bitcast i8* %call to %swift_error*
152 store %swift_error* %call.0, %swift_error** %error_ptr_ref
153 %tmp = getelementptr inbounds i8, i8* %call, i64 8
161 ; "foo_loop" is a function that takes a swifterror parameter, it sets swifterror
162 ; under a certain condition inside a loop.
163 define float @foo_loop(%swift_error** swifterror %error_ptr_ref, i32 %cc, float %cc2) {
164 ; CHECK-APPLE-LABEL: foo_loop:
165 ; CHECK-APPLE: mov x0, x21
167 ; CHECK-APPLE: orr w0, wzr, #0x10
168 ; CHECK-APPLE: malloc
169 ; CHECK-APPLE: strb w{{.*}}, [x0, #8]
172 ; CHECK-APPLE: mov x21, x0
175 ; CHECK-O0-LABEL: foo_loop:
177 ; CHECK-O0: str x21, [sp, [[SLOT:#[0-9]+]]]
178 ; CHECK-O0: b [[BB1:[A-Za-z0-9_]*]]
180 ; CHECK-O0: ldr x0, [sp, [[SLOT]]]
181 ; CHECK-O0: str x0, [sp, [[SLOT2:#[0-9]+]]]
182 ; CHECK-O0: cbz {{.*}}, [[BB2:[A-Za-z0-9_]*]]
183 ; CHECK-O0: orr w{{.*}}, wzr, #0x10
185 ; CHECK-O0: mov [[ID:x[0-9]+]], x0
186 ; CHECK-O0: strb w{{.*}}, [{{.*}}[[ID]], #8]
188 ; CHECK-O0: str x0, [sp, [[SLOT2]]]
190 ; CHECK-O0: ldr x0, [sp, [[SLOT2]]]
192 ; CHECK-O0: str x0, [sp, [[SLOT3:#[0-9]+]]
193 ; CHECK-O0: b.le [[BB1]]
195 ; CHECK-O0: ldr [[ID3:x[0-9]+]], [sp, [[SLOT3]]]
196 ; CHECK-O0: mov x21, [[ID3]]
202 %cond = icmp ne i32 %cc, 0
203 br i1 %cond, label %gen_error, label %bb_cont
206 %call = call i8* @malloc(i64 16)
207 %call.0 = bitcast i8* %call to %swift_error*
208 store %swift_error* %call.0, %swift_error** %error_ptr_ref
209 %tmp = getelementptr inbounds i8, i8* %call, i64 8
214 %cmp = fcmp ogt float %cc2, 1.000000e+00
215 br i1 %cmp, label %bb_end, label %bb_loop
220 %struct.S = type { i32, i32, i32, i32, i32, i32 }
222 ; "foo_sret" is a function that takes a swifterror parameter, it also has a sret
224 define void @foo_sret(%struct.S* sret %agg.result, i32 %val1, %swift_error** swifterror %error_ptr_ref) {
225 ; CHECK-APPLE-LABEL: foo_sret:
226 ; CHECK-APPLE: mov [[SRET:x[0-9]+]], x8
227 ; CHECK-APPLE: orr w0, wzr, #0x10
228 ; CHECK-APPLE: malloc
229 ; CHECK-APPLE: orr [[ID:w[0-9]+]], wzr, #0x1
230 ; CHECK-APPLE: strb [[ID]], [x0, #8]
231 ; CHECK-APPLE: str w{{.*}}, [{{.*}}[[SRET]], #4]
232 ; CHECK-APPLE: mov x21, x0
233 ; CHECK-APPLE-NOT: x21
235 ; CHECK-O0-LABEL: foo_sret:
236 ; CHECK-O0: orr w{{.*}}, wzr, #0x10
238 ; CHECK-O0-DAG: str x8
240 ; CHECK-O0-DAG: str x21
242 ; CHECK-O0: orr [[ID:w[0-9]+]], wzr, #0x1
243 ; CHECK-O0: strb [[ID]], [x0, #8]
245 ; CHECK-O0: ldr [[SRET:x[0-9]+]]
246 ; CHECK-O0: str w{{.*}}, [{{.*}}[[SRET]], #4]
250 %call = call i8* @malloc(i64 16)
251 %call.0 = bitcast i8* %call to %swift_error*
252 store %swift_error* %call.0, %swift_error** %error_ptr_ref
253 %tmp = getelementptr inbounds i8, i8* %call, i64 8
255 %v2 = getelementptr inbounds %struct.S, %struct.S* %agg.result, i32 0, i32 1
256 store i32 %val1, i32* %v2
260 ; "caller3" calls "foo_sret" that takes a swifterror parameter.
261 define float @caller3(i8* %error_ref) {
262 ; CHECK-APPLE-LABEL: caller3:
263 ; CHECK-APPLE: mov [[ID:x[0-9]+]], x0
264 ; CHECK-APPLE: mov x21, xzr
265 ; CHECK-APPLE: bl {{.*}}foo_sret
266 ; CHECK-APPLE: mov x0, x21
267 ; CHECK-APPLE: cbnz x21
268 ; Access part of the error object and save it to error_ref
269 ; CHECK-APPLE: ldrb [[CODE:w[0-9]+]], [x0, #8]
270 ; CHECK-APPLE: strb [[CODE]], [{{.*}}[[ID]]]
271 ; CHECK-APPLE: bl {{.*}}free
273 ; CHECK-O0-LABEL: caller3:
277 ; CHECK-O0: bl {{.*}}foo_sret
278 ; CHECK-O0: mov [[ID2:x[0-9]+]], x21
280 ; Access part of the error object and save it to error_ref
282 ; CHECK-O0: ldrb [[CODE:w[0-9]+]]
283 ; CHECK-O0: ldr [[ID:x[0-9]+]]
284 ; CHECK-O0: strb [[CODE]], [{{.*}}[[ID]]]
285 ; CHECK-O0: bl {{.*}}free
287 %s = alloca %struct.S, align 8
288 %error_ptr_ref = alloca swifterror %swift_error*
289 store %swift_error* null, %swift_error** %error_ptr_ref
290 call void @foo_sret(%struct.S* sret %s, i32 1, %swift_error** swifterror %error_ptr_ref)
291 %error_from_foo = load %swift_error*, %swift_error** %error_ptr_ref
292 %had_error_from_foo = icmp ne %swift_error* %error_from_foo, null
293 %tmp = bitcast %swift_error* %error_from_foo to i8*
294 br i1 %had_error_from_foo, label %handler, label %cont
296 %v1 = getelementptr inbounds %swift_error, %swift_error* %error_from_foo, i64 0, i32 1
297 %t = load i8, i8* %v1
298 store i8 %t, i8* %error_ref
301 call void @free(i8* %tmp)
305 ; "foo_vararg" is a function that takes a swifterror parameter, it also has
306 ; variable number of arguments.
307 declare void @llvm.va_start(i8*) nounwind
308 define float @foo_vararg(%swift_error** swifterror %error_ptr_ref, ...) {
309 ; CHECK-APPLE-LABEL: foo_vararg:
310 ; CHECK-APPLE: orr w0, wzr, #0x10
311 ; CHECK-APPLE: malloc
312 ; CHECK-APPLE-DAG: orr [[ID:w[0-9]+]], wzr, #0x1
313 ; CHECK-APPLE-DAG: add [[ARGS:x[0-9]+]], [[TMP:x[0-9]+]], #16
314 ; CHECK-APPLE-DAG: strb [[ID]], [x0, #8]
317 ; CHECK-APPLE-DAG: ldr {{w[0-9]+}}, [{{.*}}[[TMP]], #16]
319 ; CHECK-APPLE-DAG: ldr {{w[0-9]+}}, [{{.*}}[[TMP]], #24]
320 ; CHECK-APPLE-DAG: add {{x[0-9]+}}, {{x[0-9]+}}, #16
322 ; CHECK-APPLE-DAG: ldr {{w[0-9]+}}, [{{.*}}[[TMP]], #32]
324 ; CHECK-APPLE: mov x21, x0
325 ; CHECK-APPLE-NOT: x21
327 %call = call i8* @malloc(i64 16)
328 %call.0 = bitcast i8* %call to %swift_error*
329 store %swift_error* %call.0, %swift_error** %error_ptr_ref
330 %tmp = getelementptr inbounds i8, i8* %call, i64 8
333 %args = alloca i8*, align 8
334 %a10 = alloca i32, align 4
335 %a11 = alloca i32, align 4
336 %a12 = alloca i32, align 4
337 %v10 = bitcast i8** %args to i8*
338 call void @llvm.va_start(i8* %v10)
339 %v11 = va_arg i8** %args, i32
340 store i32 %v11, i32* %a10, align 4
341 %v12 = va_arg i8** %args, i32
342 store i32 %v12, i32* %a11, align 4
343 %v13 = va_arg i8** %args, i32
344 store i32 %v13, i32* %a12, align 4
349 ; "caller4" calls "foo_vararg" that takes a swifterror parameter.
350 define float @caller4(i8* %error_ref) {
351 ; CHECK-APPLE-LABEL: caller4:
353 ; CHECK-APPLE: mov [[ID:x[0-9]+]], x0
354 ; CHECK-APPLE: stp {{x[0-9]+}}, {{x[0-9]+}}, [sp, #8]
355 ; CHECK-APPLE: str {{x[0-9]+}}, [sp]
357 ; CHECK-APPLE: mov x21, xzr
358 ; CHECK-APPLE: bl {{.*}}foo_vararg
359 ; CHECK-APPLE: mov x0, x21
360 ; CHECK-APPLE: cbnz x21
361 ; Access part of the error object and save it to error_ref
362 ; CHECK-APPLE: ldrb [[CODE:w[0-9]+]], [x0, #8]
363 ; CHECK-APPLE: strb [[CODE]], [{{.*}}[[ID]]]
364 ; CHECK-APPLE: bl {{.*}}free
366 %error_ptr_ref = alloca swifterror %swift_error*
367 store %swift_error* null, %swift_error** %error_ptr_ref
369 %a10 = alloca i32, align 4
370 %a11 = alloca i32, align 4
371 %a12 = alloca i32, align 4
372 store i32 10, i32* %a10, align 4
373 store i32 11, i32* %a11, align 4
374 store i32 12, i32* %a12, align 4
375 %v10 = load i32, i32* %a10, align 4
376 %v11 = load i32, i32* %a11, align 4
377 %v12 = load i32, i32* %a12, align 4
379 %call = call float (%swift_error**, ...) @foo_vararg(%swift_error** swifterror %error_ptr_ref, i32 %v10, i32 %v11, i32 %v12)
380 %error_from_foo = load %swift_error*, %swift_error** %error_ptr_ref
381 %had_error_from_foo = icmp ne %swift_error* %error_from_foo, null
382 %tmp = bitcast %swift_error* %error_from_foo to i8*
383 br i1 %had_error_from_foo, label %handler, label %cont
386 %v1 = getelementptr inbounds %swift_error, %swift_error* %error_from_foo, i64 0, i32 1
387 %t = load i8, i8* %v1
388 store i8 %t, i8* %error_ref
391 call void @free(i8* %tmp)
395 ; Check that we don't blow up on tail calling swifterror argument functions.
396 define float @tailcallswifterror(%swift_error** swifterror %error_ptr_ref) {
398 %0 = tail call float @tailcallswifterror(%swift_error** swifterror %error_ptr_ref)
401 define swiftcc float @tailcallswifterror_swiftcc(%swift_error** swifterror %error_ptr_ref) {
403 %0 = tail call swiftcc float @tailcallswifterror_swiftcc(%swift_error** swifterror %error_ptr_ref)
407 ; CHECK-APPLE-LABEL: swifterror_clobber
408 ; CHECK-APPLE: mov [[REG:x[0-9]+]], x21
410 ; CHECK-APPLE: mov x21, [[REG]]
411 define swiftcc void @swifterror_clobber(%swift_error** nocapture swifterror %err) {
412 call void asm sideeffect "nop", "~{x21}"()
416 ; CHECK-APPLE-LABEL: swifterror_reg_clobber
417 ; CHECK-APPLE: stp {{.*}}x21
419 ; CHECK-APPLE: ldp {{.*}}x21
420 define swiftcc void @swifterror_reg_clobber(%swift_error** nocapture %err) {
421 call void asm sideeffect "nop", "~{x21}"()
424 ; CHECK-APPLE-LABEL: params_in_reg
425 ; Save callee saved registers and swifterror since it will be clobbered by the first call to params_in_reg2.
426 ; CHECK-APPLE: stp x21, x28, [sp
427 ; CHECK-APPLE: stp x27, x26, [sp
428 ; CHECK-APPLE: stp x25, x24, [sp
429 ; CHECK-APPLE: stp x23, x22, [sp
430 ; CHECK-APPLE: stp x20, x19, [sp
431 ; CHECK-APPLE: stp x29, x30, [sp
432 ; CHECK-APPLE: str x20, [sp
433 ; Store argument registers.
434 ; CHECK-APPLE: mov x23, x7
435 ; CHECK-APPLE: mov x24, x6
436 ; CHECK-APPLE: mov x25, x5
437 ; CHECK-APPLE: mov x26, x4
438 ; CHECK-APPLE: mov x27, x3
439 ; CHECK-APPLE: mov x28, x2
440 ; CHECK-APPLE: mov x19, x1
441 ; CHECK-APPLE: mov x22, x0
443 ; CHECK-APPLE: orr w0, wzr, #0x1
444 ; CHECK-APPLE: orr w1, wzr, #0x2
445 ; CHECK-APPLE: orr w2, wzr, #0x3
446 ; CHECK-APPLE: orr w3, wzr, #0x4
447 ; CHECK-APPLE: mov w4, #5
448 ; CHECK-APPLE: orr w5, wzr, #0x6
449 ; CHECK-APPLE: orr w6, wzr, #0x7
450 ; CHECK-APPLE: orr w7, wzr, #0x8
451 ; CHECK-APPLE: mov x20, xzr
452 ; CHECK-APPLE: mov x21, xzr
453 ; CHECK-APPLE: bl _params_in_reg2
454 ; Restore original arguments for next call.
455 ; CHECK-APPLE: mov x0, x22
456 ; CHECK-APPLE: mov x1, x19
457 ; CHECK-APPLE: mov x2, x28
458 ; CHECK-APPLE: mov x3, x27
459 ; CHECK-APPLE: mov x4, x26
460 ; CHECK-APPLE: mov x5, x25
461 ; CHECK-APPLE: mov x6, x24
462 ; CHECK-APPLE: mov x7, x23
463 ; Restore original swiftself argument and swifterror %err.
464 ; CHECK-APPLE: ldp x20, x21, [sp
465 ; CHECK-APPLE: bl _params_in_reg2
466 ; Restore calle save registers but don't clober swifterror x21.
467 ; CHECK-APPLE-NOT: x21
468 ; CHECK-APPLE: ldp x29, x30, [sp
469 ; CHECK-APPLE-NOT: x21
470 ; CHECK-APPLE: ldp x20, x19, [sp
471 ; CHECK-APPLE-NOT: x21
472 ; CHECK-APPLE: ldp x23, x22, [sp
473 ; CHECK-APPLE-NOT: x21
474 ; CHECK-APPLE: ldp x25, x24, [sp
475 ; CHECK-APPLE-NOT: x21
476 ; CHECK-APPLE: ldp x27, x26, [sp
477 ; CHECK-APPLE-NOT: x21
478 ; CHECK-APPLE: ldr x28, [sp
479 ; CHECK-APPLE-NOT: x21
481 define swiftcc void @params_in_reg(i64, i64, i64, i64, i64, i64, i64, i64, i8* swiftself, %swift_error** nocapture swifterror %err) {
482 %error_ptr_ref = alloca swifterror %swift_error*, align 8
483 store %swift_error* null, %swift_error** %error_ptr_ref
484 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)
485 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)
488 declare swiftcc void @params_in_reg2(i64, i64, i64, i64, i64, i64, i64, i64, i8* swiftself, %swift_error** nocapture swifterror %err)
490 ; CHECK-APPLE-LABEL: params_and_return_in_reg
491 ; Store callee saved registers.
492 ; CHECK-APPLE: stp x20, x28, [sp, #24
493 ; CHECK-APPLE: stp x27, x26, [sp
494 ; CHECK-APPLE: stp x25, x24, [sp
495 ; CHECK-APPLE: stp x23, x22, [sp
496 ; CHECK-APPLE: stp x20, x19, [sp
497 ; CHECK-APPLE: stp x29, x30, [sp
498 ; Save original arguments.
499 ; CHECK-APPLE: mov x23, x21
500 ; CHECK-APPLE: str x7, [sp, #16]
501 ; CHECK-APPLE: mov x24, x6
502 ; CHECK-APPLE: mov x25, x5
503 ; CHECK-APPLE: mov x26, x4
504 ; CHECK-APPLE: mov x27, x3
505 ; CHECK-APPLE: mov x28, x2
506 ; CHECK-APPLE: mov x19, x1
507 ; CHECK-APPLE: mov x22, x0
508 ; Setup call arguments.
509 ; CHECK-APPLE: orr w0, wzr, #0x1
510 ; CHECK-APPLE: orr w1, wzr, #0x2
511 ; CHECK-APPLE: orr w2, wzr, #0x3
512 ; CHECK-APPLE: orr w3, wzr, #0x4
513 ; CHECK-APPLE: mov w4, #5
514 ; CHECK-APPLE: orr w5, wzr, #0x6
515 ; CHECK-APPLE: orr w6, wzr, #0x7
516 ; CHECK-APPLE: orr w7, wzr, #0x8
517 ; CHECK-APPLE: mov x20, xzr
518 ; CHECK-APPLE: mov x21, xzr
519 ; CHECK-APPLE: bl _params_in_reg2
520 ; Store swifterror %error_ptr_ref.
521 ; CHECK-APPLE: str x21, [sp, #8]
522 ; Setup call arguments from original arguments.
523 ; CHECK-APPLE: mov x0, x22
524 ; CHECK-APPLE: mov x1, x19
525 ; CHECK-APPLE: mov x2, x28
526 ; CHECK-APPLE: mov x3, x27
527 ; CHECK-APPLE: mov x4, x26
528 ; CHECK-APPLE: mov x5, x25
529 ; CHECK-APPLE: mov x6, x24
530 ; CHECK-APPLE: ldp x7, x20, [sp, #16]
531 ; CHECK-APPLE: mov x21, x23
532 ; CHECK-APPLE: bl _params_and_return_in_reg2
533 ; Store return values.
534 ; CHECK-APPLE: mov x19, x0
535 ; CHECK-APPLE: mov x22, x1
536 ; CHECK-APPLE: mov x24, x2
537 ; CHECK-APPLE: mov x25, x3
538 ; CHECK-APPLE: mov x26, x4
539 ; CHECK-APPLE: mov x27, x5
540 ; CHECK-APPLE: mov x28, x6
541 ; CHECK-APPLE: mov x23, x7
542 ; Save swifterror %err.
543 ; CHECK-APPLE: str x21, [sp, #24]
545 ; CHECK-APPLE: orr w0, wzr, #0x1
546 ; CHECK-APPLE: orr w1, wzr, #0x2
547 ; CHECK-APPLE: orr w2, wzr, #0x3
548 ; CHECK-APPLE: orr w3, wzr, #0x4
549 ; CHECK-APPLE: mov w4, #5
550 ; CHECK-APPLE: orr w5, wzr, #0x6
551 ; CHECK-APPLE: orr w6, wzr, #0x7
552 ; CHECK-APPLE: orr w7, wzr, #0x8
553 ; CHECK-APPLE: mov x20, xzr
554 ; ... setup call with swiferror %error_ptr_ref.
555 ; CHECK-APPLE: ldr x21, [sp, #8]
556 ; CHECK-APPLE: bl _params_in_reg2
557 ; Restore return values for return from this function.
558 ; CHECK-APPLE: mov x0, x19
559 ; CHECK-APPLE: mov x1, x22
560 ; CHECK-APPLE: mov x2, x24
561 ; CHECK-APPLE: mov x3, x25
562 ; CHECK-APPLE: mov x4, x26
563 ; CHECK-APPLE: mov x5, x27
564 ; CHECK-APPLE: mov x6, x28
565 ; CHECK-APPLE: mov x7, x23
566 ; Restore swifterror %err and callee save registers.
567 ; CHECK-APPLE: ldp x21, x28, [sp, #24
568 ; CHECK-APPLE: ldp x29, x30, [sp
569 ; CHECK-APPLE: ldp x20, x19, [sp
570 ; CHECK-APPLE: ldp x23, x22, [sp
571 ; CHECK-APPLE: ldp x25, x24, [sp
572 ; CHECK-APPLE: ldp x27, x26, [sp
574 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) {
575 %error_ptr_ref = alloca swifterror %swift_error*, align 8
576 store %swift_error* null, %swift_error** %error_ptr_ref
577 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)
578 %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)
579 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)
580 ret { i64, i64, i64, i64, i64, i64, i64, i64 } %val
583 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)
585 declare void @acallee(i8*)
587 ; Make sure we don't tail call if the caller returns a swifterror value. We
588 ; would have to move into the swifterror register before the tail call.
589 ; CHECK-APPLE: tailcall_from_swifterror:
590 ; CHECK-APPLE-NOT: b _acallee
591 ; CHECK-APPLE: bl _acallee
593 define swiftcc void @tailcall_from_swifterror(%swift_error** swifterror %error_ptr_ref) {
595 tail call void @acallee(i8* null)
599 declare swiftcc void @foo2(%swift_error** swifterror)
601 ; Make sure we properly assign registers during fast-isel.
602 ; CHECK-O0-LABEL: testAssign
603 ; CHECK-O0: mov [[TMP:x.*]], xzr
604 ; CHECK-O0: mov x21, [[TMP]]
606 ; CHECK-O0: str x21, [s[[STK:.*]]]
607 ; CHECK-O0: ldr x0, [s[[STK]]]
609 ; CHECK-APPLE-LABEL: testAssign
610 ; CHECK-APPLE: mov x21, xzr
611 ; CHECK-APPLE: bl _foo2
612 ; CHECK-APPLE: mov x0, x21
614 define swiftcc %swift_error* @testAssign(i8* %error_ref) {
616 %error_ptr = alloca swifterror %swift_error*
617 store %swift_error* null, %swift_error** %error_ptr
618 call swiftcc void @foo2(%swift_error** swifterror %error_ptr)
622 %error = load %swift_error*, %swift_error** %error_ptr
623 ret %swift_error* %error