Skip to content

Commit e981834

Browse files
committed
[IRGen] Stop forcing Objective-C class references to be file-local.
Now that we're never relatively addressing an Objective-C class reference, stop emitting them as file-local (by eliminating the \01l_ prefix). This is both a minor optimization and also a way to ensure that things will break more consistently if a problem remains.
1 parent 50b5044 commit e981834

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

lib/IRGen/Linking.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ std::string LinkEntity::mangleAsString() const {
265265
case Kind::ObjCClassRef: {
266266
llvm::SmallString<64> tempBuffer;
267267
StringRef name = cast<ClassDecl>(getDecl())->getObjCRuntimeName(tempBuffer);
268-
std::string Result("\01l_OBJC_CLASS_REF_$_");
268+
std::string Result("OBJC_CLASS_REF_$_");
269269
Result.append(name.data(), name.size());
270270
return Result;
271271
}

test/ClangImporter/attr-swift_private.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public func testTopLevel() {
9292
}
9393

9494
// CHECK-LABEL: define linkonce_odr hidden swiftcc %swift.metadata_response @"$sSo10PrivFooSubCMa{{.*}} {
95-
// CHECK: %objc_class** @"\01l_OBJC_CLASS_REF_$_PrivFooSub"
95+
// CHECK: %objc_class** @"OBJC_CLASS_REF_$_PrivFooSub"
9696
// CHECK: }
9797

9898
// CHECK-LABEL: define linkonce_odr hidden {{.+}} @"$sSo3BarC8__noArgsABSgyt_tcfcTO"

test/ClangImporter/objc_ir.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ func propertyAccess(b b: B) {
7474
// CHECK: load i8*, i8** @"\01L_selector(setCounter:)"
7575
b.counter = b.counter + 1
7676

77-
// CHECK: load %objc_class*, %objc_class** @"\01l_OBJC_CLASS_REF_$_B"
77+
// CHECK: load %objc_class*, %objc_class** @"OBJC_CLASS_REF_$_B"
7878
// CHECK: load i8*, i8** @"\01L_selector(sharedCounter)"
7979
// CHECK: load i8*, i8** @"\01L_selector(setSharedCounter:)"
8080
B.sharedCounter = B.sharedCounter + 1
8181
}
8282

8383
// CHECK-LABEL: define hidden swiftcc %TSo1BC* @"$s7objc_ir8downcast1aSo1BCSo1AC_tF"(
8484
func downcast(a a: A) -> B {
85-
// CHECK: [[CLASS:%.*]] = load %objc_class*, %objc_class** @"\01l_OBJC_CLASS_REF_$_B"
85+
// CHECK: [[CLASS:%.*]] = load %objc_class*, %objc_class** @"OBJC_CLASS_REF_$_B"
8686
// CHECK: [[T0:%.*]] = call %objc_class* @swift_getInitializedObjCClass(%objc_class* [[CLASS]])
8787
// CHECK: [[T1:%.*]] = bitcast %objc_class* [[T0]] to i8*
8888
// CHECK: call i8* @swift_dynamicCastObjCClassUnconditional(i8* [[A:%.*]], i8* [[T1]]) [[NOUNWIND:#[0-9]+]]

test/IRGen/objc_casts.sil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ bb0(%unused : $@thick T.Type, %obj : $NSObject):
3333
// CHECK: [[T0:%.*]] = call %objc_object* @swift_dynamicCastMetatypeToObjectUnconditional(%swift.type* %0)
3434
// TODO: is this really necessary? also, this really shouldn't use a direct reference
3535
// CHECK-NEXT: [[T1:%.*]] = bitcast %objc_object* [[T0]] to i8*
36-
// CHECK-NEXT: [[T2a:%.*]] = load %objc_class*, %objc_class** @"\01l_OBJC_CLASS_REF_$_Foo"
36+
// CHECK-NEXT: [[T2a:%.*]] = load %objc_class*, %objc_class** @"OBJC_CLASS_REF_$_Foo"
3737
// CHECK-NEXT: [[T2:%.*]] = call %objc_class* @swift_getInitializedObjCClass(%objc_class* [[T2a]])
3838
// CHECK-NEXT: [[T3:%.*]] = bitcast %objc_class* [[T2]] to i8*
3939
// CHECK-NEXT: call i8* @swift_dynamicCastObjCClassUnconditional(i8* [[T1]], i8* [[T3]])
@@ -49,7 +49,7 @@ bb0(%metatype : $@thick T.Type):
4949
// CHECK: [[T0:%.*]] = call %objc_object* @swift_dynamicCastMetatypeToObjectUnconditional(%swift.type* [[ARG]])
5050
// TODO: is this really necessary? also, this really shouldn't use a direct reference
5151
// CHECK-NEXT: [[T1:%.*]] = bitcast %objc_object* [[T0]] to i8*
52-
// CHECK-NEXT: [[T2a:%.*]] = load %objc_class*, %objc_class** @"\01l_OBJC_CLASS_REF_$_Foo"
52+
// CHECK-NEXT: [[T2a:%.*]] = load %objc_class*, %objc_class** @"OBJC_CLASS_REF_$_Foo"
5353
// CHECK-NEXT: [[T2:%.*]] = call %objc_class* @swift_getInitializedObjCClass(%objc_class* [[T2a]])
5454
// CHECK-NEXT: [[T3:%.*]] = bitcast %objc_class* [[T2]] to i8*
5555
// CHECK-NEXT: call i8* @swift_dynamicCastObjCClassUnconditional(i8* [[T1]], i8* [[T3]])

test/IRGen/objc_generic_class_metadata.sil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ entry:
3939
%b = metatype $@thick GenericClass<NSObject>.Type
4040
apply %z<GenericClass<NSObject>>(%b) : $@convention(thin) <T> (@thick T.Type) -> ()
4141

42-
// CHECK: [[T0:%.*]] = load %objc_class*, %objc_class** @"\01l_OBJC_CLASS_REF_$_GenericClass",
42+
// CHECK: [[T0:%.*]] = load %objc_class*, %objc_class** @"OBJC_CLASS_REF_$_GenericClass",
4343
// CHECK: [[OBJC_CLASS:%.*]] = call %objc_class* @swift_getInitializedObjCClass(%objc_class* [[T0]])
4444
// CHECK: call swiftcc void @objc_class_sink(%objc_class* [[OBJC_CLASS]], %swift.type* [[METADATA]])
4545
%c = metatype $@objc_metatype GenericClass<NSString>.Type
@@ -79,7 +79,7 @@ entry(%0: @owned $Subclass, %1: @owned $NSDictionary):
7979
}
8080

8181
// CHECK-LABEL: define linkonce_odr hidden swiftcc %swift.metadata_response @"$sSo12GenericClassCMa"(
82-
// CHECK: [[T0:%.*]] = load %objc_class*, %objc_class** @"\01l_OBJC_CLASS_REF_$_GenericClass",
82+
// CHECK: [[T0:%.*]] = load %objc_class*, %objc_class** @"OBJC_CLASS_REF_$_GenericClass",
8383
// CHECK: call %objc_class* @swift_getInitializedObjCClass(%objc_class* [[T0]])
8484

8585
// CHECK-LABEL: define linkonce_odr hidden swiftcc %swift.metadata_response @"$sSaySo12GenericClassC_SitGMa"

test/IRGen/objc_properties_jit.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extension NSString {
1414
}
1515

1616
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} private void @runtime_registration
17-
// CHECK: [[NSOBJECT_UNINIT:%.*]] = load %objc_class*, %objc_class** @"\01l_OBJC_CLASS_REF_$_NSString"
17+
// CHECK: [[NSOBJECT_UNINIT:%.*]] = load %objc_class*, %objc_class** @"OBJC_CLASS_REF_$_NSString"
1818
// CHECK: [[NSOBJECT:%.*]] = call %objc_class* @swift_getInitializedObjCClass(%objc_class* [[NSOBJECT_UNINIT]])
1919
// CHECK: [[GET_CLASS_PROP:%.*]] = call i8* @sel_registerName({{.*}}(classProp)
2020
// CHECK: call i8* @class_replaceMethod(%objc_class* @"OBJC_METACLASS_$_NSString", i8* [[GET_CLASS_PROP]]

0 commit comments

Comments
 (0)