]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
rs6000.c (rs6000_function_arg_boundary): Issue -Wpsabi note when encountering a type...
authorUlrich Weigand <uweigand@de.ibm.com>
Thu, 24 Jul 2014 17:32:40 +0000 (17:32 +0000)
committerUlrich Weigand <uweigand@gcc.gnu.org>
Thu, 24 Jul 2014 17:32:40 +0000 (17:32 +0000)
gcc/

* config/rs6000/rs6000.c (rs6000_function_arg_boundary): Issue
-Wpsabi note when encountering a type where future GCC releases
will apply different alignment requirements.

gcc/testsuite/

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

From-SVN: r213024

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 f03a8192a0e9d870033e80fef1cdac604f3f7a19..bdec5df39867e8163140280f377e3baf66a0a5c8 100644 (file)
@@ -1,4 +1,10 @@
-2014-07-23  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
+2014-07-24  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
+
+       * config/rs6000/rs6000.c (rs6000_function_arg_boundary): Issue
+       -Wpsabi note when encountering a type where future GCC releases
+       will apply different alignment requirements.
+
+2014-07-24  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
        * config/rs6000/rs6000.c (rs6000_function_arg): If a float argument
        does not fit fully into floating-point registers, and there is still
index 7bdbdccda109a037dd4649194daa066a48ef209b..199e36b513dfb6c7b9e297fc4b70c28a4e1aba92 100644 (file)
@@ -9200,14 +9200,51 @@ 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"
+                     " will change in a future GCC release",
+                     (int) TYPE_ALIGN (type) / BITS_PER_UNIT);
+           }
+       }
+
+      /* GCC 4.8/4.9 Note: To avoid any ABI change on a release branch, we
+        keep using the BLKmode check, but warn if there will be differences
+        in future GCC releases.  */
+      if (mode == BLKmode)
+       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 0289f57bf9a13904291f8def7d5d01a0f507e5a9..5ed916b004cabb3aecd2149a0193726c98e69431 100644 (file)
@@ -1,3 +1,10 @@
+2014-07-24  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
+
+       Backport from mainline:
+       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>
 
        Backport from mainline:
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..9b443bf
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile { target { powerpc*-*-linux* && lp64 } } } */
+/* { dg-options "-mno-compat-align-parm" } */
+
+struct test
+  {
+    long a __attribute__((aligned (16)));
+  };
+
+void test (struct test a) /* { dg-message "note: the ABI of passing aggregates with 16-byte alignment will change" } */
+{
+}
+