Skip to content

Commit 9984b81

Browse files
committedAug 7, 2021
MemAccessUtils cleanup: rename hasIdenticalBase
to hasIdenticalStorage. Be precise in preparation for unifying and clarifying the access base model.
1 parent bdebe03 commit 9984b81

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed
 

‎include/swift/SIL/MemAccessUtils.h

+8-7
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ class AccessedStorage {
485485
/// This compares only the AccessedStorage base class bits, ignoring the
486486
/// subclass bits. It is used for hash lookup equality, so it should not
487487
/// perform any additional lookups or dereference memory outside itself.
488-
bool hasIdenticalBase(const AccessedStorage &other) const {
488+
bool hasIdenticalStorage(const AccessedStorage &other) const {
489489
if (getKind() != other.getKind())
490490
return false;
491491

@@ -609,7 +609,7 @@ class AccessedStorage {
609609
template <bool (AccessedStorage::*IsUniqueFn)() const>
610610
bool isDistinctFrom(const AccessedStorage &other) const {
611611
if ((this->*IsUniqueFn)()) {
612-
if ((other.*IsUniqueFn)() && !hasIdenticalBase(other))
612+
if ((other.*IsUniqueFn)() && !hasIdenticalStorage(other))
613613
return true;
614614

615615
if (other.isObjectAccess())
@@ -706,7 +706,7 @@ template <> struct DenseMapInfo<swift::AccessedStorage> {
706706
}
707707

708708
static bool isEqual(swift::AccessedStorage LHS, swift::AccessedStorage RHS) {
709-
return LHS.hasIdenticalBase(RHS);
709+
return LHS.hasIdenticalStorage(RHS);
710710
}
711711
};
712712

@@ -944,8 +944,9 @@ class AccessPath {
944944

945945
bool operator==(AccessPath other) const {
946946
return
947-
storage.hasIdenticalBase(other.storage) && pathNode == other.pathNode &&
948-
offset == other.offset;
947+
storage.hasIdenticalStorage(other.storage)
948+
&& pathNode == other.pathNode
949+
&& offset == other.offset;
949950
}
950951
bool operator!=(AccessPath other) const { return !(*this == other); }
951952

@@ -1220,8 +1221,8 @@ void checkSwitchEnumBlockArg(SILPhiArgument *arg);
12201221
/// This is not a member of AccessedStorage because it only makes sense to use
12211222
/// in SILGen before access markers are emitted, or when verifying access
12221223
/// markers.
1223-
bool isPossibleFormalAccessBase(const AccessedStorage &storage,
1224-
SILFunction *F);
1224+
bool isPossibleFormalAccessStorage(const AccessedStorage &storage,
1225+
SILFunction *F);
12251226

12261227
/// Perform a RAUW operation on begin_access with it's own source operand.
12271228
/// Then erase the begin_access and all associated end_access instructions.

‎lib/SIL/Utils/MemAccessUtils.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ class FindAccessedStorageVisitor
689689
// `storage` may still be invalid. If both `storage` and `foundStorage`
690690
// are invalid, this check passes, but we return an invalid storage
691691
// below.
692-
if (!result.storage->hasIdenticalBase(foundStorage))
692+
if (!result.storage->hasIdenticalStorage(foundStorage))
693693
result.storage = AccessedStorage();
694694
if (result.base != foundBase)
695695
result.base = SILValue();
@@ -777,7 +777,7 @@ bool AccessPath::contains(AccessPath subPath) const {
777777
if (!isValid() || !subPath.isValid()) {
778778
return false;
779779
}
780-
if (!storage.hasIdenticalBase(subPath.storage)) {
780+
if (!storage.hasIdenticalStorage(subPath.storage)) {
781781
return false;
782782
}
783783
// Does the offset index match?
@@ -1228,7 +1228,7 @@ bool AccessPathDefUseTraversal::pushPhiUses(const SILPhiArgument *phi,
12281228
// looking through it. If the phi input differ the its storage is invalid.
12291229
auto phiPath = AccessPath::compute(phi);
12301230
if (phiPath.isValid()) {
1231-
assert(phiPath.getStorage().hasIdenticalBase(storage)
1231+
assert(phiPath.getStorage().hasIdenticalStorage(storage)
12321232
&& "inconsistent phi storage");
12331233
// If the phi paths have different offsets, its path has unknown offset.
12341234
if (phiPath.getOffset() == AccessPath::UnknownOffset) {
@@ -1699,8 +1699,8 @@ void swift::checkSwitchEnumBlockArg(SILPhiArgument *arg) {
16991699
}
17001700
}
17011701

1702-
bool swift::isPossibleFormalAccessBase(const AccessedStorage &storage,
1703-
SILFunction *F) {
1702+
bool swift::isPossibleFormalAccessStorage(const AccessedStorage &storage,
1703+
SILFunction *F) {
17041704
switch (storage.getKind()) {
17051705
case AccessedStorage::Nested:
17061706
assert(false && "don't pass nested storage to this helper");

‎lib/SILGen/SILGenLValue.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ SILValue UnenforcedAccess::beginAccess(SILGenFunction &SGF, SILLocation loc,
619619

620620
auto storage = AccessedStorage::compute(address);
621621
// Unsafe access may have invalid storage (e.g. a RawPointer).
622-
if (storage && !isPossibleFormalAccessBase(storage, &SGF.F))
622+
if (storage && !isPossibleFormalAccessStorage(storage, &SGF.F))
623623
return address;
624624

625625
auto BAI =

‎lib/SILOptimizer/Mandatory/DiagnoseStaticExclusivity.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ static void checkAccessedAddress(Operand *memOper, StorageMap &Accesses) {
10341034

10351035
// Some identifiable addresses can also be recognized as local initialization
10361036
// or other patterns that don't qualify as formal access.
1037-
if (!isPossibleFormalAccessBase(storage, memInst->getFunction()))
1037+
if (!isPossibleFormalAccessStorage(storage, memInst->getFunction()))
10381038
return;
10391039

10401040
// A box or stack variable may represent lvalues, but they can only conflict

‎lib/SILOptimizer/Transforms/AccessEnforcementOpts.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ BeginAccessInst *AccessConflictAndMergeAnalysis::findMergeableOutOfScopeAccess(
428428
auto identicalStorageIter = llvm::find_if(
429429
state.outOfScopeConflictFreeAccesses, [&](BeginAccessInst *bai) {
430430
auto storageInfo = result.getAccessInfo(bai);
431-
return storageInfo.hasIdenticalBase(currStorageInfo);
431+
return storageInfo.hasIdenticalStorage(currStorageInfo);
432432
});
433433
if (identicalStorageIter == state.outOfScopeConflictFreeAccesses.end())
434434
return nullptr;
@@ -484,7 +484,7 @@ void AccessConflictAndMergeAnalysis::insertOutOfScopeAccess(
484484
auto identicalStorageIter = llvm::find_if(
485485
state.outOfScopeConflictFreeAccesses, [&](BeginAccessInst *bai) {
486486
auto storageInfo = result.getAccessInfo(bai);
487-
return storageInfo.hasIdenticalBase(currStorageInfo);
487+
return storageInfo.hasIdenticalStorage(currStorageInfo);
488488
});
489489
if (identicalStorageIter == state.outOfScopeConflictFreeAccesses.end())
490490
state.outOfScopeConflictFreeAccesses.insert(beginAccess);

0 commit comments

Comments
 (0)