|
1 |
| -; RUN: llc -verify-machineinstrs < %s -mtriple=aarch64-apple-ios | FileCheck --check-prefix=CHECK-APPLE %s |
2 |
| -; RUN: llc -O0 -verify-machineinstrs < %s -mtriple=aarch64-apple-ios | FileCheck --check-prefix=CHECK-O0 %s |
| 1 | +; RUN: llc -verify-machineinstrs -mtriple=aarch64-apple-ios -o - %s | FileCheck --check-prefix=CHECK --check-prefix=OPT %s |
| 2 | +; RUN: llc -O0 -verify-machineinstrs -mtriple=aarch64-apple-ios -o - %s | FileCheck %s |
| 3 | +; RUN: llc -verify-machineinstrs -mtriple=aarch64-unknown-linux-gnu -o - %s | FileCheck --check-prefix=CHECK --check-prefix=OPT %s |
3 | 4 |
|
4 |
| -; Parameter with swiftself should be allocated to x9. |
5 |
| -define void @check_swiftself(i32* swiftself %addr0) { |
6 |
| -; CHECK-APPLE-LABEL: check_swiftself: |
7 |
| -; CHECK-O0-LABEL: check_swiftself: |
| 5 | +; Parameter with swiftself should be allocated to x20. |
| 6 | +; CHECK-LABEL: swiftself_param: |
| 7 | +; CHECK: mov x0, x20 |
| 8 | +; CHECK-NEXT: ret |
| 9 | +define i8* @swiftself_param(i8* swiftself %addr0) { |
| 10 | + ret i8 *%addr0 |
| 11 | +} |
8 | 12 |
|
9 |
| - %val0 = load volatile i32, i32* %addr0 |
10 |
| -; CHECK-APPLE: ldr w{{.*}}, [x9] |
11 |
| -; CHECK-O0: ldr w{{.*}}, [x9] |
12 |
| - ret void |
| 13 | +; Check that x20 is used to pass a swiftself argument. |
| 14 | +; CHECK-LABEL: call_swiftself: |
| 15 | +; CHECK: mov x20, x0 |
| 16 | +; CHECK: bl {{_?}}swiftself_param |
| 17 | +; CHECK: ret |
| 18 | +define i8 *@call_swiftself(i8* %arg) { |
| 19 | + %res = call i8 *@swiftself_param(i8* swiftself %arg) |
| 20 | + ret i8 *%res |
13 | 21 | }
|
14 | 22 |
|
15 |
| -@var8_3 = global i8 0 |
16 |
| -declare void @take_swiftself(i8* swiftself %addr0) |
| 23 | +; x20 should be saved by the callee even if used for swiftself |
| 24 | +; CHECK-LABEL: swiftself_clobber: |
| 25 | +; CHECK: {{stp|str}} {{.*}}x20{{.*}}sp |
| 26 | +; ... |
| 27 | +; CHECK: {{ldp|ldr}} {{.*}}x20{{.*}}sp |
| 28 | +; CHECK: ret |
| 29 | +define i8 *@swiftself_clobber(i8* swiftself %addr0) { |
| 30 | + call void asm sideeffect "", "~{x20}"() |
| 31 | + ret i8 *%addr0 |
| 32 | +} |
17 | 33 |
|
18 |
| -define void @simple_args() { |
19 |
| -; CHECK-APPLE-LABEL: simple_args: |
20 |
| -; CHECK-O0-LABEL: simple_args: |
| 34 | +; Demonstrate that we do not need any movs when calling multiple functions |
| 35 | +; with swiftself argument. |
| 36 | +; CHECK-LABEL: swiftself_passthrough: |
| 37 | +; OPT-NOT: mov{{.*}}x20 |
| 38 | +; OPT: bl {{_?}}swiftself_param |
| 39 | +; OPT-NOT: mov{{.*}}x20 |
| 40 | +; OPT-NEXT: bl {{_?}}swiftself_param |
| 41 | +; OPT: ret |
| 42 | +define void @swiftself_passthrough(i8* swiftself %addr0) { |
| 43 | + call i8 *@swiftself_param(i8* swiftself %addr0) |
| 44 | + call i8 *@swiftself_param(i8* swiftself %addr0) |
| 45 | + ret void |
| 46 | +} |
21 | 47 |
|
22 |
| - call void @take_swiftself(i8* @var8_3) |
23 |
| -; CHECK-APPLE: add x9, |
24 |
| -; CHECK-APPLE: bl {{_?}}take_swiftself |
25 |
| -; CHECK-O0: add x9, |
26 |
| -; CHECK-O0: bl {{_?}}take_swiftself |
| 48 | +; We can use a tail call if the callee swiftself is the same as the caller one. |
| 49 | +; CHECK-LABEL: swiftself_tail: |
| 50 | +; OPT: b {{_?}}swiftself_param |
| 51 | +; OPT-NOT: ret |
| 52 | +define i8* @swiftself_tail(i8* swiftself %addr0) { |
| 53 | + call void asm sideeffect "", "~{x20}"() |
| 54 | + %res = tail call i8* @swiftself_param(i8* swiftself %addr0) |
| 55 | + ret i8* %res |
| 56 | +} |
27 | 57 |
|
28 |
| - ret void |
| 58 | +; We can not use a tail call if the callee swiftself is not the same as the |
| 59 | +; caller one. |
| 60 | +; CHECK-LABEL: swiftself_notail: |
| 61 | +; CHECK: mov x20, x0 |
| 62 | +; CHECK: bl {{_?}}swiftself_param |
| 63 | +; CHECK: ret |
| 64 | +define i8* @swiftself_notail(i8* swiftself %addr0, i8* %addr1) nounwind { |
| 65 | + %res = tail call i8* @swiftself_param(i8* swiftself %addr1) |
| 66 | + ret i8* %res |
29 | 67 | }
|
0 commit comments