[PATCH] D43192: [GlobalMerge] Allow merging of dllexported variables
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 12 13:16:15 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL324937: [GlobalMerge] Allow merging of dllexported variables (authored by mstorsjo, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D43192?vs=133856&id=133922#toc
Repository:
rL LLVM
https://reviews.llvm.org/D43192
Files:
llvm/trunk/lib/CodeGen/GlobalMerge.cpp
llvm/trunk/test/CodeGen/ARM/global-merge-dllexport.ll
Index: llvm/trunk/test/CodeGen/ARM/global-merge-dllexport.ll
===================================================================
--- llvm/trunk/test/CodeGen/ARM/global-merge-dllexport.ll
+++ llvm/trunk/test/CodeGen/ARM/global-merge-dllexport.ll
@@ -5,11 +5,17 @@
define void @f1(i32 %a1, i32 %a2) {
; CHECK: f1:
-; CHECK: movw [[REG1:r[0-9]+]], :lower16:x
-; CHECK: movt [[REG1]], :upper16:x
+; CHECK: movw [[REG1:r[0-9]+]], :lower16:.L_MergedGlobals
+; CHECK: movt [[REG1]], :upper16:.L_MergedGlobals
store i32 %a1, i32* @x, align 4
store i32 %a2, i32* @y, align 4
ret void
}
-; CHECK-NOT: .L_MergedGlobals
+; CHECK: .lcomm .L_MergedGlobals,8,4
+; CHECK: .globl x
+; CHECK: x = .L_MergedGlobals
+; CHECK: .globl y
+; CHECK: y = .L_MergedGlobals+4
+; CHECK: .section .drectve,"yn"
+; CHECK: .ascii " /EXPORT:y,DATA"
Index: llvm/trunk/lib/CodeGen/GlobalMerge.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/GlobalMerge.cpp
+++ llvm/trunk/lib/CodeGen/GlobalMerge.cpp
@@ -497,6 +497,8 @@
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 @@
// 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 @@
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43192.133922.patch
Type: text/x-patch
Size: 2374 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180212/4b7c3547/attachment.bin>
More information about the llvm-commits
mailing list