File tree Expand file tree Collapse file tree 4 files changed +63
-3
lines changed
SwiftCompilerSources/Sources/SIL/Utilities Expand file tree Collapse file tree 4 files changed +63
-3
lines changed Original file line number Diff line number Diff line change @@ -156,15 +156,20 @@ extension LoadBorrowInst : VerifiableInstruction {
156156
157157extension BeginAccessInst : VerifiableInstruction {
158158 func verify( _ context: VerifierContext ) {
159- if context. silStage == . raw {
160- return
161- }
162159 // Catch violations like
163160 // ```
164161 // %1 = begin_access [read] %0
165162 // store %2 to %0
166163 // end_access %1
167164 // ```
165+
166+ guard context. silStage == . canonical else {
167+ // Mandatory passes on raw SIL need to be completed until we can verify this.
168+ // Also, LoadableByAddress in lowered SIL can insert `copy_addr`s inside read-only access scope.
169+ // Therefore we can only run this verification in canonical SIL.
170+ return
171+ }
172+
168173 if address. type. isMoveOnly && enforcement == . static {
169174 // This is a workaround for a bug in the move-only checker: rdar://151841926.
170175 // The move-only checker sometimes inserts destroy_addr within read-only static access scopes.
Original file line number Diff line number Diff line change 1+ // RUN: not --crash %target-sil-opt %s -o /dev/null
2+
3+ // REQUIRES: asserts
4+
5+ sil_stage canonical
6+
7+ import Builtin
8+ import Swift
9+
10+ sil [ossa] @write_in_read_only_scope : $@convention(thin) (@inout Int, Int) -> () {
11+ bb0(%0 : $*Int, %1 : $Int):
12+ %2 = begin_access [read] [static] %0
13+ store %1 to [trivial] %0
14+ end_access %2
15+ %5 = tuple()
16+ return %5
17+ }
Original file line number Diff line number Diff line change 1+ // RUN: %target-sil-opt %s -o /dev/null
2+
3+ // REQUIRES: asserts
4+
5+ sil_stage raw
6+
7+ // Need to complete mandatory passes until we can verify that there are no stores in read-only access scopes.
8+
9+ import Builtin
10+ import Swift
11+
12+ sil [ossa] @write_in_read_only_scope : $@convention(thin) (@inout Int, Int) -> () {
13+ bb0(%0 : $*Int, %1 : $Int):
14+ %2 = begin_access [read] [static] %0
15+ store %1 to [trivial] %0
16+ end_access %2
17+ %5 = tuple()
18+ return %5
19+ }
Original file line number Diff line number Diff line change 1+ // RUN: %target-sil-opt %s -o /dev/null
2+
3+ // REQUIRES: asserts
4+
5+ sil_stage lowered
6+
7+ // LoadableByAddress in lowered SIL can insert copy_addrs inside read-only access scope.
8+
9+ import Builtin
10+ import Swift
11+
12+ sil [ossa] @write_in_read_only_scope : $@convention(thin) (@inout Int, Int) -> () {
13+ bb0(%0 : $*Int, %1 : $Int):
14+ %2 = begin_access [read] [static] %0
15+ store %1 to [trivial] %0
16+ end_access %2
17+ %5 = tuple()
18+ return %5
19+ }
You can’t perform that action at this time.
0 commit comments