Skip to content

Commit bb1cbe6

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

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,18 @@ 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+
SmallVector<SILBasicBlock *, 8> exitBlocks;
480+
markedAddr->getFunction()->findExitingBlocks(exitBlocks);
481+
for (auto *block : exitBlocks) {
482+
visit(block->getTerminator(), ScopeRequiringFinalInit::InoutArgument);
483+
}
484+
return true;
485+
}
486+
}
475487
return false;
476488
}
477489

0 commit comments

Comments
 (0)