Skip to content

Commit f230023

Browse files
committed
Eliminate @_objcImpl type and field descriptors
1 parent 2a367a3 commit f230023

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4752,8 +4752,10 @@ llvm::GlobalValue *IRGenModule::defineTypeMetadata(
47524752
unsigned adjustmentIndex = MetadataAdjustmentIndex::ValueType;
47534753

47544754
if (auto nominal = concreteType->getAnyNominal()) {
4755-
// Keep type metadata around for all types.
4756-
addRuntimeResolvableType(nominal);
4755+
// Keep type metadata around for all types (except @_objcImplementation,
4756+
// since we're using ObjC metadata for that).
4757+
if (!isObjCImpl)
4758+
addRuntimeResolvableType(nominal);
47574759

47584760
// Don't define the alias for foreign type metadata or prespecialized
47594761
// generic metadata, since neither is ABI.

lib/IRGen/GenMeta.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3912,6 +3912,8 @@ namespace {
39123912
: IGM(IGM), Target(theClass), B(builder), FieldLayout(fieldLayout) {}
39133913

39143914
llvm::Constant *emitNominalTypeDescriptor() {
3915+
if (FieldLayout.hasObjCImplementation())
3916+
return nullptr;
39153917
return ClassContextDescriptorBuilder(IGM, Target, RequireMetadata).emit();
39163918
}
39173919

lib/IRGen/GenReflection.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -844,8 +844,7 @@ class FieldTypeMetadataBuilder : public ReflectionMetadataBuilder {
844844
if (NTD->hasClangNode()) {
845845
auto *enumDecl = dyn_cast<EnumDecl>(NTD);
846846
// Structs and namespace-like enums are ok.
847-
assert(isa<StructDecl>(NTD) || (enumDecl && !enumDecl->hasCases())
848-
|| !NTD->getObjCImplementationDecls().empty());
847+
assert(isa<StructDecl>(NTD) || (enumDecl && !enumDecl->hasCases()));
849848
}
850849

851850
PrettyStackTraceDecl DebugStack("emitting field type metadata", NTD);
@@ -1560,6 +1559,11 @@ void IRGenModule::emitFieldDescriptor(const NominalTypeDecl *D) {
15601559
needsOpaqueDescriptor = true;
15611560
}
15621561

1562+
if (auto *CD = dyn_cast<ClassDecl>(D)) {
1563+
if (!CD->getObjCImplementationDecls().empty())
1564+
needsFieldDescriptor = false;
1565+
}
1566+
15631567
// If the type has custom @_alignment, emit a fixed record with the
15641568
// alignment since remote mirrors will need to treat the type as opaque.
15651569
//

test/IRGen/objc_implementation.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,5 @@
4545
// NEGATIVE-NOT: Category2
4646
// NEGATIVE-NOT: NoImplClass
4747
// NEGATIVE-NOT: OBJC_CLASS_$_ImplClass.{{[0-9]}}
48+
// NEGATIVE-NOT: $sSo9ImplClassCMn
49+
// NEGATIVE-NOT: $sSo9ImplClassCHn

0 commit comments

Comments
 (0)