@@ -620,8 +620,7 @@ class LetValueInitialization : public Initialization {
620620public:
621621 LetValueInitialization (VarDecl *vd, SILGenFunction &SGF) : vd(vd) {
622622 const TypeLowering *lowering = nullptr ;
623- if (SGF.getASTContext ().LangOpts .Features .count (Feature::MoveOnly) &&
624- vd->isNoImplicitCopy ()) {
623+ if (vd->isNoImplicitCopy ()) {
625624 lowering = &SGF.getTypeLowering (
626625 SILMoveOnlyWrappedType::get (vd->getType ()->getCanonicalType ()));
627626 } else {
@@ -661,8 +660,7 @@ class LetValueInitialization : public Initialization {
661660
662661 // Make sure that we have a non-address only type when binding a
663662 // @_noImplicitCopy let.
664- if (SGF.getASTContext ().LangOpts .Features .count (Feature::MoveOnly) &&
665- lowering->isAddressOnly () && vd->isNoImplicitCopy ()) {
663+ if (lowering->isAddressOnly () && vd->isNoImplicitCopy ()) {
666664 auto d = diag::noimplicitcopy_used_on_generic_or_existential;
667665 diagnose (SGF.getASTContext (), vd->getLoc (), d);
668666 }
@@ -740,10 +738,6 @@ class LetValueInitialization : public Initialization {
740738 SILValue value, bool wasPlusOne) {
741739 // If we have none...
742740 if (value->getOwnershipKind () == OwnershipKind::None) {
743- // If we don't have move only features enabled, just return, we are done.
744- if (!SGF.getASTContext ().LangOpts .Features .count (Feature::MoveOnly))
745- return value;
746-
747741 // Then check if we have a pure move only type. In that case, we need to
748742 // insert a no implicit copy
749743 if (value->getType ().isPureMoveOnly ()) {
@@ -768,15 +762,6 @@ class LetValueInitialization : public Initialization {
768762 MarkMustCheckInst::CheckKind::ConsumableAndAssignable);
769763 }
770764
771- // Then if we don't have move only, just perform a lexical borrow if the
772- // lifetime is lexical.
773- if (!SGF.getASTContext ().LangOpts .Features .count (Feature::MoveOnly)) {
774- if (SGF.F .getLifetime (vd, value->getType ()).isLexical ())
775- return SGF.B .createBeginBorrow (PrologueLoc, value, /* isLexical*/ true );
776- else
777- return value;
778- }
779-
780765 // Otherwise, we need to perform some additional processing. First, if we
781766 // have an owned moveonly value that had a cleanup, then create a move_value
782767 // that acts as a consuming use of the value. The reason why we want this is
@@ -2136,35 +2121,22 @@ void SILGenFunction::destroyLocalVariable(SILLocation silLoc, VarDecl *vd) {
21362121 return ;
21372122 }
21382123
2139- if (getASTContext ().LangOpts .hasFeature (Feature::MoveOnly)) {
2140- if (auto *mvi = dyn_cast<MarkMustCheckInst>(Val.getDefiningInstruction ())) {
2141- if (mvi->hasMoveCheckerKind ()) {
2142- if (auto *cvi = dyn_cast<CopyValueInst>(mvi->getOperand ())) {
2143- if (auto *bbi = dyn_cast<BeginBorrowInst>(cvi->getOperand ())) {
2144- if (bbi->isLexical ()) {
2145- B.emitDestroyValueOperation (silLoc, mvi);
2146- B.createEndBorrow (silLoc, bbi);
2147- B.emitDestroyValueOperation (silLoc, bbi->getOperand ());
2148- return ;
2149- }
2150- }
2151- }
2152-
2153- if (auto *copyToMove = dyn_cast<CopyableToMoveOnlyWrapperValueInst>(
2154- mvi->getOperand ())) {
2155- if (auto *cvi = dyn_cast<CopyValueInst>(copyToMove->getOperand ())) {
2156- if (auto *bbi = dyn_cast<BeginBorrowInst>(cvi->getOperand ())) {
2157- if (bbi->isLexical ()) {
2158- B.emitDestroyValueOperation (silLoc, mvi);
2159- B.createEndBorrow (silLoc, bbi);
2160- B.emitDestroyValueOperation (silLoc, bbi->getOperand ());
2161- return ;
2162- }
2163- }
2124+ if (auto *mvi = dyn_cast<MarkMustCheckInst>(Val.getDefiningInstruction ())) {
2125+ if (mvi->hasMoveCheckerKind ()) {
2126+ if (auto *cvi = dyn_cast<CopyValueInst>(mvi->getOperand ())) {
2127+ if (auto *bbi = dyn_cast<BeginBorrowInst>(cvi->getOperand ())) {
2128+ if (bbi->isLexical ()) {
2129+ B.emitDestroyValueOperation (silLoc, mvi);
2130+ B.createEndBorrow (silLoc, bbi);
2131+ B.emitDestroyValueOperation (silLoc, bbi->getOperand ());
2132+ return ;
21642133 }
21652134 }
2135+ }
21662136
2167- if (auto *cvi = dyn_cast<ExplicitCopyValueInst>(mvi->getOperand ())) {
2137+ if (auto *copyToMove = dyn_cast<CopyableToMoveOnlyWrapperValueInst>(
2138+ mvi->getOperand ())) {
2139+ if (auto *cvi = dyn_cast<CopyValueInst>(copyToMove->getOperand ())) {
21682140 if (auto *bbi = dyn_cast<BeginBorrowInst>(cvi->getOperand ())) {
21692141 if (bbi->isLexical ()) {
21702142 B.emitDestroyValueOperation (silLoc, mvi);
@@ -2174,15 +2146,26 @@ void SILGenFunction::destroyLocalVariable(SILLocation silLoc, VarDecl *vd) {
21742146 }
21752147 }
21762148 }
2149+ }
21772150
2178- // Handle trivial arguments.
2179- if (auto *move = dyn_cast<MoveValueInst>(mvi ->getOperand ())) {
2180- if (move ->isLexical ()) {
2151+ if ( auto *cvi = dyn_cast<ExplicitCopyValueInst>(mvi-> getOperand ())) {
2152+ if (auto *bbi = dyn_cast<BeginBorrowInst>(cvi ->getOperand ())) {
2153+ if (bbi ->isLexical ()) {
21812154 B.emitDestroyValueOperation (silLoc, mvi);
2155+ B.createEndBorrow (silLoc, bbi);
2156+ B.emitDestroyValueOperation (silLoc, bbi->getOperand ());
21822157 return ;
21832158 }
21842159 }
21852160 }
2161+
2162+ // Handle trivial arguments.
2163+ if (auto *move = dyn_cast<MoveValueInst>(mvi->getOperand ())) {
2164+ if (move->isLexical ()) {
2165+ B.emitDestroyValueOperation (silLoc, mvi);
2166+ return ;
2167+ }
2168+ }
21862169 }
21872170 }
21882171
0 commit comments