File tree Expand file tree Collapse file tree 3 files changed +50
-3
lines changed
test/SIL/OwnershipVerifier Expand file tree Collapse file tree 3 files changed +50
-3
lines changed Original file line number Diff line number Diff line change @@ -363,9 +363,9 @@ bool LoadBorrowImmutabilityAnalysis::isImmutable(LoadBorrowInst *lbi) {
363
363
// cases to try and exhaustively identify if those writes overlap with our
364
364
// load_borrow.
365
365
SmallVector<Operand *, 8 > endBorrowUses;
366
- transform (lbi-> getUsersOfType <EndBorrowInst>(),
367
- std::back_inserter ( endBorrowUses),
368
- [](EndBorrowInst *ebi) { return &ebi-> getAllOperands ()[ 0 ]; });
366
+ visitTransitiveEndBorrows (lbi, [&](EndBorrowInst *endBorrow) {
367
+ endBorrowUses. push_back (&endBorrow-> getOperandRef ());
368
+ });
369
369
370
370
switch (accessPath.getStorage ().getKind ()) {
371
371
case AccessStorage::Nested: {
Original file line number Diff line number Diff line change @@ -153,3 +153,23 @@ bb0(%0 : @owned $K):
153
153
return %r : $()
154
154
}
155
155
156
+ sil @use_guaranteed : $@convention(thin) (@guaranteed K) -> ()
157
+
158
+ sil [ossa] @test_write_reborrow : $@convention(thin) (@owned K, @owned K) -> () {
159
+ bb0(%0 : @owned $K, %1 : @owned $K):
160
+ %stk = alloc_stack [lexical] $K
161
+ store %0 to [init] %stk : $*K
162
+ %ld1 = load_borrow %stk : $*K
163
+ br bb2(%ld1 : $K)
164
+
165
+ bb2(%ld : @guaranteed $K):
166
+ %3 = function_ref @use_guaranteed : $@convention(thin) (@guaranteed K) -> ()
167
+ %4 = apply %3(%ld) : $@convention(thin) (@guaranteed K) -> ()
168
+ end_borrow %ld : $K
169
+ store %1 to [assign] %stk : $*K
170
+ destroy_addr %stk : $*K
171
+ dealloc_stack %stk : $*K
172
+ %6 = tuple ()
173
+ return %6 : $()
174
+ }
175
+
Original file line number Diff line number Diff line change
1
+ // RUN: %target-sil-opt %s -verify-continue-on-failure=true -o /dev/null 2>&1 | %FileCheck %s
2
+
3
+ class Klass {}
4
+
5
+ sil @use_guaranteed : $@convention(thin) (@guaranteed Klass) -> ()
6
+
7
+ // Write: store {{.*}} [assign] {{.*}}
8
+ // CHECK: Begin Error in function test_write_reborrow
9
+ // CHECK: SIL verification failed: Found load borrow that is invalidated by a local write?!: loadBorrowImmutabilityAnalysis.isImmutable(LBI)
10
+ // CHECK: End Error in function test_write_reborrow
11
+ sil [ossa] @test_write_reborrow : $@convention(thin) (@owned Klass, @owned Klass) -> () {
12
+ bb0(%0 : @owned $Klass, %1 : @owned $Klass):
13
+ %stk = alloc_stack [lexical] $Klass
14
+ store %0 to [init] %stk : $*Klass
15
+ %ld1 = load_borrow %stk : $*Klass
16
+ br bb2(%ld1 : $Klass)
17
+
18
+ bb2(%ld : @guaranteed $Klass):
19
+ store %1 to [assign] %stk : $*Klass
20
+ %3 = function_ref @use_guaranteed : $@convention(thin) (@guaranteed Klass) -> ()
21
+ %4 = apply %3(%ld) : $@convention(thin) (@guaranteed Klass) -> ()
22
+ end_borrow %ld : $Klass
23
+ destroy_addr %stk : $*Klass
24
+ dealloc_stack %stk : $*Klass
25
+ %6 = tuple ()
26
+ return %6 : $()
27
+ }
You can’t perform that action at this time.
0 commit comments