Set explicit alignment for normal global variables, ensures alignment is correct for globals with union type.

This commit is contained in:
Tomas Lindquist Olsen
2009-05-15 17:17:20 +02:00
parent 0680e6a3ca
commit 62e8384da0

View File

@@ -136,6 +136,9 @@ void VarDeclaration::codegen(Ir* p)
llvm::GlobalVariable* gvar = new llvm::GlobalVariable(_type,_isconst,_linkage,NULL,_name,gIR->module);
this->ir.irGlobal->value = gvar;
// set the alignment
gvar->setAlignment(this->type->alignsize());
if (Logger::enabled())
Logger::cout() << *gvar << '\n';