File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
lib/SILOptimizer/Mandatory Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -1663,10 +1663,20 @@ struct CopiedLoadBorrowEliminationVisitor
1663
1663
}
1664
1664
1665
1665
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
+ }
1667
1677
// We can only hit this if our load_borrow was copied.
1668
1678
llvm_unreachable (" We should never hit this" );
1669
-
1679
+ }
1670
1680
case OperandOwnership::GuaranteedForwarding: {
1671
1681
SmallVector<SILValue, 8 > forwardedValues;
1672
1682
auto *fn = nextUse->getUser ()->getFunction ();
You can’t perform that action at this time.
0 commit comments