summaryrefslogtreecommitdiff
path: root/include/llvm/GlobalValue.h
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2012-01-11 00:13:08 +0000
committerBill Wendling <isanbard@gmail.com>2012-01-11 00:13:08 +0000
commit37b94c6b4e605c522164bcafc58ea1e1afb50cc0 (patch)
tree70979afa0d13ea1f8c04a6dfea8a4b40e2cd2e67 /include/llvm/GlobalValue.h
parentdcc296d420d064e4cedfc80abc8df6bfb0b35b03 (diff)
downloadllvm-37b94c6b4e605c522164bcafc58ea1e1afb50cc0.tar.gz
llvm-37b94c6b4e605c522164bcafc58ea1e1afb50cc0.tar.bz2
llvm-37b94c6b4e605c522164bcafc58ea1e1afb50cc0.tar.xz
If the global variable is removed by the linker, then don't constant merge it
with other symbols. An object in the __cfstring section is suppoed to be filled with CFString objects, which have a pointer to ___CFConstantStringClassReference followed by a pointer to a __cstring. If we allow the object in the __cstring section to be merged with another global, then it could end up in any section. Because the linker is going to remove these symbols in the final executable, we shouldn't bother to merge them. <rdar://problem/10564621> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147899 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/GlobalValue.h')
-rw-r--r--include/llvm/GlobalValue.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/llvm/GlobalValue.h b/include/llvm/GlobalValue.h
index 81a11a4c92..d43a2fa227 100644
--- a/include/llvm/GlobalValue.h
+++ b/include/llvm/GlobalValue.h
@@ -192,6 +192,14 @@ public:
Linkage == LinkerPrivateWeakDefAutoLinkage;
}
+ /// mayBeRemovedByLinker - Whether the definition of this global may be
+ /// removed at link time.
+ static bool mayBeRemovedByLinker(LinkageTypes Linkage) {
+ return isLinkerPrivateLinkage(Linkage) ||
+ isLinkerPrivateWeakLinkage(Linkage) ||
+ isLinkerPrivateWeakDefAutoLinkage(Linkage);
+ }
+
bool hasExternalLinkage() const { return isExternalLinkage(Linkage); }
bool hasAvailableExternallyLinkage() const {
return isAvailableExternallyLinkage(Linkage);
@@ -225,6 +233,8 @@ public:
bool isWeakForLinker() const { return isWeakForLinker(Linkage); }
+ bool mayBeRemovedByLinker() const { return mayBeRemovedByLinker(Linkage); }
+
/// copyAttributesFrom - copy all additional attributes (those not needed to
/// create a GlobalValue) from the GlobalValue Src to this one.
virtual void copyAttributesFrom(const GlobalValue *Src);