From 62e8384da0bf5877b5b0588b4100a6f20d679806 Mon Sep 17 00:00:00 2001 From: Tomas Lindquist Olsen Date: Fri, 15 May 2009 17:17:20 +0200 Subject: [PATCH] Set explicit alignment for normal global variables, ensures alignment is correct for globals with union type. --- gen/declarations.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gen/declarations.cpp b/gen/declarations.cpp index f3baf5a6..4d495208 100644 --- a/gen/declarations.cpp +++ b/gen/declarations.cpp @@ -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';