@@ -31,6 +31,12 @@ entry(%instance : $S):
31
31
return %retval : $()
32
32
}
33
33
34
+ sil [ossa] [always_inline] @callee_address : $@convention(thin) (@in S) -> () {
35
+ entry(%instance : $*S):
36
+ %retval = tuple ()
37
+ return %retval : $()
38
+ }
39
+
34
40
// tests
35
41
36
42
// CHECK-LABEL: sil [ossa] @caller_owned_callee_owned : $@convention(thin) (@owned C) -> () {
@@ -111,6 +117,18 @@ entry(%instance : $S):
111
117
return %result : $()
112
118
}
113
119
120
+ // CHECK-LABEL: sil [ossa] @caller_address_callee_address : $@convention(thin) (@in S) -> () {
121
+ // CHECK: {{bb[^,]+}}({{%[^,]+}} : $*S):
122
+ // CHECK: [[RETVAL:%[^,]+]] = tuple ()
123
+ // CHECK: return [[RETVAL]]
124
+ // CHECK-LABEL: } // end sil function 'caller_address_callee_address'
125
+ sil [ossa] @caller_address_callee_address : $@convention(thin) (@in S) -> () {
126
+ entry(%instance : $*S):
127
+ %callee_address = function_ref @callee_address : $@convention(thin) (@in S) -> ()
128
+ %result = apply %callee_address(%instance) : $@convention(thin) (@in S) -> ()
129
+ return %result : $()
130
+ }
131
+
114
132
////////////////////////////////////////////////////////////////////////////////
115
133
// begin_apply
116
134
////////////////////////////////////////////////////////////////////////////////
@@ -164,6 +182,16 @@ bb2:
164
182
unwind
165
183
}
166
184
185
+ sil hidden [ossa] [always_inline] @callee_coro_address : $@yield_once @convention(method) (@in S) -> @yields @inout S {
186
+ bb0(%instance : $*S):
187
+ yield %instance : $*S, resume bb1, unwind bb2
188
+ bb1:
189
+ %result = tuple ()
190
+ return %result : $()
191
+ bb2:
192
+ unwind
193
+ }
194
+
167
195
// tests
168
196
169
197
// CHECK-LABEL: sil [ossa] @caller_owned_callee_coro_owned : $@convention(method) (@owned C) -> () {
@@ -297,6 +325,23 @@ bb0(%instance : $S):
297
325
return %retval : $()
298
326
}
299
327
328
+ // CHECK-LABEL: sil hidden [ossa] @caller_address_callee_coro_address : $@convention(method) (@in S) -> () {
329
+ // CHECK: {{bb[^,]+}}({{%[^,]+}} : $*S):
330
+ // CHECK: {{%[^,]+}} = tuple ()
331
+ // CHECK: [[RETVAL:%[^,]+]] = tuple ()
332
+ // CHECK: return [[RETVAL]]
333
+ // CHECK: {{bb[^,]+}}:
334
+ // CHECK: unreachable
335
+ // CHECK-LABEL: } // end sil function 'caller_address_callee_coro_address'
336
+ sil hidden [ossa] @caller_address_callee_coro_address : $@convention(method) (@in S) -> () {
337
+ bb0(%instance : $*S):
338
+ %callee_coro_address = function_ref @callee_coro_address : $@yield_once @convention(method) (@in S) -> @yields @inout S
339
+ (%addr, %continuation) = begin_apply %callee_coro_address(%instance) : $@yield_once @convention(method) (@in S) -> @yields @inout S
340
+ end_apply %continuation
341
+ %retval = tuple ()
342
+ return %retval : $()
343
+ }
344
+
300
345
////////////////////////////////////////////////////////////////////////////////
301
346
// try_apply
302
347
////////////////////////////////////////////////////////////////////////////////
@@ -335,6 +380,16 @@ bb2:
335
380
return %18 : $()
336
381
}
337
382
383
+ sil [ossa] @callee_error_address : $@convention(thin) (@in S) -> @error Error {
384
+ bb0(%0 : $*S):
385
+ cond_br undef, bb1, bb2
386
+ bb1:
387
+ throw undef : $Error
388
+ bb2:
389
+ %18 = tuple ()
390
+ return %18 : $()
391
+ }
392
+
338
393
// tests
339
394
340
395
// CHECK-LABEL: sil [ossa] @callee_owned_callee_error_owned : $@convention(thin) (@owned C) -> @error Error {
@@ -470,3 +525,24 @@ bb1(%9 : $()):
470
525
bb2(%12 : @owned $Error):
471
526
throw %12 : $Error
472
527
}
528
+
529
+ // CHECK-LABEL: sil hidden [ossa] @callee_address_callee_error_address : $@convention(thin) (@in S) -> @error Error {
530
+ // CHECK: {{bb[^,]+}}({{%[^,]+}} : $*S):
531
+ // CHECK: cond_br undef, [[THROW_BLOCK:bb[0-9]+]], [[REGULAR_BLOCK:bb[0-9]+]]
532
+ // CHECK: [[THROW_BLOCK]]:
533
+ // CHECK: throw undef
534
+ // CHECK: [[REGULAR_BLOCK]]:
535
+ // CHECK: {{%[^,]+}} = tuple ()
536
+ // CHECK: [[RETVAL:%[^,]+]] = tuple ()
537
+ // CHECK: return [[RETVAL]]
538
+ // CHECK-LABEL: } // end sil function 'callee_address_callee_error_address'
539
+ sil hidden [ossa] @callee_address_callee_error_address : $@convention(thin) (@in S) -> @error Error {
540
+ bb0(%instance : $*S):
541
+ %callee_error_address = function_ref @callee_error_address : $@convention(thin) (@in S) -> @error Error
542
+ try_apply %callee_error_address(%instance) : $@convention(thin) (@in S) -> @error Error, normal bb1, error bb2
543
+ bb1(%9 : $()):
544
+ %10 = tuple ()
545
+ return %10 : $()
546
+ bb2(%12 : @owned $Error):
547
+ throw %12 : $Error
548
+ }
0 commit comments