From 951d8c8a23f37136cd377f8069ddeb5be8a67183 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Wed, 22 Jun 2016 13:13:22 +0000 Subject: [PATCH] * function.c (assign_parm_setup_reg): Prevent sharing in another case. From-SVN: r237703 --- gcc/ChangeLog | 4 +++ gcc/function.c | 7 +++-- gcc/testsuite/ChangeLog | 4 +++ gcc/testsuite/gcc.dg/guality/param-5.c | 38 ++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/guality/param-5.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 909a7429f86..6ba6728320e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2016-06-22 Eric Botcazou + + * function.c (assign_parm_setup_reg): Prevent sharing in another case. + 2016-06-22 Bernd Edlinger * config/i386/i386.c (print_reg): Emit an error message on attempt to diff --git a/gcc/function.c b/gcc/function.c index c15d47d2103..abee3640494 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -3314,6 +3314,8 @@ assign_parm_setup_reg (struct assign_parm_data_all *all, tree parm, set_mem_attributes (parmreg, parm, 1); } + /* We need to preserve an address based on VIRTUAL_STACK_VARS_REGNUM for + the debug info in case it is not legitimate. */ if (GET_MODE (parmreg) != GET_MODE (rtl)) { rtx tempreg = gen_reg_rtx (GET_MODE (rtl)); @@ -3323,7 +3325,8 @@ assign_parm_setup_reg (struct assign_parm_data_all *all, tree parm, all->last_conversion_insn); emit_move_insn (tempreg, rtl); tempreg = convert_to_mode (GET_MODE (parmreg), tempreg, unsigned_p); - emit_move_insn (parmreg, tempreg); + emit_move_insn (MEM_P (parmreg) ? copy_rtx (parmreg) : parmreg, + tempreg); all->first_conversion_insn = get_insns (); all->last_conversion_insn = get_last_insn (); end_sequence (); @@ -3331,7 +3334,7 @@ assign_parm_setup_reg (struct assign_parm_data_all *all, tree parm, did_conversion = true; } else - emit_move_insn (parmreg, rtl); + emit_move_insn (MEM_P (parmreg) ? copy_rtx (parmreg) : parmreg, rtl); rtl = parmreg; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b8546af8dbe..62fdac4b381 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2016-06-22 Eric Botcazou + + * gcc.dg/guality/param-5.c: New test. + 2016-06-22 Bernd Edlinger * gcc.target/i386/asm-flag-7.c: New test. diff --git a/gcc/testsuite/gcc.dg/guality/param-5.c b/gcc/testsuite/gcc.dg/guality/param-5.c new file mode 100644 index 00000000000..83a5c0ed93d --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/param-5.c @@ -0,0 +1,38 @@ +/* { dg-do run } */ +/* { dg-options "-g" } */ +/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */ + +typedef __UINTPTR_TYPE__ uintptr_t; + +typedef struct { uintptr_t pa; uintptr_t pb; } fatp_t + __attribute__ ((aligned (2 * __alignof__ (uintptr_t)))); + +__attribute__((noinline, noclone)) void +clear_stack (void) +{ + char a[128 * 1024 + 128]; + + __builtin_memset (a, 0, sizeof (a)); +} + +__attribute__((noinline, noclone)) void +foo (fatp_t str, int count) +{ + char a[128 * 1024]; + + if (count > 0) + foo (str, count - 1); + clear_stack (); + count--; /* BREAK */ +} + +int +main (void) +{ + fatp_t ptr = { 31415927, 27182818 }; + foo (ptr, 1); + return 0; +} + +/* { dg-final { gdb-test 26 "str.pa" "31415927" } } */ +/* { dg-final { gdb-test 26 "str.pb" "27182818" } } */ -- 2.30.2