summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
diff options
context:
space:
mode:
authorJohn Brawn <john.brawn@arm.com>2015-07-17 12:12:03 +0000
committerJohn Brawn <john.brawn@arm.com>2015-07-17 12:12:03 +0000
commit9ca9ca2805db7542530dbc41c9ee0f8a20cfa769 (patch)
treeeecdceffe2ee2441b78f7c73a83a0547f5ec9463 /llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
parent022622f1d4ee7fc981d182868e0d8aded4c346fe (diff)
downloadbcm5719-llvm-9ca9ca2805db7542530dbc41c9ee0f8a20cfa769.tar.gz
bcm5719-llvm-9ca9ca2805db7542530dbc41c9ee0f8a20cfa769.zip
Make global aliases have symbol size equal to their type
This is mainly for the benefit of GlobalMerge, so that an alias into a MergedGlobals variable has the same size as the original non-merged variable. Differential Revision: http://reviews.llvm.org/D10837 llvm-svn: 242520
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 6766fb62b66..068b9172e9f 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1111,6 +1111,16 @@ bool AsmPrinter::doFinalization(Module &M) {
// Emit the directives as assignments aka .set:
OutStreamer->EmitAssignment(Name, lowerConstant(Alias.getAliasee()));
+
+ // Set the size of the alias symbol if we can, as otherwise the alias gets
+ // the size of the aliasee which may not be correct e.g. if the alias is of
+ // a member of a struct.
+ if (MAI->hasDotTypeDotSizeDirective() && Alias.getValueType()->isSized()) {
+ const DataLayout &DL = M.getDataLayout();
+ uint64_t Size = DL.getTypeAllocSize(Alias.getValueType());
+ OutStreamer->emitELFSize(cast<MCSymbolELF>(Name),
+ MCConstantExpr::create(Size, OutContext));
+ }
}
GCModuleInfo *MI = getAnalysisIfAvailable<GCModuleInfo>();
OpenPOWER on IntegriCloud