diff --git a/include/swift/Runtime/RuntimeFunctions.def b/include/swift/Runtime/RuntimeFunctions.def index 44cde707d176f..c4a2e265554ec 100644 --- a/include/swift/Runtime/RuntimeFunctions.def +++ b/include/swift/Runtime/RuntimeFunctions.def @@ -1310,7 +1310,8 @@ FUNCTION(GetExistentialMetadata, // swift_getExtendedExistentialTypeShape( // const NonUniqueExtendedExistentialTypeShape *nonUnique); FUNCTION(GetExtendedExistentialTypeShape, - swift_getExtendedExistentialTypeShape, C_CC, AlwaysAvailable, + swift_getExtendedExistentialTypeShape, C_CC, + ParameterizedExistentialAvailability, RETURNS(TypeMetadataPtrTy), ARGS(Int8PtrTy, Int8PtrPtrTy), ATTRS(NoUnwind, WillReturn), @@ -1321,7 +1322,8 @@ FUNCTION(GetExtendedExistentialTypeShape, // const NonUniqueExtendedExistentialTypeShape *shape, // const void * const *generalizationArgs); FUNCTION(GetExtendedExistentialTypeMetadata, - swift_getExtendedExistentialTypeMetadata, C_CC, AlwaysAvailable, + swift_getExtendedExistentialTypeMetadata, C_CC, + ParameterizedExistentialAvailability, RETURNS(TypeMetadataPtrTy), ARGS(Int8PtrTy, Int8PtrPtrTy), ATTRS(NoUnwind, WillReturn), @@ -1332,7 +1334,8 @@ FUNCTION(GetExtendedExistentialTypeMetadata, // const ExtendedExistentialTypeShape *shape, // const void * const *generalizationArgs); FUNCTION(GetExtendedExistentialTypeMetadataUnique, - swift_getExtendedExistentialTypeMetadata_unique, C_CC, AlwaysAvailable, + swift_getExtendedExistentialTypeMetadata_unique, C_CC, + ParameterizedExistentialAvailability, RETURNS(TypeMetadataPtrTy), ARGS(Int8PtrTy, Int8PtrPtrTy), ATTRS(NoUnwind, WillReturn), diff --git a/lib/IRGen/IRGenModule.cpp b/lib/IRGen/IRGenModule.cpp index 91c65a6e43ad4..42bdae3f786b3 100644 --- a/lib/IRGen/IRGenModule.cpp +++ b/lib/IRGen/IRGenModule.cpp @@ -930,6 +930,14 @@ namespace RuntimeConstants { return RuntimeAvailability::ConditionallyAvailable; } + RuntimeAvailability ParameterizedExistentialAvailability(ASTContext &Context) { + auto featureAvailability = Context.getParameterizedExistentialRuntimeAvailability(); + if (!isDeploymentAvailabilityContainedIn(Context, featureAvailability)) { + return RuntimeAvailability::ConditionallyAvailable; + } + return RuntimeAvailability::AlwaysAvailable; + } + } // namespace RuntimeConstants // We don't use enough attributes to justify generalizing the diff --git a/test/IRGen/extended_existential_metadata_weak.swift b/test/IRGen/extended_existential_metadata_weak.swift new file mode 100644 index 0000000000000..d293d98009916 --- /dev/null +++ b/test/IRGen/extended_existential_metadata_weak.swift @@ -0,0 +1,13 @@ +// RUN: %target-swift-frontend -emit-ir %s -target %target-swift-abi-5.5-triple | %FileCheck %s +// REQUIRES: VENDOR=apple + +public protocol P { + associatedtype A +} + +public func f(_: T.Type) {} + +@available(SwiftStdlib 5.7, *) +public func g(_: T.Type) { f((any P).self) } + +// CHECK-LABEL: declare extern_weak ptr @swift_getExtendedExistentialTypeMetadata(ptr, ptr) \ No newline at end of file