@@ -30,6 +30,7 @@ sil @foo_allocating_init : $@convention(thin) (@thick Foo.Type) -> @owned Foo
30
30
sil @baz_init : $@convention(thin) (@thin Baz.Type) -> @owned Baz
31
31
sil @dummy_func : $@convention(thin) (Int, Int, Int) -> Int
32
32
sil @destructured_baz_user : $@convention(thin) (@owned Bar, @guaranteed Bar, Int) -> ()
33
+ sil @guaranteed_nativeobject_user : $@convention(thin) (@guaranteed Builtin.NativeObject) -> ()
33
34
34
35
// CHECK-LABEL: sil [ossa] @test_capture_promotion
35
36
sil [ossa] @test_capture_promotion : $@convention(thin) () -> @owned @callee_owned () -> (Int, Builtin.Int64) {
@@ -471,3 +472,36 @@ bb0(%0 : @owned $<τ_0_0> { var τ_0_0 } <Baz>, %1 : @owned $<τ_0_0> { var τ_0
471
472
%t = tuple()
472
473
return %t : $()
473
474
}
475
+
476
+
477
+
478
+ // Make sure that we properly handle guaranteed arguments when specializing here.
479
+ sil [ossa] @capture_promotion_callee_guaranteed_box : $@convention(thin) (@guaranteed { var Builtin.NativeObject }) -> () {
480
+ bb0(%0 : @guaranteed ${ var Builtin.NativeObject }):
481
+ %1 = project_box %0 : ${ var Builtin.NativeObject }, 0
482
+ %2 = begin_access [read] [unknown] %1 : $*Builtin.NativeObject
483
+ %3 = load [copy] %2 : $*Builtin.NativeObject
484
+ end_access %2 : $*Builtin.NativeObject
485
+ %4 = function_ref @guaranteed_nativeobject_user : $@convention(thin) (@guaranteed Builtin.NativeObject) -> ()
486
+ apply %4(%3) : $@convention(thin) (@guaranteed Builtin.NativeObject) -> ()
487
+ destroy_value %3 : $Builtin.NativeObject
488
+ %9999 = tuple()
489
+ return %9999 : $()
490
+ }
491
+
492
+ // Just make sure that we specialized so that the ownership verifier can make
493
+ // sure we emitted ownership correctly.
494
+ //
495
+ // CHECK-LABEL: sil [ossa] @capture_promotion_caller_guaranteed_box : $@convention(thin) (@owned Builtin.NativeObject) -> @owned @callee_owned () -> () {
496
+ // CHECK: [[FUNC_REF:%.*]] = function_ref @$s39capture_promotion_callee_guaranteed_boxTf2i_n :
497
+ // CHECK: apply [[FUNC_REF]](
498
+ // CHECK: } // end sil function 'capture_promotion_caller_guaranteed_box'
499
+ sil [ossa] @capture_promotion_caller_guaranteed_box : $@convention(thin) (@owned Builtin.NativeObject) -> @owned @callee_owned () -> () {
500
+ bb0(%0 : @owned $Builtin.NativeObject):
501
+ %1 = alloc_box ${ var Builtin.NativeObject }
502
+ %2 = project_box %1 : ${ var Builtin.NativeObject }, 0
503
+ store %0 to [init] %2 : $*Builtin.NativeObject
504
+ %3 = function_ref @capture_promotion_callee_guaranteed_box : $@convention(thin) (@guaranteed { var Builtin.NativeObject }) -> ()
505
+ %pai = partial_apply %3(%1) : $@convention(thin) (@guaranteed { var Builtin.NativeObject }) -> ()
506
+ return %pai : $@callee_owned () -> ()
507
+ }
0 commit comments