]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
rs6000.c (rs6000_function_arg_boundary): In the AIX and ELFv2 ABI...
authorUlrich Weigand <uweigand@de.ibm.com>
Thu, 24 Jul 2014 17:12:45 +0000 (17:12 +0000)
committerUlrich Weigand <uweigand@gcc.gnu.org>
Thu, 24 Jul 2014 17:12:45 +0000 (17:12 +0000)
gcc/

* config/rs6000/rs6000.c (rs6000_function_arg_boundary): In the AIX
and ELFv2 ABI, do not use the "mode == BLKmode" check to test for
aggregate types.  Instead, *all* aggregate types, except for single-
element or homogeneous float/vector aggregates, are quadword-aligned
if required by their type alignment.  Issue -Wpsabi note when a type
is now treated differently than before.

gcc/testsuite/

* gcc.target/powerpc/ppc64-abi-warn-2.c: New test.

From-SVN: r213016

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

index 244cf230c41be099c5cee5ad1f75705db437be75..5436866a48da8d79575e260d15332d4c403b694d 100644 (file)
@@ -1,3 +1,12 @@
+2014-07-24  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
+
+       * config/rs6000/rs6000.c (rs6000_function_arg_boundary): In the AIX
+       and ELFv2 ABI, do not use the "mode == BLKmode" check to test for
+       aggregate types.  Instead, *all* aggregate types, except for single-
+       element or homogeneous float/vector aggregates, are quadword-aligned
+       if required by their type alignment.  Issue -Wpsabi note when a type
+       is now treated differently than before.
+
 2014-07-24  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
        * config/rs6000/rs6000.c (rs6000_function_arg): If a float argument
index 0f028623871faa1bbceb6fc3ee21495b1811e929..49d50a6874cbc183e5a1974d62d788af2fd96e61 100644 (file)
@@ -9184,14 +9184,48 @@ rs6000_function_arg_boundary (enum machine_mode mode, const_tree type)
           || (type && TREE_CODE (type) == VECTOR_TYPE
               && int_size_in_bytes (type) >= 16))
     return 128;
-  else if (((TARGET_MACHO && rs6000_darwin64_abi)
-           || DEFAULT_ABI == ABI_ELFv2
-            || (DEFAULT_ABI == ABI_AIX && !rs6000_compat_align_parm))
-          && mode == BLKmode
-          && type && TYPE_ALIGN (type) > 64)
+
+  /* Aggregate types that need > 8 byte alignment are quadword-aligned
+     in the parameter area in the ELFv2 ABI, and in the AIX ABI unless
+     -mcompat-align-parm is used.  */
+  if (((DEFAULT_ABI == ABI_AIX && !rs6000_compat_align_parm)
+       || DEFAULT_ABI == ABI_ELFv2)
+      && type && TYPE_ALIGN (type) > 64)
+    {
+      /* "Aggregate" means any AGGREGATE_TYPE except for single-element
+         or homogeneous float/vector aggregates here.  We already handled
+         vector aggregates above, but still need to check for float here. */
+      bool aggregate_p = (AGGREGATE_TYPE_P (type)
+                         && !SCALAR_FLOAT_MODE_P (elt_mode));
+
+      /* We used to check for BLKmode instead of the above aggregate type
+        check.  Warn when this results in any difference to the ABI.  */
+      if (aggregate_p != (mode == BLKmode))
+       {
+         static bool warned;
+         if (!warned && warn_psabi)
+           {
+             warned = true;
+             inform (input_location,
+                     "the ABI of passing aggregates with %d-byte alignment"
+                     " has changed in GCC 4.10",
+                     (int) TYPE_ALIGN (type) / BITS_PER_UNIT);
+           }
+       }
+
+      if (aggregate_p)
+       return 128;
+    }
+
+  /* Similar for the Darwin64 ABI.  Note that for historical reasons we
+     implement the "aggregate type" check as a BLKmode check here; this
+     means certain aggregate types are in fact not aligned.  */
+  if (TARGET_MACHO && rs6000_darwin64_abi
+      && mode == BLKmode
+      && type && TYPE_ALIGN (type) > 64)
     return 128;
-  else
-    return PARM_BOUNDARY;
+
+  return PARM_BOUNDARY;
 }
 
 /* The offset in words to the start of the parameter save area.  */
index f64ab591c9864f78ccf2cfcc3d4c3d6d7936c893..bf929fa924ee759af3cad818ee6cdd9832acad00 100644 (file)
@@ -1,3 +1,7 @@
+2014-07-24  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
+
+       * gcc.target/powerpc/ppc64-abi-warn-2.c: New test.
+
 2014-07-24  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
        * gcc.target/powerpc/ppc64-abi-warn-1.c: New test.
diff --git a/gcc/testsuite/gcc.target/powerpc/ppc64-abi-warn-2.c b/gcc/testsuite/gcc.target/powerpc/ppc64-abi-warn-2.c
new file mode 100644 (file)
index 0000000..fdbeddf
--- /dev/null
@@ -0,0 +1,11 @@
+/* { dg-do compile { target { powerpc*-*-linux* && lp64 } } } */
+
+struct test
+  {
+    long a __attribute__((aligned (16)));
+  };
+
+void test (struct test a) /* { dg-message "note: the ABI of passing aggregates with 16-byte alignment has changed" } */
+{
+}
+