74 lines · plain
1; RUN: llc -verify-machineinstrs -mtriple=aarch64-apple-ios -o - %s -global-isel | FileCheck %s2 3; Parameter with swiftself should be allocated to x20.4; CHECK-LABEL: swiftself_param:5; CHECK: mov x0, x206; CHECK-NEXT: ret7define ptr @swiftself_param(ptr swiftself %addr0) {8 ret ptr %addr09}10 11; Check that x20 is used to pass a swiftself argument.12; CHECK-LABEL: call_swiftself:13; CHECK: mov x20, x014; CHECK: bl {{_?}}swiftself_param15; CHECK: ret16define ptr @call_swiftself(ptr %arg) {17 %res = call ptr @swiftself_param(ptr swiftself %arg)18 ret ptr %res19}20 21; Demonstrate that we do not need any movs when calling multiple functions22; with swiftself argument.23; CHECK-LABEL: swiftself_passthrough:24; CHECK-NOT: mov{{.*}}x2025; CHECK: bl {{_?}}swiftself_param26; CHECK-NOT: mov{{.*}}x2027; CHECK-NEXT: bl {{_?}}swiftself_param28; CHECK: ret29define void @swiftself_passthrough(ptr swiftself %addr0) {30 call ptr @swiftself_param(ptr swiftself %addr0)31 call ptr @swiftself_param(ptr swiftself %addr0)32 ret void33}34 35; We can not use a tail call if the callee swiftself is not the same as the36; caller one.37; CHECK-LABEL: swiftself_notail:38; CHECK: mov x20, x039; CHECK: bl {{_?}}swiftself_param40; CHECK: ret41define ptr @swiftself_notail(ptr swiftself %addr0, ptr %addr1) nounwind {42 %res = tail call ptr @swiftself_param(ptr swiftself %addr1)43 ret ptr %res44}45 46; We cannot pretend that 'x0' is alive across the thisreturn_attribute call as47; we normally would. We marked the first parameter with swiftself which means it48; will no longer be passed in x0.49declare 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].*]], x853; CHECK: bl {{_?}}thisreturn_attribute54; CHECK: str x0, [[[CSREG]]55; CHECK: ret56define hidden swiftcc void @swiftself_nothisreturn(ptr noalias nocapture sret(ptr), ptr noalias nocapture readonly swiftself) {57entry:58 %2 = load ptr, ptr %1, align 859 %3 = tail call swiftcc ptr @thisreturn_attribute(ptr swiftself %2)60 store ptr %3, ptr %0, align 861 ret void62}63 64; Check that x20 is used to pass a swiftself argument when the parameter is65; only in the declaration's arguments.66; CHECK-LABEL: _swiftself_not_on_call_params:67; CHECK: mov x20, x068; CHECK: bl {{_?}}swiftself_param69; CHECK: ret70define ptr @swiftself_not_on_call_params(ptr %arg) {71 %res = call ptr @swiftself_param(ptr %arg)72 ret ptr %res73}74