From fcd70cb06d862d1cce39032776bc45fd0f91db54 Mon Sep 17 00:00:00 2001 From: Nate Chandler Date: Thu, 12 Nov 2020 07:54:30 -0800 Subject: [PATCH] [Async CC] Add execution test for thin_to_thick. --- .../async/run-thintothick-int64-to-void.sil | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 test/IRGen/async/run-thintothick-int64-to-void.sil diff --git a/test/IRGen/async/run-thintothick-int64-to-void.sil b/test/IRGen/async/run-thintothick-int64-to-void.sil new file mode 100644 index 0000000000000..fe34fee02b038 --- /dev/null +++ b/test/IRGen/async/run-thintothick-int64-to-void.sil @@ -0,0 +1,49 @@ +// RUN: %empty-directory(%t) +// 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 +// RUN: %target-codesign %t/%target-library-name(PrintShims) +// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL +// 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) +// RUN: %target-codesign %t/main +// RUN: %target-run %t/main %t/%target-library-name(PrintShims) | %FileCheck %s + +// REQUIRES: executable_test +// REQUIRES: swift_test_mode_optimize_none +// REQUIRES: concurrency +// UNSUPPORTED: use_os_stdlib + +import Builtin +import Swift +import PrintShims +import _Concurrency + +sil public_external @printInt64 : $@convention(thin) (Int64) -> () + +// CHECK-LL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @afun2(%swift.task* {{%[0-9]+}}, %swift.executor* {{%[0-9]+}}, %swift.context* {{%[0-9]+}}) {{#[0-9]*}} { +sil @afun2 : $@async @convention(thin) (Int64) -> () { +entry(%int : $Int64): + %print = function_ref @printInt64 : $@convention(thin) (Int64) -> () + %result = apply %print(%int) : $@convention(thin) (Int64) -> () // CHECK: 9999 + return %result : $() +} + +// CHECK-LL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @test_apply_of_thin_to_thick(%swift.task* {{%[0-9]+}}, %swift.executor* {{%[0-9]+}}, %swift.context* {{%[0-9]+}}) {{#[0-9]*}} { +sil @test_apply_of_thin_to_thick : $@async @convention(thin) () -> () { +entry: + %f = function_ref @afun2 : $@async @convention(thin) (Int64) -> () + %c = thin_to_thick_function %f : $@async @convention(thin) (Int64) -> () to $@async @callee_guaranteed (Int64) -> () + %int_literal = integer_literal $Builtin.Int64, 9999 + %int = struct $Int64 (%int_literal : $Builtin.Int64) + %app = apply %c(%int) : $@async @callee_guaranteed (Int64) -> () + %result = tuple() + return %result : $() +} + +sil @main : $@async @convention(c) (Int32, UnsafeMutablePointer>>) -> Int32 { +bb0(%argc : $Int32, %argv : $UnsafeMutablePointer>>): + %test_apply_of_thin_to_thick = function_ref @test_apply_of_thin_to_thick : $@async @convention(thin) () -> () + %result = apply %test_apply_of_thin_to_thick() : $@async @convention(thin) () -> () + + %out_literal = integer_literal $Builtin.Int32, 0 + %out = struct $Int32 (%out_literal : $Builtin.Int32) + return %out : $Int32 +}