Skip to content

Commit 17a3b8a

Browse files
committed
[MoveAddrChecker] load from borrowed value looks through mark_depend
Required to add dependencies to unsafe addressors.
1 parent bdcc409 commit 17a3b8a

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

include/swift/SIL/MemAccessUtils.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,6 +1650,21 @@ inline bool isAccessStorageIdentityCast(SingleValueInstruction *svi) {
16501650
}
16511651
}
16521652

1653+
// Strip access markers and casts that preserve the address type.
1654+
//
1655+
// Consider using RelativeAccessStorageWithBase::compute().
1656+
inline SILValue stripAccessAndIdentityCasts(SILValue v) {
1657+
if (auto *bai = dyn_cast<BeginAccessInst>(v)) {
1658+
return stripAccessAndIdentityCasts(bai->getOperand());
1659+
}
1660+
if (auto *svi = dyn_cast<SingleValueInstruction>(v)) {
1661+
if (isAccessStorageIdentityCast(svi)) {
1662+
return stripAccessAndIdentityCasts(svi->getAllOperands()[0].get());
1663+
}
1664+
}
1665+
return v;
1666+
}
1667+
16531668
/// An address, pointer, or box cast that occurs outside of the formal
16541669
/// access. These convert the base of accessed storage without affecting the
16551670
/// AccessPath. Useful for both use-def and def-use traversal. The source

lib/SILOptimizer/Mandatory/MoveOnlyAddressCheckerUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2379,7 +2379,7 @@ bool GatherUsesVisitor::visitUse(Operand *op) {
23792379
if (moveChecker.canonicalizer.foundAnyConsumingUses()) {
23802380
LLVM_DEBUG(llvm::dbgs()
23812381
<< "Found mark must check [nocopy] error: " << *user);
2382-
auto operand = stripAccessMarkers(markedValue->getOperand());
2382+
auto operand = stripAccessAndIdentityCasts(markedValue->getOperand());
23832383
auto *fArg = dyn_cast<SILFunctionArgument>(operand);
23842384
auto *ptrToAddr = dyn_cast<PointerToAddressInst>(operand);
23852385

0 commit comments

Comments
 (0)