@@ -660,24 +660,27 @@ void SILInlineCloner::visitBuiltinInst(BuiltinInst *Inst) {
660660 auto otherResultAddr = getOpValue (Inst->getOperand (0 ));
661661 auto otherSrcAddr = getOpValue (Inst->getOperand (1 ));
662662 auto otherType = otherSrcAddr->getType ();
663-
664- if (!otherType.isLoadable (*Inst->getFunction ())) {
665- // If otherType is not loadable, emit a diagnostic since it was used
666- // on a generic or existential value.
667- diagnose (Inst->getModule ().getASTContext (),
668- getOpLocation (Inst->getLoc ()).getSourceLoc (),
669- diag::move_operator_used_on_generic_or_existential_value);
670- return SILCloner<SILInlineCloner>::visitBuiltinInst (Inst);
671- }
663+ auto opLoc = getOpLocation (Inst->getLoc ());
672664
673665 // If our otherType is loadable, convert it to move_value.
674666 getBuilder ().setCurrentDebugScope (getOpScope (Inst->getDebugScope ()));
675- // We stash otherValue in originalOtherValue in case we need to
676- // perform a writeback.
677- auto opLoc = getOpLocation (Inst->getLoc ());
667+
668+ if (!otherType.isLoadable (*Inst->getFunction ())) {
669+ // If otherType is not loadable, convert the builtin to a
670+ // mark_unresolved_move_addr. This builtin is a +1, but
671+ // mark_unresolved_move_addr simulates a +0, so we put in our own
672+ // destroy_addr.
673+ getBuilder ().createMarkUnresolvedMoveAddr (opLoc, otherSrcAddr,
674+ otherResultAddr);
675+ getBuilder ().createDestroyAddr (opLoc, otherSrcAddr);
676+ auto *tup = getBuilder ().createTuple (opLoc, {});
677+ return recordFoldedValue (Inst, tup);
678+ }
678679
679680 assert (otherType.isAddress ());
680681
682+ // We stash otherValue in originalOtherValue in case we need to
683+ // perform a writeback.
681684 SILValue otherValue = getBuilder ().emitLoadValueOperation (
682685 opLoc, otherSrcAddr, LoadOwnershipQualifier::Take);
683686
0 commit comments