@@ -616,24 +616,21 @@ bb2:
616
616
617
617
// Original Overlapping (unnecessarilly extends pruned liveness):
618
618
//
619
- // TODO: this copy could be avoided but is probably an unusual case,
620
- // and sinking the destroy outside the access scope might help to
621
- // optimize the access itself.
622
- //
623
619
// %def
624
620
// begin_access // access scope unrelated to def
625
621
// use %def // pruned liveness ends here
626
622
// destroy %def
627
623
// end_access
628
624
//
629
625
// CHECK-LABEL: sil [ossa] @testOriginalOverlapInLiveBlock : $@convention(thin) () -> () {
630
- // CHECK: [[DEF:%.*]] = apply %{{.*}}() : $@convention(thin) () -> @owned AnyObject
631
- // CHECK: begin_access
632
- // CHECK: [[COPY:%.*]] = copy_value [[DEF]] : $AnyObject
633
- // CHECK: store [[COPY]] to [init] %{{.*}} : $*AnyObject
634
- // CHECK: end_access
635
- // CHECK: destroy_value [[DEF]] : $AnyObject
636
- // CHECK: br bb1
626
+ // CHECK: [[DEF:%.*]] = apply %{{.*}}() : $@convention(thin) () -> @owned AnyObject
627
+ // CHECK: begin_access
628
+ // CHECK-OPT: store [[DEF]] to [init] %{{.*}} : $*AnyObject
629
+ // CHECK-ONONE: [[COPY:%[^,]+]] = copy_value [[DEF]]
630
+ // CHECK-ONONE: store [[COPY]] to [init] %{{.*}} : $*AnyObject
631
+ // CHECK-ONONE: destroy_value [[DEF]]
632
+ // CHECK: end_access
633
+ // CHECK: br bb1
637
634
// CHECK-LABEL: } // end sil function 'testOriginalOverlapInLiveBlock'
638
635
sil [ossa] @testOriginalOverlapInLiveBlock : $@convention(thin) () -> () {
639
636
bb0:
@@ -901,3 +898,44 @@ exit:
901
898
%retval = tuple ()
902
899
return %retval : $()
903
900
}
901
+
902
+ // CHECK-LABEL: sil [ossa] @dont_extend_beyond_nonoverlapping_end_access_after_store_in_consuming_block : {{.*}} {
903
+ // CHECK: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] : @owned $C
904
+ // CHECK: [[COPY:%[^,]+]] = copy_value [[INSTANCE]]
905
+ // CHECK: begin_access
906
+ // CHECK-NOT: copy_value
907
+ // CHECK: store [[COPY]] to [init] {{%[^,]+}}
908
+ // CHECK-LABEL: } // end sil function 'dont_extend_beyond_nonoverlapping_end_access_after_store_in_consuming_block'
909
+ sil [ossa] @dont_extend_beyond_nonoverlapping_end_access_after_store_in_consuming_block : $@convention(thin) (@owned C) -> () {
910
+ bb0(%instance : @owned $C):
911
+ %addr = alloc_stack [lexical] $C, var
912
+ %borrow = begin_borrow %instance : $C
913
+ %copy = copy_value %borrow : $C
914
+ end_borrow %borrow : $C
915
+ destroy_value %instance : $C
916
+ %access = begin_access [static] [modify] %addr : $*C
917
+ store %copy to [init] %addr : $*C
918
+ end_access %access : $*C
919
+ destroy_addr %addr : $*C
920
+ dealloc_stack %addr : $*C
921
+ %retval = tuple()
922
+ return %retval : $()
923
+ }
924
+
925
+ // CHECK-LABEL: sil [ossa] @dont_extend_beyond_nonoverlapping_endaccess_after_destroyvalue_in_consuming_block : $@convention(thin) () -> () {
926
+ // CHECK: begin_access
927
+ // CHECK: destroy_value
928
+ // CHECK: end_access
929
+ // CHECK-NOT: destroy_value
930
+ // CHECK-LABEL: } // end sil function 'dont_extend_beyond_nonoverlapping_endaccess_after_destroyvalue_in_consuming_block'
931
+ sil [ossa] @dont_extend_beyond_nonoverlapping_endaccess_after_destroyvalue_in_consuming_block : $@convention(thin) () -> () {
932
+ %instance = apply undef() : $@convention(thin) () -> @owned C
933
+ %addr = alloc_stack [lexical] $C, var
934
+ %access = begin_access [static] [modify] %addr : $*C
935
+ apply undef(%instance) : $@convention(thin) (@guaranteed C) -> ()
936
+ destroy_value %instance : $C
937
+ end_access %access : $*C
938
+ dealloc_stack %addr : $*C
939
+ %retval = tuple()
940
+ return %retval : $()
941
+ }
0 commit comments