@@ -305,13 +305,15 @@ bb0(%0 : @owned $B):
305305
306306// FIXME: mark_dependence is currently a PointerEscape, so dependent live ranges are not canonicalized.
307307//
308- // CHECK-LABEL: sil [ossa] @testMarkDependence : $@convention(thin) (@inout Builtin.Int64, @owned B) -> Builtin.Int64 {
308+ // CHECK-LABEL: sil [ossa] @testMarkDependence : {{.*}} {
309309// CHECK: copy_value
310310// CHECK: destroy_value
311311// CHECK: destroy_value
312312// CHECK-LABEL: } // end sil function 'testMarkDependence'
313- sil [ossa] @testMarkDependence : $@convention(thin) (@inout Builtin.Int64, @owned B) -> Builtin.Int64 {
314- bb0(%0 : $*Builtin.Int64, %1 : @owned $B):
313+ sil [ossa] @testMarkDependence : $@convention(thin) (@inout Builtin.Int64) -> Builtin.Int64 {
314+ bb0(%0 : $*Builtin.Int64):
315+ %getOwnedB = function_ref @getOwnedB : $@convention(thin) () -> (@owned B)
316+ %1 = apply %getOwnedB() : $@convention(thin) () -> (@owned B)
315317 %ptr = mark_dependence %0 : $*Builtin.Int64 on %1 : $B
316318 %val = load [trivial] %ptr : $*Builtin.Int64
317319 %copy = copy_value %1 : $B
@@ -831,16 +833,18 @@ bb4:
831833// Test a dead begin_borrow (with no scope ending uses). Make sure
832834// copy-propagation doesn't end the lifetime before the dead borrow.
833835//
834- // CHECK-LABEL: sil hidden [ossa] @testDeadBorrow : $@convention(thin) (@owned C) -> () {
835- // CHECK: bb0(%0 : @owned $C) :
836- // CHECK: copy_value %0 : $C
836+ // CHECK-LABEL: sil hidden [ossa] @testDeadBorrow : {{.*}} {
837+ // CHECK: bb0:
838+ // CHECK: copy_value %1 : $C
837839// CHECK: destroy_value
838- // CHECK: copy_value %0 : $C
840+ // CHECK: copy_value %1 : $C
839841// CHECK: begin_borrow
840842// CHECK: unreachable
841843// CHECK-LABEL: } // end sil function 'testDeadBorrow'
842- sil hidden [ossa] @testDeadBorrow : $@convention(thin) (@owned C) -> () {
843- bb0(%0 : @owned $C):
844+ sil hidden [ossa] @testDeadBorrow : $@convention(thin) () -> () {
845+ bb0:
846+ %getOwnedC = function_ref @getOwnedC : $@convention(thin) () -> (@owned C)
847+ %0 = apply %getOwnedC() : $@convention(thin) () -> (@owned C)
844848 %1 = copy_value %0 : $C
845849 destroy_value %1 : $C
846850 %6 = copy_value %0 : $C
@@ -989,3 +993,26 @@ bb0:
989993 %99 = tuple ()
990994 return %99 : $()
991995}
996+
997+ // CHECK-LABEL: sil [ossa] @hoist_destroy_of_copy_of_lexical_over_deinit_barrier : $@convention(thin) (@owned C) -> () {
998+ // CHECK: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] : @owned
999+ // CHECK: [[BARRIER:%[^,]+]] = function_ref @barrier
1000+ // CHECK: [[BORROW:%[^,]+]] = function_ref @takeGuaranteedC
1001+ // CHECK: apply [[BORROW]]([[INSTANCE]])
1002+ // The destroy of the copy should be hoisted over the deinit barrier, and then
1003+ // canonicalization of the lexical value should remove the copy.
1004+ // CHECK: destroy_value [[INSTANCE]]
1005+ // CHECK: apply [[BARRIER]]()
1006+ // CHECK-LABEL: } // end sil function 'hoist_destroy_of_copy_of_lexical_over_deinit_barrier'
1007+ sil [ossa] @hoist_destroy_of_copy_of_lexical_over_deinit_barrier : $(@owned C) -> () {
1008+ entry(%instance : @owned $C):
1009+ %barrier = function_ref @barrier : $@convention(thin) () -> ()
1010+ %borrow = function_ref @takeGuaranteedC : $@convention(thin) (@guaranteed C) -> ()
1011+ %copy = copy_value %instance : $C
1012+ apply %borrow(%instance) : $@convention(thin) (@guaranteed C) -> ()
1013+ destroy_value %instance : $C
1014+ apply %barrier() : $@convention(thin) () -> ()
1015+ destroy_value %copy : $C
1016+ %retval = tuple ()
1017+ return %retval : $()
1018+ }
0 commit comments