@@ -28,6 +28,7 @@ class C {
28
28
}
29
29
30
30
sil [ossa] @dummy : $@convention(thin) () -> ()
31
+ sil [ossa] @barrier : $@convention(thin) () -> ()
31
32
sil [ossa] @getOwnedC : $@convention(thin) () -> (@owned C)
32
33
sil [ossa] @takeOwnedC : $@convention(thin) (@owned C) -> ()
33
34
sil [ossa] @takeOwnedCTwice : $@convention(thin) (@owned C, @owned C) -> ()
@@ -836,3 +837,26 @@ bb0(%0 : @owned $C):
836
837
%7 = begin_borrow %6 : $C
837
838
unreachable
838
839
}
840
+
841
+ // Test that copy propagation doesn't hoist a destroy_value corresponding to
842
+ // a move value [lexical] over a barrier.
843
+ // CHECK-ONONE-LABEL: sil [ossa] @dont_hoist_move_value_lexical_destroy_over_barrier_apply : {{.*}} {
844
+ // CHECK-ONONE: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] : @owned $C):
845
+ // CHECK-ONONE: [[LIFETIME:%[^,]+]] = move_value [lexical] [[INSTANCE]]
846
+ // CHECK-ONONE: [[BARRIER:%[^,]+]] = function_ref @barrier
847
+ // CHECK-ONONE: [[TAKE_GUARANTEED_C:%[^,]+]] = function_ref @takeGuaranteedC
848
+ // CHECK-ONONE: apply [[TAKE_GUARANTEED_C]]([[LIFETIME]])
849
+ // CHECK-ONONE: apply [[BARRIER]]()
850
+ // CHECK-ONONE: destroy_value [[LIFETIME]]
851
+ // CHECK-ONONE-LABEL: } // end sil function 'dont_hoist_move_value_lexical_destroy_over_barrier_apply'
852
+ sil [ossa] @dont_hoist_move_value_lexical_destroy_over_barrier_apply : $@convention(thin) (@owned C) -> () {
853
+ entry(%instance : @owned $C):
854
+ %lifetime = move_value [lexical] %instance : $C
855
+ %barrier = function_ref @barrier : $@convention(thin) () -> ()
856
+ %takeGuaranteedC = function_ref @takeGuaranteedC : $@convention(thin) (@guaranteed C) -> ()
857
+ apply %takeGuaranteedC(%lifetime) : $@convention(thin) (@guaranteed C) -> ()
858
+ apply %barrier() : $@convention(thin) () -> ()
859
+ destroy_value %lifetime : $C
860
+ %retval = tuple ()
861
+ return %retval : $()
862
+ }
0 commit comments