-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set dllstorage on ObjectiveC ivar offsets #77385
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write If you have received no comments on your PR for a week, you can request a review If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-clang @llvm/pr-subscribers-clang-codegen Author: Frederik Carlier (qmfrederik) ChangesMark instance variable offset symbols with /cc @davidchisnall Full diff: https://github.com/llvm/llvm-project/pull/77385.diff 2 Files Affected:
diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp
index 4ca1a8cce64d89..9443fecf9b7946 100644
--- a/clang/lib/CodeGen/CGObjCGNU.cpp
+++ b/clang/lib/CodeGen/CGObjCGNU.cpp
@@ -1851,6 +1851,8 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
llvm::GlobalValue::HiddenVisibility :
llvm::GlobalValue::DefaultVisibility;
OffsetVar->setVisibility(ivarVisibility);
+ if (ivarVisibility != llvm::GlobalValue::HiddenVisibility)
+ CGM.setGVProperties(OffsetVar, OID->getClassInterface());
ivarBuilder.add(OffsetVar);
// Ivar size
ivarBuilder.addInt(Int32Ty,
diff --git a/clang/test/CodeGenObjC/dllstorage.m b/clang/test/CodeGenObjC/dllstorage.m
index 64ba21f9769ae2..0dbf1881caa9c0 100644
--- a/clang/test/CodeGenObjC/dllstorage.m
+++ b/clang/test/CodeGenObjC/dllstorage.m
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -fdeclspec -fobjc-runtime=ios -fobjc-exceptions -S -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap -check-prefix CHECK-IR %s
+// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -fdeclspec -fobjc-runtime=gnustep-2.0 -fobjc-exceptions -S -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap -check-prefix CHECK-NF %s
// RUN: %clang_cc1 -triple i686-windows-itanium -fms-extensions -fobjc-runtime=macosx -fdeclspec -fobjc-exceptions -S -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap -check-prefix CHECK-IR %s
// RUN: %clang_cc1 -triple i686-windows-itanium -fms-extensions -fobjc-runtime=objfw -fdeclspec -fobjc-exceptions -S -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap -check-prefix CHECK-FW %s
@@ -12,6 +13,8 @@ + (instancetype) new;
// CHECK-IR-DAG: @"OBJC_METACLASS_$_I" = external dllimport global %struct._class_t
// CHECK-IR-DAG: @"OBJC_CLASS_$_I" = external dllimport global %struct._class_t
+// CHECK-NF-DAG: @"$_OBJC_CLASS_I" = external dllimport global ptr
+
__declspec(dllexport)
@interface J : I
@end
@@ -22,6 +25,9 @@ @interface J : I
// CHECK-FW-DAG: @_OBJC_METACLASS_J = dso_local dllexport global
// CHECK-FW-DAG: @_OBJC_CLASS_J = dso_local dllexport global
+// CHECK-NF-DAG: @"$_OBJC_METACLASS_J" = internal global
+// CHECK-NF-DAG: @"$_OBJC_CLASS_J" = dllexport global
+
@implementation J {
id _ivar;
}
@@ -29,6 +35,8 @@ @implementation J {
// CHECK-IR-DAG: @"OBJC_IVAR_$_J._ivar" = global i32
+// CHECK-NF-DAG: @"__objc_ivar_offset_J._ivar.\01" = hidden global i32
+
@interface K : J
@end
@@ -38,6 +46,9 @@ @interface K : J
// CHECK-FW-DAG: @_OBJC_METACLASS_K = dso_local global
// CHECK-FW-DAG: @_OBJC_CLASS_K = dso_local global
+// CHECK-NF-DAG: @"$_OBJC_METACLASS_K" = internal global
+// CHECK-NF-DAG: @"$_OBJC_CLASS_K" = global
+
@implementation K {
id _ivar;
}
@@ -45,6 +56,8 @@ @implementation K {
// CHECK-IR-DAG: @"OBJC_IVAR_$_K._ivar" = global i32
+// CHECK-NF-DAG: @"__objc_ivar_offset_K._ivar.\01" = hidden global i32
+
__declspec(dllexport)
@interface L : K
@end
@@ -55,6 +68,9 @@ @interface L : K
// CHECK-FW-DAG: @_OBJC_METACLASS_L = dso_local dllexport global
// CHECK-FW-DAG: @_OBJC_CLASS_L = dso_local dllexport global
+// CHECK-NF-DAG: @"$_OBJC_METACLASS_L" = internal global
+// CHECK-NF-DAG: @"$_OBJC_CLASS_L" = dllexport global
+
@implementation L {
id _none;
@@ -78,6 +94,12 @@ @implementation L {
// CHECK-IR-DAG: @"OBJC_IVAR_$_L._package" = global i32
// CHECK-IR-DAG: @"OBJC_IVAR_$_L._private" = global i32
+// CHECK-NF-DAG: @"__objc_ivar_offset_L._none.\01" = hidden global i32
+// CHECK-NF-DAG: @"__objc_ivar_offset_L._public.\01" = dso_local dllexport global i32
+// CHECK-NF-DAG: @"__objc_ivar_offset_L._protected.\01" = dso_local dllexport global i32
+// CHECK-NF-DAG: @"__objc_ivar_offset_L._package.\01" = hidden global i32
+// CHECK-NF-DAG: @"__objc_ivar_offset_L._private.\01" = hidden global i32
+
__declspec(dllimport)
@interface M : I {
@public
@@ -89,6 +111,9 @@ @interface M : I {
// CHECK-IR-DAG: @"OBJC_IVAR_$_M._ivar" = external dllimport global i32
+// CHECK-NF-DAG: @"$_OBJC_REF_CLASS_M" = external dllimport global ptr
+// CHECK-NF-DAG: @"__objc_ivar_offset_M._ivar.\01" = external global i32
+
__declspec(dllexport)
__attribute__((__objc_exception__))
@interface N : I
@@ -97,6 +122,8 @@ @interface N : I
// CHECK-FW-DAG: @_OBJC_METACLASS_N = dso_local dllexport global
// CHECK-FW-DAG: @_OBJC_CLASS_N = dso_local dllexport global
+// CHECK-NF-DAG: @"$_OBJC_CLASS_N" = dllexport global
+
@implementation N : I
@end
@@ -124,6 +151,8 @@ id f(Q *q) {
// CHECK-IR-DAG: @"OBJC_IVAR_$_M._ivar" = external dllimport global i32
+// CHECK-NF-DAG: @"__objc_ivar_offset_M._ivar.\01" = external global i32
+
int g(void) {
@autoreleasepool {
M *mi = [M new];
|
Thanks @davidchisnall . Do you plan to get this merged? |
I didn’t intentional hit close, not sure what happened there. |
No worries, thanks! :-) |
Mark instance variable offset symbols with `dllexport`/`dllimport` if they are not hidden and the interface declaration is marked with `dllexport`/`dllimport`, when using the GNUstep 2.x ABI. /cc @davidchisnall
Mark instance variable offset symbols with
dllexport
/dllimport
if they are not hidden and the interface declaration is marked withdllexport
/dllimport
, when using the GNUstep 2.x ABI./cc @davidchisnall