Skip to content

[IRGen] RuntimeMetadata: Reference type descriptors indirectly when required #62850

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
7 changes: 5 additions & 2 deletions include/swift/ABI/Metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -4740,7 +4740,7 @@ using AccessibleFunctionRecord = TargetAccessibleFunctionRecord<InProcess>;
/// that relates a type attribute is attached to a generator function.
template <typename Runtime>
struct TargetRuntimeDiscoverableAttributeEntry {
ConstTargetMetadataPointer<Runtime, TargetMetadata> Type;
RelativeDirectPointer<const char, /*nullable*/ false> Type;
RelativeDirectPointer<TargetAccessibleFunctionRecord<Runtime>> Generator;
};

Expand All @@ -4759,7 +4759,10 @@ class RuntimeDiscoverableAttributeRecord
uint32_t flags;

/// The nominal type that describes the attribute.
TargetSignedContextPointer<Runtime, TargetTypeContextDescriptor> Attribute;
TargetRelativeIndirectablePointer<Runtime,
TargetTypeContextDescriptor<Runtime>,
/*nullable*/ false>
Attribute;

/// The number of types this attribute is associated with.
uint32_t numEntries;
Expand Down
4 changes: 2 additions & 2 deletions lib/IRGen/GenDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4449,8 +4449,8 @@ void IRGenModule::emitRuntimeDiscoverableAttributes(
B.addInt32(0);

// Attribute metadata descriptor
B.addRelativeAddress(
getAddrOfTypeContextDescriptor(attrType, RequireMetadata));
B.addRelativeAddress(getAddrOfLLVMVariableOrGOTEquivalent(
LinkEntity::forNominalTypeDescriptor(attrType)));

// Number of types it's attached to.
B.addInt32(attachedTo.size());
Expand Down
4 changes: 2 additions & 2 deletions test/IRGen/runtime_attributes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@

// CHECK: @"$s3RAD6IgnoreVHa" = internal constant
// CHECK-SAME: i32 0
// CHECK-SAME: @"$s3RAD6IgnoreVMn"
// CHECK-SAME: %swift.type_descriptor** @"got.$s3RAD6IgnoreVMn"
// CHECK-SAME: i32 5
// CHECK-SAME: @"$s18runtime_attributes1AV5InnerC11extComputedSivpfa3RAD6IgnoreHF"
// CHECK-SAME: @"$s18runtime_attributes16WithExternalAttrAaBVmvpfa3RAD6IgnoreHF"
Expand All @@ -96,7 +96,7 @@

// CHECK: @"$s3RAD13TestAmbiguityVHa" = internal constant
// CHECK-SAME: i32 0
// CHECK-SAME: @"$s3RAD13TestAmbiguityVMn"
// CHECK-SAME: %swift.type_descriptor** @"got.$s3RAD13TestAmbiguityVMn"
// CHECK-SAME: i32 6
// CHECK-SAME: @"$s18runtime_attributes4testyySicvpfa3RAD13TestAmbiguityHF"
// CHECK-SAME: @"$s18runtime_attributes4testyySScvpfa3RAD13TestAmbiguityHF"
Expand Down