From 08d7802a406ee4a7cc18e8fce0c137b8c410ea7c Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Thu, 29 May 2008 11:10:27 +0000 Subject: Add CodeGen support for alignment on globals, both for unusual natural alignment and alignment attributes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51676 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenModule.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/CodeGen/CodeGenModule.cpp') diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 0b7d30ac50..e5bd15e856 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -477,6 +477,12 @@ void CodeGenModule::EmitGlobalVarInit(const VarDecl *D) { "Initializer codegen type mismatch!"); GV->setInitializer(Init); + unsigned Align = Context.getTypeAlign(D->getType()); + if (const AlignedAttr* AA = D->getAttr()) { + Align = std::max(Align, AA->getAlignment()); + } + GV->setAlignment(Align / 8); + if (const VisibilityAttr *attr = D->getAttr()) setVisibility(GV, attr->getVisibility()); // FIXME: else handle -fvisibility -- cgit v1.2.3-18-g5258