1 ; RUN: llc -fast-isel-sink-local-values -verify-machineinstrs < %s -mtriple=armv7-apple-ios | FileCheck --check-prefix=CHECK-APPLE --check-prefix=CHECK-ARMV7 %s
2 ; RUN: llc -fast-isel-sink-local-values -verify-machineinstrs -O0 < %s -mtriple=armv7-apple-ios | FileCheck --check-prefix=CHECK-O0 %s
3 ; RUN: llc -fast-isel-sink-local-values -verify-machineinstrs < %s -mtriple=armv7-linux-androideabi | FileCheck --check-prefix=CHECK-ANDROID %s
5 declare i8* @malloc(i64)
6 declare void @free(i8*)
7 %swift_error = type { i64, i8 }
8 %struct.S = type { i32, i32, i32, i32, i32, i32 }
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 r0, #16
16 ; CHECK-APPLE-DAG: mov [[ID:r[0-9]+]], #1
17 ; CHECK-APPLE-DAG: mov r8, r{{.*}}
18 ; CHECK-APPLE-DAG: strb [[ID]], [r{{.*}}, #8]
20 ; CHECK-O0-LABEL: foo:
21 ; CHECK-O0: mov r{{.*}}, #16
23 ; CHECK-O0: mov [[ID2:r[0-9]+]], r0
24 ; CHECK-O0: mov [[ID:r[0-9]+]], #1
25 ; CHECK-O0: strb [[ID]], [r0, #8]
26 ; CHECK-O0: mov r8, [[ID2]]
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-DAG: mov [[ID:r[0-9]+]], r0
40 ; CHECK-APPLE-DAG: mov r8, #0
41 ; CHECK-APPLE: bl {{.*}}foo
42 ; CHECK-APPLE: mov r0, r8
43 ; CHECK-APPLE: cmp r8, #0
44 ; Access part of the error object and save it to error_ref
45 ; CHECK-APPLE: ldrbeq [[CODE:r[0-9]+]], [r0, #8]
46 ; CHECK-APPLE: strbeq [[CODE]], [{{.*}}[[ID]]]
47 ; CHECK-APPLE: bl {{.*}}free
49 ; CHECK-O0-LABEL: caller:
51 ; CHECK-O0-DAG: mov r8, #0
52 ; CHECK-O0-DAG: str r0, [sp, [[SLOT:#[0-9]+]]
53 ; CHECK-O0: bl {{.*}}foo
54 ; CHECK-O0: mov [[TMP:r[0-9]+]], r8
55 ; CHECK-O0: str [[TMP]], [sp]
57 ; CHECK-O0: ldrb [[CODE:r[0-9]+]], [r0, #8]
58 ; CHECK-O0: ldr [[ID:r[0-9]+]], [sp, [[SLOT]]]
59 ; CHECK-O0: strb [[CODE]], [{{.*}}[[ID]]]
61 ; CHECK-O0: ldr r0, [sp]
64 %error_ptr_ref = alloca swifterror %swift_error*
65 store %swift_error* null, %swift_error** %error_ptr_ref
66 %call = call float @foo(%swift_error** swifterror %error_ptr_ref)
67 %error_from_foo = load %swift_error*, %swift_error** %error_ptr_ref
68 %had_error_from_foo = icmp ne %swift_error* %error_from_foo, null
69 %tmp = bitcast %swift_error* %error_from_foo to i8*
70 br i1 %had_error_from_foo, label %handler, label %cont
72 %v1 = getelementptr inbounds %swift_error, %swift_error* %error_from_foo, i64 0, i32 1
74 store i8 %t, i8* %error_ref
77 call void @free(i8* %tmp)
81 ; "caller2" is the caller of "foo", it calls "foo" inside a loop.
82 define float @caller2(i8* %error_ref) {
83 ; CHECK-APPLE-LABEL: caller2:
84 ; CHECK-APPLE-DAG: mov [[ID:r[0-9]+]], r0
85 ; CHECK-APPLE-DAG: mov r8, #0
86 ; CHECK-APPLE: bl {{.*}}foo
87 ; CHECK-APPLE: cmp r8, #0
89 ; Access part of the error object and save it to error_ref
90 ; CHECK-APPLE: ldrb [[CODE:r[0-9]+]], [r8, #8]
91 ; CHECK-APPLE: strb [[CODE]], [{{.*}}[[ID]]]
92 ; CHECK-APPLE: mov r0, r8
93 ; CHECK-APPLE: bl {{.*}}free
95 ; CHECK-O0-LABEL: caller2:
97 ; CHECK-O0-DAG: str r0,
98 ; CHECK-O0-DAG: mov r8, #0
99 ; CHECK-O0: bl {{.*}}foo
100 ; CHECK-O0: mov r{{.*}}, r8
101 ; CHECK-O0: str r0, [sp]
104 ; CHECK-O0: ldrb [[CODE:r[0-9]+]], [r0, #8]
106 ; CHECK-O0: ldr [[ID:r[0-9]+]],
107 ; CHECK-O0: strb [[CODE]], [{{.*}}[[ID]]]
108 ; CHECK-O0: ldr r0, [sp]
111 %error_ptr_ref = alloca swifterror %swift_error*
114 store %swift_error* null, %swift_error** %error_ptr_ref
115 %call = call float @foo(%swift_error** swifterror %error_ptr_ref)
116 %error_from_foo = load %swift_error*, %swift_error** %error_ptr_ref
117 %had_error_from_foo = icmp ne %swift_error* %error_from_foo, null
118 %tmp = bitcast %swift_error* %error_from_foo to i8*
119 br i1 %had_error_from_foo, label %handler, label %cont
121 %cmp = fcmp ogt float %call, 1.000000e+00
122 br i1 %cmp, label %bb_end, label %bb_loop
124 %v1 = getelementptr inbounds %swift_error, %swift_error* %error_from_foo, i64 0, i32 1
125 %t = load i8, i8* %v1
126 store i8 %t, i8* %error_ref
129 call void @free(i8* %tmp)
133 ; "foo_if" is a function that takes a swifterror parameter, it sets swifterror
134 ; under a certain condition.
135 define float @foo_if(%swift_error** swifterror %error_ptr_ref, i32 %cc) {
136 ; CHECK-APPLE-LABEL: foo_if:
137 ; CHECK-APPLE: cmp r0, #0
139 ; CHECK-APPLE: mov r0, #16
140 ; CHECK-APPLE: malloc
141 ; CHECK-APPLE-DAG: mov [[ID:r[0-9]+]], #1
142 ; CHECK-APPLE-DAG: mov r8, r{{.*}}
143 ; CHECK-APPLE-DAG: strb [[ID]], [r{{.*}}, #8]
145 ; CHECK-O0-LABEL: foo_if:
146 ; CHECK-O0: cmp r0, #0
150 ; CHECK-O0: mov r0, #16
152 ; CHECK-O0: mov [[ID:r[0-9]+]], r0
153 ; CHECK-O0: mov [[ID2:[a-z0-9]+]], #1
154 ; CHECK-O0: strb [[ID2]], [r0, #8]
155 ; CHECK-O0: mov r8, [[ID]]
159 %cond = icmp ne i32 %cc, 0
160 br i1 %cond, label %gen_error, label %normal
163 %call = call i8* @malloc(i64 16)
164 %call.0 = bitcast i8* %call to %swift_error*
165 store %swift_error* %call.0, %swift_error** %error_ptr_ref
166 %tmp = getelementptr inbounds i8, i8* %call, i64 8
174 ; "foo_loop" is a function that takes a swifterror parameter, it sets swifterror
175 ; under a certain condition inside a loop.
176 define float @foo_loop(%swift_error** swifterror %error_ptr_ref, i32 %cc, float %cc2) {
177 ; CHECK-APPLE-LABEL: foo_loop:
178 ; CHECK-APPLE: mov [[CODE:r[0-9]+]], r0
179 ; swifterror is kept in a register
180 ; CHECK-APPLE: cmp [[CODE]], #0
182 ; CHECK-APPLE: mov r0, #16
183 ; CHECK-APPLE: malloc
184 ; CHECK-APPLE: strb r{{.*}}, [r0, #8]
187 ; CHECK-O0-LABEL: foo_loop:
188 ; CHECK-O0: cmp r{{.*}}, #0
190 ; CHECK-O0: mov r0, #16
192 ; CHECK-O0-DAG: mov [[ID:r[0-9]+]], r0
193 ; CHECK-O0-DAG: movw [[ID2:.*]], #1
194 ; CHECK-O0: strb [[ID2]], [{{.*}}[[ID]], #8]
196 ; CHECK-O0: str r0, [sp{{.*}}]
205 %cond = icmp ne i32 %cc, 0
206 br i1 %cond, label %gen_error, label %bb_cont
209 %call = call i8* @malloc(i64 16)
210 %call.0 = bitcast i8* %call to %swift_error*
211 store %swift_error* %call.0, %swift_error** %error_ptr_ref
212 %tmp = getelementptr inbounds i8, i8* %call, i64 8
217 %cmp = fcmp ogt float %cc2, 1.000000e+00
218 br i1 %cmp, label %bb_end, label %bb_loop
223 ; "foo_sret" is a function that takes a swifterror parameter, it also has a sret
225 define void @foo_sret(%struct.S* sret %agg.result, i32 %val1, %swift_error** swifterror %error_ptr_ref) {
226 ; CHECK-APPLE-LABEL: foo_sret:
227 ; CHECK-APPLE: mov [[SRET:r[0-9]+]], r0
228 ; CHECK-APPLE: mov r0, #16
229 ; CHECK-APPLE: malloc
230 ; CHECK-APPLE: mov [[REG:r[0-9]+]], #1
231 ; CHECK-APPLE-DAG: mov r8, r0
232 ; CHECK-APPLE-DAG: strb [[REG]], [r0, #8]
233 ; CHECK-APPLE-DAG: str r{{.*}}, [{{.*}}[[SRET]], #4]
235 ; CHECK-O0-LABEL: foo_sret:
236 ; CHECK-O0: mov r{{.*}}, #16
237 ; spill to stack: sret and val1
238 ; CHECK-O0-DAG: str r0
239 ; CHECK-O0-DAG: str r1
241 ; CHECK-O0: mov [[ID:r[0-9]+]], #1
242 ; CHECK-O0: strb [[ID]], [r0, #8]
243 ; reload from stack: sret and val1
246 ; CHECK-O0: str r{{.*}}, [{{.*}}, #4]
249 %call = call i8* @malloc(i64 16)
250 %call.0 = bitcast i8* %call to %swift_error*
251 store %swift_error* %call.0, %swift_error** %error_ptr_ref
252 %tmp = getelementptr inbounds i8, i8* %call, i64 8
254 %v2 = getelementptr inbounds %struct.S, %struct.S* %agg.result, i32 0, i32 1
255 store i32 %val1, i32* %v2
259 ; "caller3" calls "foo_sret" that takes a swifterror parameter.
260 define float @caller3(i8* %error_ref) {
261 ; CHECK-APPLE-LABEL: caller3:
262 ; CHECK-APPLE: mov [[ID:r[0-9]+]], r0
263 ; CHECK-APPLE: mov r8, #0
264 ; CHECK-APPLE: bl {{.*}}foo_sret
265 ; CHECK-APPLE: mov r0, r8
266 ; CHECK-APPLE: cmp r8, #0
267 ; Access part of the error object and save it to error_ref
268 ; CHECK-APPLE: ldrbeq [[CODE:r[0-9]+]], [r0, #8]
269 ; CHECK-APPLE: strbeq [[CODE]], [{{.*}}[[ID]]]
270 ; CHECK-APPLE: bl {{.*}}free
272 ; CHECK-O0-LABEL: caller3:
273 ; CHECK-O0-DAG: mov r8, #0
274 ; CHECK-O0-DAG: mov r0
275 ; CHECK-O0-DAG: mov r1
276 ; CHECK-O0: bl {{.*}}foo_sret
277 ; CHECK-O0: mov [[ID2:r[0-9]+]], r8
279 ; CHECK-O0: str [[ID2]], [sp[[SLOT:.*]]]
281 ; Access part of the error object and save it to error_ref
282 ; CHECK-O0: ldrb [[CODE:r[0-9]+]]
283 ; CHECK-O0: ldr [[ID:r[0-9]+]]
284 ; CHECK-O0: strb [[CODE]], [{{.*}}[[ID]]]
285 ; CHECK-O0: ldr r0, [sp[[SLOT]]
286 ; CHECK-O0: bl {{.*}}free
288 %s = alloca %struct.S, align 8
289 %error_ptr_ref = alloca swifterror %swift_error*
290 store %swift_error* null, %swift_error** %error_ptr_ref
291 call void @foo_sret(%struct.S* sret %s, i32 1, %swift_error** swifterror %error_ptr_ref)
292 %error_from_foo = load %swift_error*, %swift_error** %error_ptr_ref
293 %had_error_from_foo = icmp ne %swift_error* %error_from_foo, null
294 %tmp = bitcast %swift_error* %error_from_foo to i8*
295 br i1 %had_error_from_foo, label %handler, label %cont
297 %v1 = getelementptr inbounds %swift_error, %swift_error* %error_from_foo, i64 0, i32 1
298 %t = load i8, i8* %v1
299 store i8 %t, i8* %error_ref
302 call void @free(i8* %tmp)
306 ; "foo_vararg" is a function that takes a swifterror parameter, it also has
307 ; variable number of arguments.
308 declare void @llvm.va_start(i8*) nounwind
309 define float @foo_vararg(%swift_error** swifterror %error_ptr_ref, ...) {
310 ; CHECK-APPLE-LABEL: foo_vararg:
311 ; CHECK-APPLE: mov r0, #16
312 ; CHECK-APPLE: malloc
313 ; CHECK-APPLE: mov r8, r0
314 ; CHECK-APPLE: mov [[ID:r[0-9]+]], #1
315 ; CHECK-APPLE-DAG: strb [[ID]], [r8, #8]
318 %call = call i8* @malloc(i64 16)
319 %call.0 = bitcast i8* %call to %swift_error*
320 store %swift_error* %call.0, %swift_error** %error_ptr_ref
321 %tmp = getelementptr inbounds i8, i8* %call, i64 8
324 %args = alloca i8*, align 8
325 %a10 = alloca i32, align 4
326 %a11 = alloca i32, align 4
327 %a12 = alloca i32, align 4
328 %v10 = bitcast i8** %args to i8*
329 call void @llvm.va_start(i8* %v10)
330 %v11 = va_arg i8** %args, i32
331 store i32 %v11, i32* %a10, align 4
332 %v12 = va_arg i8** %args, i32
333 store i32 %v12, i32* %a11, align 4
334 %v13 = va_arg i8** %args, i32
335 store i32 %v13, i32* %a12, align 4
340 ; "caller4" calls "foo_vararg" that takes a swifterror parameter.
341 define float @caller4(i8* %error_ref) {
342 ; CHECK-APPLE-LABEL: caller4:
343 ; CHECK-APPLE: mov [[ID:r[0-9]+]], r0
344 ; CHECK-APPLE: mov r8, #0
345 ; CHECK-APPLE: bl {{.*}}foo_vararg
346 ; CHECK-APPLE: mov r0, r8
347 ; CHECK-APPLE: cmp r8, #0
348 ; Access part of the error object and save it to error_ref
349 ; CHECK-APPLE: ldrbeq [[CODE:r[0-9]+]], [r0, #8]
350 ; CHECK-APPLE: strbeq [[CODE]], [{{.*}}[[ID]]]
351 ; CHECK-APPLE: bl {{.*}}free
353 %error_ptr_ref = alloca swifterror %swift_error*
354 store %swift_error* null, %swift_error** %error_ptr_ref
356 %a10 = alloca i32, align 4
357 %a11 = alloca i32, align 4
358 %a12 = alloca i32, align 4
359 store i32 10, i32* %a10, align 4
360 store i32 11, i32* %a11, align 4
361 store i32 12, i32* %a12, align 4
362 %v10 = load i32, i32* %a10, align 4
363 %v11 = load i32, i32* %a11, align 4
364 %v12 = load i32, i32* %a12, align 4
366 %call = call float (%swift_error**, ...) @foo_vararg(%swift_error** swifterror %error_ptr_ref, i32 %v10, i32 %v11, i32 %v12)
367 %error_from_foo = load %swift_error*, %swift_error** %error_ptr_ref
368 %had_error_from_foo = icmp ne %swift_error* %error_from_foo, null
369 %tmp = bitcast %swift_error* %error_from_foo to i8*
370 br i1 %had_error_from_foo, label %handler, label %cont
373 %v1 = getelementptr inbounds %swift_error, %swift_error* %error_from_foo, i64 0, i32 1
374 %t = load i8, i8* %v1
375 store i8 %t, i8* %error_ref
378 call void @free(i8* %tmp)
382 ; Check that we don't blow up on tail calling swifterror argument functions.
383 define float @tailcallswifterror(%swift_error** swifterror %error_ptr_ref) {
385 %0 = tail call float @tailcallswifterror(%swift_error** swifterror %error_ptr_ref)
388 define swiftcc float @tailcallswifterror_swiftcc(%swift_error** swifterror %error_ptr_ref) {
390 %0 = tail call swiftcc float @tailcallswifterror_swiftcc(%swift_error** swifterror %error_ptr_ref)
394 ; CHECK-APPLE-LABEL: swifterror_clobber
395 ; CHECK-APPLE: mov [[REG:r[0-9]+]], r8
397 ; CHECK-APPLE: mov r8, [[REG]]
398 define swiftcc void @swifterror_clobber(%swift_error** nocapture swifterror %err) {
399 call void asm sideeffect "nop", "~{r8}"()
403 ; CHECK-APPLE-LABEL: swifterror_reg_clobber
404 ; CHECK-APPLE: push {{.*}}r8
406 ; CHECK-APPLE: pop {{.*}}r8
407 define swiftcc void @swifterror_reg_clobber(%swift_error** nocapture %err) {
408 call void asm sideeffect "nop", "~{r8}"()
412 ; CHECK-ARMV7-LABEL: _params_in_reg
413 ; Store callee saved registers excluding swifterror.
414 ; CHECK-ARMV7: push {r4, r5, r6, r7, r10, r11, lr}
415 ; Store swiftself (r10) and swifterror (r8).
416 ; CHECK-ARMV7-DAG: str r8, [s[[STK1:.*]]]
417 ; CHECK-ARMV7-DAG: str r10, [s[[STK2:.*]]]
419 ; CHECK-ARMV7-DAG: mov r6, r3
420 ; CHECK-ARMV7-DAG: mov r4, r2
421 ; CHECK-ARMV7-DAG: mov r11, r1
422 ; CHECK-ARMV7-DAG: mov r5, r0
424 ; CHECK-ARMV7: mov r0, #1
425 ; CHECK-ARMV7: mov r1, #2
426 ; CHECK-ARMV7: mov r2, #3
427 ; CHECK-ARMV7: mov r3, #4
428 ; CHECK-ARMV7: mov r10, #0
429 ; CHECK-ARMV7: mov r8, #0
430 ; CHECK-ARMV7: bl _params_in_reg2
431 ; Restore original arguments.
432 ; CHECK-ARMV7-DAG: ldr r10, [s[[STK2]]]
433 ; CHECK-ARMV7-DAG: ldr r8, [s[[STK1]]]
434 ; CHECK-ARMV7-DAG: mov r0, r5
435 ; CHECK-ARMV7-DAG: mov r1, r11
436 ; CHECK-ARMV7-DAG: mov r2, r4
437 ; CHECK-ARMV7-DAG: mov r3, r6
438 ; CHECK-ARMV7: bl _params_in_reg2
439 ; CHECK-ARMV7: pop {r4, r5, r6, r7, r10, r11, pc}
440 define swiftcc void @params_in_reg(i32, i32, i32, i32, i8* swiftself, %swift_error** nocapture swifterror %err) {
441 %error_ptr_ref = alloca swifterror %swift_error*, align 8
442 store %swift_error* null, %swift_error** %error_ptr_ref
443 call swiftcc void @params_in_reg2(i32 1, i32 2, i32 3, i32 4, i8* swiftself null, %swift_error** nocapture swifterror %error_ptr_ref)
444 call swiftcc void @params_in_reg2(i32 %0, i32 %1, i32 %2, i32 %3, i8* swiftself %4, %swift_error** nocapture swifterror %err)
447 declare swiftcc void @params_in_reg2(i32, i32, i32, i32, i8* swiftself, %swift_error** nocapture swifterror %err)
449 ; CHECK-ARMV7-LABEL: params_and_return_in_reg
450 ; CHECK-ARMV7: push {r4, r5, r6, r7, r10, r11, lr}
451 ; Store swifterror and swiftself
452 ; CHECK-ARMV7: mov r6, r8
453 ; CHECK-ARMV7: str r10, [s[[STK1:.*]]]
455 ; CHECK-ARMV7: str r3, [s[[STK2:.*]]]
456 ; CHECK-ARMV7: mov r4, r2
457 ; CHECK-ARMV7: mov r11, r1
458 ; CHECK-ARMV7: mov r5, r0
460 ; CHECK-ARMV7: mov r0, #1
461 ; CHECK-ARMV7: mov r1, #2
462 ; CHECK-ARMV7: mov r2, #3
463 ; CHECK-ARMV7: mov r3, #4
464 ; CHECK-ARMV7: mov r10, #0
465 ; CHECK-ARMV7: mov r8, #0
466 ; CHECK-ARMV7: bl _params_in_reg2
467 ; Restore original arguments.
468 ; CHECK-ARMV7-DAG: ldr r3, [s[[STK2]]]
469 ; CHECK-ARMV7-DAG: ldr r10, [s[[STK1]]]
470 ; Store %error_ptr_ref;
471 ; CHECK-ARMV7-DAG: str r8, [s[[STK3:.*]]]
472 ; Restore original arguments.
473 ; CHECK-ARMV7-DAG: mov r0, r5
474 ; CHECK-ARMV7-DAG: mov r1, r11
475 ; CHECK-ARMV7-DAG: mov r2, r4
476 ; CHECK-ARMV7-DAG: mov r8, r6
477 ; CHECK-ARMV7: bl _params_and_return_in_reg2
478 ; Store swifterror return %err;
479 ; CHECK-ARMV7-DAG: str r8, [s[[STK1]]]
480 ; Load swifterror value %error_ptr_ref.
481 ; CHECK-ARMV7-DAG: ldr r8, [s[[STK3]]]
482 ; Save return values.
483 ; CHECK-ARMV7-DAG: mov r4, r0
484 ; CHECK-ARMV7-DAG: mov r5, r1
485 ; CHECK-ARMV7-DAG: mov r6, r2
486 ; CHECK-ARMV7-DAG: mov r11, r3
488 ; CHECK-ARMV7: mov r0, #1
489 ; CHECK-ARMV7: mov r1, #2
490 ; CHECK-ARMV7: mov r2, #3
491 ; CHECK-ARMV7: mov r3, #4
492 ; CHECK-ARMV7: mov r10, #0
493 ; CHECK-ARMV7: bl _params_in_reg2
494 ; Load swifterror %err;
495 ; CHECK-ARMV7-DAG: ldr r8, [s[[STK1]]]
496 ; Restore return values for returning.
497 ; CHECK-ARMV7-DAG: mov r0, r4
498 ; CHECK-ARMV7-DAG: mov r1, r5
499 ; CHECK-ARMV7-DAG: mov r2, r6
500 ; CHECK-ARMV7-DAG: mov r3, r11
501 ; CHECK-ARMV7: pop {r4, r5, r6, r7, r10, r11, pc}
503 ; CHECK-ANDROID-LABEL: params_and_return_in_reg
504 ; CHECK-ANDROID: push {r4, r5, r6, r7, r9, r10, r11, lr}
505 ; CHECK-ANDROID: sub sp, sp, #16
506 ; CHECK-ANDROID: str r8, [sp, #4] @ 4-byte Spill
507 ; CHECK-ANDROID: mov r11, r10
508 ; CHECK-ANDROID: mov r6, r3
509 ; CHECK-ANDROID: mov r7, r2
510 ; CHECK-ANDROID: mov r4, r1
511 ; CHECK-ANDROID: mov r5, r0
512 ; CHECK-ANDROID: mov r0, #1
513 ; CHECK-ANDROID: mov r1, #2
514 ; CHECK-ANDROID: mov r2, #3
515 ; CHECK-ANDROID: mov r3, #4
516 ; CHECK-ANDROID: mov r10, #0
517 ; CHECK-ANDROID: mov r8, #0
518 ; CHECK-ANDROID: bl params_in_reg2
519 ; CHECK-ANDROID: mov r9, r8
520 ; CHECK-ANDROID: ldr r8, [sp, #4] @ 4-byte Reload
521 ; CHECK-ANDROID: mov r0, r5
522 ; CHECK-ANDROID: mov r1, r4
523 ; CHECK-ANDROID: mov r2, r7
524 ; CHECK-ANDROID: mov r3, r6
525 ; CHECK-ANDROID: mov r10, r11
526 ; CHECK-ANDROID: bl params_and_return_in_reg2
527 ; CHECK-ANDROID: mov r4, r0
528 ; CHECK-ANDROID: mov r5, r1
529 ; CHECK-ANDROID: mov r6, r2
530 ; CHECK-ANDROID: mov r7, r3
531 ; CHECK-ANDROID: mov r11, r8
532 ; CHECK-ANDROID: mov r0, #1
533 ; CHECK-ANDROID: mov r1, #2
534 ; CHECK-ANDROID: mov r2, #3
535 ; CHECK-ANDROID: mov r3, #4
536 ; CHECK-ANDROID: mov r10, #0
537 ; CHECK-ANDROID: mov r8, r9
538 ; CHECK-ANDROID: bl params_in_reg2
539 ; CHECK-ANDROID: mov r0, r4
540 ; CHECK-ANDROID: mov r1, r5
541 ; CHECK-ANDROID: mov r2, r6
542 ; CHECK-ANDROID: mov r3, r7
543 ; CHECK-ANDROID: mov r8, r11
544 ; CHECK-ANDROID: add sp, sp, #16
545 ; CHECK-ANDROID: pop {r4, r5, r6, r7, r9, r10, r11, pc}
547 define swiftcc { i32, i32, i32, i32} @params_and_return_in_reg(i32, i32, i32, i32, i8* swiftself, %swift_error** nocapture swifterror %err) {
548 %error_ptr_ref = alloca swifterror %swift_error*, align 8
549 store %swift_error* null, %swift_error** %error_ptr_ref
550 call swiftcc void @params_in_reg2(i32 1, i32 2, i32 3, i32 4, i8* swiftself null, %swift_error** nocapture swifterror %error_ptr_ref)
551 %val = call swiftcc { i32, i32, i32, i32 } @params_and_return_in_reg2(i32 %0, i32 %1, i32 %2, i32 %3, i8* swiftself %4, %swift_error** nocapture swifterror %err)
552 call swiftcc void @params_in_reg2(i32 1, i32 2, i32 3, i32 4, i8* swiftself null, %swift_error** nocapture swifterror %error_ptr_ref)
553 ret { i32, i32, i32, i32 }%val
556 declare swiftcc { i32, i32, i32, i32 } @params_and_return_in_reg2(i32, i32, i32, i32, i8* swiftself, %swift_error** nocapture swifterror %err)
559 declare void @acallee(i8*)
561 ; Make sure we don't tail call if the caller returns a swifterror value. We
562 ; would have to move into the swifterror register before the tail call.
563 ; CHECK-APPLE: tailcall_from_swifterror:
564 ; CHECK-APPLE-NOT: b _acallee
565 ; CHECK-APPLE: bl _acallee
566 ; CHECK-ANDROID: tailcall_from_swifterror:
567 ; CHECK-ANDROID-NOT: b acallee
568 ; CHECK-ANDROID: bl acallee
570 define swiftcc void @tailcall_from_swifterror(%swift_error** swifterror %error_ptr_ref) {
572 tail call void @acallee(i8* null)
577 declare swiftcc void @foo2(%swift_error** swifterror)
579 ; Make sure we properly assign registers during fast-isel.
580 ; CHECK-O0-LABEL: testAssign
581 ; CHECK-O0: mov r8, #0
583 ; CHECK-O0: str r8, [s[[STK:p.*]]]
584 ; CHECK-O0: ldr r0, [s[[STK]]]
587 ; CHECK-APPLE-LABEL: testAssign
588 ; CHECK-APPLE: mov r8, #0
589 ; CHECK-APPLE: bl _foo2
590 ; CHECK-APPLE: mov r0, r8
592 ; CHECK-ANDROID-LABEL: testAssign
593 ; CHECK-ANDROID: mov r8, #0
594 ; CHECK-ANDROID: bl foo2
595 ; CHECK-ANDROID: mov r0, r8
597 define swiftcc %swift_error* @testAssign(i8* %error_ref) {
599 %error_ptr = alloca swifterror %swift_error*
600 store %swift_error* null, %swift_error** %error_ptr
601 call swiftcc void @foo2(%swift_error** swifterror %error_ptr)
605 %error = load %swift_error*, %swift_error** %error_ptr
606 ret %swift_error* %error