Skip to content

Commit 61872fa

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 9b4906d commit 61872fa

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

lib/IRGen/MetadataRequest.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2137,10 +2137,7 @@ static bool shouldAccessByMangledName(IRGenModule &IGM, CanType type) {
21372137
if (auto nom = dyn_cast<NominalType>(type)) {
21382138
if (!isa<ProtocolDecl>(nom->getDecl())
21392139
&& (!nom->getDecl()->isGenericContext()
2140-
|| nom->getDecl()->getGenericSignature()->areAllParamsConcrete())
2141-
&& (!nom->getClassOrBoundGenericClass()
2142-
|| !nom->getClassOrBoundGenericClass()->hasClangNode()
2143-
|| nom->getClassOrBoundGenericClass()->isForeign())) {
2140+
|| nom->getDecl()->getGenericSignature()->areAllParamsConcrete())) {
21442141
return false;
21452142
}
21462143
}

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) -> () {

test/IRGen/prespecialized-metadata/struct-inmodule-1argument-clang_node-1distinct_use.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ struct Value<T> {
2626

2727
// CHECK: define hidden swiftcc void @"$s4main4doityyF"() #{{[0-9]+}} {
2828
// CHECK: [[TYPE:%[0-9]+]] = call %swift.type* @__swift_instantiateConcreteTypeFromMangledName({ i32, i32 }* @"$s4main5ValueVySo12NSDictionaryCGMD") #{{[0-9]+}}
29-
// CHECK: call swiftcc void @"$s4main7consumeyyxlF"(%swift.opaque* noalias nocapture %12, %swift.type* [[TYPE]])
29+
// CHECK: call swiftcc void @"$s4main7consumeyyxlF"(%swift.opaque* noalias nocapture {{%.*}}, %swift.type* [[TYPE]])
3030
// CHECK: }
3131
func doit() {
3232
consume(Value(NSDictionary()))

0 commit comments

Comments
 (0)