Skip to content

fix a crash in AccessEnforementWMO #42368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions lib/SILOptimizer/Transforms/AccessEnforcementWMO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class GlobalAccessRemoval {
void perform();

protected:
void visitInstruction(SILInstruction *I);
bool visitInstruction(SILInstruction *I);
void recordAccess(SILInstruction *beginAccess, DisjointAccessLocationKey key,
AccessStorage::Kind storageKind, bool hasNoNestedConflict);
void removeNonreentrantAccess();
Expand All @@ -180,27 +180,33 @@ void GlobalAccessRemoval::perform() {
continue;

for (auto &BB : F) {
for (auto &I : BB)
visitInstruction(&I);
for (auto &I : BB) {
if (!visitInstruction(&I))
return;
}
}
}
removeNonreentrantAccess();
}

void GlobalAccessRemoval::visitInstruction(SILInstruction *I) {
bool GlobalAccessRemoval::visitInstruction(SILInstruction *I) {
if (auto *BAI = dyn_cast<BeginAccessInst>(I)) {
auto storageAndBase = AccessStorageWithBase::compute(BAI->getSource());
if (!storageAndBase.base)
return false;
auto key = getDisjointAccessLocation(storageAndBase);
recordAccess(BAI, key, storageAndBase.storage.getKind(),
BAI->hasNoNestedConflict());
return;
return true;
}
if (auto *BUAI = dyn_cast<BeginUnpairedAccessInst>(I)) {
auto storageAndBase = AccessStorageWithBase::compute(BUAI->getSource());
if (!storageAndBase.base)
return false;
auto key = getDisjointAccessLocation(storageAndBase);
recordAccess(BUAI, key, storageAndBase.storage.getKind(),
BUAI->hasNoNestedConflict());
return;
return true;
}
if (auto *KPI = dyn_cast<KeyPathInst>(I)) {
for (const KeyPathPatternComponent &component :
Expand All @@ -219,8 +225,8 @@ void GlobalAccessRemoval::visitInstruction(SILInstruction *I) {
break;
}
}
return;
}
return true;
}

// Record an access in the disjointAccessMap.
Expand Down