summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/GlobalMerge.cpp
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2018-02-12 21:14:21 +0000
committerMartin Storsjo <martin@martin.st>2018-02-12 21:14:21 +0000
commit9ca8b5718682b54cc9de5d215a590d54eb4dd4b0 (patch)
treeb3e78c107a79a3bb2e21dcf15f6f0ffdfabf7210 /llvm/lib/CodeGen/GlobalMerge.cpp
parent520789e139565fa588f172700908d5c8fe8f6876 (diff)
downloadbcm5719-llvm-9ca8b5718682b54cc9de5d215a590d54eb4dd4b0.tar.gz
bcm5719-llvm-9ca8b5718682b54cc9de5d215a590d54eb4dd4b0.zip
[GlobalMerge] Allow merging of dllexported variables
If merging them, the dllexport attribute needs to be brought along to the new GlobalAlias. Differential Revision: https://reviews.llvm.org/D43192 llvm-svn: 324937
Diffstat (limited to 'llvm/lib/CodeGen/GlobalMerge.cpp')
-rw-r--r--llvm/lib/CodeGen/GlobalMerge.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/GlobalMerge.cpp b/llvm/lib/CodeGen/GlobalMerge.cpp
index 3888226fa05..6d47b29bc3c 100644
--- a/llvm/lib/CodeGen/GlobalMerge.cpp
+++ b/llvm/lib/CodeGen/GlobalMerge.cpp
@@ -497,6 +497,8 @@ bool GlobalMerge::doMerge(const SmallVectorImpl<GlobalVariable *> &Globals,
for (ssize_t k = i, idx = 0; k != j; k = GlobalSet.find_next(k), ++idx) {
GlobalValue::LinkageTypes Linkage = Globals[k]->getLinkage();
std::string Name = Globals[k]->getName();
+ GlobalValue::DLLStorageClassTypes DLLStorage =
+ Globals[k]->getDLLStorageClass();
// Copy metadata while adjusting any debug info metadata by the original
// global's offset within the merged global.
@@ -517,7 +519,9 @@ bool GlobalMerge::doMerge(const SmallVectorImpl<GlobalVariable *> &Globals,
// It's not safe on Mach-O as the alias (and thus the portion of the
// MergedGlobals variable) may be dead stripped at link time.
if (Linkage != GlobalValue::InternalLinkage || !IsMachO) {
- GlobalAlias::create(Tys[idx], AddrSpace, Linkage, Name, GEP, &M);
+ GlobalAlias *GA =
+ GlobalAlias::create(Tys[idx], AddrSpace, Linkage, Name, GEP, &M);
+ GA->setDLLStorageClass(DLLStorage);
}
NumMerged++;
@@ -577,8 +581,7 @@ bool GlobalMerge::doInitialization(Module &M) {
for (auto &GV : M.globals()) {
// Merge is safe for "normal" internal or external globals only
if (GV.isDeclaration() || GV.isThreadLocal() ||
- GV.hasSection() || GV.hasImplicitSection() ||
- GV.hasDLLExportStorageClass())
+ GV.hasSection() || GV.hasImplicitSection())
continue;
// It's not safe to merge globals that may be preempted
OpenPOWER on IntegriCloud