Skip to content

Commit 650f931

Browse files
committed
IRGen: Don't use the demangler to realize imported Objective-C class metadata for now
Recently we started using the runtime demangler to realize imported Objective-C class metadata, to save on code size since no metadata accessor function needs to be emitted in this case. This introduced a regression where OBJC_CLASSREF symbols were no longer being emitted in some cases, which breaks autolinking. The fix for this was tracked by rdar://56136123, but unfortunately had to be reverted because it caused other problems. Until the original fix can be re-applied, let's put in a temporary workaround where we avoid going through the runtime demangler for imported Objective-C classes. This regresses code size but unblocks everyone involved, until the fix for the demangling code path (8247525) can be re-applied. Fixes <rdar://56621277>.
1 parent 8089899 commit 650f931

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

lib/IRGen/MetadataRequest.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,10 +2008,7 @@ static bool shouldAccessByMangledName(IRGenModule &IGM, CanType type) {
20082008
if (auto nom = dyn_cast<NominalType>(type)) {
20092009
if (!isa<ProtocolDecl>(nom->getDecl())
20102010
&& (!nom->getDecl()->isGenericContext()
2011-
|| nom->getDecl()->getGenericSignature()->areAllParamsConcrete())
2012-
&& (!nom->getClassOrBoundGenericClass()
2013-
|| !nom->getClassOrBoundGenericClass()->hasClangNode()
2014-
|| nom->getClassOrBoundGenericClass()->isForeign())) {
2011+
|| nom->getDecl()->getGenericSignature()->areAllParamsConcrete())) {
20152012
return false;
20162013
}
20172014
}

test/IRGen/access_type_metadata_by_mangled_name_objc.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ public func test() {
1212
var x: Any.Type
1313

1414
// Access ObjC classes by mangled name.
15-
// CHECK: @"$sSo8NSObjectCMD"
15+
// FIXME: Disabled for now.
16+
// CHECK: @"$sSo8NSObjectCMa"
1617
x = NSObject.self
1718

1819
// Use the metadata accessor for CF classes that already has to exist.

test/IRGen/objc_types_as_member.sil

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ import gizmo
99
sil @use_metatype : $@convention(thin) <T> (@thin T.Type) -> ()
1010

1111
// CHECK-LABEL: define swiftcc void @test(%TSo014OuterTypeInnerB0C* swiftself, %swift.type* %Self, i8** %SelfWitnessTable)
12-
// CHECK: [[TMP:%.*]] = call {{.*}}@"$sSo9OuterTypeCMD"
13-
// CHECK: call swiftcc void @use_metatype(%swift.type* [[TMP]])
12+
// FIXME: Metadata realization via demangling is disabled for now
13+
// CHECK: [[TMP:%.*]] = call swiftcc %swift.metadata_response @"$sSo9OuterTypeCMa"
14+
// CHECK: [[METADATA:%.*]] = extractvalue %swift.metadata_response %1, 0
15+
// CHECK: call swiftcc void @use_metatype(%swift.type* [[METADATA]])
1416
// CHECK: ret void
1517

1618
sil @test : $@convention(witness_method: NSRuncing) (@guaranteed OuterType.InnerType) -> () {

0 commit comments

Comments
 (0)