PR target/23071
authormrs <mrs@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 22 Mar 2010 23:13:10 +0000 (23:13 +0000)
committermrs <mrs@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 22 Mar 2010 23:13:10 +0000 (23:13 +0000)
* config/rs6000/rs6000.c (darwin_rs6000_special_round_type_align):
Don't overly align based upon packed packed fields.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157654 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/rs6000/rs6000.c
gcc/testsuite/gcc.target/powerpc/darwin-abi-12.c [new file with mode: 0644]

index f8515cd..e1bd54a 100644 (file)
@@ -1,3 +1,9 @@
+2010-03-22  Mike Stump  <mikestump@comcast.net>
+
+       PR target/23071
+       * config/rs6000/rs6000.c (darwin_rs6000_special_round_type_align):
+       Don't overly align based upon packed packed fields.
+
 2010-03-22  Jason Merrill  <jason@redhat.com>
 
        * c-pretty-print.c (pp_c_specifier_qualifier_list) [VECTOR_TYPE]:
index dea0271..ab48e82 100644 (file)
@@ -4653,6 +4653,9 @@ darwin_rs6000_special_round_type_align (tree type, unsigned int computed,
       field = TREE_CHAIN (field);
     if (! field)
       break;
+    /* A packed field does not contribute any extra alignment.  */
+    if (DECL_PACKED (field))
+      return align;
     type = TREE_TYPE (field);
     while (TREE_CODE (type) == ARRAY_TYPE)
       type = TREE_TYPE (type);
diff --git a/gcc/testsuite/gcc.target/powerpc/darwin-abi-12.c b/gcc/testsuite/gcc.target/powerpc/darwin-abi-12.c
new file mode 100644 (file)
index 0000000..d02c486
--- /dev/null
@@ -0,0 +1,14 @@
+/* { dg-do compile { target powerpc*-*-darwin* } } */
+/* { dg-final { scan-assembler ".comm _x,12,2" } } */
+/* { dg-final { scan-assembler-not ".space 7" } } */
+/* PR 23071 */
+
+struct Test {
+  double D __attribute__((packed,aligned(4)));
+  short X;
+} x;
+
+struct {
+  char x;
+  struct Test t;
+} b = { 1, { 2, 3 } };