File tree Expand file tree Collapse file tree 1 file changed +15
-9
lines changed
lib/SILOptimizer/Transforms Expand file tree Collapse file tree 1 file changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -616,17 +616,23 @@ void TempRValueOptPass::tryOptimizeCopyIntoTemp(CopyAddrInst *copyInst) {
616616 if (lastLoadInst == copyInst)
617617 return true ;
618618 if (auto *cai = dyn_cast<CopyAddrInst>(lastLoadInst)) {
619- auto retval = cai->getSrc () != tempObj || !cai->isTakeOfSrc ();
620- assert (!tempObj->getType ().isMoveOnly () ||
621- !retval && " introducing copy of move-only value!?" );
622- return retval;
619+ if (cai->getSrc () == tempObj && cai->isTakeOfSrc ()) {
620+ // This copy_addr [take] will perform the final deinitialization.
621+ return false ;
622+ }
623+ assert (!tempObj->getType ().isMoveOnly () &&
624+ " introducing copy of move-only value!?" );
625+ return true ;
623626 }
624627 if (auto *li = dyn_cast<LoadInst>(lastLoadInst)) {
625- auto retval = li->getOperand () != tempObj ||
626- li->getOwnershipQualifier () != LoadOwnershipQualifier::Take;
627- assert (!tempObj->getType ().isMoveOnly () ||
628- !retval && " introducing copy of move-only value!?" );
629- return retval;
628+ if (li->getOperand () == tempObj &&
629+ li->getOwnershipQualifier () == LoadOwnershipQualifier::Take) {
630+ // This load [take] will perform the final deinitialization.
631+ return false ;
632+ }
633+ assert (!tempObj->getType ().isMoveOnly () &&
634+ " introducing copy of move-only value!?" );
635+ return true ;
630636 }
631637 return true ;
632638 }();
You can’t perform that action at this time.
0 commit comments