Skip to content

IRGen: Weak-link references to swift_getExtendedExistentialTypeMetadata() #69459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions include/swift/Runtime/RuntimeFunctions.def
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
Expand All @@ -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),
Expand Down
8 changes: 8 additions & 0 deletions lib/IRGen/IRGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions test/IRGen/extended_existential_metadata_weak.swift
Original file line number Diff line number Diff line change
@@ -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<A> {
associatedtype A
}

public func f<T>(_: T.Type) {}

@available(SwiftStdlib 5.7, *)
public func g<T>(_: T.Type) { f((any P<T>).self) }

// CHECK-LABEL: declare extern_weak ptr @swift_getExtendedExistentialTypeMetadata(ptr, ptr)