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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
// 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 -g -parse-sil %s -emit-ir -I %t -L %t -lPrintShim | %FileCheck %s --check-prefix=CHECK-LL
// RUN: %target-build-swift -g -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
// REQUIRES: concurrency_runtime
// UNSUPPORTED: back_deployment_runtime
import Builtin
import Swift
import PrintShims
import _Concurrency
sil public_external @printGeneric : $@convention(thin) <T> (@in_guaranteed T) -> ()
struct Big {
@_hasStorage let i1: Int64 { get }
@_hasStorage let i2: Int64 { get }
@_hasStorage let i3: Int64 { get }
@_hasStorage let i4: Int64 { get }
@_hasStorage let i5: Int64 { get }
@_hasStorage let i6: Int64 { get }
@_hasStorage let i7: Int64 { get }
@_hasStorage let i8: Int64 { get }
@_hasStorage let i9: Int64 { get }
@_hasStorage let i0: Int64 { get }
init()
}
sil hidden @Big_init : $@convention(method) (@thin Big.Type) -> Big {
// %0 "$metatype"
bb0(%0 : $@thin Big.Type):
%1 = alloc_stack $Big, var, name "self"
%2 = integer_literal $Builtin.Int64, 1
%3 = struct $Int64 (%2 : $Builtin.Int64)
%4 = begin_access [modify] [static] %1 : $*Big
%5 = struct_element_addr %4 : $*Big, #Big.i1
store %3 to %5 : $*Int64
end_access %4 : $*Big
%8 = integer_literal $Builtin.Int64, 2
%9 = struct $Int64 (%8 : $Builtin.Int64)
%10 = begin_access [modify] [static] %1 : $*Big
%11 = struct_element_addr %10 : $*Big, #Big.i2
store %9 to %11 : $*Int64
end_access %10 : $*Big
%14 = integer_literal $Builtin.Int64, 3
%15 = struct $Int64 (%14 : $Builtin.Int64)
%16 = begin_access [modify] [static] %1 : $*Big
%17 = struct_element_addr %16 : $*Big, #Big.i3
store %15 to %17 : $*Int64
end_access %16 : $*Big
%20 = integer_literal $Builtin.Int64, 4
%21 = struct $Int64 (%20 : $Builtin.Int64)
%22 = begin_access [modify] [static] %1 : $*Big
%23 = struct_element_addr %22 : $*Big, #Big.i4
store %21 to %23 : $*Int64
end_access %22 : $*Big
%26 = integer_literal $Builtin.Int64, 5
%27 = struct $Int64 (%26 : $Builtin.Int64)
%28 = begin_access [modify] [static] %1 : $*Big
%29 = struct_element_addr %28 : $*Big, #Big.i5
store %27 to %29 : $*Int64
end_access %28 : $*Big
%32 = integer_literal $Builtin.Int64, 6
%33 = struct $Int64 (%32 : $Builtin.Int64)
%34 = begin_access [modify] [static] %1 : $*Big
%35 = struct_element_addr %34 : $*Big, #Big.i6
store %33 to %35 : $*Int64
end_access %34 : $*Big
%38 = integer_literal $Builtin.Int64, 7
%39 = struct $Int64 (%38 : $Builtin.Int64)
%40 = begin_access [modify] [static] %1 : $*Big
%41 = struct_element_addr %40 : $*Big, #Big.i7
store %39 to %41 : $*Int64
end_access %40 : $*Big
%44 = integer_literal $Builtin.Int64, 8
%45 = struct $Int64 (%44 : $Builtin.Int64)
%46 = begin_access [modify] [static] %1 : $*Big
%47 = struct_element_addr %46 : $*Big, #Big.i8
store %45 to %47 : $*Int64
end_access %46 : $*Big
%50 = integer_literal $Builtin.Int64, 9
%51 = struct $Int64 (%50 : $Builtin.Int64)
%52 = begin_access [modify] [static] %1 : $*Big
%53 = struct_element_addr %52 : $*Big, #Big.i9
store %51 to %53 : $*Int64
end_access %52 : $*Big
%56 = integer_literal $Builtin.Int64, 0
%57 = struct $Int64 (%56 : $Builtin.Int64)
%58 = begin_access [modify] [static] %1 : $*Big
%59 = struct_element_addr %58 : $*Big, #Big.i0
store %57 to %59 : $*Int64
end_access %58 : $*Big
%62 = struct $Big (%3 : $Int64, %9 : $Int64, %15 : $Int64, %21 : $Int64, %27 : $Int64, %33 : $Int64, %39 : $Int64, %45 : $Int64, %51 : $Int64, %57 : $Int64)
dealloc_stack %1 : $*Big
return %62 : $Big
}
// CHECK-LL: @getBigTu =
// CHECK-LL: define hidden swift{{(tail)?}}cc void @getBig
sil hidden @getBig : $@async @convention(thin) () -> Big {
bb0:
%0 = metatype $@thin Big.Type
// function_ref Big.init()
%1 = function_ref @Big_init : $@convention(method) (@thin Big.Type) -> Big
%2 = apply %1(%0) : $@convention(method) (@thin Big.Type) -> Big
return %2 : $Big
}
sil hidden @printBig : $@async @convention(thin) () -> () {
%getBig = function_ref @getBig : $@async @convention(thin) () -> Big
%big = apply %getBig() : $@async @convention(thin) () -> Big
%big_addr = alloc_stack $Big
store %big to %big_addr : $*Big
%print = function_ref @printGeneric : $@convention(thin) <T> (@in_guaranteed T) -> ()
%result = apply %print<Big>(%big_addr) : $@convention(thin) <T> (@in_guaranteed T) -> ()
dealloc_stack %big_addr : $*Big
%out = tuple ()
return %out : $()
}
sil @test_case : $@convention(thin) @async () -> () {
%printBig = function_ref @printBig : $@async @convention(thin) () -> ()
%result = apply %printBig() : $@async @convention(thin) () -> () // CHECK: Big(i1: 1, i2: 2, i3: 3, i4: 4, i5: 5, i6: 6, i7: 7, i8: 8, i9: 9, i0: 0)
%void = tuple()
return %void : $()
}
// Defined in _Concurrency
sil @$ss13_runAsyncMainyyyyYaKcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> @error Error) -> ()
sil @no_throw_to_throw_think : $@convention(thin) @async (@guaranteed @async @callee_guaranteed () -> ()) -> @error Error {
bb0(%0 :$@async @callee_guaranteed () -> ()):
%void = apply %0() : $@async @callee_guaranteed () -> ()
return %void : $()
}
// main
sil @main : $@convention(c) () -> Int32 {
%test_case_nothrow = function_ref @test_case : $@convention(thin) @async () -> ()
%thick_test_case = thin_to_thick_function %test_case_nothrow : $@convention(thin) @async () -> () to $@callee_guaranteed @async () -> ()
%thunk = function_ref @no_throw_to_throw_think : $@convention(thin) @async (@guaranteed @async @callee_guaranteed () -> ()) -> @error Error
%throwing = partial_apply [callee_guaranteed] %thunk(%thick_test_case) : $@convention(thin) @async (@guaranteed @async @callee_guaranteed () -> ()) -> @error Error
%runAsyncMain = function_ref @$ss13_runAsyncMainyyyyYaKcF : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> @error Error) -> ()
%result = apply %runAsyncMain(%throwing) : $@convention(thin) (@guaranteed @async @callee_guaranteed () -> @error Error) -> ()
%out_literal = integer_literal $Builtin.Int32, 0
%out = struct $Int32 (%out_literal : $Builtin.Int32)
return %out : $Int32
}
|