@@ -290,3 +290,80 @@ bb0(%0 : $Foo):
290
290
%17 = tuple ()
291
291
return %17 : $()
292
292
}
293
+
294
+ struct MyInt {
295
+ @sil_stored var val: Builtin.Int32
296
+ }
297
+
298
+ // CHECK-LABEL: sil @testUnsafeGuaranteed_sideeffectfree_inst
299
+ // CHECK: bb0([[P:%.*]] : $Foo
300
+ // CHECK-NOT: retain
301
+ // CHECK-NOT: unsafeGuaranteed
302
+ // CHECK: [[M:%.*]] = class_method [[P]] : $Foo, #Foo.beep
303
+ // CHECK: apply [[M]]([[P]])
304
+ // CHECK-NOT: release
305
+ // CHECK-NOT: unsafeGuaranteedEnd
306
+ // CHECK: [[T:%.*]] = tuple ()
307
+ // CHECK: return [[T]]
308
+ // CHECK: }
309
+ sil @testUnsafeGuaranteed_sideeffectfree_inst : $@convention(method) (@guaranteed Foo, Builtin.Int32) -> () {
310
+ bb0(%0 : $Foo, %1: $Builtin.Int32):
311
+ strong_retain %0 : $Foo
312
+ debug_value %0 : $Foo
313
+ %3 = struct $MyInt(%1 : $Builtin.Int32)
314
+ %4 = builtin "unsafeGuaranteed"<Foo>(%0 : $Foo) : $(Foo, Builtin.Int8)
315
+ %5 = tuple_extract %4 : $(Foo, Builtin.Int8), 0
316
+ %6 = tuple_extract %4 : $(Foo, Builtin.Int8), 1
317
+ %19 = class_method %5 : $Foo, #Foo.beep!1 : (Foo) -> () -> () , $@convention(method) (@guaranteed Foo) -> ()
318
+ %20 = apply %19(%5) : $@convention(method) (@guaranteed Foo) -> ()
319
+ strong_release %5 : $Foo
320
+ %21 = struct $MyInt(%1 : $Builtin.Int32)
321
+ debug_value %5 : $Foo
322
+ %16 = builtin "unsafeGuaranteedEnd"(%6 : $Builtin.Int8) : $()
323
+ %17 = tuple ()
324
+ return %17 : $()
325
+ }
326
+
327
+ // CHECK-LABEL: sil @testUnsafeGuaranteed_sideeffect_inst
328
+ // CHECK: bb0([[P:%.*]] : $Foo
329
+ // CHECK: retain
330
+ // CHECK: unsafeGuaranteed
331
+ // CHECK: release
332
+ // CHECK: unsafeGuaranteedEnd
333
+ // CHECK: }
334
+ sil @testUnsafeGuaranteed_sideeffect_inst : $@convention(method) (@guaranteed Foo, @inout Builtin.Int32, Builtin.Int32) -> () {
335
+ bb0(%0 : $Foo, %1: $*Builtin.Int32, %2: $Builtin.Int32):
336
+ strong_retain %0 : $Foo
337
+ store %2 to %1 : $*Builtin.Int32
338
+ %4 = builtin "unsafeGuaranteed"<Foo>(%0 : $Foo) : $(Foo, Builtin.Int8)
339
+ %5 = tuple_extract %4 : $(Foo, Builtin.Int8), 0
340
+ %6 = tuple_extract %4 : $(Foo, Builtin.Int8), 1
341
+ %19 = class_method %5 : $Foo, #Foo.beep!1 : (Foo) -> () -> () , $@convention(method) (@guaranteed Foo) -> ()
342
+ %20 = apply %19(%5) : $@convention(method) (@guaranteed Foo) -> ()
343
+ strong_release %5 : $Foo
344
+ %16 = builtin "unsafeGuaranteedEnd"(%6 : $Builtin.Int8) : $()
345
+ %17 = tuple ()
346
+ return %17 : $()
347
+ }
348
+
349
+ // CHECK-LABEL: sil @testUnsafeGuaranteed_sideeffect_inst2
350
+ // CHECK: bb0([[P:%.*]] : $Foo
351
+ // CHECK: retain
352
+ // CHECK: unsafeGuaranteed
353
+ // CHECK: release
354
+ // CHECK: unsafeGuaranteedEnd
355
+ // CHECK: }
356
+ sil @testUnsafeGuaranteed_sideeffect_inst2 : $@convention(method) (@guaranteed Foo, @inout Builtin.Int32, Builtin.Int32) -> () {
357
+ bb0(%0 : $Foo, %1: $*Builtin.Int32, %2: $Builtin.Int32):
358
+ strong_retain %0 : $Foo
359
+ %4 = builtin "unsafeGuaranteed"<Foo>(%0 : $Foo) : $(Foo, Builtin.Int8)
360
+ %5 = tuple_extract %4 : $(Foo, Builtin.Int8), 0
361
+ %6 = tuple_extract %4 : $(Foo, Builtin.Int8), 1
362
+ %19 = class_method %5 : $Foo, #Foo.beep!1 : (Foo) -> () -> () , $@convention(method) (@guaranteed Foo) -> ()
363
+ %20 = apply %19(%5) : $@convention(method) (@guaranteed Foo) -> ()
364
+ strong_release %5 : $Foo
365
+ store %2 to %1 : $*Builtin.Int32
366
+ %16 = builtin "unsafeGuaranteedEnd"(%6 : $Builtin.Int8) : $()
367
+ %17 = tuple ()
368
+ return %17 : $()
369
+ }
0 commit comments