Skip to content

Commit 3f151fe

Browse files
authored
Merge pull request #62850 from xedin/fix-type-reference-for-runtime-metadata-entry
[IRGen] RuntimeMetadata: Reference type descriptors indirectly when required
2 parents b5217e6 + 55a6b34 commit 3f151fe

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

include/swift/ABI/Metadata.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4740,7 +4740,7 @@ using AccessibleFunctionRecord = TargetAccessibleFunctionRecord<InProcess>;
47404740
/// that relates a type attribute is attached to a generator function.
47414741
template <typename Runtime>
47424742
struct TargetRuntimeDiscoverableAttributeEntry {
4743-
ConstTargetMetadataPointer<Runtime, TargetMetadata> Type;
4743+
RelativeDirectPointer<const char, /*nullable*/ false> Type;
47444744
RelativeDirectPointer<TargetAccessibleFunctionRecord<Runtime>> Generator;
47454745
};
47464746

@@ -4759,7 +4759,10 @@ class RuntimeDiscoverableAttributeRecord
47594759
uint32_t flags;
47604760

47614761
/// The nominal type that describes the attribute.
4762-
TargetSignedContextPointer<Runtime, TargetTypeContextDescriptor> Attribute;
4762+
TargetRelativeIndirectablePointer<Runtime,
4763+
TargetTypeContextDescriptor<Runtime>,
4764+
/*nullable*/ false>
4765+
Attribute;
47634766

47644767
/// The number of types this attribute is associated with.
47654768
uint32_t numEntries;

lib/IRGen/GenDecl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4449,8 +4449,8 @@ void IRGenModule::emitRuntimeDiscoverableAttributes(
44494449
B.addInt32(0);
44504450

44514451
// Attribute metadata descriptor
4452-
B.addRelativeAddress(
4453-
getAddrOfTypeContextDescriptor(attrType, RequireMetadata));
4452+
B.addRelativeAddress(getAddrOfLLVMVariableOrGOTEquivalent(
4453+
LinkEntity::forNominalTypeDescriptor(attrType)));
44544454

44554455
// Number of types it's attached to.
44564456
B.addInt32(attachedTo.size());

test/IRGen/runtime_attributes.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585

8686
// CHECK: @"$s3RAD6IgnoreVHa" = internal constant
8787
// CHECK-SAME: i32 0
88-
// CHECK-SAME: @"$s3RAD6IgnoreVMn"
88+
// CHECK-SAME: %swift.type_descriptor** @"got.$s3RAD6IgnoreVMn"
8989
// CHECK-SAME: i32 5
9090
// CHECK-SAME: @"$s18runtime_attributes1AV5InnerC11extComputedSivpfa3RAD6IgnoreHF"
9191
// CHECK-SAME: @"$s18runtime_attributes16WithExternalAttrAaBVmvpfa3RAD6IgnoreHF"
@@ -96,7 +96,7 @@
9696

9797
// CHECK: @"$s3RAD13TestAmbiguityVHa" = internal constant
9898
// CHECK-SAME: i32 0
99-
// CHECK-SAME: @"$s3RAD13TestAmbiguityVMn"
99+
// CHECK-SAME: %swift.type_descriptor** @"got.$s3RAD13TestAmbiguityVMn"
100100
// CHECK-SAME: i32 6
101101
// CHECK-SAME: @"$s18runtime_attributes4testyySicvpfa3RAD13TestAmbiguityHF"
102102
// CHECK-SAME: @"$s18runtime_attributes4testyySScvpfa3RAD13TestAmbiguityHF"

0 commit comments

Comments
 (0)