mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-11 18:33:14 +01:00
Fix GitHub issue #168 – alignment of globals.
This commit is contained in:
@@ -171,8 +171,12 @@ void VarDeclaration::codegen(Ir* p)
|
||||
#endif
|
||||
this->ir.irGlobal->value = gvar;
|
||||
|
||||
// set the alignment
|
||||
gvar->setAlignment(this->type->alignsize());
|
||||
// Set the alignment (it is important not to use type->alignsize because
|
||||
// VarDeclarations can have an align() attribute independent of the type
|
||||
// as well). FIXME: ~0 is really STRUCTALIGN_DEFAULT, change as soon as
|
||||
// 1.075 has been merged.
|
||||
if (alignment != ~0)
|
||||
gvar->setAlignment(alignment);
|
||||
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << *gvar << '\n';
|
||||
|
||||
@@ -60,8 +60,12 @@ LLGlobalVariable * IrStruct::getInitSymbol()
|
||||
init = new llvm::GlobalVariable(
|
||||
*gIR->module, init_type, true, _linkage, NULL, initname);
|
||||
|
||||
// set alignment
|
||||
init->setAlignment(type->alignsize());
|
||||
// set alignment (use of StructDeclaration::alignment analogous to DMD)
|
||||
// FIXME: ~0 is really STRUCTALIGN_DEFAULT, change as soon as 1.075 has
|
||||
// been merged.
|
||||
StructDeclaration *sd = aggrdecl->isStructDeclaration();
|
||||
if (sd && sd->alignment != ~0)
|
||||
init->setAlignment(sd->alignment);
|
||||
|
||||
return init;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user