@@ -510,8 +510,7 @@ class LetValueInitialization : public Initialization {
510
510
public:
511
511
LetValueInitialization (VarDecl *vd, SILGenFunction &SGF) : vd(vd) {
512
512
const TypeLowering *lowering = nullptr ;
513
- if (SGF.getASTContext ().LangOpts .Features .count (Feature::MoveOnly) &&
514
- vd->isNoImplicitCopy ()) {
513
+ if (vd->isNoImplicitCopy ()) {
515
514
lowering = &SGF.getTypeLowering (
516
515
SILMoveOnlyWrappedType::get (vd->getType ()->getCanonicalType ()));
517
516
} else {
@@ -551,8 +550,7 @@ class LetValueInitialization : public Initialization {
551
550
552
551
// Make sure that we have a non-address only type when binding a
553
552
// @_noImplicitCopy let.
554
- if (SGF.getASTContext ().LangOpts .Features .count (Feature::MoveOnly) &&
555
- lowering->isAddressOnly () && vd->isNoImplicitCopy ()) {
553
+ if (lowering->isAddressOnly () && vd->isNoImplicitCopy ()) {
556
554
auto d = diag::noimplicitcopy_used_on_generic_or_existential;
557
555
diagnose (SGF.getASTContext (), vd->getLoc (), d);
558
556
}
@@ -630,10 +628,6 @@ class LetValueInitialization : public Initialization {
630
628
SILValue value, bool wasPlusOne) {
631
629
// If we have none...
632
630
if (value->getOwnershipKind () == OwnershipKind::None) {
633
- // If we don't have move only features enabled, just return, we are done.
634
- if (!SGF.getASTContext ().LangOpts .Features .count (Feature::MoveOnly))
635
- return value;
636
-
637
631
// Then check if we have a pure move only type. In that case, we need to
638
632
// insert a no implicit copy
639
633
if (value->getType ().isPureMoveOnly ()) {
@@ -658,15 +652,6 @@ class LetValueInitialization : public Initialization {
658
652
MarkMustCheckInst::CheckKind::ConsumableAndAssignable);
659
653
}
660
654
661
- // Then if we don't have move only, just perform a lexical borrow if the
662
- // lifetime is lexical.
663
- if (!SGF.getASTContext ().LangOpts .Features .count (Feature::MoveOnly)) {
664
- if (SGF.F .getLifetime (vd, value->getType ()).isLexical ())
665
- return SGF.B .createBeginBorrow (PrologueLoc, value, /* isLexical*/ true );
666
- else
667
- return value;
668
- }
669
-
670
655
// Otherwise, we need to perform some additional processing. First, if we
671
656
// have an owned moveonly value that had a cleanup, then create a move_value
672
657
// that acts as a consuming use of the value. The reason why we want this is
@@ -2025,35 +2010,22 @@ void SILGenFunction::destroyLocalVariable(SILLocation silLoc, VarDecl *vd) {
2025
2010
return ;
2026
2011
}
2027
2012
2028
- if (getASTContext ().LangOpts .hasFeature (Feature::MoveOnly)) {
2029
- if (auto *mvi = dyn_cast<MarkMustCheckInst>(Val.getDefiningInstruction ())) {
2030
- if (mvi->hasMoveCheckerKind ()) {
2031
- if (auto *cvi = dyn_cast<CopyValueInst>(mvi->getOperand ())) {
2032
- if (auto *bbi = dyn_cast<BeginBorrowInst>(cvi->getOperand ())) {
2033
- if (bbi->isLexical ()) {
2034
- B.emitDestroyValueOperation (silLoc, mvi);
2035
- B.createEndBorrow (silLoc, bbi);
2036
- B.emitDestroyValueOperation (silLoc, bbi->getOperand ());
2037
- return ;
2038
- }
2039
- }
2040
- }
2041
-
2042
- if (auto *copyToMove = dyn_cast<CopyableToMoveOnlyWrapperValueInst>(
2043
- mvi->getOperand ())) {
2044
- if (auto *cvi = dyn_cast<CopyValueInst>(copyToMove->getOperand ())) {
2045
- if (auto *bbi = dyn_cast<BeginBorrowInst>(cvi->getOperand ())) {
2046
- if (bbi->isLexical ()) {
2047
- B.emitDestroyValueOperation (silLoc, mvi);
2048
- B.createEndBorrow (silLoc, bbi);
2049
- B.emitDestroyValueOperation (silLoc, bbi->getOperand ());
2050
- return ;
2051
- }
2052
- }
2013
+ if (auto *mvi = dyn_cast<MarkMustCheckInst>(Val.getDefiningInstruction ())) {
2014
+ if (mvi->hasMoveCheckerKind ()) {
2015
+ if (auto *cvi = dyn_cast<CopyValueInst>(mvi->getOperand ())) {
2016
+ if (auto *bbi = dyn_cast<BeginBorrowInst>(cvi->getOperand ())) {
2017
+ if (bbi->isLexical ()) {
2018
+ B.emitDestroyValueOperation (silLoc, mvi);
2019
+ B.createEndBorrow (silLoc, bbi);
2020
+ B.emitDestroyValueOperation (silLoc, bbi->getOperand ());
2021
+ return ;
2053
2022
}
2054
2023
}
2024
+ }
2055
2025
2056
- if (auto *cvi = dyn_cast<ExplicitCopyValueInst>(mvi->getOperand ())) {
2026
+ if (auto *copyToMove = dyn_cast<CopyableToMoveOnlyWrapperValueInst>(
2027
+ mvi->getOperand ())) {
2028
+ if (auto *cvi = dyn_cast<CopyValueInst>(copyToMove->getOperand ())) {
2057
2029
if (auto *bbi = dyn_cast<BeginBorrowInst>(cvi->getOperand ())) {
2058
2030
if (bbi->isLexical ()) {
2059
2031
B.emitDestroyValueOperation (silLoc, mvi);
@@ -2063,15 +2035,26 @@ void SILGenFunction::destroyLocalVariable(SILLocation silLoc, VarDecl *vd) {
2063
2035
}
2064
2036
}
2065
2037
}
2038
+ }
2066
2039
2067
- // Handle trivial arguments.
2068
- if (auto *move = dyn_cast<MoveValueInst>(mvi ->getOperand ())) {
2069
- if (move ->isLexical ()) {
2040
+ if ( auto *cvi = dyn_cast<ExplicitCopyValueInst>(mvi-> getOperand ())) {
2041
+ if (auto *bbi = dyn_cast<BeginBorrowInst>(cvi ->getOperand ())) {
2042
+ if (bbi ->isLexical ()) {
2070
2043
B.emitDestroyValueOperation (silLoc, mvi);
2044
+ B.createEndBorrow (silLoc, bbi);
2045
+ B.emitDestroyValueOperation (silLoc, bbi->getOperand ());
2071
2046
return ;
2072
2047
}
2073
2048
}
2074
2049
}
2050
+
2051
+ // Handle trivial arguments.
2052
+ if (auto *move = dyn_cast<MoveValueInst>(mvi->getOperand ())) {
2053
+ if (move->isLexical ()) {
2054
+ B.emitDestroyValueOperation (silLoc, mvi);
2055
+ return ;
2056
+ }
2057
+ }
2075
2058
}
2076
2059
}
2077
2060
0 commit comments