Ensure we have atleast 2-byte alignment for member functions.

llvm-svn: 83337
This commit is contained in:
Mike Stump 2009-10-05 22:49:20 +00:00
parent 2dfb5da6bb
commit 3472ae5bac
2 changed files with 14 additions and 3 deletions

View File

@ -348,6 +348,9 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
if (const AlignedAttr *AA = D->getAttr<AlignedAttr>())
F->setAlignment(AA->getAlignment()/8);
// C++ ABI requires 2-byte alignment for member functions.
if (F->getAlignment() < 16 && isa<CXXMethodDecl>(D))
F->setAlignment(16/8);
}
void CodeGenModule::SetCommonAttributes(const Decl *D,

View File

@ -10,8 +10,9 @@ int foo() { }
class C {
virtual void bar1() __attribute__((aligned(2)));
virtual void bar2() __attribute__((aligned(1024)));
virtual void bar1() __attribute__((aligned(1)));
virtual void bar2() __attribute__((aligned(2)));
virtual void bar3() __attribute__((aligned(1024)));
} c;
void C::bar1() { }
@ -23,6 +24,13 @@ void C::bar1() { }
void C::bar2() { }
// CHECK:.align 10, 0x90
// CHECK:.align 1, 0x90
// CHECK-NEXT:.globl __ZN1C4bar2Ev
// CHECK-NEXT:__ZN1C4bar2Ev:
void C::bar3() { }
// CHECK:.align 10, 0x90
// CHECK-NEXT:.globl __ZN1C4bar3Ev
// CHECK-NEXT:__ZN1C4bar3Ev: