mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
41 lines
2.4 KiB
Plaintext
41 lines
2.4 KiB
Plaintext
// RUN: %target-swift-frontend -enable-experimental-concurrency -primary-file %s -module-name=test -disable-llvm-optzns -disable-swift-specific-llvm-optzns -emit-ir -sil-verify-all | %IRGenFileCheck %s
|
|
|
|
// REQUIRES: concurrency
|
|
|
|
sil_stage canonical
|
|
|
|
import Builtin
|
|
import Swift
|
|
import _Concurrency
|
|
|
|
// CHECK-LABEL: define{{.*}} void @test_simple(
|
|
// CHECK-SAME: %swift.context* swiftasync %0, [[INT]] %1, [[INT]] %2)
|
|
// CHECK: [[CTX:%[0-9]+]] = bitcast %swift.context* %0
|
|
// CHECK: [[RESUME:%[0-9]+]] = call i8* @llvm.coro.async.resume()
|
|
// CHECK-x86_64: call {{.*}} @llvm.coro.suspend.async{{.*}}(i32 0, i8* [[RESUME]], i8* bitcast (i8* (i8*)* @__swift_async_resume_get_context to i8*), i8* bitcast (void (i8*, [[INT]], [[INT]], %swift.context*)* @__swift_suspend_point to i8*), i8* [[RESUME]], [[INT]] %1, [[INT]] %2, %swift.context* {{%[0-9]+}})
|
|
// CHECK-arm64e: call {{.*}} @llvm.coro.suspend.async{{.*}}(i32 0, i8* [[RESUME]], i8* bitcast (i8* (i8*)* @__swift_async_resume_get_context to i8*), i8* bitcast (void (i8*, [[INT]], [[INT]], %swift.context*)* @__swift_suspend_point to i8*), i8* [[RESUME]], [[INT]] %1, [[INT]] %2, %swift.context* {{%[0-9]+}})
|
|
// CHECK: [[RET_CONTINUATION:%.*]] = bitcast void (%swift.context*)* {{.*}} to i8*
|
|
// CHECK: call i1 (i8*, i1, ...) @llvm.coro.end.async(i8* {{.*}}, i1 false, void (i8*, %swift.context*)* @[[TAIL_CALL_FUNC:.*]], i8* [[RET_CONTINUATION]]
|
|
// CHECK: unreachable
|
|
|
|
sil @test_simple : $@async (@guaranteed Optional<Builtin.Executor>) -> () {
|
|
bb0(%0 : $Optional<Builtin.Executor>):
|
|
hop_to_executor %0 : $Optional<Builtin.Executor>
|
|
%3 = tuple ()
|
|
return %3 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: define internal swift{{(tail)?}}cc void @__swift_suspend_point
|
|
// CHECK-SAME: (i8* [[RESUME_FN:%0]], [[INT]] %1, [[INT]] %2, %swift.context* [[CTXT:%[^,]+]])
|
|
// CHECK-arm64e: [[RESUME_FN_INT:%[^,]+]] = ptrtoint i8* [[RESUME_FN]] to i64
|
|
// CHECK-arm64e: [[PTRAUTH_SIGN:%[^,]+]] = call i64 @llvm.ptrauth.sign.i64(i64 [[RESUME_FN_INT]], i32 0, i64 0)
|
|
// CHECK-arm64e: [[RESUME_FN:%[^,]+]] = inttoptr i64 [[PTRAUTH_SIGN]] to i8*
|
|
// CHECK: {{(must)?}}tail call swift{{(tail)?}}cc void @swift_task_switch(%swift.context* swiftasync [[CTXT]], i8* [[RESUME_FN]], [[INT]] %1, [[INT]] %2)
|
|
// CHECK: ret void
|
|
|
|
// CHECK: define{{.*}} void @[[TAIL_CALL_FUNC]](i8* %0, %swift.context* %1)
|
|
// CHECK: %2 = bitcast i8* %0 to void (%swift.context*)*
|
|
// CHECK: {{(must)?}}tail call swift{{(tail)?}}cc void %2(%swift.context* swiftasync %1)
|
|
// CHECK: ret void
|
|
// CHECK: }
|