diff mbox

[AArch64,ILP32] Pad pointer-typed stack argument downward in ILP32

Message ID 51CC61A5.8050406@arm.com
State New
Headers show

Commit Message

Yufeng Zhang June 27, 2013, 4 p.m. UTC
This patch fixes the bug that pointer-typed argument passed on stack is 
not padded properly in ILP32.

OK for the trunk?

Thanks,
Yufeng



gcc/

         * config/aarch64/aarch64.c (aarch64_pad_arg_upward): In big-endian,
         pad pointer-typed argument downward.

gcc/testsuite/

         * gcc.target/aarch64/test-ptr-arg-on-stack-1.c: New test.

Comments

Yufeng Zhang July 18, 2013, 10:33 a.m. UTC | #1
Ping~

Thanks,
Yufeng

On 06/27/13 17:00, Yufeng Zhang wrote:
> This patch fixes the bug that pointer-typed argument passed on stack is
> not padded properly in ILP32.
>
> OK for the trunk?
>
> Thanks,
> Yufeng
>
>
>
> gcc/
>
>           * config/aarch64/aarch64.c (aarch64_pad_arg_upward): In big-endian,
>           pad pointer-typed argument downward.
>
> gcc/testsuite/
>
>           * gcc.target/aarch64/test-ptr-arg-on-stack-1.c: New test.
>
Marcus Shawcroft July 23, 2013, 11:33 a.m. UTC | #2
On 27 June 2013 17:00, Yufeng Zhang <Yufeng.Zhang@arm.com> wrote:
> This patch fixes the bug that pointer-typed argument passed on stack is not
> padded properly in ILP32.
>
> OK for the trunk?

OK
/Marcus
diff mbox

Patch

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index f78e0d6..79f8761 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -1585,11 +1585,12 @@  aarch64_pad_arg_upward (enum machine_mode mode, const_tree type)
   if (!BYTES_BIG_ENDIAN)
     return true;
 
-  /* Otherwise, integral types and floating point types are padded downward:
+  /* Otherwise, integral, floating-point and pointer types are padded downward:
      the least significant byte of a stack argument is passed at the highest
      byte address of the stack slot.  */
   if (type
-      ? (INTEGRAL_TYPE_P (type) || SCALAR_FLOAT_TYPE_P (type))
+      ? (INTEGRAL_TYPE_P (type) || SCALAR_FLOAT_TYPE_P (type)
+	 || POINTER_TYPE_P (type))
       : (SCALAR_INT_MODE_P (mode) || SCALAR_FLOAT_MODE_P (mode)))
     return false;
 
diff --git a/gcc/testsuite/gcc.target/aarch64/test-ptr-arg-on-stack-1.c b/gcc/testsuite/gcc.target/aarch64/test-ptr-arg-on-stack-1.c
new file mode 100644
index 0000000..bb68e0a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/test-ptr-arg-on-stack-1.c
@@ -0,0 +1,39 @@ 
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-inline" } */
+
+/* Test pass-by-reference and pointer-typed argument passing on stack.
+   This test shall pass on any of the following four combinitions:
+    {big-endian, little-endian} {LP64, ILP32}.  */
+
+struct s5
+{
+  double a;
+  double b;
+  double c;
+  double d;
+  double e;
+} gS = {1.0, 2.0, 3.0, 4.0, 5.0};
+
+double  __attribute__ ((noinline))
+foo (struct s5 p1, struct s5 p2, struct s5 p3, struct s5 p4,
+     struct s5 p5, struct s5 p6, struct s5 p7, struct s5 p8,
+     struct s5 p9)
+{
+  asm ("");
+  return p9.c;
+}
+
+void abort (void);
+int printf (const char *, ...);
+
+int main (void)
+{
+  printf ("Here we print out some values and more importantly hope that"
+	  " the stack is getting a bit dirty for the bug to manifest itself"
+	  "\n\t%f, %f, %f, %f, %f\n", gS.a, gS.b, gS.c, gS.d, gS.e);
+
+  if (foo (gS, gS, gS, gS, gS, gS, gS, gS, gS) != 3.0)
+    abort ();
+
+  return 0;
+}