@@ -1484,11 +1484,20 @@ template <typename ImplClass>
14841484void SILCloner<ImplClass>::visitExplicitCopyAddrInst(
14851485 ExplicitCopyAddrInst *Inst) {
14861486 getBuilder ().setCurrentDebugScope (getOpScope (Inst->getDebugScope ()));
1487- recordClonedInstruction (
1488- Inst, getBuilder ().createExplicitCopyAddr (
1489- getOpLocation (Inst->getLoc ()), getOpValue (Inst->getSrc ()),
1490- getOpValue (Inst->getDest ()), Inst->isTakeOfSrc (),
1491- Inst->isInitializationOfDest ()));
1487+ if (!getBuilder ().hasOwnership ()) {
1488+ recordClonedInstruction (
1489+ Inst, getBuilder ().createCopyAddr (
1490+ getOpLocation (Inst->getLoc ()), getOpValue (Inst->getSrc ()),
1491+ getOpValue (Inst->getDest ()), Inst->isTakeOfSrc (),
1492+ Inst->isInitializationOfDest ()));
1493+ } else {
1494+ // preserve the explicit_*
1495+ recordClonedInstruction (
1496+ Inst, getBuilder ().createExplicitCopyAddr (
1497+ getOpLocation (Inst->getLoc ()), getOpValue (Inst->getSrc ()),
1498+ getOpValue (Inst->getDest ()), Inst->isTakeOfSrc (),
1499+ Inst->isInitializationOfDest ()));
1500+ }
14921501}
14931502
14941503template <typename ImplClass>
0 commit comments