@@ -454,7 +454,7 @@ static AccessedStorage findAccessedStorage(SILValue Source) {
454
454
455
455
if (auto *REA = dyn_cast<RefElementAddrInst>(Iter)) {
456
456
// 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
458
458
// actually refer the same address) because these will be dynamically
459
459
// checked.
460
460
SILValue Object = findUnderlyingObject (REA->getOperand ());
@@ -463,27 +463,18 @@ static AccessedStorage findAccessedStorage(SILValue Source) {
463
463
return AccessedStorage (AccessedStorageKind::ClassProperty, OP);
464
464
}
465
465
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.
482
470
return AccessedStorage (Iter);
483
- default :
484
- DEBUG (llvm::dbgs () << " Bad memory access source: " << Iter);
485
- llvm_unreachable (" Unexpected access source." );
486
471
}
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);
487
478
}
488
479
}
489
480
0 commit comments