[llvm] r324551 - Fix PR36268.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 7 17:16:05 PST 2018
Author: rafael
Date: Wed Feb 7 17:16:05 2018
New Revision: 324551
URL: http://llvm.org/viewvc/llvm-project?rev=324551&view=rev
Log:
Fix PR36268.
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.
I will commit a patch to clang in a minute.
Modified:
llvm/trunk/include/llvm/IR/GlobalValue.h
Modified: llvm/trunk/include/llvm/IR/GlobalValue.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/GlobalValue.h?rev=324551&r1=324550&r2=324551&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/GlobalValue.h (original)
+++ llvm/trunk/include/llvm/IR/GlobalValue.h Wed Feb 7 17:16:05 2018
@@ -112,6 +112,12 @@ protected:
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 @@ public:
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 @@ public:
}
void setLinkage(LinkageTypes LT) {
- if (isLocalLinkage(LT)) {
+ if (isLocalLinkage(LT))
Visibility = DefaultVisibility;
- setDSOLocal(true);
- }
Linkage = LT;
+ maybeSetDsoLocal();
}
LinkageTypes getLinkage() const { return LinkageTypes(Linkage); }
More information about the llvm-commits
mailing list