@@ -9,6 +9,7 @@ public class Foo {
9
9
}
10
10
11
11
sil @beep : $@convention(thin) () -> ()
12
+ sil @beep2 : $@convention(thin) (@owned Foo) -> ()
12
13
13
14
// CHECK-LABEL: sil @testUnsafeGuaranteed_simple
14
15
// CHECK: bb0([[P:%.*]] : $Foo):
@@ -235,3 +236,57 @@ bb3:
235
236
%20 = apply %19(%5) : $@convention(method) (@guaranteed Foo) -> ()
236
237
br bb2
237
238
}
239
+
240
+ // CHECK-LABEL: sil @testUnsafeGuaranteed_debug_inst
241
+ // CHECK: bb0([[P:%.*]] : $Foo):
242
+ // CHECK-NOT: retain
243
+ // CHECK-NOT: unsafeGuaranteed
244
+ // CHECK: [[M:%.*]] = class_method [[P]] : $Foo, #Foo.beep
245
+ // CHECK: apply [[M]]([[P]])
246
+ // CHECK-NOT: release
247
+ // CHECK-NOT: unsafeGuaranteedEnd
248
+ // CHECK: [[T:%.*]] = tuple ()
249
+ // CHECK: return [[T]]
250
+ // CHECK: }
251
+ sil @testUnsafeGuaranteed_debug_inst : $@convention(method) (@guaranteed Foo) -> () {
252
+ bb0(%0 : $Foo):
253
+ strong_retain %0 : $Foo
254
+ debug_value %0 : $Foo
255
+ %4 = builtin "unsafeGuaranteed"<Foo>(%0 : $Foo) : $(Foo, Builtin.Int8)
256
+ %5 = tuple_extract %4 : $(Foo, Builtin.Int8), 0
257
+ %6 = tuple_extract %4 : $(Foo, Builtin.Int8), 1
258
+ %19 = class_method %5 : $Foo, #Foo.beep!1 : (Foo) -> () -> () , $@convention(method) (@guaranteed Foo) -> ()
259
+ %20 = apply %19(%5) : $@convention(method) (@guaranteed Foo) -> ()
260
+ strong_release %5 : $Foo
261
+ debug_value %5 : $Foo
262
+ %16 = builtin "unsafeGuaranteedEnd"(%6 : $Builtin.Int8) : $()
263
+ %17 = tuple ()
264
+ return %17 : $()
265
+ }
266
+
267
+ // CHECK-LABEL: sil @testUnsafeGuaranteed_retain_release
268
+ // CHECK: bb0([[P:%.*]] : $Foo):
269
+ // CHECK-NOT: strong_retain
270
+ // CHECK-NOT: unsafeGuaranteed
271
+ // CHECK: retain_value [[P]]
272
+ // CHECK: [[M:%.*]] = function_ref @beep2
273
+ // CHECK: apply [[M]]([[P]])
274
+ // CHECK-NOT: release
275
+ // CHECK-NOT: unsafeGuaranteedEnd
276
+ // CHECK: [[T:%.*]] = tuple ()
277
+ // CHECK: return [[T]]
278
+ // CHECK: }
279
+ sil @testUnsafeGuaranteed_retain_release : $@convention(method) (@guaranteed Foo) -> () {
280
+ bb0(%0 : $Foo):
281
+ strong_retain %0 : $Foo
282
+ %4 = builtin "unsafeGuaranteed"<Foo>(%0 : $Foo) : $(Foo, Builtin.Int8)
283
+ %5 = tuple_extract %4 : $(Foo, Builtin.Int8), 0
284
+ %6 = tuple_extract %4 : $(Foo, Builtin.Int8), 1
285
+ retain_value %4 : $(Foo, Builtin.Int8)
286
+ %19 = function_ref @beep2 : $@convention(thin) (@owned Foo) -> ()
287
+ %20 = apply %19(%5) : $@convention(thin) (@owned Foo) -> ()
288
+ release_value %4 : $(Foo, Builtin.Int8)
289
+ %16 = builtin "unsafeGuaranteedEnd"(%6 : $Builtin.Int8) : $()
290
+ %17 = tuple ()
291
+ return %17 : $()
292
+ }
0 commit comments