@@ -842,12 +842,15 @@ class TestKlass {
842
842
843
843
sil [ossa] @use_klass : $@convention(thin) (@guaranteed Klass) -> ()
844
844
845
- // Currently ownership rauw does not handle this case
846
- // CHECK-LABEL: sil [ossa] @cse_ossa_accesspathclonetest :
845
+ // An interior pointer, struct_element_addr, can be reused during an
846
+ // OSSA/RAUW because its new uses are within the borrowed value
847
+ // (function argument %0).
848
+ //
849
+ // CHECK-LABEL: sil [ossa] @cse_ossa_interioruseswithinarg :
847
850
// CHECK: struct_element_addr
848
- // CHECK: struct_element_addr
849
- // CHECK-LABEL: } // end sil function 'cse_ossa_accesspathclonetest '
850
- sil [ossa] @cse_ossa_accesspathclonetest : $@convention(thin) (@guaranteed TestKlass) -> () {
851
+ // CHECK-NOT : struct_element_addr
852
+ // CHECK-LABEL: } // end sil function 'cse_ossa_interioruseswithinarg '
853
+ sil [ossa] @cse_ossa_interioruseswithinarg : $@convention(thin) (@guaranteed TestKlass) -> () {
851
854
bb0(%0 : @guaranteed $TestKlass):
852
855
%1 = ref_element_addr %0 : $TestKlass, #TestKlass.testStruct
853
856
%2 = begin_access [modify] [dynamic] %1 : $*NonTrivialStruct
@@ -865,6 +868,34 @@ bb0(%0 : @guaranteed $TestKlass):
865
868
return %139 : $()
866
869
}
867
870
871
+ // An interior pointer, struct_element_addr, cannot be reused without
872
+ // cloning the access scope, which we don't do. The two
873
+ // struct_element_addr's are not currently considered equivalent.
874
+ //
875
+ // CHECK-LABEL: sil [ossa] @cse_ossa_outsideaccessscope :
876
+ // CHECK: struct_element_addr
877
+ // CHECK: struct_element_addr
878
+ // CHECK-LABEL: } // end sil function 'cse_ossa_outsideaccessscope'
879
+ sil [ossa] @cse_ossa_outsideaccessscope : $@convention(thin) (@guaranteed TestKlass) -> () {
880
+ bb0(%0 : @guaranteed $TestKlass):
881
+ %1 = ref_element_addr %0 : $TestKlass, #TestKlass.testStruct
882
+ %a1 = begin_access [modify] [dynamic] %1 : $*NonTrivialStruct
883
+ %e1 = struct_element_addr %a1 : $*NonTrivialStruct, #NonTrivialStruct.val
884
+ %l1 = load_borrow %e1 : $*Klass
885
+ end_access %a1 : $*NonTrivialStruct
886
+ %f = function_ref @use_klass : $@convention(thin) (@guaranteed Klass) -> ()
887
+ %c1 = apply %f(%l1) : $@convention(thin) (@guaranteed Klass) -> ()
888
+ end_borrow %l1 : $Klass
889
+ %a2 = begin_access [modify] [dynamic] %1 : $*NonTrivialStruct
890
+ %e2 = struct_element_addr %a2 : $*NonTrivialStruct, #NonTrivialStruct.val
891
+ %l2 = load_borrow %e2 : $*Klass
892
+ end_access %a2 : $*NonTrivialStruct
893
+ %c2 = apply %f(%l2) : $@convention(thin) (@guaranteed Klass) -> ()
894
+ end_borrow %l2 : $Klass
895
+ %139 = tuple ()
896
+ return %139 : $()
897
+ }
898
+
868
899
struct X {
869
900
var i: Int64
870
901
}
0 commit comments