File: partial_apply_forwarder.sil

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (259 lines) | stat: -rw-r--r-- 13,117 bytes parent folder | download
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
// RUN: %target-swift-frontend  -g -enable-objc-interop  -primary-file %s -emit-ir | %FileCheck %s -DINT=i%target-ptrsize --check-prefixes=CHECK,CHECK-objc
// RUN: %target-swift-frontend  -g -disable-objc-interop -primary-file %s -emit-ir | %FileCheck %s -DINT=i%target-ptrsize --check-prefixes=CHECK,CHECK-native

// REQUIRES: concurrency, objc_codegen

sil_stage canonical

import Builtin
import Swift

public protocol P {}
public class C : P {}
public class D<T : P> {}
class E {}

public protocol Observable {
  associatedtype Result
  func subscribe<T: Observer>(o: T) async -> ()
}

public protocol Observer {
  associatedtype Result
}

sil hidden @witness_method : $@async @convention(thin) <S where S : Observable><O where O : Observer, S.Result == O.Result> (@in S) -> @owned @async @callee_guaranteed (@in O) -> () {
bb0(%0 : $*S):
  %1 = witness_method $S, #Observable.subscribe : $@async @convention(witness_method: Observable) <τ_0_0 where τ_0_0 : Observable><τ_1_0 where τ_1_0 : Observer, τ_0_0.Result == τ_1_0.Result> (@in τ_1_0, @in_guaranteed τ_0_0) -> ()
  %2 = partial_apply [callee_guaranteed] %1<S, O>(%0) : $@async @convention(witness_method: Observable) <τ_0_0 where τ_0_0 : Observable><τ_1_0 where τ_1_0 : Observer, τ_0_0.Result == τ_1_0.Result> (@in τ_1_0, @in_guaranteed τ_0_0) -> ()
  return %2 : $@async @callee_guaranteed (@in O) -> ()
}

sil hidden @specialized_curried : $@async @convention(thin) (@owned E) -> @owned @async @callee_guaranteed () -> @owned D<C> {
bb0(%0 : $E):
  %1 = function_ref @unspecialized_uncurried : $@async @convention(method) <τ_0_0 where τ_0_0 : P> (@guaranteed E) -> @owned D<τ_0_0>
  %2 = partial_apply [callee_guaranteed] %1<C>(%0) : $@async @convention(method) <τ_0_0 where τ_0_0 : P> (@guaranteed E) -> @owned D<τ_0_0>
  return %2 : $@async @callee_guaranteed () -> @owned D<C>
}

sil hidden @unspecialized_uncurried : $@async @convention(method) <τ_0_0 where τ_0_0 : P> (@guaranteed E) -> @owned D<τ_0_0> {
entry(%e : $E):
  %0 = builtin "int_trap"() : $Never
  unreachable
}


sil hidden @takingP : $@async @convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> () {
entry(%p : $*τ_0_0):
  %0 = builtin "int_trap"() : $Never
  unreachable
}

sil hidden @reabstract_context : $@async @convention(thin) (@owned C) -> () {
bb0(%0 : $C):
  %6 = alloc_stack $C
  store %0 to %6 : $*C
  %8 = function_ref @takingP : $@async @convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> ()
  %9 = partial_apply [callee_guaranteed] %8<C>(%6) : $@async @convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> ()
  dealloc_stack %6 : $*C
  strong_release %9 : $@async @callee_guaranteed() -> ()
  %10 = tuple ()
  return %10 : $()
}

public protocol Q {
  associatedtype Update
}

public struct BaseProducer<T> : Q {
  public typealias Update = T
}

public class WeakBox<T> {}

public struct EmptyType {}

sil hidden @takingQ : $@async @convention(thin) <τ_0_0 where  τ_0_0 : Q> (@owned WeakBox<τ_0_0>) -> () {
entry(%b : $WeakBox<τ_0_0>):
  %0 = builtin "int_trap"() : $Never
  unreachable
}
sil hidden @takingQAndEmpty : $@async @convention(thin) <τ_0_0 where  τ_0_0 : Q> (@owned WeakBox<τ_0_0>, EmptyType) -> () {
entry(%b : $WeakBox<τ_0_0>, %e : $EmptyType):
  %0 = builtin "int_trap"() : $Never
  unreachable
}
sil hidden @takingEmptyAndQ : $@async @convention(thin) <τ_0_0 where  τ_0_0 : Q> (EmptyType, @owned WeakBox<τ_0_0>) -> () {
entry(%e : $EmptyType, %b : $WeakBox<τ_0_0>):
  %0 = builtin "int_trap"() : $Never
  unreachable
}

// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swift{{(tail)?}}cc void @bind_polymorphic_param_from_context(
// CHECK-LABEL: define internal swift{{(tail)?}}cc void @"$s7takingQTA"(
sil public @bind_polymorphic_param_from_context : $@async @convention(thin) <τ_0_1>(@in τ_0_1) -> @owned @async @callee_guaranteed () -> () {
bb0(%0 : $*τ_0_1):
  %1 = alloc_ref $WeakBox<BaseProducer<τ_0_1>>
  %8 = function_ref @takingQ : $@async @convention(thin) <τ_0_0 where τ_0_0 : Q> (@owned WeakBox<τ_0_0>) -> ()
  %9 = partial_apply [callee_guaranteed] %8<BaseProducer<τ_0_1>>(%1) : $@async @convention(thin) <τ_0_0 where τ_0_0 : Q> (@owned WeakBox<τ_0_0>) -> ()
  return %9 : $@async @callee_guaranteed () -> ()
}

// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swift{{(tail)?}}cc void @bind_polymorphic_param_from_context_2(
sil public @bind_polymorphic_param_from_context_2 : $@async @convention(thin) <τ_0_1>(@in τ_0_1, EmptyType) -> @owned @async @callee_guaranteed () -> () {
bb0(%0 : $*τ_0_1, %2: $EmptyType):
  %1 = alloc_ref $WeakBox<BaseProducer<τ_0_1>>
  %8 = function_ref @takingQAndEmpty : $@async @convention(thin) <τ_0_0 where τ_0_0 : Q> (@owned WeakBox<τ_0_0>, EmptyType) -> ()
  %9 = partial_apply [callee_guaranteed] %8<BaseProducer<τ_0_1>>(%1, %2) : $@async @convention(thin) <τ_0_0 where τ_0_0 : Q> (@owned WeakBox<τ_0_0>, EmptyType) -> ()
  return %9 : $@async @callee_guaranteed () -> ()
}

// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swift{{(tail)?}}cc void @bind_polymorphic_param_from_context_3(
sil public @bind_polymorphic_param_from_context_3 : $@async @convention(thin) <τ_0_1>(@in τ_0_1, EmptyType) -> @owned @async @callee_guaranteed () -> () {
bb0(%0 : $*τ_0_1, %2: $EmptyType):
  %1 = alloc_ref $WeakBox<BaseProducer<τ_0_1>>
  %8 = function_ref @takingEmptyAndQ : $@async @convention(thin) <τ_0_0 where τ_0_0 : Q> (EmptyType, @owned WeakBox<τ_0_0>) -> ()
  %9 = partial_apply [callee_guaranteed] %8<BaseProducer<τ_0_1>>(%2, %1) : $@async @convention(thin) <τ_0_0 where τ_0_0 : Q> (EmptyType, @owned WeakBox<τ_0_0>) -> ()
  return %9 : $@async @callee_guaranteed () -> ()
}

// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swift{{(tail)?}}cc void @bind_polymorphic_param_from_forwarder_parameter(
sil public @bind_polymorphic_param_from_forwarder_parameter : $@async @convention(thin) <τ_0_1>(@in τ_0_1) -> () {
bb0(%0 : $*τ_0_1):
  %1 = alloc_ref $WeakBox<BaseProducer<τ_0_1>>
  %8 = function_ref @takingQ : $@async @convention(thin) <τ_0_0 where τ_0_0 : Q> (@owned WeakBox<τ_0_0>) -> ()
  %9 = partial_apply [callee_guaranteed] %8<BaseProducer<τ_0_1>>() : $@async @convention(thin) <τ_0_0 where τ_0_0 : Q> (@owned WeakBox<τ_0_0>) -> ()
  %10 = tuple ()
  return %10 : $()
}

struct S {
  var x : Builtin.Int64
}

sil hidden @takingQAndS : $@async @convention(thin) <τ_0_0 where  τ_0_0 : Q> (S, @owned WeakBox<τ_0_0>) -> () {
entry(%s : $S, %b : $WeakBox<τ_0_0>):
  %0 = builtin "int_trap"() : $Never
  unreachable
}

// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swift{{(tail)?}}cc void @bind_polymorphic_param_from_context_with_layout(
// CHECK-LABEL: define internal swift{{(tail)?}}cc void @"$s11takingQAndSTA"(
sil public @bind_polymorphic_param_from_context_with_layout : $@async @convention(thin) <τ_0_1>(@in τ_0_1, S) -> @owned @async @callee_guaranteed () -> () {
bb0(%0 : $*τ_0_1, %1: $S):
  %2 = alloc_ref $WeakBox<BaseProducer<τ_0_1>>
  %8 = function_ref @takingQAndS : $@async @convention(thin) <τ_0_0 where τ_0_0 : Q> (S, @owned WeakBox<τ_0_0>) -> ()
  %9 = partial_apply [callee_guaranteed] %8<BaseProducer<τ_0_1>>(%1, %2) : $@async @convention(thin) <τ_0_0 where τ_0_0 : Q> (S, @owned WeakBox<τ_0_0>) -> ()
  return %9 : $@async @callee_guaranteed () -> ()
}

public class Empty<T> {}

sil private @inner_closure : $@async @convention(thin) <T> (Empty<T>) -> @owned Empty<T> {
bb0(%0 : $Empty<T>):
  return %0 : $Empty<T>
}

sil hidden @returns_closure : $@async @convention(thin) <T> (Empty<T>) -> (@owned Empty<T>, @async @callee_guaranteed @owned (Empty<T>) -> @owned Empty<T>) {
bb0(%0 : $Empty<T>):
  %1 = function_ref @inner_closure : $@async @convention(thin) <τ_0_0> (Empty<τ_0_0>) -> @owned Empty<τ_0_0>
  %2 = partial_apply [callee_guaranteed] %1<T>() : $@async @convention(thin) <τ_0_0> (Empty<τ_0_0>) -> @owned Empty<τ_0_0>
  %5 = tuple (%0 : $Empty<T>, %2 : $@async @callee_guaranteed (Empty<T>) -> @owned Empty<T>)
  return %5 : $(Empty<T>, @async @callee_guaranteed (Empty<T>) -> @owned Empty<T>)
}

sil hidden @specializes_closure_returning_closure : $@async @convention(thin) () -> @async @callee_guaranteed (Empty<S>) -> (@owned Empty<S>, @owned @async @callee_guaranteed (Empty<S>) -> @owned Empty<S>) {
bb0:
  %0 = function_ref @returns_closure : $@async @convention(thin) <τ_0_0> (Empty<τ_0_0>) -> (@owned Empty<τ_0_0>, @owned @async @callee_guaranteed (Empty<τ_0_0>) -> @owned Empty<τ_0_0>)
  %1 = partial_apply [callee_guaranteed] %0<S>() : $@async @convention(thin) <τ_0_0> (Empty<τ_0_0>) -> (@owned Empty<τ_0_0>, @owned @async @callee_guaranteed (Empty<τ_0_0>) -> @owned Empty<τ_0_0>)
  return %1 : $@async @callee_guaranteed (Empty<S>) -> (@owned Empty<S>, @owned @async @callee_guaranteed (Empty<S>) -> @owned Empty<S>)
}

// CHECK-LABEL: define hidden swift{{(tail)?}}cc void @specializes_closure_returning_closure(
// CHECK-LABEL: define internal swift{{(tail)?}}cc void @"$s15returns_closureTA"(
protocol MyEquatable {
  static func isEqual (lhs: Self, rhs: Self) -> Builtin.Int1
}

protocol MyExtended : MyEquatable {
  func extended()
}
public struct Inner<Element> {
  public init()
  public init(_ e: Element)
}

extension Inner : MyEquatable where Element : MyEquatable {
  public static func isEqual (lhs: Inner<Element>, rhs: Inner<Element>) -> Builtin.Int1
}

public struct Outer<Value> {
  init()
}

extension Outer : MyEquatable where Value : MyEquatable {
  public static func isEqual (lhs: Outer<Value>, rhs: Outer<Value>) -> Builtin.Int1
}

public struct Outermost<Value> {
}

sil @$closure : $@async @convention(method) <Value where Value : MyEquatable> (Outer<Value>, Outer<Value>, @thin Outer<Value>.Type) -> Builtin.Int1 {
entry(%o1 : $Outer<Value>, %o2 : $Outer<Value>, %ot : $@thin Outer<Value>.Type):
  %0 = builtin "int_trap"() : $Never
  unreachable
}
sil @$closure2 : $@async @convention(method) <Value where Value : MyEquatable> (Outermost<Value>, Outermost<Value>, @thin Outermost<Value>.Type) -> Builtin.Int1 {
entry(%o1 : $Outermost<Value>, %o2 : $Outermost<Value>, %t : $@thin Outermost<Value>.Type):
  %0 = builtin "int_trap"() : $Never
  unreachable
}

sil @$dont_crash_test_capture_specialized_conditional_conformance : $@async @convention(thin) <Element where Element : MyExtended> (Outer<Inner<Element>>) -> () {
bb0(%0 : $Outer<Inner<Element>>):
  %2 = alloc_stack $Outer<Inner<Element>>
  store %0 to %2 : $*Outer<Inner<Element>>
  %4 = metatype $@thin Outer<Inner<Element>>.Type
  %5 = function_ref @$closure : $@async @convention(method) <τ_0_0 where τ_0_0 : MyEquatable> (Outer<τ_0_0>, Outer<τ_0_0>, @thin Outer<τ_0_0>.Type) -> Builtin.Int1
  %6 = partial_apply [callee_guaranteed] %5<Inner<Element>>(%4) : $@async @convention(method) <τ_0_0 where τ_0_0 : MyEquatable> (Outer<τ_0_0>, Outer<τ_0_0>, @thin Outer<τ_0_0>.Type) -> Builtin.Int1
  strong_release %6 : $@async @callee_guaranteed (Outer<Inner<Element>>, Outer<Inner<Element>>) -> Builtin.Int1
  dealloc_stack %2 : $*Outer<Inner<Element>>
  %15 = tuple ()
  return %15 : $()
}

protocol AssocType {
  associatedtype A : MyExtended
}

sil @$dont_crash_test_capture_specialized_conditional_conformance_associated_type : $@async @convention(thin) <Element where Element : AssocType> (Outer<Inner<Element.A>>) -> () {
bb0(%0 : $Outer<Inner<Element.A>>):
  %2 = alloc_stack $Outer<Inner<Element.A>>
  store %0 to %2 : $*Outer<Inner<Element.A>>
  %4 = metatype $@thin Outer<Inner<Element.A>>.Type
  %5 = function_ref @$closure : $@async @convention(method) <τ_0_0 where τ_0_0 : MyEquatable> (Outer<τ_0_0>, Outer<τ_0_0>, @thin Outer<τ_0_0>.Type) -> Builtin.Int1
  %6 = partial_apply [callee_guaranteed] %5<Inner<Element.A>>(%4) : $@async @convention(method) <τ_0_0 where τ_0_0 : MyEquatable> (Outer<τ_0_0>, Outer<τ_0_0>, @thin Outer<τ_0_0>.Type) -> Builtin.Int1
  strong_release %6 : $@async @callee_guaranteed (Outer<Inner<Element.A>>, Outer<Inner<Element.A>>) -> Builtin.Int1
  dealloc_stack %2 : $*Outer<Inner<Element.A>>
  %15 = tuple ()
  return %15 : $()
}

sil @$dont_crash_test_capture_specialized_conditional_conformance_nested : $@async @convention(thin) <A, B, Element where Element : MyEquatable> (Outer<Inner<Element>>) -> () {
bb0(%0 : $Outer<Inner<Element>>):
  %4 = metatype $@thin Outermost<Outer<Inner<Element>>>.Type
  %5 = function_ref @$closure2 : $@async @convention(method) <Value where Value : MyEquatable> (Outermost<Value>, Outermost<Value>, @thin Outermost<Value>.Type) -> Builtin.Int1
  %6 = partial_apply [callee_guaranteed] %5<Outer<Inner<Element>>>(%4) : $@async @convention(method) <Value where Value : MyEquatable> (Outermost<Value>, Outermost<Value>, @thin Outermost<Value>.Type) -> Builtin.Int1
  strong_release %6 : $@async @callee_guaranteed (Outermost<Outer<Inner<Element>>>, Outermost<Outer<Inner<Element>>>) -> Builtin.Int1
  %15 = tuple ()
  return %15 : $()
}


sil_vtable WeakBox {}
sil_vtable C {}
sil_vtable D {}
sil_vtable E {}
sil_vtable Empty {}
sil_witness_table C: P module main {}