]> granicus.if.org Git - clang/commitdiff
Ensure we have atleast 2-byte alignment for member functions.
authorMike Stump <mrs@apple.com>
Mon, 5 Oct 2009 22:49:20 +0000 (22:49 +0000)
committerMike Stump <mrs@apple.com>
Mon, 5 Oct 2009 22:49:20 +0000 (22:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83337 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenModule.cpp
test/CodeGenCXX/attr.cpp

index f7fe69e3262509598f524bf1a094dea409ddf413..b9013a8667c4dab207d7508c298f3dbbab439b04 100644 (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,
index 57507d87b3378449378930b0bfc37f44ec0cda2a..8077b7839d88b3bbd76245012330da5005fe74eb 100644 (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: