File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed
SwiftCompilerSources/Sources/SIL/Utilities Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -258,6 +258,15 @@ private struct MutatingUsesWalker : AddressDefUseWalker {
258258 }
259259 }
260260
261+ mutating func walkDown( address: Operand , path: UnusedWalkingPath ) -> WalkResult {
262+ if let beginAccess = address. instruction as? BeginAccessInst , beginAccess. accessKind != . read {
263+ // Don't verify that there are no stores in read-only access scopes if there is a conflicting scope.
264+ // This is a programming error, but the compiler should not crash. The violation is caught at runtime.
265+ return . continueWalk
266+ }
267+ return walkDownDefault ( address: address, path: path)
268+ }
269+
261270 mutating func leafUse( address: Operand , path: UnusedWalkingPath ) -> WalkResult {
262271 if address. isMutatedAddress {
263272 mutatingInstructions. insert ( address. instruction)
@@ -288,7 +297,7 @@ private extension Operand {
288297 {
289298 switch convention {
290299 case . indirectIn, . indirectInGuaranteed:
291- // Such operands are consumed by the `partial_apply` and therefore cound as "written".
300+ // Such operands are consumed by the `partial_apply` and therefore count as "written".
292301 return true
293302 default :
294303 return false
Original file line number Diff line number Diff line change 1+
2+ // RUN: %target-sil-opt %s -o /dev/null
3+
4+ // REQUIRES: asserts
5+
6+ sil_stage canonical
7+
8+ // Don't verify that there are no stores in read-only access scopes if there is a conflicting scope.
9+ // This is a programming error, but the compiler should not crash. The violation is caught at runtime.
10+
11+ import Builtin
12+ import Swift
13+
14+ sil_global @g : $Int
15+
16+ sil [ossa] @write_in_read_only_scope : $@convention(thin) (Int) -> () {
17+ bb0(%0 : $Int):
18+ %1 = global_addr @g : $*Int
19+ %2 = begin_access [read] [dynamic] %1
20+ %3 = begin_access [modify] [dynamic] %1
21+ store %0 to [trivial] %3
22+ end_access %3
23+ end_access %2
24+ %7 = tuple()
25+ return %7
26+ }
You can’t perform that action at this time.
0 commit comments