@@ -4,6 +4,8 @@ import Swift
4
4
5
5
class C {}
6
6
7
+ struct S {}
8
+
7
9
////////////////////////////////////////////////////////////////////////////////
8
10
// apply
9
11
////////////////////////////////////////////////////////////////////////////////
@@ -23,6 +25,12 @@ entry(%instance : @guaranteed $C):
23
25
return %retval : $()
24
26
}
25
27
28
+ sil [ossa] [always_inline] @callee_trivial : $@convention(thin) (S) -> () {
29
+ entry(%instance : $S):
30
+ %retval = tuple ()
31
+ return %retval : $()
32
+ }
33
+
26
34
// tests
27
35
28
36
// CHECK-LABEL: sil [ossa] @caller_owned_callee_owned : $@convention(thin) (@owned C) -> () {
@@ -91,6 +99,18 @@ entry(%instance : @guaranteed $C):
91
99
return %result : $()
92
100
}
93
101
102
+ // CHECK-LABEL: sil [ossa] @caller_trivial_callee_trivial : $@convention(thin) (S) -> () {
103
+ // CHECK: {{bb[^,]+}}({{%[^,]+}} : $S):
104
+ // CHECK: [[RETVAL:%[^,]+]] = tuple ()
105
+ // CHECK: return [[RETVAL]]
106
+ // CHECK-LABEL: } // end sil function 'caller_trivial_callee_trivial'
107
+ sil [ossa] @caller_trivial_callee_trivial : $@convention(thin) (S) -> () {
108
+ entry(%instance : $S):
109
+ %callee_trivial = function_ref @callee_trivial : $@convention(thin) (S) -> ()
110
+ %result = apply %callee_trivial(%instance) : $@convention(thin) (S) -> ()
111
+ return %result : $()
112
+ }
113
+
94
114
////////////////////////////////////////////////////////////////////////////////
95
115
// begin_apply
96
116
////////////////////////////////////////////////////////////////////////////////
@@ -130,6 +150,20 @@ bb2:
130
150
unwind
131
151
}
132
152
153
+ sil hidden [ossa] [always_inline] @callee_coro_trivial : $@yield_once @convention(method) (S) -> @yields @inout S {
154
+ bb0(%instance : $S):
155
+ %addr = alloc_stack $S
156
+ store %instance to [trivial] %addr : $*S
157
+ yield %addr : $*S, resume bb1, unwind bb2
158
+ bb1:
159
+ dealloc_stack %addr : $*S
160
+ %result = tuple ()
161
+ return %result : $()
162
+ bb2:
163
+ dealloc_stack %addr : $*S
164
+ unwind
165
+ }
166
+
133
167
// tests
134
168
135
169
// CHECK-LABEL: sil [ossa] @caller_owned_callee_coro_owned : $@convention(method) (@owned C) -> () {
@@ -242,6 +276,27 @@ bb0(%instance : @guaranteed $C):
242
276
return %retval : $()
243
277
}
244
278
279
+ // CHECK-LABEL: sil hidden [ossa] @caller_trivial_callee_coro_trivial : $@convention(method) (S) -> () {
280
+ // CHECK: {{bb[0-9]+}}([[REGISTER_0:%[^,]+]] : $S):
281
+ // CHECK: [[REGISTER_1:%[^,]+]] = alloc_stack $S
282
+ // CHECK: store [[REGISTER_0]] to [trivial] [[REGISTER_1]] : $*S
283
+ // CHECK: dealloc_stack [[REGISTER_1]] : $*S
284
+ // CHECK: [[REGISTER_4:%[^,]+]] = tuple ()
285
+ // CHECK: [[REGISTER_5:%[^,]+]] = tuple ()
286
+ // CHECK: return [[REGISTER_5]] : $()
287
+ // CHECK: {{bb[0-9]+}}:
288
+ // CHECK: dealloc_stack [[REGISTER_1]] : $*S
289
+ // CHECK: unreachable
290
+ // CHECK-LABEL: } // end sil function 'caller_trivial_callee_coro_trivial'
291
+ sil hidden [ossa] @caller_trivial_callee_coro_trivial : $@convention(method) (S) -> () {
292
+ bb0(%instance : $S):
293
+ %callee_coro_trivial = function_ref @callee_coro_trivial : $@yield_once @convention(method) (S) -> @yields @inout S
294
+ (%addr, %continuation) = begin_apply %callee_coro_trivial(%instance) : $@yield_once @convention(method) (S) -> @yields @inout S
295
+ end_apply %continuation
296
+ %retval = tuple ()
297
+ return %retval : $()
298
+ }
299
+
245
300
////////////////////////////////////////////////////////////////////////////////
246
301
// try_apply
247
302
////////////////////////////////////////////////////////////////////////////////
@@ -270,6 +325,16 @@ bb2:
270
325
return %18 : $()
271
326
}
272
327
328
+ sil [ossa] @callee_error_trivial : $@convention(thin) (S) -> @error Error {
329
+ bb0(%0 : $S):
330
+ cond_br undef, bb1, bb2
331
+ bb1:
332
+ throw undef : $Error
333
+ bb2:
334
+ %18 = tuple ()
335
+ return %18 : $()
336
+ }
337
+
273
338
// tests
274
339
275
340
// CHECK-LABEL: sil [ossa] @callee_owned_callee_error_owned : $@convention(thin) (@owned C) -> @error Error {
@@ -384,3 +449,24 @@ bb1(%9 : $()):
384
449
bb2(%12 : @owned $Error):
385
450
throw %12 : $Error
386
451
}
452
+
453
+ // CHECK-LABEL: sil hidden [ossa] @callee_trivial_callee_error_trivial : $@convention(thin) (S) -> @error Error {
454
+ // CHECK: {{bb[^,]+}}({{%[^,]+}} : $S):
455
+ // CHECK: cond_br undef, [[THROW_BLOCK:bb[^,]+]], [[REGULAR_BLOCK:bb[0-9]+]]
456
+ // CHECK: [[THROW_BLOCK]]:
457
+ // CHECK: throw undef
458
+ // CHECK: [[REGULAR_BLOCK]]:
459
+ // CHECK: [[ORIGINAL_RETVAL:%[^,]+]] = tuple ()
460
+ // CHECK: [[RETVAL:%[^,]+]] = tuple ()
461
+ // CHECK: return [[RETVAL]]
462
+ // CHECK-LABEL: } // end sil function 'callee_trivial_callee_error_trivial'
463
+ sil hidden [ossa] @callee_trivial_callee_error_trivial : $@convention(thin) (S) -> @error Error {
464
+ bb0(%instance : $S):
465
+ %callee_error_trivial = function_ref @callee_error_trivial : $@convention(thin) (S) -> @error Error
466
+ try_apply %callee_error_trivial(%instance) : $@convention(thin) (S) -> @error Error, normal bb1, error bb2
467
+ bb1(%9 : $()):
468
+ %10 = tuple ()
469
+ return %10 : $()
470
+ bb2(%12 : @owned $Error):
471
+ throw %12 : $Error
472
+ }
0 commit comments