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
|
// RUN: %target-swift-frontend -primary-file %s -module-name=test -disable-llvm-optzns -disable-swift-specific-llvm-optzns -emit-ir -sil-verify-all | %IRGenFileCheck %s
// REQUIRES: concurrency
// rdar://106849189 move-only types should be supported in freestanding mode
// UNSUPPORTED: freestanding
sil_stage canonical
import Builtin
import Swift
import _Concurrency
final actor MyDefaultActor {
@_semantics("defaultActor")
nonisolated var unownedExecutor: UnownedSerialExecutor { get }
}
sil_vtable MyDefaultActor {}
actor MyCustomActor : SerialExecutor {
final nonisolated var unownedExecutor: UnownedSerialExecutor { get }
final nonisolated func enqueue(_ job: UnownedJob)
final nonisolated func asUnownedSerialExecutor() -> UnownedSerialExecutor
}
sil_vtable MyCustomActor {}
// CHECK: define{{.*}} swiftcc { [[INT]], [[INT]] } @test_none()
sil @test_none : $() -> Optional<Builtin.Executor> {
bb0:
// CHECK: ret { [[INT]], [[INT]] } zeroinitializer
%0 = enum $Optional<Builtin.Executor>, #Optional.none
return %0 : $Optional<Builtin.Executor>
}
// CHECK: define{{.*}} swiftcc { [[INT]], [[INT]] } @test_some([[INT]] %0, [[INT]] %1)
sil @test_some : $(Builtin.Executor) -> Optional<Builtin.Executor> {
bb0(%0 : $Builtin.Executor):
// CHECK: [[ONE:%.*]] = insertvalue { [[INT]], [[INT]] } undef, [[INT]] %0, 0
// CHECK-NEXT: [[TWO:%.*]] = insertvalue { [[INT]], [[INT]] } [[ONE]], [[INT]] %1, 1
// CHECK-NEXT: ret { [[INT]], [[INT]] } [[TWO]]
%1 = enum $Optional<Builtin.Executor>, #Optional.some, %0 : $Builtin.Executor
return %1 : $Optional<Builtin.Executor>
}
// CHECK: define{{.*}} swiftcc { [[INT]], [[INT]] } @test_build_default_actor(ptr %0)
sil @test_build_default_actor : $(@guaranteed MyDefaultActor) -> Builtin.Executor {
bb0(%0 : $MyDefaultActor):
// CHECK: [[T0:%.*]] = ptrtoint ptr %0 to [[INT]]
// CHECK-NEXT: [[ONE:%.*]] = insertvalue { [[INT]], [[INT]] } undef, [[INT]] [[T0]], 0
// CHECK-NEXT: [[TWO:%.*]] = insertvalue { [[INT]], [[INT]] } [[ONE]], [[INT]] 0, 1
// CHECK-NEXT: ret { [[INT]], [[INT]] } [[TWO]]
%1 = builtin "buildDefaultActorExecutorRef"<MyDefaultActor>(%0 : $MyDefaultActor) : $Builtin.Executor
return %1 : $Builtin.Executor
}
// CHECK: define{{.*}} swiftcc { [[INT]], [[INT]] } @test_build_custom_actor(ptr %0)
sil @test_build_custom_actor : $(@guaranteed MyCustomActor) -> Builtin.Executor {
bb0(%0 : $MyCustomActor):
// CHECK: [[T0:%.*]] = ptrtoint ptr %0 to [[INT]]
// CHECK-NEXT: [[T1:%.*]] = call ptr @"$s4test13MyCustomActorCACScfAAWl"()
// CHECK-NEXT: [[T2:%.*]] = ptrtoint ptr [[T1]] to [[INT]]
// CHECK: [[ONE:%.*]] = insertvalue { [[INT]], [[INT]] } undef, [[INT]] [[T0]], 0
// CHECK-NEXT: [[TWO:%.*]] = insertvalue { [[INT]], [[INT]] } [[ONE]], [[INT]] [[T2]], 1
// CHECK-NEXT: ret { [[INT]], [[INT]] } [[TWO]]
%1 = builtin "buildOrdinarySerialExecutorRef"<MyCustomActor>(%0 : $MyCustomActor) : $Builtin.Executor
return %1 : $Builtin.Executor
}
|