Fix GitHub issue #168 – alignment of globals.

This commit is contained in:
David Nadlinger
2012-09-28 01:46:24 +02:00
parent 4b3662adfd
commit 5f6447e52c
2 changed files with 12 additions and 4 deletions

View File

@@ -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;
}