1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
// RUN: %target-swift-frontend -Xllvm -sil-disable-pass=OnoneSimplification %s -emit-ir | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-%target-ptrsize %s
// UNSUPPORTED: CPU=arm64_32
import Swift
import Builtin
struct Huge {
var x, y, z, w, v: Builtin.Word
}
@_alignment(16)
struct HugeAlignment {
var x, y, z, w, v: Builtin.Word
}
// TODO: could be the context param
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @huge_method(ptr noalias nocapture swiftself dereferenceable({{.*}}) %0)
// CHECK-NOT: alloca
// CHECK: call swiftcc void @huge_method(ptr noalias nocapture swiftself dereferenceable({{.*}}) %0)
sil @huge_method : $@convention(method) (Huge) -> () {
entry(%x : $Huge):
%f = function_ref @huge_method : $@convention(method) (Huge) -> ()
%z = apply %f(%x) : $@convention(method) (Huge) -> ()
return %z : $()
}
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @huge_param(ptr noalias nocapture dereferenceable({{.*}}) %0)
// CHECK-NOT: alloca
// CHECK: call swiftcc void @huge_param(ptr noalias nocapture dereferenceable({{.*}}) %0)
sil @huge_param : $@convention(thin) (Huge) -> () {
entry(%x : $Huge):
%f = function_ref @huge_param : $@convention(thin) (Huge) -> ()
%z = apply %f(%x) : $@convention(thin) (Huge) -> ()
return %z : $()
}
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @huge_alignment_param(ptr noalias nocapture dereferenceable({{.*}}) %0)
// CHECK-NOT: alloca
// CHECK: call swiftcc void @huge_alignment_param(ptr noalias nocapture dereferenceable({{.*}}) %0)
sil @huge_alignment_param : $@convention(thin) (HugeAlignment) -> () {
entry(%x : $HugeAlignment):
%f = function_ref @huge_alignment_param : $@convention(thin) (HugeAlignment) -> ()
%z = apply %f(%x) : $@convention(thin) (HugeAlignment) -> ()
return %z : $()
}
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @huge_param_and_return(ptr noalias nocapture sret({{.*}}) %0, ptr noalias nocapture dereferenceable({{.*}}) %1)
// CHECK: [[TMP_RET:%.*]] = alloca
// CHECK: call swiftcc void @huge_param_and_return(ptr noalias nocapture sret({{.*}}) [[TMP_RET]], ptr noalias nocapture dereferenceable({{.*}}) %1)
sil @huge_param_and_return : $@convention(thin) (Huge) -> Huge {
entry(%x : $Huge):
%f = function_ref @huge_param_and_return : $@convention(thin) (Huge) -> Huge
%z = apply %f(%x) : $@convention(thin) (Huge) -> Huge
return %z : $Huge
}
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @huge_param_and_indirect_return(ptr noalias nocapture sret({{.*}}) %0, ptr noalias nocapture dereferenceable({{.*}}) %1)
// CHECK-NOT: alloca
// CHECK: call swiftcc void @huge_param_and_indirect_return(ptr noalias nocapture sret({{.*}}) %0, ptr noalias nocapture dereferenceable({{.*}}) %1)
sil @huge_param_and_indirect_return : $@convention(thin) (Huge) -> @out Huge {
entry(%o : $*Huge, %x : $Huge):
%f = function_ref @huge_param_and_indirect_return : $@convention(thin) (Huge) -> @out Huge
%z = apply %f(%o, %x) : $@convention(thin) (Huge) -> @out Huge
return %z : $()
}
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @huge_partial_application(ptr noalias nocapture dereferenceable({{.*}}) %0, ptr noalias nocapture dereferenceable({{.*}}) %1)
// CHECK-NOT: alloca
// CHECK: [[CLOSURE:%.*]] = call noalias ptr @swift_allocObject
// CHECK: call swiftcc {{.*}} @"$s24huge_partial_applicationTA{{(\.ptrauth)?}}"{{.*}}(ptr noalias nocapture dereferenceable({{.*}}) %0, ptr swiftself [[CLOSURE]])
// CHECK: define internal swiftcc void @"$s24huge_partial_applicationTA"(ptr noalias nocapture dereferenceable({{.*}}) %0, ptr swiftself %1)
// CHECK-NOT: alloca
// CHECK: [[GEP:%.*]] = getelementptr inbounds <{ %swift.refcounted, %T17indirect_argument4HugeV }>, ptr %1, i32 0, i32 1
// CHECK-NOT: alloca
// CHECK-NOT: tail
// CHECK: call swiftcc void @huge_partial_application(ptr noalias nocapture dereferenceable({{.*}}) %0, ptr noalias nocapture dereferenceable({{.*}}) [[GEP]]
// CHECK: call void @swift_release(ptr %1)
sil @huge_partial_application : $@convention(thin) (Huge, Huge) -> () {
entry(%x : $Huge, %y : $Huge):
%f = function_ref @huge_partial_application : $@convention(thin) (Huge, Huge) -> ()
%a = partial_apply %f(%y) : $@convention(thin) (Huge, Huge) -> ()
%z = apply %a(%x) : $@convention(thick) @callee_owned (Huge) -> ()
return %z : $()
}
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @huge_partial_application_stret(ptr noalias nocapture sret({{.*}}) %0, ptr noalias nocapture dereferenceable({{.*}}) %1, ptr noalias nocapture dereferenceable({{.*}}) %2)
// CHECK: [[TMP_RET:%.*]] = alloca
// CHECK: [[CLOSURE:%.*]] = call noalias ptr @swift_allocObject
// CHECK: call swiftcc {{.*}} @"$s30huge_partial_application_stretTA{{(\.ptrauth)?}}"{{.*}}(ptr noalias nocapture sret({{.*}}) [[TMP_RET]], ptr noalias nocapture dereferenceable({{.*}}) %1, ptr swiftself [[CLOSURE]])
// CHECK: define internal swiftcc void @"$s30huge_partial_application_stretTA"(ptr noalias nocapture sret({{.*}}) %0, ptr noalias nocapture dereferenceable({{.*}}) %1, ptr swiftself %2)
// CHECK-NOT: alloca
// CHECK: [[GEP:%.*]] = getelementptr inbounds <{ %swift.refcounted, %T17indirect_argument4HugeV }>, ptr %2, i32 0, i32 1
// CHECK-NOT: alloca
// CHECK-NOT: tail
// CHECK: call swiftcc void @huge_partial_application_stret(ptr noalias nocapture sret({{.*}}) %0, ptr noalias nocapture dereferenceable({{.*}}) %1, ptr noalias nocapture dereferenceable({{.*}}) [[GEP]])
// CHECK: call void @swift_release(ptr %2)
sil @huge_partial_application_stret : $@convention(thin) (Huge, Huge) -> Huge {
entry(%x : $Huge, %y : $Huge):
%f = function_ref @huge_partial_application_stret : $@convention(thin) (Huge, Huge) -> Huge
%a = partial_apply %f(%y) : $@convention(thin) (Huge, Huge) -> Huge
%z = apply %a(%x) : $@convention(thick) @callee_owned (Huge) -> Huge
return %z : $Huge
}
|