Skip to content

Commit 5373f34

Browse files
committed
Tweak exclusivity access marker verification.
Narrow the list of address producers that verification can "peek through" to avoid trigger an assertion in the previous commit with -enable-verify-exclusivity.
1 parent df0214a commit 5373f34

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

lib/SIL/MemAccessUtils.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,12 @@ AccessedStorage swift::findAccessedStorage(SILValue sourceAddr) {
241241
if (kind != AccessedStorage::Unidentified)
242242
return AccessedStorage(address, kind);
243243

244+
// If the address producer cannot immediately be classified, follow the
245+
// use-def chain of address, box, or RawPointer producers.
246+
assert(address->getType().isAddress()
247+
|| isa<SILBoxType>(address->getType().getASTType())
248+
|| isa<BuiltinRawPointerType>(address->getType().getASTType()));
249+
244250
// Handle other unidentified address sources.
245251
switch (address->getKind()) {
246252
default:
@@ -294,6 +300,12 @@ AccessedStorage swift::findAccessedStorage(SILValue sourceAddr) {
294300
return AccessedStorage();
295301
}
296302

303+
// ref_tail_addr project an address from a reference.
304+
// This is a valid address producer for nested @inout argument
305+
// access, but it is never used for formal access of identified objects.
306+
case ValueKind::RefTailAddrInst:
307+
return AccessedStorage(address, AccessedStorage::Unidentified);
308+
297309
// Inductive cases:
298310
// Look through address casts to find the source address.
299311
case ValueKind::MarkUninitializedInst:
@@ -338,11 +350,10 @@ AccessedStorage swift::findAccessedStorage(SILValue sourceAddr) {
338350
address = cast<SingleValueInstruction>(address)->getOperand(0);
339351
continue;
340352

341-
// Subobject projections.
353+
// Address-to-address subobject projections.
342354
case ValueKind::StructElementAddrInst:
343355
case ValueKind::TupleElementAddrInst:
344356
case ValueKind::UncheckedTakeEnumDataAddrInst:
345-
case ValueKind::RefTailAddrInst:
346357
case ValueKind::TailAddrInst:
347358
case ValueKind::IndexAddrInst:
348359
address = cast<SingleValueInstruction>(address)->getOperand(0);

test/Interpreter/enforce_exclusive_access.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
//
44
// RUN: %target-run %t/a.out
55
// REQUIRES: executable_test
6-
// REQUIRES: rdar41660554
76

87
// Tests for traps at run time when enforcing exclusive access.
98

0 commit comments

Comments
 (0)