Skip to content

Commit eee923b

Browse files
committed
[IRGen] [AST] NFC: Remove @runtimeMetadata related code and metadata records
1 parent 23d838a commit eee923b

File tree

9 files changed

+0
-183
lines changed

9 files changed

+0
-183
lines changed

include/swift/ABI/Metadata.h

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4907,48 +4907,6 @@ struct TargetAccessibleFunctionRecord final {
49074907

49084908
using AccessibleFunctionRecord = TargetAccessibleFunctionRecord<InProcess>;
49094909

4910-
/// A single entry in an runtine discoverable attribute record
4911-
/// that relates a type attribute is attached to a generator function.
4912-
template <typename Runtime>
4913-
struct TargetRuntimeDiscoverableAttributeEntry {
4914-
RelativeDirectPointer<const char, /*nullable*/ false> Type;
4915-
RelativeDirectPointer<TargetAccessibleFunctionRecord<Runtime>> Generator;
4916-
};
4917-
4918-
/// A record that relates a runtime discoverable attribute to all of the
4919-
/// types (i.e. a nominal type, method, property etc.) it's attached to.
4920-
template <typename Runtime>
4921-
class RuntimeDiscoverableAttributeRecord
4922-
: private swift::ABI::TrailingObjects<
4923-
RuntimeDiscoverableAttributeRecord<Runtime>,
4924-
TargetRuntimeDiscoverableAttributeEntry<Runtime>> {
4925-
using TrailingObjects = swift::ABI::TrailingObjects<
4926-
RuntimeDiscoverableAttributeRecord<Runtime>,
4927-
ConstTargetMetadataPointer<Runtime, TargetMetadata>>;
4928-
friend TrailingObjects;
4929-
4930-
uint32_t flags;
4931-
4932-
/// The nominal type that describes the attribute.
4933-
TargetRelativeIndirectablePointer<Runtime,
4934-
TargetTypeContextDescriptor<Runtime>,
4935-
/*nullable*/ false>
4936-
Attribute;
4937-
4938-
/// The number of types this attribute is associated with.
4939-
uint32_t numEntries;
4940-
4941-
public:
4942-
uint32_t getFlags() { return flags; }
4943-
4944-
llvm::ArrayRef<TargetRuntimeDiscoverableAttributeEntry<Runtime>>
4945-
getEntries() const {
4946-
return {this->template getTrailingObjects<
4947-
TargetRuntimeDiscoverableAttributeEntry<Runtime>>(),
4948-
numEntries};
4949-
}
4950-
};
4951-
49524910
enum class PackLifetime : uint8_t {
49534911
OnStack = 0,
49544912
OnHeap = 1

include/swift/IRGen/Linking.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -342,11 +342,6 @@ class LinkEntity {
342342
/// the metadata cache once.
343343
CanonicalPrespecializedGenericTypeCachingOnceToken,
344344

345-
/// The record that describes an attribute that could be looked
346-
/// up at runtime together with all types it's attached to and
347-
/// generator functions.
348-
RuntimeDiscoverableAttributeRecord,
349-
350345
/// The same as AsyncFunctionPointer but with a different stored value, for
351346
/// use by TBDGen.
352347
/// The pointer is an AbstractFunctionDecl*.
@@ -1385,12 +1380,6 @@ class LinkEntity {
13851380
return entity;
13861381
}
13871382

1388-
static LinkEntity forRuntimeDiscoverableAttributeRecord(NominalTypeDecl *attr) {
1389-
LinkEntity entity;
1390-
entity.setForDecl(Kind::RuntimeDiscoverableAttributeRecord, attr);
1391-
return entity;
1392-
}
1393-
13941383
void mangle(llvm::raw_ostream &out) const;
13951384
void mangle(SmallVectorImpl<char> &buffer) const;
13961385
std::string mangleAsString() const;

lib/IRGen/GenDecl.cpp

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -4533,101 +4533,6 @@ void IRGenModule::emitAccessibleFunctions() {
45334533
}
45344534
}
45354535

4536-
void IRGenModule::emitRuntimeDiscoverableAttributes(
4537-
TinyPtrVector<FileUnit *> &filesToEmit) {
4538-
StringRef sectionName;
4539-
switch (TargetInfo.OutputObjectFormat) {
4540-
case llvm::Triple::DXContainer:
4541-
case llvm::Triple::GOFF:
4542-
case llvm::Triple::SPIRV:
4543-
case llvm::Triple::UnknownObjectFormat:
4544-
llvm_unreachable("Don't know how to emit attribute section for "
4545-
"the selected object format.");
4546-
case llvm::Triple::MachO:
4547-
sectionName = "__TEXT, __swift5_rattrs, regular";
4548-
break;
4549-
case llvm::Triple::ELF:
4550-
case llvm::Triple::Wasm:
4551-
sectionName = "swift5_runtime_attributes";
4552-
break;
4553-
case llvm::Triple::XCOFF:
4554-
case llvm::Triple::COFF:
4555-
sectionName = ".sw5ratt$B";
4556-
break;
4557-
}
4558-
4559-
// Map attribute type to each declaration it's attached to
4560-
// and a corresponding generator function.
4561-
llvm::MapVector<NominalTypeDecl *, SmallVector<SILDeclRef, 2>> attributes;
4562-
{
4563-
for (auto *fileUnit : filesToEmit) {
4564-
auto *SF = dyn_cast<SourceFile>(fileUnit);
4565-
if (!SF)
4566-
continue;
4567-
4568-
for (auto *decl : SF->getDeclsWithRuntimeDiscoverableAttrs()) {
4569-
for (auto *attr : decl->getRuntimeDiscoverableAttrs()) {
4570-
auto *attrType = decl->getRuntimeDiscoverableAttrTypeDecl(attr);
4571-
attributes[attrType].push_back(
4572-
SILDeclRef::getRuntimeAttributeGenerator(attr, decl)
4573-
.asRuntimeAccessible());
4574-
}
4575-
}
4576-
}
4577-
}
4578-
4579-
auto &SM = getSILModule();
4580-
4581-
for (auto &attr : attributes) {
4582-
auto *attrType = attr.first;
4583-
const auto &attachedTo = attr.second;
4584-
4585-
auto mangledRecordName =
4586-
LinkEntity::forRuntimeDiscoverableAttributeRecord(attrType)
4587-
.mangleAsString();
4588-
4589-
ConstantInitBuilder builder(*this);
4590-
ConstantStructBuilder B = builder.beginStruct();
4591-
4592-
// Flags
4593-
B.addInt32(0);
4594-
4595-
// Attribute metadata descriptor
4596-
B.addRelativeAddress(getAddrOfLLVMVariableOrGOTEquivalent(
4597-
LinkEntity::forNominalTypeDescriptor(attrType)));
4598-
4599-
// Number of types it's attached to.
4600-
B.addInt32(attachedTo.size());
4601-
4602-
// Emit all of the trailing objects
4603-
for (auto &ref : attachedTo) {
4604-
auto type = ref.getDecl()->getInterfaceType()->getCanonicalType();
4605-
auto *generator = SM.lookUpFunction(ref);
4606-
4607-
B.addRelativeAddress(
4608-
getTypeRef(type, /*genericSig=*/nullptr, MangledTypeRefRole::Metadata)
4609-
.first);
4610-
B.addRelativeAddressOrNull(getAddrOfAccessibleFunctionRecord(generator));
4611-
}
4612-
4613-
B.suggestType(RuntimeDiscoverableAttributeTy);
4614-
4615-
auto entity = LinkEntity::forRuntimeDiscoverableAttributeRecord(attrType);
4616-
4617-
auto *var = cast<llvm::GlobalVariable>(getAddrOfLLVMVariable(
4618-
entity, B.finishAndCreateFuture(), DebugTypeInfo()));
4619-
4620-
var->setConstant(true);
4621-
setTrueConstGlobal(var);
4622-
4623-
var->setSection(sectionName);
4624-
var->setAlignment(llvm::MaybeAlign(4));
4625-
4626-
disableAddressSanitizer(*this, var);
4627-
addUsedGlobal(var);
4628-
}
4629-
}
4630-
46314536
/// Fetch a global reference to a reference to the given Objective-C class.
46324537
/// The result is of type ObjCClassPtrTy->getPointerTo().
46334538
Address IRGenModule::getAddrOfObjCClassRef(ClassDecl *theClass) {

lib/IRGen/GenObjC.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,6 @@ namespace {
670670
case SILDeclRef::Kind::PropertyWrapperInitFromProjectedValue:
671671
case SILDeclRef::Kind::EntryPoint:
672672
case SILDeclRef::Kind::AsyncEntryPoint:
673-
case SILDeclRef::Kind::RuntimeAttributeGenerator:
674673
llvm_unreachable("Method does not have a selector");
675674

676675
case SILDeclRef::Kind::Destroyer:

lib/IRGen/IRGen.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,6 @@ GeneratedModule IRGenRequest::evaluate(Evaluator &evaluator,
11851185
IGM.emitAccessibleFunctions();
11861186
IGM.emitBuiltinReflectionMetadata();
11871187
IGM.emitReflectionMetadataVersion();
1188-
IGM.emitRuntimeDiscoverableAttributes(filesToEmit);
11891188
irgen.emitEagerClassInitialization();
11901189
irgen.emitObjCActorsNeedingSuperclassSwizzle();
11911190
irgen.emitDynamicReplacements();

lib/IRGen/IRGenMangler.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -651,12 +651,6 @@ class IRGenMangler : public Mangle::ASTMangler {
651651
std::string mangleSymbolNameForGenericEnvironment(
652652
CanGenericSignature genericSig);
653653

654-
std::string
655-
mangleRuntimeAccessibleAttributeRecord(const NominalTypeDecl *attr) {
656-
assert(attr->getAttrs().hasAttribute<RuntimeMetadataAttr>());
657-
return mangleNominalTypeSymbol(attr, "Ha");
658-
}
659-
660654
protected:
661655
SymbolicMangling
662656
withSymbolicReferences(IRGenModule &IGM,

lib/IRGen/IRGenModule.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -638,10 +638,6 @@ IRGenModule::IRGenModule(IRGenerator &irgen,
638638
{RelativeAddressTy, RelativeAddressTy, RelativeAddressTy,
639639
RelativeAddressTy, Int32Ty});
640640

641-
RuntimeDiscoverableAttributeTy =
642-
createStructType(*this, "swift.runtime_attr",
643-
{Int32Ty, RelativeAddressTy, Int32Ty});
644-
645641
AsyncFunctionPointerTy = createStructType(*this, "swift.async_func_pointer",
646642
{RelativeAddressTy, Int32Ty}, true);
647643
SwiftContextTy = llvm::StructType::create(getLLVMContext(), "swift.context");

lib/IRGen/IRGenModule.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -780,8 +780,6 @@ class IRGenModule {
780780
llvm::StructType *ClassMetadataBaseOffsetTy;
781781
llvm::StructType *DifferentiabilityWitnessTy; // { i8*, i8* }
782782

783-
llvm::StructType *RuntimeDiscoverableAttributeTy; // { i32, i32*, i32 }
784-
785783
llvm::GlobalVariable *TheTrivialPropertyDescriptor = nullptr;
786784

787785
llvm::GlobalVariable *swiftImmortalRefCount = nullptr;
@@ -1511,10 +1509,6 @@ private: \
15111509
void emitProtocolConformance(const ConformanceDescription &record);
15121510
void emitNestedTypeDecls(DeclRange members);
15131511
void emitClangDecl(const clang::Decl *decl);
1514-
/// Emit runtime discoverable attribute metadata section for the given set
1515-
/// of source files.
1516-
void
1517-
emitRuntimeDiscoverableAttributes(TinyPtrVector<FileUnit *> &filesToEmit);
15181512

15191513
void finalizeClangCodeGen();
15201514
void finishEmitAfterTopLevel();

lib/IRGen/Linking.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -537,11 +537,6 @@ std::string LinkEntity::mangleAsString() const {
537537
return mangler.mangleExtendedExistentialTypeShapeSymbol(
538538
genSig, existentialType, isUnique);
539539
}
540-
541-
case Kind::RuntimeDiscoverableAttributeRecord: {
542-
auto *attr = cast<NominalTypeDecl>(getDecl());
543-
return mangler.mangleRuntimeAccessibleAttributeRecord(attr);
544-
}
545540
}
546541
llvm_unreachable("bad entity kind!");
547542
}
@@ -888,9 +883,6 @@ SILLinkage LinkEntity::getLinkage(ForDefinition_t forDefinition) const {
888883
case Kind::ExtendedExistentialTypeShape:
889884
return (isExtendedExistentialTypeShapeShared()
890885
? SILLinkage::Shared : SILLinkage::Private);
891-
case Kind::RuntimeDiscoverableAttributeRecord:
892-
return SILLinkage::Private;
893-
894886
}
895887
llvm_unreachable("bad link entity kind");
896888
}
@@ -985,7 +977,6 @@ bool LinkEntity::isContextDescriptor() const {
985977
case Kind::DistributedAccessor:
986978
case Kind::AccessibleFunctionRecord:
987979
case Kind::ExtendedExistentialTypeShape:
988-
case Kind::RuntimeDiscoverableAttributeRecord:
989980
return false;
990981
}
991982
llvm_unreachable("invalid descriptor");
@@ -1113,8 +1104,6 @@ llvm::Type *LinkEntity::getDefaultDeclarationType(IRGenModule &IGM) const {
11131104
return IGM.AccessibleFunctionRecordTy;
11141105
case Kind::ExtendedExistentialTypeShape:
11151106
return IGM.RelativeAddressTy;
1116-
case Kind::RuntimeDiscoverableAttributeRecord:
1117-
return IGM.RuntimeDiscoverableAttributeTy;
11181107
default:
11191108
llvm_unreachable("declaration LLVM type not specified");
11201109
}
@@ -1147,7 +1136,6 @@ Alignment LinkEntity::getAlignment(IRGenModule &IGM) const {
11471136
case Kind::OpaqueTypeDescriptorRecord:
11481137
case Kind::AccessibleFunctionRecord:
11491138
case Kind::ExtendedExistentialTypeShape:
1150-
case Kind::RuntimeDiscoverableAttributeRecord:
11511139
return Alignment(4);
11521140
case Kind::AsyncFunctionPointer:
11531141
case Kind::DispatchThunkAsyncFunctionPointer:
@@ -1312,7 +1300,6 @@ bool LinkEntity::isWeakImported(ModuleDecl *module) const {
13121300
case Kind::DifferentiabilityWitness:
13131301
case Kind::AccessibleFunctionRecord:
13141302
case Kind::ExtendedExistentialTypeShape:
1315-
case Kind::RuntimeDiscoverableAttributeRecord:
13161303
return false;
13171304

13181305
case Kind::AsyncFunctionPointer:
@@ -1459,10 +1446,6 @@ DeclContext *LinkEntity::getDeclContextForEmission() const {
14591446
case Kind::AccessibleFunctionRecord: {
14601447
return getSILFunction()->getParentModule();
14611448
}
1462-
1463-
case Kind::RuntimeDiscoverableAttributeRecord: {
1464-
return nullptr;
1465-
}
14661449
}
14671450
llvm_unreachable("invalid decl kind");
14681451
}

0 commit comments

Comments
 (0)