Skip to content

Commit b2afe0d

Browse files
committed
[NoncopyablePartialConsumption] Ungate feature.
Remove all checks for the feature flag. It's on all the time.
1 parent 3a81548 commit b2afe0d

File tree

6 files changed

+30
-43
lines changed

6 files changed

+30
-43
lines changed

lib/SILGen/SILGenDestructor.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -264,14 +264,11 @@ void SILGenFunction::emitDeallocatingMoveOnlyDestructor(DestructorDecl *dd) {
264264
dd->getDeclContext()->getSelfNominalTypeDecl(),
265265
cleanupLoc);
266266

267-
if (getASTContext().LangOpts.hasFeature(
268-
Feature::MoveOnlyPartialConsumption)) {
269-
if (auto *ddi = dyn_cast<DropDeinitInst>(selfValue)) {
270-
if (auto *mu =
271-
dyn_cast<MarkUnresolvedNonCopyableValueInst>(ddi->getOperand())) {
272-
if (auto *asi = dyn_cast<AllocStackInst>(mu->getOperand())) {
273-
B.createDeallocStack(loc, asi);
274-
}
267+
if (auto *ddi = dyn_cast<DropDeinitInst>(selfValue)) {
268+
if (auto *mu =
269+
dyn_cast<MarkUnresolvedNonCopyableValueInst>(ddi->getOperand())) {
270+
if (auto *asi = dyn_cast<AllocStackInst>(mu->getOperand())) {
271+
B.createDeallocStack(loc, asi);
275272
}
276273
}
277274
}

lib/SILGen/SILGenProlog.cpp

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -59,30 +59,19 @@ SILValue SILGenFunction::emitSelfDeclForDestructor(VarDecl *selfDecl) {
5959
// owned, lets mark them as needing to be no implicit copy checked so they
6060
// cannot escape.
6161
if (selfType.isMoveOnly() && !selfType.isAnyClassReferenceType()) {
62-
if (getASTContext().LangOpts.hasFeature(
63-
Feature::MoveOnlyPartialConsumption)) {
64-
SILValue addr = B.createAllocStack(selfDecl, selfValue->getType(), dv);
65-
addr = B.createMarkUnresolvedNonCopyableValueInst(
66-
selfDecl, addr,
67-
MarkUnresolvedNonCopyableValueInst::CheckKind::
68-
ConsumableAndAssignable);
69-
if (selfValue->getType().isObject()) {
70-
B.createStore(selfDecl, selfValue, addr, StoreOwnershipQualifier::Init);
71-
} else {
72-
B.createCopyAddr(selfDecl, selfValue, addr, IsTake, IsInitialization);
73-
}
74-
// drop_deinit invalidates any user-defined struct/enum deinit
75-
// before the individual members are destroyed.
76-
addr = B.createDropDeinit(selfDecl, addr);
77-
selfValue = addr;
62+
SILValue addr = B.createAllocStack(selfDecl, selfValue->getType(), dv);
63+
addr = B.createMarkUnresolvedNonCopyableValueInst(
64+
selfDecl, addr,
65+
MarkUnresolvedNonCopyableValueInst::CheckKind::ConsumableAndAssignable);
66+
if (selfValue->getType().isObject()) {
67+
B.createStore(selfDecl, selfValue, addr, StoreOwnershipQualifier::Init);
7868
} else {
79-
if (selfValue->getOwnershipKind() == OwnershipKind::Owned) {
80-
selfValue = B.createMarkUnresolvedNonCopyableValueInst(
81-
selfDecl, selfValue,
82-
MarkUnresolvedNonCopyableValueInst::CheckKind::
83-
ConsumableAndAssignable);
84-
}
69+
B.createCopyAddr(selfDecl, selfValue, addr, IsTake, IsInitialization);
8570
}
71+
// drop_deinit invalidates any user-defined struct/enum deinit
72+
// before the individual members are destroyed.
73+
addr = B.createDropDeinit(selfDecl, addr);
74+
selfValue = addr;
8675
}
8776

8877
VarLocs[selfDecl] = VarLoc::get(selfValue);

lib/SILOptimizer/Mandatory/MoveOnlyAddressCheckerUtils.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,10 +1791,11 @@ shouldEmitPartialMutationError(UseState &useState, PartialMutation::Kind kind,
17911791
}
17921792

17931793
auto feature = partialMutationFeature(kind);
1794-
if (!fn->getModule().getASTContext().LangOpts.hasFeature(feature) &&
1794+
if (feature &&
1795+
!fn->getModule().getASTContext().LangOpts.hasFeature(*feature) &&
17951796
!isa<DropDeinitInst>(user)) {
17961797
LLVM_DEBUG(llvm::dbgs()
1797-
<< " " << getFeatureName(feature) << " disabled!\n");
1798+
<< " " << getFeatureName(*feature) << " disabled!\n");
17981799
// If the types equal, just bail early.
17991800
// Emit the error.
18001801
return {PartialMutationError::featureDisabled(iterType, kind)};

lib/SILOptimizer/Mandatory/MoveOnlyDiagnostics.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -807,8 +807,9 @@ void DiagnosticEmitter::emitCannotPartiallyMutateError(
807807

808808
switch (error) {
809809
case PartialMutationError::Kind::FeatureDisabled: {
810-
assert(!astContext.LangOpts.hasFeature(
811-
partialMutationFeature(error.getKind())));
810+
auto feature = partialMutationFeature(error.getKind());
811+
assert(feature);
812+
assert(!astContext.LangOpts.hasFeature(*feature));
812813

813814
switch (kind) {
814815
case PartialMutation::Kind::Consume:

lib/SILOptimizer/Mandatory/MoveOnlyTypeUtils.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,13 @@ class PartialMutation {
128128
}
129129
};
130130

131-
inline Feature partialMutationFeature(PartialMutation::Kind kind) {
131+
inline std::optional<Feature>
132+
partialMutationFeature(PartialMutation::Kind kind) {
132133
switch (kind) {
133134
case PartialMutation::Kind::Consume:
134-
return Feature::MoveOnlyPartialConsumption;
135+
return std::nullopt;
135136
case PartialMutation::Kind::Reinit:
136-
return Feature::MoveOnlyPartialReinitialization;
137+
return {Feature::MoveOnlyPartialReinitialization};
137138
}
138139
}
139140

@@ -184,7 +185,7 @@ class PartialMutationError {
184185
enum class Kind : uint8_t {
185186
/// The partial consumption feature is disabled.
186187
///
187-
/// See -enable-experimental-feature MoveOnlyPartialConsumption.
188+
/// See -enable-experimental-feature MoveOnlyPartialReinitialization.
188189
FeatureDisabled,
189190
/// A partially consumed/reinitialized aggregate has a deinit.
190191
///

lib/Sema/MiscDiagnostics.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,6 @@ static void diagSyntacticUseRestrictions(const Expr *E, const DeclContext *DC,
422422
}
423423

424424
void checkConsumeExpr(ConsumeExpr *consumeExpr) {
425-
auto partialConsumptionEnabled =
426-
Ctx.LangOpts.hasFeature(Feature::MoveOnlyPartialConsumption);
427425
auto *subExpr = consumeExpr->getSubExpr();
428426
bool noncopyable =
429427
subExpr->getType()->getCanonicalType()->isNoncopyable();
@@ -447,7 +445,7 @@ static void diagSyntacticUseRestrictions(const Expr *E, const DeclContext *DC,
447445
continue;
448446
}
449447
auto *mre = dyn_cast<MemberRefExpr>(current);
450-
if (mre && partialConsumptionEnabled) {
448+
if (mre) {
451449
auto *vd = dyn_cast<VarDecl>(mre->getMember().getDecl());
452450
if (!vd) {
453451
Ctx.Diags.diagnose(consumeExpr->getLoc(),
@@ -475,7 +473,7 @@ static void diagSyntacticUseRestrictions(const Expr *E, const DeclContext *DC,
475473
continue;
476474
}
477475
auto *ce = dyn_cast<CallExpr>(current);
478-
if (ce && partialConsumptionEnabled) {
476+
if (ce) {
479477
if (noncopyable) {
480478
Ctx.Diags.diagnose(consumeExpr->getLoc(),
481479
diag::consume_expression_non_storage);
@@ -488,7 +486,7 @@ static void diagSyntacticUseRestrictions(const Expr *E, const DeclContext *DC,
488486
return;
489487
}
490488
auto *se = dyn_cast<SubscriptExpr>(current);
491-
if (se && partialConsumptionEnabled) {
489+
if (se) {
492490
if (noncopyable) {
493491
Ctx.Diags.diagnose(consumeExpr->getLoc(),
494492
diag::consume_expression_non_storage);

0 commit comments

Comments
 (0)