forked from OSchip/llvm-project
Add CodeGen support for alignment on globals, both for unusual natural
alignment and alignment attributes. llvm-svn: 51676
This commit is contained in:
parent
b65ff27f53
commit
174d9c26f1
|
@ -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<AlignedAttr>()) {
|
||||
Align = std::max(Align, AA->getAlignment());
|
||||
}
|
||||
GV->setAlignment(Align / 8);
|
||||
|
||||
if (const VisibilityAttr *attr = D->getAttr<VisibilityAttr>())
|
||||
setVisibility(GV, attr->getVisibility());
|
||||
// FIXME: else handle -fvisibility
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
// RUN: clang -emit-llvm %s -o - | grep "align 16" | count 2
|
||||
|
||||
__attribute((aligned(16))) float a[128];
|
||||
union {int a[4]; __attribute((aligned(16))) float b[4];} u;
|
Loading…
Reference in New Issue