mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-08 11:56:12 +03:00
Use the target pointer size as lower bound for the alignment of LL globals
This is apparently assumed by a std.conv unittest. Using DtoAlignment() here instead of checking for an explicit vd->alignment != STRUCTALIGN_DEFAULT is not only nice for consistency, but also leads to a `struct S { align(16) int a; }` global being correctly aligned on a 16-bytes boundary. The struct itself has no explicit alignment, but alignsize() is 16; so the upstream code doesn't set any explicit alignment for the global.
This commit is contained in:
parent
310ad102d7
commit
a39997d326
1 changed files with 3 additions and 4 deletions
|
@ -892,10 +892,9 @@ void DtoResolveVariable(VarDeclaration* vd)
|
|||
vd->isThreadlocal());
|
||||
getIrGlobal(vd)->value = gvar;
|
||||
|
||||
// Set the alignment (it is important not to use type->alignsize because
|
||||
// VarDeclarations can have an align() attribute independent of the type
|
||||
// as well).
|
||||
gvar->setAlignment(DtoAlignment(vd));
|
||||
// Set the alignment and use the target pointer size as lower bound.
|
||||
unsigned alignment = std::max(DtoAlignment(vd), gDataLayout->getPointerSize());
|
||||
gvar->setAlignment(alignment);
|
||||
|
||||
IF_LOG Logger::cout() << *gvar << '\n';
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue