summaryrefslogtreecommitdiff
path: root/lib/CodeGen/AsmPrinter
diff options
context:
space:
mode:
authorJiangning Liu <jiangning.liu@arm.com>2014-05-15 23:45:42 +0000
committerJiangning Liu <jiangning.liu@arm.com>2014-05-15 23:45:42 +0000
commitd5db8765d61ca77a55867cf1f39aecb8cae3a6cd (patch)
treefd12d05d5eac5450fa954c2aee66443a36a82df2 /lib/CodeGen/AsmPrinter
parent01a02d91dcb47cdc31fe6570f59eac3740d3da0e (diff)
downloadllvm-d5db8765d61ca77a55867cf1f39aecb8cae3a6cd.tar.gz
llvm-d5db8765d61ca77a55867cf1f39aecb8cae3a6cd.tar.bz2
llvm-d5db8765d61ca77a55867cf1f39aecb8cae3a6cd.tar.xz
Implement global merge optimization for global variables.
This commit implements two command line switches -global-merge-on-external and -global-merge-aligned, and both of them are false by default, so this optimization is disabled by default for all targets. For ARM64, some back-end behaviors need to be tuned to get this optimization further enabled. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208934 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/AsmPrinter')
-rw-r--r--lib/CodeGen/AsmPrinter/AsmPrinter.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 37a2c3220c..0c4865f2f2 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -946,8 +946,11 @@ bool AsmPrinter::doFinalization(Module &M) {
EmitVisibility(Name, Alias.getVisibility());
// Emit the directives as assignments aka .set:
- OutStreamer.EmitAssignment(Name,
- MCSymbolRefExpr::Create(Target, OutContext));
+ const MCExpr *Expr = MCSymbolRefExpr::Create(Target, OutContext);
+ if (uint64_t Offset = Alias.calculateOffset(*TM.getDataLayout()))
+ Expr = MCBinaryExpr::CreateAdd(Expr,
+ MCConstantExpr::Create(Offset, OutContext), OutContext);
+ OutStreamer.EmitAssignment(Name, Expr);
}
}