@@ -620,8 +620,7 @@ class LetValueInitialization : public Initialization {
620
620
public:
621
621
LetValueInitialization (VarDecl *vd, SILGenFunction &SGF) : vd(vd) {
622
622
const TypeLowering *lowering = nullptr ;
623
- if (SGF.getASTContext ().LangOpts .Features .count (Feature::MoveOnly) &&
624
- vd->isNoImplicitCopy ()) {
623
+ if (vd->isNoImplicitCopy ()) {
625
624
lowering = &SGF.getTypeLowering (
626
625
SILMoveOnlyWrappedType::get (vd->getType ()->getCanonicalType ()));
627
626
} else {
@@ -661,8 +660,7 @@ class LetValueInitialization : public Initialization {
661
660
662
661
// Make sure that we have a non-address only type when binding a
663
662
// @_noImplicitCopy let.
664
- if (SGF.getASTContext ().LangOpts .Features .count (Feature::MoveOnly) &&
665
- lowering->isAddressOnly () && vd->isNoImplicitCopy ()) {
663
+ if (lowering->isAddressOnly () && vd->isNoImplicitCopy ()) {
666
664
auto d = diag::noimplicitcopy_used_on_generic_or_existential;
667
665
diagnose (SGF.getASTContext (), vd->getLoc (), d);
668
666
}
@@ -740,10 +738,6 @@ class LetValueInitialization : public Initialization {
740
738
SILValue value, bool wasPlusOne) {
741
739
// If we have none...
742
740
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
-
747
741
// Then check if we have a pure move only type. In that case, we need to
748
742
// insert a no implicit copy
749
743
if (value->getType ().isPureMoveOnly ()) {
@@ -768,15 +762,6 @@ class LetValueInitialization : public Initialization {
768
762
MarkMustCheckInst::CheckKind::ConsumableAndAssignable);
769
763
}
770
764
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
-
780
765
// Otherwise, we need to perform some additional processing. First, if we
781
766
// have an owned moveonly value that had a cleanup, then create a move_value
782
767
// 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) {
2136
2121
return ;
2137
2122
}
2138
2123
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 ;
2164
2133
}
2165
2134
}
2135
+ }
2166
2136
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 ())) {
2168
2140
if (auto *bbi = dyn_cast<BeginBorrowInst>(cvi->getOperand ())) {
2169
2141
if (bbi->isLexical ()) {
2170
2142
B.emitDestroyValueOperation (silLoc, mvi);
@@ -2174,15 +2146,26 @@ void SILGenFunction::destroyLocalVariable(SILLocation silLoc, VarDecl *vd) {
2174
2146
}
2175
2147
}
2176
2148
}
2149
+ }
2177
2150
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 ()) {
2181
2154
B.emitDestroyValueOperation (silLoc, mvi);
2155
+ B.createEndBorrow (silLoc, bbi);
2156
+ B.emitDestroyValueOperation (silLoc, bbi->getOperand ());
2182
2157
return ;
2183
2158
}
2184
2159
}
2185
2160
}
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
+ }
2186
2169
}
2187
2170
}
2188
2171
0 commit comments