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 i8* @swiftself_param(i8* 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 i8 *@call_swiftself(i8* %arg) {
17 %res = call i8 *@swiftself_param(i8* 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(i8* swiftself %addr0) {
30 call i8 *@swiftself_param(i8* swiftself %addr0)
31 call i8 *@swiftself_param(i8* 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 i8* @swiftself_notail(i8* swiftself %addr0, i8* %addr1) nounwind {
42 %res = tail call i8* @swiftself_param(i8* 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 i8* @thisreturn_attribute(i8* 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(i8** noalias nocapture sret, i8** noalias nocapture readonly swiftself) {
58 %2 = load i8*, i8** %1, align 8
59 %3 = tail call swiftcc i8* @thisreturn_attribute(i8* swiftself %2)
60 store i8* %3, i8** %0, align 8