Skip to content

Commit c6dad96

Browse files
committed
Make LayoutPrespecialization a baseline feature instead of experimental.
Since LayoutPrespecialization has been enabled by default in all compiler invocations for quite some time, it doesn't make sense for it to be treated as experimental feature. Make it a baseline feature and remove all the checks for it from the compiler.
1 parent dbedb21 commit c6dad96

File tree

13 files changed

+48
-83
lines changed

13 files changed

+48
-83
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7910,11 +7910,6 @@ ERROR(has_symbol_invalid_decl,none,
79107910
ERROR(no_metadata_on_non_generic_param, none,
79117911
"'@_noMetadata' must appear on a generic parameter",
79127912
())
7913-
ERROR(experimental_no_metadata_feature_can_only_be_used_when_enabled,
7914-
none, "Can not use feature when experimental layout based"
7915-
" pre-specializations are disabled! Pass the frontend flag"
7916-
" -enable-experimental-feature LayoutPrespecialization to swift to enable "
7917-
" the usage of this language feature", ())
79187913

79197914

79207915
//------------------------------------------------------------------------------

include/swift/Basic/Features.def

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ LANGUAGE_FEATURE(BuiltinInterleave, 0, "Builtin.interleave and Builtin.deinterle
270270
LANGUAGE_FEATURE(BuiltinVectorsExternC, 0, "Extern C support for Builtin vector types")
271271
LANGUAGE_FEATURE(AddressOfProperty, 0, "Builtin.unprotectedAddressOf properties")
272272
LANGUAGE_FEATURE(NonescapableAccessorOnTrivial, 0, "Support UnsafeMutablePointer.mutableSpan")
273+
BASELINE_LANGUAGE_FEATURE(LayoutPrespecialization, 0, "Layout pre-specialization")
273274

274275
// Swift 6
275276
UPCOMING_FEATURE(ConciseMagicFile, 274, 6)
@@ -331,8 +332,6 @@ EXPERIMENTAL_FEATURE(MoveOnlyTuples, true)
331332
EXPERIMENTAL_FEATURE(MoveOnlyPartialReinitialization, true)
332333
EXPERIMENTAL_FEATURE(ConsumeSelfInDeinit, true)
333334

334-
EXPERIMENTAL_FEATURE(LayoutPrespecialization, true)
335-
336335
EXPERIMENTAL_FEATURE(AccessLevelOnImport, true)
337336

338337
/// Enables a module to allow non resilient access from other

lib/AST/Attr.cpp

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2504,15 +2504,13 @@ SpecializeAttr *SpecializeAttr::create(ASTContext &Ctx, SourceLoc atLoc,
25042504
ArrayRef<AvailableAttr *> availableAttrs,
25052505
GenericSignature specializedSignature) {
25062506
size_t typeErasedParamsCount = 0;
2507-
if (Ctx.LangOpts.hasFeature(Feature::LayoutPrespecialization)) {
2508-
if (clause != nullptr) {
2509-
for (auto &req : clause->getRequirements()) {
2510-
if (req.getKind() == RequirementReprKind::LayoutConstraint) {
2511-
if (auto *attributedTy =
2512-
dyn_cast<AttributedTypeRepr>(req.getSubjectRepr())) {
2513-
if (attributedTy->has(TypeAttrKind::NoMetadata)) {
2514-
typeErasedParamsCount += 1;
2515-
}
2507+
if (clause != nullptr) {
2508+
for (auto &req : clause->getRequirements()) {
2509+
if (req.getKind() == RequirementReprKind::LayoutConstraint) {
2510+
if (auto *attributedTy =
2511+
dyn_cast<AttributedTypeRepr>(req.getSubjectRepr())) {
2512+
if (attributedTy->has(TypeAttrKind::NoMetadata)) {
2513+
typeErasedParamsCount += 1;
25162514
}
25172515
}
25182516
}
@@ -2570,15 +2568,13 @@ SpecializedAttr *SpecializedAttr::create(ASTContext &Ctx, SourceLoc atLoc,
25702568
ArrayRef<AvailableAttr *> availableAttrs,
25712569
GenericSignature specializedSignature) {
25722570
size_t typeErasedParamsCount = 0;
2573-
if (Ctx.LangOpts.hasFeature(Feature::LayoutPrespecialization)) {
2574-
if (clause != nullptr) {
2575-
for (auto &req : clause->getRequirements()) {
2576-
if (req.getKind() == RequirementReprKind::LayoutConstraint) {
2577-
if (auto *attributedTy =
2578-
dyn_cast<AttributedTypeRepr>(req.getSubjectRepr())) {
2579-
if (attributedTy->has(TypeAttrKind::NoMetadata)) {
2580-
typeErasedParamsCount += 1;
2581-
}
2571+
if (clause != nullptr) {
2572+
for (auto &req : clause->getRequirements()) {
2573+
if (req.getKind() == RequirementReprKind::LayoutConstraint) {
2574+
if (auto *attributedTy =
2575+
dyn_cast<AttributedTypeRepr>(req.getSubjectRepr())) {
2576+
if (attributedTy->has(TypeAttrKind::NoMetadata)) {
2577+
typeErasedParamsCount += 1;
25822578
}
25832579
}
25842580
}

lib/AST/FeatureSet.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ UNINTERESTING_FEATURE(OldOwnershipOperatorSpellings)
9191
UNINTERESTING_FEATURE(MoveOnlyEnumDeinits)
9292
UNINTERESTING_FEATURE(MoveOnlyTuples)
9393
UNINTERESTING_FEATURE(MoveOnlyPartialReinitialization)
94-
UNINTERESTING_FEATURE(LayoutPrespecialization)
9594
UNINTERESTING_FEATURE(AccessLevelOnImport)
9695
UNINTERESTING_FEATURE(AllowNonResilientAccessInPackage)
9796
UNINTERESTING_FEATURE(ClientBypassResilientAccessInPackage)

lib/DriverTool/sil_opt_main.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -795,8 +795,6 @@ int sil_opt_main(ArrayRef<const char *> argv, void *MainAddr) {
795795
options.EnableObjCInterop ? true :
796796
options.DisableObjCInterop ? false : llvm::Triple(options.Target).isOSDarwin();
797797

798-
Invocation.getLangOptions().enableFeature(Feature::LayoutPrespecialization);
799-
800798
Invocation.getLangOptions().OptimizationRemarkPassedPattern =
801799
createOptRemarkRegex(options.PassRemarksPassed);
802800
Invocation.getLangOptions().OptimizationRemarkMissedPattern =

lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,8 +1004,6 @@ static bool ParseEnabledFeatureArgs(LangOptions &Opts, ArgList &Args,
10041004
if (Args.hasArg(OPT_enable_builtin_module))
10051005
Opts.enableFeature(Feature::BuiltinModule);
10061006

1007-
Opts.enableFeature(Feature::LayoutPrespecialization);
1008-
10091007
if (Args.hasArg(OPT_strict_memory_safety))
10101008
Opts.enableFeature(Feature::StrictMemorySafety);
10111009
else if (Args.hasArg(OPT_strict_memory_safety_migrate))

lib/Frontend/ModuleInterfaceLoader.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1785,11 +1785,6 @@ void InterfaceSubContextDelegateImpl::inheritOptionsForBuildingInterface(
17851785
GenericArgs.push_back(ArgSaver.save(pair));
17861786
});
17871787

1788-
if (LangOpts.hasFeature(Feature::LayoutPrespecialization)) {
1789-
genericSubInvocation.getLangOptions().enableFeature(
1790-
Feature::LayoutPrespecialization);
1791-
}
1792-
17931788
genericSubInvocation.getClangImporterOptions().DirectClangCC1ModuleBuild =
17941789
clangImporterOpts.DirectClangCC1ModuleBuild;
17951790
genericSubInvocation.getClangImporterOptions().ClangImporterDirectCC1Scan =

lib/SIL/Parser/ParseSIL.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -653,11 +653,10 @@ void SILParser::convertRequirements(ArrayRef<RequirementRepr> From,
653653
Req.getLayoutConstraint());
654654
To.push_back(ConvertedRequirement);
655655

656-
if (SILMod.getASTContext().LangOpts.hasFeature(Feature::LayoutPrespecialization)) {
657-
if (auto *attributedTy = dyn_cast<AttributedTypeRepr>(Req.getSubjectRepr())) {
658-
if (attributedTy->has(TypeAttrKind::NoMetadata)) {
659-
typeErasedParams.push_back(Subject);
660-
}
656+
if (auto *attributedTy =
657+
dyn_cast<AttributedTypeRepr>(Req.getSubjectRepr())) {
658+
if (attributedTy->has(TypeAttrKind::NoMetadata)) {
659+
typeErasedParams.push_back(Subject);
661660
}
662661
}
663662

lib/SILOptimizer/Utils/Generics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3129,7 +3129,7 @@ static bool usePrespecialized(
31293129
SA->getUnerasedSpecializedSignature().withoutMarkerProtocols();
31303130

31313131
auto erasedParams = SA->getTypeErasedParams();
3132-
if(!ctxt.LangOpts.hasFeature(Feature::LayoutPrespecialization) || erasedParams.empty()) {
3132+
if (erasedParams.empty()) {
31333133
continue;
31343134
}
31353135

lib/Sema/TypeCheckAttr.cpp

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3471,26 +3471,25 @@ SerializeAttrGenericSignatureRequest::evaluate(Evaluator &evaluator,
34713471
// Check the validity of provided requirements.
34723472
checkSpecializeAttrRequirements(attr, genericSig, specializedSig, Ctx);
34733473

3474-
if (Ctx.LangOpts.hasFeature(Feature::LayoutPrespecialization)) {
3475-
llvm::SmallVector<Type, 4> typeErasedParams;
3476-
for (const auto &reqRepr :
3477-
attr->getTrailingWhereClause()->getRequirements()) {
3478-
if (reqRepr.getKind() == RequirementReprKind::LayoutConstraint) {
3479-
if (auto *attributedTy = dyn_cast<AttributedTypeRepr>(reqRepr.getSubjectRepr())) {
3480-
if (attributedTy->has(TypeAttrKind::NoMetadata)) {
3481-
const auto resolution = TypeResolution::forInterface(
3482-
FD->getDeclContext(), genericSig, std::nullopt,
3483-
/*unboundTyOpener*/ nullptr,
3484-
/*placeholderHandler*/ nullptr,
3485-
/*packElementOpener*/ nullptr);
3486-
const auto ty = resolution.resolveType(attributedTy);
3487-
typeErasedParams.push_back(ty);
3488-
}
3474+
llvm::SmallVector<Type, 4> typeErasedParams;
3475+
for (const auto &reqRepr :
3476+
attr->getTrailingWhereClause()->getRequirements()) {
3477+
if (reqRepr.getKind() == RequirementReprKind::LayoutConstraint) {
3478+
if (auto *attributedTy =
3479+
dyn_cast<AttributedTypeRepr>(reqRepr.getSubjectRepr())) {
3480+
if (attributedTy->has(TypeAttrKind::NoMetadata)) {
3481+
const auto resolution = TypeResolution::forInterface(
3482+
FD->getDeclContext(), genericSig, std::nullopt,
3483+
/*unboundTyOpener*/ nullptr,
3484+
/*placeholderHandler*/ nullptr,
3485+
/*packElementOpener*/ nullptr);
3486+
const auto ty = resolution.resolveType(attributedTy);
3487+
typeErasedParams.push_back(ty);
34893488
}
34903489
}
34913490
}
3492-
attr->setTypeErasedParams(typeErasedParams);
34933491
}
3492+
attr->setTypeErasedParams(typeErasedParams);
34943493

34953494
// Check the target function if there is one.
34963495
attr->getTargetFunctionDecl(FD);
@@ -4885,13 +4884,6 @@ AttributeChecker::visitSPIOnlyAttr(SPIOnlyAttr *attr) {
48854884
}
48864885

48874886
void AttributeChecker::visitNoMetadataAttr(NoMetadataAttr *attr) {
4888-
if (!Ctx.LangOpts.hasFeature(Feature::LayoutPrespecialization)) {
4889-
auto error =
4890-
diag::experimental_no_metadata_feature_can_only_be_used_when_enabled;
4891-
diagnoseAndRemoveAttr(attr, error);
4892-
return;
4893-
}
4894-
48954887
if (!isa<GenericTypeParamDecl>(D)) {
48964888
attr->setInvalid();
48974889
diagnoseAndRemoveAttr(attr, diag::no_metadata_on_non_generic_param);

0 commit comments

Comments
 (0)