Skip to content

Commit fcd70cb

Browse files
committed
[Async CC] Add execution test for thin_to_thick.
1 parent 39b966a commit fcd70cb

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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 @afun2(%swift.task* {{%[0-9]+}}, %swift.executor* {{%[0-9]+}}, %swift.context* {{%[0-9]+}}) {{#[0-9]*}} {
22+
sil @afun2 : $@async @convention(thin) (Int64) -> () {
23+
entry(%int : $Int64):
24+
%print = function_ref @printInt64 : $@convention(thin) (Int64) -> ()
25+
%result = apply %print(%int) : $@convention(thin) (Int64) -> () // CHECK: 9999
26+
return %result : $()
27+
}
28+
29+
// 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]*}} {
30+
sil @test_apply_of_thin_to_thick : $@async @convention(thin) () -> () {
31+
entry:
32+
%f = function_ref @afun2 : $@async @convention(thin) (Int64) -> ()
33+
%c = thin_to_thick_function %f : $@async @convention(thin) (Int64) -> () to $@async @callee_guaranteed (Int64) -> ()
34+
%int_literal = integer_literal $Builtin.Int64, 9999
35+
%int = struct $Int64 (%int_literal : $Builtin.Int64)
36+
%app = apply %c(%int) : $@async @callee_guaranteed (Int64) -> ()
37+
%result = tuple()
38+
return %result : $()
39+
}
40+
41+
sil @main : $@async @convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
42+
bb0(%argc : $Int32, %argv : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
43+
%test_apply_of_thin_to_thick = function_ref @test_apply_of_thin_to_thick : $@async @convention(thin) () -> ()
44+
%result = apply %test_apply_of_thin_to_thick() : $@async @convention(thin) () -> ()
45+
46+
%out_literal = integer_literal $Builtin.Int32, 0
47+
%out = struct $Int32 (%out_literal : $Builtin.Int32)
48+
return %out : $Int32
49+
}

0 commit comments

Comments
 (0)