[llvm-branch-commits] [cfe-branch] r102091 - in /cfe/branches/Apple/williamson: lib/Basic/Targets.cpp test/CodeGen/arm-arguments.c test/Sema/arm-layout.c

Daniel Dunbar daniel at zuster.org
Thu Apr 22 10:18:24 PDT 2010


Author: ddunbar
Date: Thu Apr 22 12:18:24 2010
New Revision: 102091

URL: http://llvm.org/viewvc/llvm-project?rev=102091&view=rev
Log:
ARM/APCS: Don't respect bit-field types when laying out structures. - This fixes the last known ABI issues with ARM/APCS.

- I've run the first 1k ABITests with '--no-unsigned --no-vector --no-complex'
   on {armv6, armv7} x {-mno-thumb, -mthumb}, and the first 10k tests for armv7
   -mthumb, for both function return types and single argument calls. These all
   pass now (they failed horribly before without --no-bitfield).

Modified:
    cfe/branches/Apple/williamson/lib/Basic/Targets.cpp
    cfe/branches/Apple/williamson/test/CodeGen/arm-arguments.c
    cfe/branches/Apple/williamson/test/Sema/arm-layout.c

Modified: cfe/branches/Apple/williamson/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/williamson/lib/Basic/Targets.cpp?rev=102091&r1=102090&r2=102091&view=diff
==============================================================================
--- cfe/branches/Apple/williamson/lib/Basic/Targets.cpp (original)
+++ cfe/branches/Apple/williamson/lib/Basic/Targets.cpp Thu Apr 22 12:18:24 2010
@@ -1396,6 +1396,10 @@
       DoubleAlign = LongLongAlign = LongDoubleAlign = 32;
       SizeType = UnsignedLong;
 
+      // Do not respect the alignment of bit-field types when laying out
+      // structures. This corresponds to PCC_BITFIELD_TYPE_MATTERS in gcc.
+      UseBitFieldTypeAlignment = false;
+
       if (IsThumb) {
         DescriptionString = ("e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-"
                              "i64:32:32-f32:32:32-f64:32:32-"

Modified: cfe/branches/Apple/williamson/test/CodeGen/arm-arguments.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/williamson/test/CodeGen/arm-arguments.c?rev=102091&r1=102090&r2=102091&view=diff
==============================================================================
--- cfe/branches/Apple/williamson/test/CodeGen/arm-arguments.c (original)
+++ cfe/branches/Apple/williamson/test/CodeGen/arm-arguments.c Thu Apr 22 12:18:24 2010
@@ -115,7 +115,7 @@
 struct s20 { struct s8 f1; int f0; };
 struct s20 f20(void) {}
 
-// APCS-GNU: define arm_apcscc i32 @f21()
+// APCS-GNU: define arm_apcscc i8 @f21()
 // AAPCS: define arm_aapcscc i32 @f21()
 struct s21 { struct {} f1; int f0 : 4; };
 struct s21 f21(void) {}

Modified: cfe/branches/Apple/williamson/test/Sema/arm-layout.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/williamson/test/Sema/arm-layout.c?rev=102091&r1=102090&r2=102091&view=diff
==============================================================================
--- cfe/branches/Apple/williamson/test/Sema/arm-layout.c (original)
+++ cfe/branches/Apple/williamson/test/Sema/arm-layout.c Thu Apr 22 12:18:24 2010
@@ -1,20 +1,53 @@
 // RUN: %clang_cc1 -triple armv7-unknown-unknown -target-abi apcs-gnu %s -verify
 // RUN: %clang_cc1 -triple armv7-unknown-unknown -target-abi aapcs %s -verify
 
-#ifdef __ARM_EABI__
+#define check(name, cond) int _##name##_check[(cond) ? 1 : -1]
 
 struct s0 { char field0; double field1; };
-int g0[sizeof(struct s0) == 16 ? 1 : -1];
+#ifdef __ARM_EABI__
+check(s0_size, sizeof(struct s0) == 16);
+#else
+check(s0_size, sizeof(struct s0) == 12);
+#endif
 
 struct s1 { char field0; long double field1; };
-int g1[sizeof(struct s1) == 16 ? 1 : -1];
-
+#ifdef __ARM_EABI__
+check(s1_size, sizeof(struct s1) == 16);
 #else
+check(s1_size, sizeof(struct s1) == 12);
+#endif
 
-struct s0 { char field0; double field1; };
-int g0[sizeof(struct s0) == 12 ? 1 : -1];
-
-struct s1 { char field0; long double field1; };
-int g1[sizeof(struct s1) == 12 ? 1 : -1];
+struct s2 {
+  short field0;
+  int field1 : 24;
+  char field2;
+};
+#ifdef __ARM_EABI__
+check(s2_size, sizeof(struct s2) == 8);
+check(s2_offset_0, __builtin_offsetof(struct s2, field0) == 0);
+check(s2_offset_1, __builtin_offsetof(struct s2, field2) == 7);
+#else
+check(s2_size, sizeof(struct s2) == 6);
+check(s2_offset_0, __builtin_offsetof(struct s2, field0) == 0);
+check(s2_offset_1, __builtin_offsetof(struct s2, field2) == 5);
+#endif
 
+struct s3 {
+  short field0;
+  int field1 : 24 __attribute__((aligned(4)));
+  char field2;
+};
+check(s3_size, sizeof(struct s3) == 8);
+check(s3_offset_0, __builtin_offsetof(struct s3, field0) == 0);
+check(s3_offset_1, __builtin_offsetof(struct s3, field2) == 7);
+
+struct s4 {
+  int field0 : 4
+};
+#ifdef __ARM_EABI__
+check(s4_size, sizeof(struct s4) == 4);
+check(s4_align, __alignof(struct s4) == 4);
+#else
+check(s4_size, sizeof(struct s4) == 1);
+check(s4_align, __alignof(struct s4) == 1);
 #endif





More information about the llvm-branch-commits mailing list