@@ -684,7 +684,7 @@ entry(%instance : @owned $S):
684
684
%store_scope = begin_access [modify] [static] %addr : $*S
685
685
store %instance to [init] %store_scope : $*S
686
686
end_access %store_scope : $*S
687
- %load_scope = begin_access [read ] [static] %addr : $*S
687
+ %load_scope = begin_access [modify ] [static] %addr : $*S
688
688
%value = load [copy] %load_scope : $*S
689
689
end_access %load_scope : $*S
690
690
destroy_addr %addr : $*S
@@ -703,7 +703,7 @@ entry(%instance : @owned $S):
703
703
%store_scope = begin_access [modify] [static] %addr : $*S
704
704
store %instance to [init] %store_scope : $*S
705
705
end_access %store_scope : $*S
706
- %load_scope = begin_access [read ] [static] %addr : $*S
706
+ %load_scope = begin_access [modify ] [static] %addr : $*S
707
707
%value = load [copy] %load_scope : $*S
708
708
%unknown = function_ref @unknown : $@convention(thin) () -> ()
709
709
apply %unknown() : $@convention(thin) () -> ()
@@ -725,7 +725,7 @@ entry(%instance : @owned $S):
725
725
%store_scope = begin_access [modify] [static] %addr : $*S
726
726
store %instance to [init] %store_scope : $*S
727
727
end_access %store_scope : $*S
728
- %load_scope = begin_access [read ] [static] %addr : $*S
728
+ %load_scope = begin_access [modify ] [static] %addr : $*S
729
729
%value = load [copy] %load_scope : $*S
730
730
%unknown = function_ref @unknown : $@convention(thin) () -> ()
731
731
apply %unknown() : $@convention(thin) () -> ()
@@ -746,7 +746,7 @@ entry(%instance : @owned $S):
746
746
%store_scope = begin_access [modify] [static] %addr : $*S
747
747
store %instance to [init] %store_scope : $*S
748
748
end_access %store_scope : $*S
749
- %load_scope = begin_access [read ] [static] %addr : $*S
749
+ %load_scope = begin_access [modify ] [static] %addr : $*S
750
750
%field_addr = struct_element_addr %load_scope : $*S, #S.x
751
751
%field = load [copy] %field_addr : $*X
752
752
end_access %load_scope : $*S
@@ -768,9 +768,9 @@ entry(%instance : @owned $S):
768
768
%store_scope = begin_access [modify] [static] %addr : $*S
769
769
store %instance to [init] %store_scope : $*S
770
770
end_access %store_scope : $*S
771
- %outer = begin_access [read ] [static] %addr : $*S
771
+ %outer = begin_access [modify ] [static] %addr : $*S
772
772
apply undef(%outer) : $@convention(thin) (@inout S) -> ()
773
- %inner = begin_access [read ] [static] %outer : $*S
773
+ %inner = begin_access [modify ] [static] %outer : $*S
774
774
%field_addr = struct_element_addr %inner : $*S, #S.x
775
775
%field_addr_2 = struct_element_addr %addr_2 : $*S, #S.x
776
776
copy_addr %field_addr to [init] %field_addr_2 : $*X
@@ -795,9 +795,9 @@ entry(%instance : @owned $S):
795
795
%store_scope = begin_access [modify] [static] %addr : $*S
796
796
store %instance to [init] %store_scope : $*S
797
797
end_access %store_scope : $*S
798
- %outer = begin_access [read ] [static] %addr : $*S
798
+ %outer = begin_access [modify ] [static] %addr : $*S
799
799
apply undef(%outer) : $@convention(thin) (@inout S) -> ()
800
- %inner = begin_access [read ] [static] %outer : $*S
800
+ %inner = begin_access [modify ] [static] %outer : $*S
801
801
copy_addr %inner to [init] %addr_2 : $*S
802
802
end_access %inner : $*S
803
803
destroy_addr %outer : $*S
@@ -1316,3 +1316,33 @@ bb0(%out : $*TwoCases):
1316
1316
inject_enum_addr %out, #TwoCases.A!enumelt
1317
1317
return %retval
1318
1318
}
1319
+
1320
+ // CHECK-LABEL: sil [ossa] @nofold_read_access_load : {{.*}} {
1321
+ // CHECK: load [copy]
1322
+ // CHECK-LABEL: } // end sil function 'nofold_read_access_load'
1323
+ sil [ossa] @nofold_read_access_load : $@convention(thin) (@in X) -> () {
1324
+ entry(%c_addr : $*X):
1325
+ %c_access = begin_access [dynamic] [read] %c_addr
1326
+ %c = load [copy] %c_access
1327
+ end_access %c_access
1328
+ destroy_addr %c_addr
1329
+ apply undef(%c) : $@convention(thin) (@owned X) -> ()
1330
+ %retval = tuple ()
1331
+ return %retval
1332
+ }
1333
+
1334
+ // CHECK-LABEL: sil [ossa] @nofold_read_access_copy_addr : {{.*}} {
1335
+ // CHECK: copy_addr {{%[^,]+}} to [init]
1336
+ // CHECK-LABEL: } // end sil function 'nofold_read_access_copy_addr'
1337
+ sil [ossa] @nofold_read_access_copy_addr : $@convention(thin) (@in X) -> () {
1338
+ entry(%c_addr : $*X):
1339
+ %stack = alloc_stack $X
1340
+ %c_access = begin_access [dynamic] [read] %c_addr
1341
+ copy_addr %c_access to [init] %stack
1342
+ end_access %c_access
1343
+ destroy_addr %c_addr
1344
+ apply undef(%stack) : $@convention(thin) (@in X) -> ()
1345
+ dealloc_stack %stack
1346
+ %retval = tuple ()
1347
+ return %retval
1348
+ }
0 commit comments