mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-28 03:25:23 +00:00
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242520 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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>();
|
||||
|
Reference in New Issue
Block a user