|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: %target-build-swift-dylib(%t/%target-library-name(PrintShims)) %S/../../Inputs/print-shims.swift -module-name PrintShims -emit-module -emit-module-path %t/PrintShims.swiftmodule |
| 3 | +// RUN: %target-codesign %t/%target-library-name(PrintShims) |
| 4 | +// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL |
| 5 | +// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -module-name main -o %t/main -I %t -L %t -lPrintShims %target-rpath(%t) |
| 6 | +// RUN: %target-codesign %t/main |
| 7 | +// RUN: %target-run %t/main %t/%target-library-name(PrintShims) | %FileCheck %s |
| 8 | + |
| 9 | +// REQUIRES: executable_test |
| 10 | +// REQUIRES: swift_test_mode_optimize_none |
| 11 | +// REQUIRES: concurrency |
| 12 | +// UNSUPPORTED: use_os_stdlib |
| 13 | + |
| 14 | +import Builtin |
| 15 | +import Swift |
| 16 | +import PrintShims |
| 17 | +import _Concurrency |
| 18 | + |
| 19 | +sil public_external @printInt64 : $@convention(thin) (Int64) -> () |
| 20 | + |
| 21 | +// CHECK-LL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @int64ToVoid(%swift.task* {{%[0-9]+}}, %swift.executor* {{%[0-9]+}}, %swift.context* {{%[0-9]+}}) {{#[0-9]*}} { |
| 22 | +sil @int64ToVoid : $@async @convention(thin) (Int64) -> () { |
| 23 | +entry(%int : $Int64): |
| 24 | + %printInt64 = function_ref @printInt64 : $@convention(thin) (Int64) -> () |
| 25 | + %result = apply %printInt64(%int) : $@convention(thin) (Int64) -> () // CHECK: 9999 |
| 26 | + return %result : $() |
| 27 | +} |
| 28 | + |
| 29 | +sil @main : $@async @convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { |
| 30 | +bb0(%argc : $Int32, %argv : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): |
| 31 | + %int64ToVoid = function_ref @int64ToVoid : $@async @convention(thin) (Int64) -> () |
| 32 | + %int64ToVoidThick = thin_to_thick_function %int64ToVoid : $@convention(thin) @async (Int64) -> () to $@async @callee_guaranteed (Int64) -> () |
| 33 | + %int64ThrowsToVoid = convert_function %int64ToVoidThick : $@async @callee_guaranteed (Int64) -> () to $@async @callee_guaranteed (Int64) -> @error Error |
| 34 | + %int_literal = integer_literal $Builtin.Int64, 9999 |
| 35 | + %int = struct $Int64 (%int_literal : $Builtin.Int64) |
| 36 | + try_apply %int64ThrowsToVoid(%int) : $@async @callee_guaranteed (Int64) -> @error Error, normal success, error failure |
| 37 | + |
| 38 | +success(%value : $()): |
| 39 | + %out_literal = integer_literal $Builtin.Int32, 0 |
| 40 | + %out = struct $Int32 (%out_literal : $Builtin.Int32) |
| 41 | + return %out : $Int32 |
| 42 | + |
| 43 | +failure(%error : $Error): |
| 44 | + %end = builtin "errorInMain"(%error : $Error) : $() |
| 45 | + unreachable |
| 46 | +} |
0 commit comments