[cfe-commits] r83337 - in /cfe/trunk: lib/CodeGen/CodeGenModule.cpp test/CodeGenCXX/attr.cpp
Mike Stump
mrs at apple.com
Mon Oct 5 15:49:20 PDT 2009
Author: mrs
Date: Mon Oct 5 17:49:20 2009
New Revision: 83337
URL: http://llvm.org/viewvc/llvm-project?rev=83337&view=rev
Log:
Ensure we have atleast 2-byte alignment for member functions.
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGenCXX/attr.cpp
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=83337&r1=83336&r2=83337&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Oct 5 17:49:20 2009
@@ -348,6 +348,9 @@
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,
Modified: cfe/trunk/test/CodeGenCXX/attr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/attr.cpp?rev=83337&r1=83336&r2=83337&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/attr.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/attr.cpp Mon Oct 5 17:49:20 2009
@@ -10,8 +10,9 @@
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::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:
More information about the cfe-commits
mailing list