[cfe-commits] r152552 - in /cfe/trunk: lib/Basic/Targets.cpp test/CodeGen/arm-aapcs-zerolength-bitfield.c
James Molloy
james.molloy at arm.com
Mon Mar 12 02:14:10 PDT 2012
Author: jamesm
Date: Mon Mar 12 04:14:10 2012
New Revision: 152552
URL: http://llvm.org/viewvc/llvm-project?rev=152552&view=rev
Log:
Use ZeroLengthBitfieldAlignment for AAPCS, as well as APCS-GNU.
Added:
cfe/trunk/test/CodeGen/arm-aapcs-zerolength-bitfield.c
- copied, changed from r152302, cfe/trunk/test/CodeGen/arm-apcs-zerolength-bitfield.c
Modified:
cfe/trunk/lib/Basic/Targets.cpp
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=152552&r1=152551&r2=152552&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Mar 12 04:14:10 2012
@@ -2653,6 +2653,12 @@
// ARM has atomics up to 8 bytes
// FIXME: Set MaxAtomicInlineWidth if we have the feature v6e
MaxAtomicPromoteWidth = 64;
+
+ // Do force alignment of members that follow zero length bitfields. If
+ // the alignment of the zero-length bitfield is greater than the member
+ // that follows it, `bar', `bar' will be aligned as the type of the
+ // zero length bitfield.
+ UseZeroLengthBitfieldAlignment = true;
}
virtual const char *getABI() const { return ABI.c_str(); }
virtual bool setABI(const std::string &Name) {
@@ -2673,12 +2679,6 @@
// structures. This corresponds to PCC_BITFIELD_TYPE_MATTERS in gcc.
UseBitFieldTypeAlignment = false;
- /// Do force alignment of members that follow zero length bitfields. If
- /// the alignment of the zero-length bitfield is greater than the member
- /// that follows it, `bar', `bar' will be aligned as the type of the
- /// zero length bitfield.
- UseZeroLengthBitfieldAlignment = true;
-
/// gcc forces the alignment to 4 bytes, regardless of the type of the
/// zero length bitfield. This corresponds to EMPTY_FIELD_BOUNDARY in
/// gcc.
Copied: cfe/trunk/test/CodeGen/arm-aapcs-zerolength-bitfield.c (from r152302, cfe/trunk/test/CodeGen/arm-apcs-zerolength-bitfield.c)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-aapcs-zerolength-bitfield.c?p2=cfe/trunk/test/CodeGen/arm-aapcs-zerolength-bitfield.c&p1=cfe/trunk/test/CodeGen/arm-apcs-zerolength-bitfield.c&r1=152302&r2=152552&rev=152552&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/arm-apcs-zerolength-bitfield.c (original)
+++ cfe/trunk/test/CodeGen/arm-aapcs-zerolength-bitfield.c Mon Mar 12 04:14:10 2012
@@ -1,8 +1,4 @@
-// RUN: %clang_cc1 -target-abi apcs-gnu -triple armv7-apple-darwin10 %s -verify
-//
-// Note: gcc forces the alignment to 4 bytes, regardless of the type of the
-// zero length bitfield.
-// rdar://9859156
+// RUN: %clang_cc1 -target-abi aapcs -triple armv7-apple-darwin10 %s -verify
#include <stddef.h>
@@ -12,8 +8,8 @@
char : 0;
char bar;
};
-static int arr1_offset[(offsetof(struct t1, bar) == 4) ? 0 : -1];
-static int arr1_sizeof[(sizeof(struct t1) == 8) ? 0 : -1];
+static int arr1_offset[(offsetof(struct t1, bar) == 1) ? 0 : -1];
+static int arr1_sizeof[(sizeof(struct t1) == 4) ? 0 : -1];
struct t2
{
@@ -21,8 +17,8 @@
short : 0;
char bar;
};
-static int arr2_offset[(offsetof(struct t2, bar) == 4) ? 0 : -1];
-static int arr2_sizeof[(sizeof(struct t2) == 8) ? 0 : -1];
+static int arr2_offset[(offsetof(struct t2, bar) == 2) ? 0 : -1];
+static int arr2_sizeof[(sizeof(struct t2) == 4) ? 0 : -1];
struct t3
{
@@ -48,8 +44,8 @@
long long : 0;
char bar;
};
-static int arr5_offset[(offsetof(struct t5, bar) == 4) ? 0 : -1];
-static int arr5_sizeof[(sizeof(struct t5) == 8) ? 0 : -1];
+static int arr5_offset[(offsetof(struct t5, bar) == 8) ? 0 : -1];
+static int arr5_sizeof[(sizeof(struct t5) == 16) ? 0 : -1];
struct t6
{
@@ -58,8 +54,8 @@
char bar : 1;
char bar2;
};
-static int arr6_offset[(offsetof(struct t6, bar2) == 5) ? 0 : -1];
-static int arr6_sizeof[(sizeof(struct t6) == 8) ? 0 : -1];
+static int arr6_offset[(offsetof(struct t6, bar2) == 2) ? 0 : -1];
+static int arr6_sizeof[(sizeof(struct t6) == 4) ? 0 : -1];
struct t7
{
@@ -68,8 +64,8 @@
char bar1 : 1;
char bar2;
};
-static int arr7_offset[(offsetof(struct t7, bar2) == 5) ? 0 : -1];
-static int arr7_sizeof[(sizeof(struct t7) == 8) ? 0 : -1];
+static int arr7_offset[(offsetof(struct t7, bar2) == 3) ? 0 : -1];
+static int arr7_sizeof[(sizeof(struct t7) == 4) ? 0 : -1];
struct t8
{
@@ -98,8 +94,8 @@
char bar1 : 1;
char bar2;
};
-static int arr10_offset[(offsetof(struct t10, bar2) == 5) ? 0 : -1];
-static int arr10_sizeof[(sizeof(struct t10) == 8) ? 0 : -1];
+static int arr10_offset[(offsetof(struct t10, bar2) == 9) ? 0 : -1];
+static int arr10_sizeof[(sizeof(struct t10) == 16) ? 0 : -1];
struct t11
{
@@ -109,8 +105,8 @@
char bar1 : 1;
char bar2;
};
-static int arr11_offset[(offsetof(struct t11, bar2) == 5) ? 0 : -1];
-static int arr11_sizeof[(sizeof(struct t11) == 8) ? 0 : -1];
+static int arr11_offset[(offsetof(struct t11, bar2) == 9) ? 0 : -1];
+static int arr11_sizeof[(sizeof(struct t11) == 16) ? 0 : -1];
struct t12
{
@@ -120,8 +116,8 @@
char : 0;
char bar;
};
-static int arr12_offset[(offsetof(struct t12, bar) == 4) ? 0 : -1];
-static int arr12_sizeof[(sizeof(struct t12) == 8) ? 0 : -1];
+static int arr12_offset[(offsetof(struct t12, bar) == 8) ? 0 : -1];
+static int arr12_sizeof[(sizeof(struct t12) == 16) ? 0 : -1];
struct t13
{
@@ -228,11 +224,11 @@
short foo7: 16;
short foo8: 16;
};
-static int arr21_bar1_offset[(offsetof(struct t21, bar1) == 8) ? 0 : -1];
-static int arr21_bar2_offset[(offsetof(struct t21, bar2) == 12) ? 0 : -1];
-static int arr21_bar3_offset[(offsetof(struct t21, bar3) == 16) ? 0 : -1];
-static int arr21_bar4_offset[(offsetof(struct t21, bar4) == 32) ? 0 : -1];
-static int arr21_sizeof[(sizeof(struct t21) == 44) ? 0 : -1];
+static int arr21_bar1_offset[(offsetof(struct t21, bar1) == 4) ? 0 : -1];
+static int arr21_bar2_offset[(offsetof(struct t21, bar2) == 8) ? 0 : -1];
+static int arr21_bar3_offset[(offsetof(struct t21, bar3) == 12) ? 0 : -1];
+static int arr21_bar4_offset[(offsetof(struct t21, bar4) == 28) ? 0 : -1];
+static int arr21_sizeof[(sizeof(struct t21) == 40) ? 0 : -1];
int main() {
return 0;
More information about the cfe-commits
mailing list