Skip to content

Commit dc9d132

Browse files
committed
Treat is_unique as a read in LoadBorrowImmutabilityChecker
1 parent 3efa18f commit dc9d132

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/SIL/Verifier/LoadBorrowImmutabilityChecker.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ bool GatherWritesVisitor::visitUse(Operand *op, AccessUseType useTy) {
9797
case SILInstructionKind::DeallocBoxInst:
9898
case SILInstructionKind::WitnessMethodInst:
9999
case SILInstructionKind::ExistentialMetatypeInst:
100+
case SILInstructionKind::IsUniqueInst:
100101
return true;
101102

102103
// Known writes...

test/SIL/ownership-verifier/load_borrow_invalidation_test.sil

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,3 +395,17 @@ bb0(%0 : @owned $Builtin.NativeObject):
395395
%9999 = tuple()
396396
return %9999 : $()
397397
}
398+
399+
struct Bool {
400+
var _value: Builtin.Int1
401+
}
402+
403+
sil [ossa] @test_withisunique : $@convention(method) <Element> (@inout Builtin.NativeObject) -> Bool {
404+
bb0(%0 : $*Builtin.NativeObject):
405+
%1 = is_unique %0 : $*Builtin.NativeObject
406+
%2 = struct $Bool (%1 : $Builtin.Int1)
407+
%3 = load_borrow %0 : $*Builtin.NativeObject
408+
end_borrow %3 : $Builtin.NativeObject
409+
return %2 : $Bool
410+
}
411+

0 commit comments

Comments
 (0)