From 1ae2a9c0b05d8922718ae12dfb7337b344c8a1c7 Mon Sep 17 00:00:00 2001 From: yufeng Date: Tue, 23 Jul 2013 12:29:51 +0000 Subject: [PATCH] [AArch64, ILP32] 5/6 Pad pointer-typed stack argument downward in ILP32. 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@201168 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 5 +++ gcc/config/aarch64/aarch64.c | 5 +-- gcc/testsuite/ChangeLog | 4 +++ .../gcc.target/aarch64/test-ptr-arg-on-stack-1.c | 39 ++++++++++++++++++++++ 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/aarch64/test-ptr-arg-on-stack-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c8d6a1b..df9bb94 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2013-07-23 Yufeng Zhang + * config/aarch64/aarch64.c (aarch64_pad_arg_upward): In big-endian, + pad pointer-typed argument downward. + +2013-07-23 Yufeng Zhang + * config/aarch64/aarch64.h (TARGET_CPU_CPP_BUILTINS): Define _ILP32 and __ILP32__ when the ILP32 model is in use. diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index da041f8..73e8657 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 e715ca5..7df09a0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2013-07-23 Yufeng Zhang + * gcc.target/aarch64/test-ptr-arg-on-stack-1.c: New test. + +2013-07-23 Yufeng Zhang + * gcc.dg/20020219-1.c: Skip the test on aarch64*-*-* in ilp32. * gcc.target/aarch64/aapcs64/test_18.c (struct y): Change the field type from long to long long. 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; +} -- 2.7.4