Skip to content

Commit 89278f8

Browse files
committed
[metadata prespecialization] Target only >=5.2.
Compatibility with earlier swift runtimes would require modifying the runtime compatibility libraries to adjust the behavior of checkMetadataState by way of typeForMangledNode or even typeForMangledName. For now, simply require that a version of swift whose runtime knows about prespecialized metadata is being targeted.
1 parent e45b054 commit 89278f8

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

include/swift/AST/ASTContext.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,14 @@ class ASTContext final {
614614
/// swift_getTypeByMangledNameInContextInMetadataState.
615615
AvailabilityContext getTypesInAbstractMetadataStateAvailability();
616616

617+
/// Get the runtime availability of support for prespecialized generic
618+
/// metadata.
619+
AvailabilityContext getPrespecializedGenericMetadataAvailability();
620+
621+
/// Get the runtime availability of features introduced in the Swift 5.2
622+
/// compiler for the target platform.
623+
AvailabilityContext getSwift52Availability();
624+
617625

618626
//===--------------------------------------------------------------------===//
619627
// Diagnostics Helper functions

lib/AST/Availability.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,14 @@ AvailabilityContext ASTContext::getSwift51Availability() {
239239
}
240240

241241
AvailabilityContext ASTContext::getTypesInAbstractMetadataStateAvailability() {
242+
return getSwift52Availability();
243+
}
244+
245+
AvailabilityContext ASTContext::getPrespecializedGenericMetadataAvailability() {
246+
return getSwift52Availability();
247+
}
248+
249+
AvailabilityContext ASTContext::getSwift52Availability() {
242250
auto target = LangOpts.Target;
243251

244252
if (target.isMacOSX() ) {

lib/IRGen/IRGenModule.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,6 +1329,15 @@ void IRGenModule::error(SourceLoc loc, const Twine &message) {
13291329

13301330
bool IRGenModule::useDllStorage() { return ::useDllStorage(Triple); }
13311331

1332+
bool IRGenModule::shouldPrespecializeGenericMetadata() {
1333+
auto &context = getSwiftModule()->getASTContext();
1334+
auto deploymentAvailability =
1335+
AvailabilityContext::forDeploymentTarget(context);
1336+
return IRGen.Opts.PrespecializeGenericMetadata &&
1337+
deploymentAvailability.isContainedIn(
1338+
context.getPrespecializedGenericMetadataAvailability());
1339+
}
1340+
13321341
void IRGenerator::addGenModule(SourceFile *SF, IRGenModule *IGM) {
13331342
assert(GenModules.count(SF) == 0);
13341343
GenModules[SF] = IGM;

lib/IRGen/IRGenModule.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,8 @@ class IRGenModule {
744744
void error(SourceLoc loc, const Twine &message);
745745

746746
bool useDllStorage();
747+
748+
bool shouldPrespecializeGenericMetadata();
747749

748750
Size getAtomicBoolSize() const { return AtomicBoolSize; }
749751
Alignment getAtomicBoolAlignment() const { return AtomicBoolAlign; }

0 commit comments

Comments
 (0)