@@ -37,6 +37,12 @@ entry(%instance : $*S):
37
37
return %retval : $()
38
38
}
39
39
40
+ sil [always_inline] [ossa] @callee_inguaranteed : $@convention(thin) <T> (@in_guaranteed T) -> () {
41
+ entry(%arg : $*T):
42
+ %retval = tuple ()
43
+ return %retval : $()
44
+ }
45
+
40
46
// tests
41
47
42
48
// CHECK-LABEL: sil [ossa] @caller_owned_callee_owned : $@convention(thin) (@owned C) -> () {
@@ -114,6 +120,16 @@ entry(%instance : $*S):
114
120
return %result : $()
115
121
}
116
122
123
+ // CHECK-LABEL: sil [ossa] @caller_inguaranteed_callee_inguaranteed : $@convention(thin) <T> (@in_guaranteed T) -> () {
124
+ // CHECK-NOT: begin_borrow [lexical]
125
+ // CHECK-LABEL: } // end sil function 'caller_inguaranteed_callee_inguaranteed'
126
+ sil [ossa] @caller_inguaranteed_callee_inguaranteed : $@convention(thin) <T> (@in_guaranteed T) -> () {
127
+ bb0(%instance : $*T):
128
+ %callee_inguaranteed = function_ref @callee_inguaranteed : $@convention(thin) <T> (@in_guaranteed T) -> ()
129
+ %retval = apply %callee_inguaranteed<T>(%instance) : $@convention(thin) <T> (@in_guaranteed T) -> ()
130
+ return %retval : $()
131
+ }
132
+
117
133
////////////////////////////////////////////////////////////////////////////////
118
134
// begin_apply
119
135
////////////////////////////////////////////////////////////////////////////////
@@ -177,6 +193,22 @@ bb2:
177
193
unwind
178
194
}
179
195
196
+ sil hidden [ossa] [always_inline] @callee_coro_inguaranteed : $@yield_once @convention(thin) <T> (@in_guaranteed T) -> @yields @inout T {
197
+ bb0(%instance : $*T):
198
+ %addr = alloc_stack $T
199
+ copy_addr %instance to [initialization] %addr : $*T
200
+ yield %addr : $*T, resume bb1, unwind bb2
201
+ bb1:
202
+ destroy_addr %addr : $*T
203
+ dealloc_stack %addr : $*T
204
+ %result = tuple ()
205
+ return %result : $()
206
+ bb2:
207
+ destroy_addr %addr : $*T
208
+ dealloc_stack %addr : $*T
209
+ unwind
210
+ }
211
+
180
212
// tests
181
213
182
214
// CHECK-LABEL: sil [ossa] @caller_owned_callee_coro_owned : $@convention(thin) (@owned C) -> () {
@@ -296,6 +328,18 @@ bb0(%instance : $*S):
296
328
return %retval : $()
297
329
}
298
330
331
+ // CHECK-LABEL: sil hidden [ossa] @caller_inguaranteed_callee_coro_inguaranteed : $@convention(thin) <T> (@in_guaranteed T) -> () {
332
+ // CHECK-NOTE: begin_borrow [lexical]
333
+ // CHECK-LABEL: } // end sil function 'caller_inguaranteed_callee_coro_inguaranteed'
334
+ sil hidden [ossa] @caller_inguaranteed_callee_coro_inguaranteed : $@convention(thin) <T> (@in_guaranteed T) -> () {
335
+ bb0(%instance : $*T):
336
+ %callee_coro_inguaranteed = function_ref @callee_coro_inguaranteed : $@yield_once @convention(thin) <T> (@in_guaranteed T) -> @yields @inout T
337
+ (%addr_out, %continuation) = begin_apply %callee_coro_inguaranteed<T>(%instance) : $@yield_once @convention(thin) <T> (@in_guaranteed T) -> @yields @inout T
338
+ end_apply %continuation
339
+ %retval = tuple ()
340
+ return %retval : $()
341
+ }
342
+
299
343
////////////////////////////////////////////////////////////////////////////////
300
344
// try_apply
301
345
////////////////////////////////////////////////////////////////////////////////
@@ -344,6 +388,16 @@ bb2:
344
388
return %18 : $()
345
389
}
346
390
391
+ sil [ossa] @callee_error_inguaranteed : $@convention(thin) <T> (@in_guaranteed T) -> @error Error {
392
+ bb0(%0 : $*T):
393
+ cond_br undef, bb1, bb2
394
+ bb1:
395
+ throw undef : $Error
396
+ bb2:
397
+ %18 = tuple ()
398
+ return %18 : $()
399
+ }
400
+
347
401
// tests
348
402
349
403
// CHECK-LABEL: sil [ossa] @caller_owned_callee_error_owned : $@convention(thin) (@owned C) -> @error Error {
@@ -469,3 +523,17 @@ bb1(%9 : $()):
469
523
bb2(%12 : @owned $Error):
470
524
throw %12 : $Error
471
525
}
526
+
527
+ // CHECK-LABEL: sil hidden [ossa] @caller_inguaranteed_callee_error_inguaranteed : $@convention(thin) <T> (@in_guaranteed T) -> @error Error {
528
+ // CHECK-NOT: begin_borrow [lexical]
529
+ // CHECK-LABEL: // end sil function 'caller_inguaranteed_callee_error_inguaranteed'
530
+ sil hidden [ossa] @caller_inguaranteed_callee_error_inguaranteed : $@convention(thin) <T> (@in_guaranteed T) -> @error Error {
531
+ bb0(%instance : $*T):
532
+ %callee_error_inguaranteed = function_ref @callee_error_inguaranteed : $@convention(thin) <T> (@in_guaranteed T) -> @error Error
533
+ try_apply %callee_error_inguaranteed<T>(%instance) : $@convention(thin) <T> (@in_guaranteed T) -> @error Error, normal bb1, error bb2
534
+ bb1(%9 : $()):
535
+ %10 = tuple ()
536
+ return %10 : $()
537
+ bb2(%12 : @owned $Error):
538
+ throw %12 : $Error
539
+ }
0 commit comments