aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2009-10-05 22:49:20 +0000
committerMike Stump <mrs@apple.com>2009-10-05 22:49:20 +0000
commitfb51ddfafcd5f8536d0312b3daa3c0b74b90ab5b (patch)
tree3a2dae6e9cd1b10a5d58118409829faf8004158d
parent9a3dcf22342c4bf2be59ffd7abaebd4a9b0b1c4b (diff)
Ensure we have atleast 2-byte alignment for member functions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83337 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/CodeGenModule.cpp3
-rw-r--r--test/CodeGenCXX/attr.cpp14
2 files changed, 14 insertions, 3 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index f7fe69e326..b9013a8667 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -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,
diff --git a/test/CodeGenCXX/attr.cpp b/test/CodeGenCXX/attr.cpp
index 57507d87b3..8077b7839d 100644
--- a/test/CodeGenCXX/attr.cpp
+++ b/test/CodeGenCXX/attr.cpp
@@ -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: