[PATCH] D43029: Fix PR36268
Rafael Avila de Espindola via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 7 10:26:26 PST 2018
espindola created this revision.
espindola added reviewers: rnk, hans, thakis.
The issue is that clang was first creating a extern_weak hidden GV and then changing the linkage to external.
Once we know it is not extern_weak we know it must be dso_local.
This patch refactors the code that sets the implicit dso_local to a helper private function that is used every time we change the linkage or visibility.
https://reviews.llvm.org/D43029
Files:
clang/test/CodeGenObjC/availability-dso-local.m
llvm/include/llvm/IR/GlobalValue.h
Index: llvm/include/llvm/IR/GlobalValue.h
===================================================================
--- llvm/include/llvm/IR/GlobalValue.h
+++ llvm/include/llvm/IR/GlobalValue.h
@@ -112,6 +112,12 @@
private:
friend class Constant;
+ void maybeSetDsoLocal() {
+ if (hasLocalLinkage() ||
+ (!hasDefaultVisibility() && !hasExternalWeakLinkage()))
+ setDSOLocal(true);
+ }
+
// Give subclasses access to what otherwise would be wasted padding.
// (17 + 4 + 2 + 2 + 2 + 3 + 1 + 1) == 32.
unsigned SubClassData : GlobalValueSubClassDataBits;
@@ -233,8 +239,7 @@
assert((!hasLocalLinkage() || V == DefaultVisibility) &&
"local linkage requires default visibility");
Visibility = V;
- if (!hasExternalWeakLinkage() && V != DefaultVisibility)
- setDSOLocal(true);
+ maybeSetDsoLocal();
}
/// If the value is "Thread Local", its value isn't shared by the threads.
@@ -437,11 +442,10 @@
}
void setLinkage(LinkageTypes LT) {
- if (isLocalLinkage(LT)) {
+ if (isLocalLinkage(LT))
Visibility = DefaultVisibility;
- setDSOLocal(true);
- }
Linkage = LT;
+ maybeSetDsoLocal();
}
LinkageTypes getLinkage() const { return LinkageTypes(Linkage); }
Index: clang/test/CodeGenObjC/availability-dso-local.m
===================================================================
--- /dev/null
+++ clang/test/CodeGenObjC/availability-dso-local.m
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple thumbv7-apple-ios10.0.0 -emit-llvm -fvisibility hidden -w %s -o - | FileCheck %s
+
+// CHECK: @"OBJC_CLASS_$_a" = hidden global %struct._class_t
+
+__attribute__((availability(ios, introduced = 11.0))) @interface a @end
+ @implementation a @end
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43029.133246.patch
Type: text/x-patch
Size: 1737 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180207/821ed1be/attachment.bin>
More information about the llvm-commits
mailing list