1 ; RUN: llc -verify-machineinstrs -mtriple=aarch64-apple-ios -o - %s -global-isel | FileCheck %s
3 ; Parameter with swiftself should be allocated to x20.
4 ; CHECK-LABEL: swiftself_param:
7 define ptr @swiftself_param(ptr swiftself %addr0) {
11 ; Check that x20 is used to pass a swiftself argument.
12 ; CHECK-LABEL: call_swiftself:
14 ; CHECK: bl {{_?}}swiftself_param
16 define ptr @call_swiftself(ptr %arg) {
17 %res = call ptr @swiftself_param(ptr swiftself %arg)
21 ; Demonstrate that we do not need any movs when calling multiple functions
22 ; with swiftself argument.
23 ; CHECK-LABEL: swiftself_passthrough:
24 ; CHECK-NOT: mov{{.*}}x20
25 ; CHECK: bl {{_?}}swiftself_param
26 ; CHECK-NOT: mov{{.*}}x20
27 ; CHECK-NEXT: bl {{_?}}swiftself_param
29 define void @swiftself_passthrough(ptr swiftself %addr0) {
30 call ptr @swiftself_param(ptr swiftself %addr0)
31 call ptr @swiftself_param(ptr swiftself %addr0)
35 ; We can not use a tail call if the callee swiftself is not the same as the
37 ; CHECK-LABEL: swiftself_notail:
39 ; CHECK: bl {{_?}}swiftself_param
41 define ptr @swiftself_notail(ptr swiftself %addr0, ptr %addr1) nounwind {
42 %res = tail call ptr @swiftself_param(ptr swiftself %addr1)
46 ; We cannot pretend that 'x0' is alive across the thisreturn_attribute call as
47 ; we normally would. We marked the first parameter with swiftself which means it
48 ; will no longer be passed in x0.
49 declare swiftcc ptr @thisreturn_attribute(ptr returned swiftself)
50 ; CHECK-LABEL: swiftself_nothisreturn:
51 ; CHECK-DAG: ldr x20, [x20]
52 ; CHECK-DAG: mov [[CSREG:x[1-9].*]], x8
53 ; CHECK: bl {{_?}}thisreturn_attribute
54 ; CHECK: str x0, [[[CSREG]]
56 define hidden swiftcc void @swiftself_nothisreturn(ptr noalias nocapture sret(ptr), ptr noalias nocapture readonly swiftself) {
58 %2 = load ptr, ptr %1, align 8
59 %3 = tail call swiftcc ptr @thisreturn_attribute(ptr swiftself %2)
60 store ptr %3, ptr %0, align 8
64 ; Check that x20 is used to pass a swiftself argument when the parameter is
65 ; only in the declaration's arguments.
66 ; CHECK-LABEL: _swiftself_not_on_call_params:
68 ; CHECK: bl {{_?}}swiftself_param
70 define ptr @swiftself_not_on_call_params(ptr %arg) {
71 %res = call ptr @swiftself_param(ptr %arg)