@@ -1698,6 +1698,16 @@ template<typename ImplClass>
16981698void
16991699SILCloner<ImplClass>::visitCopyAddrInst(CopyAddrInst *Inst) {
17001700 getBuilder ().setCurrentDebugScope (getOpScope (Inst->getDebugScope ()));
1701+ // When cloning into a function using manual ownership, convert to explicit
1702+ // copies, in order to preserve the local nature of the perf constraint.
1703+ if (getBuilder ().hasManualOwnershipAttr () && getBuilder ().hasOwnership ()) {
1704+ recordClonedInstruction (
1705+ Inst, getBuilder ().createExplicitCopyAddr (
1706+ getOpLocation (Inst->getLoc ()), getOpValue (Inst->getSrc ()),
1707+ getOpValue (Inst->getDest ()), Inst->isTakeOfSrc (),
1708+ Inst->isInitializationOfDest ()));
1709+ return ;
1710+ }
17011711 recordClonedInstruction (
17021712 Inst, getBuilder ().createCopyAddr (
17031713 getOpLocation (Inst->getLoc ()), getOpValue (Inst->getSrc ()),
@@ -2092,6 +2102,15 @@ void SILCloner<ImplClass>::visitCopyValueInst(CopyValueInst *Inst) {
20922102 return recordFoldedValue (Inst, newValue);
20932103 }
20942104
2105+ // When cloning into a function using manual ownership, convert to explicit
2106+ // copies, in order to preserve the local nature of the perf constraint.
2107+ if (getBuilder ().hasManualOwnershipAttr () && getBuilder ().hasOwnership ()) {
2108+ recordClonedInstruction (
2109+ Inst, getBuilder ().createExplicitCopyValue (getOpLocation (Inst->getLoc ()),
2110+ getOpValue (Inst->getOperand ())));
2111+ return ;
2112+ }
2113+
20952114 recordClonedInstruction (
20962115 Inst, getBuilder ().createCopyValue (getOpLocation (Inst->getLoc ()),
20972116 getOpValue (Inst->getOperand ())));
0 commit comments