diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c8d6a1bfe7ac0fce5dd6b61ef4957e224331deb8..df9bb9454dd95bb23afe52c9b1f48bb15fd94a1f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2013-07-23 Yufeng Zhang <yufeng.zhang@arm.com> + + * config/aarch64/aarch64.c (aarch64_pad_arg_upward): In big-endian, + pad pointer-typed argument downward. + 2013-07-23 Yufeng Zhang <yufeng.zhang@arm.com> * config/aarch64/aarch64.h (TARGET_CPU_CPP_BUILTINS): Define _ILP32 diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index da041f8e3f89c86ad7b43d6cfc82bdc2b263ef4a..73e8657b828e76706266533990220b0854513910 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -1612,11 +1612,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/ChangeLog b/gcc/testsuite/ChangeLog index e715ca564fdf28450c0b997e52b940947588ae85..7df09a07b4b61fe0f95202f5ec946ff88672e838 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2013-07-23 Yufeng Zhang <yufeng.zhang@arm.com> + + * gcc.target/aarch64/test-ptr-arg-on-stack-1.c: New test. + 2013-07-23 Yufeng Zhang <yufeng.zhang@arm.com> * gcc.dg/20020219-1.c: Skip the test on aarch64*-*-* in ilp32. 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 0000000000000000000000000000000000000000..bb68e0a568ce8b6e44a680a5b2fd5696d45f9468 --- /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; +}