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
|
// RUN: %target-swift-frontend -emit-ir %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-cpu
sil_stage canonical
import Swift
class C {}
sil_vtable C {}
struct SingleRefcounted {
var c: C
}
// CHECK-LABEL: define {{.*}} @escape_partial_apply_swift_class
// CHECK-arm64e: call i64 @llvm.ptrauth.resign
// CHECK: [[FPTR:%.*]] = insertvalue { ptr, ptr } undef, ptr {{.*}}, 0
// CHECK-NEXT: [[FCTX:%.*]] = insertvalue { ptr, ptr } [[FPTR]], ptr {{.*}}, 1
// CHECK-NEXT: ret { ptr, ptr } [[FCTX]]
sil @escape_partial_apply_swift_class : $@convention(thin) (@convention(method) (Int, @guaranteed C) -> Int, @guaranteed C) -> @callee_guaranteed (Int) -> Int {
entry(%body : $@convention(method) (Int, @guaranteed C) -> Int, %context : $C):
%closure = partial_apply [callee_guaranteed] %body(%context) : $@convention(method) (Int, @guaranteed C) -> Int
return %closure : $@callee_guaranteed (Int) -> Int
}
// Can't reuse the method because it does not have swiftself.
// CHECK-LABEL: define {{.*}} @escape_partial_apply_swift_single_refcount_struct
// CHECK: [[CTXT:%.*]] = call {{.*}} @swift_allocObject
// CHECK: [[FCTX:%.*]] = insertvalue { ptr, ptr } { ptr @"$sTA{{.*}}", ptr undef }, ptr [[CTXT]], 1
// CHECK-NEXT: ret { ptr, ptr } [[FCTX]]
sil @escape_partial_apply_swift_single_refcount_struct : $@convention(thin) (@convention(method) (Int, @guaranteed SingleRefcounted) -> Int, @guaranteed SingleRefcounted) -> @callee_guaranteed (Int) -> Int {
entry(%body : $@convention(method) (Int, @guaranteed SingleRefcounted) -> Int, %context : $SingleRefcounted):
%closure = partial_apply [callee_guaranteed] %body(%context) : $@convention(method) (Int, @guaranteed SingleRefcounted) -> Int
return %closure : $@callee_guaranteed (Int) -> Int
}
// CHECK-LABEL: define {{.*}} @noescape_partial_apply_swift_indirect
// CHECK: call {{.*}}void %2(ptr {{.*}}, ptr %1, ptr {{.*}}%3)
sil @noescape_partial_apply_swift_indirect : $@convention(thin) (@convention(method) (Int, @in_guaranteed C) -> Int, @in_guaranteed C, @guaranteed @callee_guaranteed (@noescape @callee_guaranteed (Int) -> Int) -> ()) -> () {
entry(%body : $@convention(method) (Int, @in_guaranteed C) -> Int, %context : $*C, %cont : $@callee_guaranteed (@noescape @callee_guaranteed (Int) -> Int) -> ()):
%closure = partial_apply [callee_guaranteed] [on_stack] %body(%context) : $@convention(method) (Int, @in_guaranteed C) -> Int
%x = apply %cont(%closure) : $@callee_guaranteed (@noescape @callee_guaranteed (Int) -> Int) -> ()
dealloc_stack %closure : $@noescape @callee_guaranteed (Int) -> Int
return undef : $()
}
// Can't reuse the method because it does not have swiftself.
// CHECK-LABEL: define {{.*}} @noescape_partial_apply_swift_direct_word
// CHECK: call swiftcc void {{.*}}(ptr @"$sTA{{.*}}", ptr {{.*}}, ptr swiftself {{.*}})
sil @noescape_partial_apply_swift_direct_word : $@convention(thin) (@convention(method) (Int, Int) -> Int, Int, @guaranteed @callee_guaranteed (@noescape @callee_guaranteed (Int) -> Int) -> ()) -> () {
entry(%body : $@convention(method) (Int, Int) -> Int, %context : $Int, %cont : $@callee_guaranteed (@noescape @callee_guaranteed (Int) -> Int) -> ()):
%closure = partial_apply [callee_guaranteed] [on_stack] %body(%context) : $@convention(method) (Int, Int) -> Int
%x = apply %cont(%closure) : $@callee_guaranteed (@noescape @callee_guaranteed (Int) -> Int) -> ()
dealloc_stack %closure : $@noescape @callee_guaranteed (Int) -> Int
return undef : $()
}
|