Skip to content

Commit ce59be7

Browse files
committed
[MoveOnlyAddressChecker] OK destroy(pai[onstack])
A destroy_value of an on-stack partial apply isn't actually a consuming use, so don't treat it as one.
1 parent b2afe0d commit ce59be7

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lib/SILOptimizer/Mandatory/MoveOnlyAddressCheckerUtils.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,10 +1663,20 @@ struct CopiedLoadBorrowEliminationVisitor
16631663
}
16641664

16651665
case OperandOwnership::ForwardingConsume:
1666-
case OperandOwnership::DestroyingConsume:
1666+
case OperandOwnership::DestroyingConsume: {
1667+
if (auto *dvi = dyn_cast<DestroyValueInst>(nextUse->getUser())) {
1668+
auto value = dvi->getOperand();
1669+
auto *pai = dyn_cast_or_null<PartialApplyInst>(
1670+
value->getDefiningInstruction());
1671+
if (pai && pai->isOnStack()) {
1672+
// A destroy_value of an on_stack partial apply isn't actually a
1673+
// consuming use--it closes a borrow scope.
1674+
continue;
1675+
}
1676+
}
16671677
// We can only hit this if our load_borrow was copied.
16681678
llvm_unreachable("We should never hit this");
1669-
1679+
}
16701680
case OperandOwnership::GuaranteedForwarding: {
16711681
SmallVector<SILValue, 8> forwardedValues;
16721682
auto *fn = nextUse->getUser()->getFunction();

0 commit comments

Comments
 (0)