Skip to content

Commit 886b1f8

Browse files
committed
Revert "[Exclusivity] Check that accesses are well-formed during diagnostics."
1 parent 6fc2efb commit 886b1f8

File tree

2 files changed

+11
-32
lines changed

2 files changed

+11
-32
lines changed

lib/SILOptimizer/Mandatory/DiagnoseStaticExclusivity.cpp

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ static AccessedStorage findAccessedStorage(SILValue Source) {
454454

455455
if (auto *REA = dyn_cast<RefElementAddrInst>(Iter)) {
456456
// Do a best-effort to find the identity of the object being projected
457-
// from. It is OK to be unsound here (i.e. miss when two ref_element_addrs
457+
// from. It is OK to unsound here (i.e., miss when two ref_element_addrs
458458
// actually refer the same address) because these will be dynamically
459459
// checked.
460460
SILValue Object = findUnderlyingObject(REA->getOperand());
@@ -463,27 +463,18 @@ static AccessedStorage findAccessedStorage(SILValue Source) {
463463
return AccessedStorage(AccessedStorageKind::ClassProperty, OP);
464464
}
465465

466-
switch (Iter->getKind()) {
467-
case ValueKind::AllocBoxInst:
468-
// An AllocBox is a fully identified memory location.
469-
LLVM_FALLTHROUGH;
470-
case ValueKind::BeginAccessInst:
471-
// The current access is nested within another access.
472-
// View the outer access as a separate location because nested accesses do
473-
// not conflict with each other.
474-
LLVM_FALLTHROUGH;
475-
case ValueKind::SILFunctionArgument:
476-
// A function argument is effectively a nested access, enforced
477-
// independently in the caller and callee.
478-
LLVM_FALLTHROUGH;
479-
case ValueKind::PointerToAddressInst:
480-
// An addressor provides access to a global or class property via a
481-
// RawPointer. Calling the address casts that raw pointer to an address.
466+
if (isa<AllocBoxInst>(Iter) || isa<BeginAccessInst>(Iter) ||
467+
isa<SILFunctionArgument>(Iter)) {
468+
// Treat the instruction itself as the identity of the storage being
469+
// being accessed.
482470
return AccessedStorage(Iter);
483-
default:
484-
DEBUG(llvm::dbgs() << "Bad memory access source: " << Iter);
485-
llvm_unreachable("Unexpected access source.");
486471
}
472+
473+
// For now we're still allowing arbitrary addresses here. Once
474+
// we start doing a best-effort static check for dynamically-enforced
475+
// accesses we should lock this down to only recognized sources.
476+
assert(Iter->getType().isAddress() || Iter->getType().is<SILBoxType>());
477+
return AccessedStorage(Iter);
487478
}
488479
}
489480

test/SILOptimizer/exclusivity_static_diagnostics.sil

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -462,15 +462,3 @@ bb23:
462462
bbUnreachable:
463463
br bb22
464464
}
465-
466-
// Check that a pointer_to_address access passes diagnostics.
467-
//
468-
// CHECK-LABEL: sil hidden @pointerToAddr
469-
sil hidden @pointerToAddr : $@convention(thin) (Builtin.RawPointer) -> Int {
470-
bb0(%0: $Builtin.RawPointer):
471-
%adr = pointer_to_address %0 : $Builtin.RawPointer to [strict] $*Int
472-
%access = begin_access [read] [dynamic] %adr : $*Int
473-
%val = load [trivial] %access : $*Int
474-
end_access %access : $*Int
475-
return %val : $Int
476-
}

0 commit comments

Comments
 (0)