Skip to content

Commit 8a512d9

Browse files
committed
Update MoveOnlyAddressCheckerUtils for mutate accessors
1 parent b19bf84 commit 8a512d9

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

include/swift/SIL/SILInstruction.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3162,6 +3162,8 @@ class ApplyInst final
31623162
bool hasAddressResult() const {
31633163
return getSubstCalleeConv().hasAddressResult();
31643164
}
3165+
3166+
bool hasInoutResult() const { return getSubstCalleeConv().hasInoutResult(); }
31653167
};
31663168

31673169
/// PartialApplyInst - Represents the creation of a closure object by partial

lib/SILOptimizer/Mandatory/MoveOnlyAddressCheckerUtils.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,22 @@ static bool visitScopeEndsRequiringInit(
472472
return true;
473473
}
474474

475+
// Check for mutate accessor.
476+
if (auto ai =
477+
dyn_cast_or_null<ApplyInst>(operand->getDefiningInstruction())) {
478+
if (ai->hasInoutResult()) {
479+
auto *access =
480+
dyn_cast<BeginAccessInst>(getAccessScope(ai->getSelfArgument()));
481+
if (access) {
482+
assert(access->getAccessKind() == SILAccessKind::Modify);
483+
for (auto *inst : access->getEndAccesses()) {
484+
visit(inst, ScopeRequiringFinalInit::ModifyMemoryAccess);
485+
}
486+
return true;
487+
}
488+
return false;
489+
}
490+
}
475491
return false;
476492
}
477493

0 commit comments

Comments
 (0)