diff mbox

Fix problematic debug info for parameters at -O0

Message ID 6244780.77zsF6gS9D@polaris
State New
Headers show

Commit Message

Eric Botcazou June 22, 2016, 1:16 p.m. UTC
> The testcase doesn't necessarily need to FAIL without the patch on x86, it
> is fine if it fails on some PowerPC* or Visium.

Here's what I have installed on mainline and 6 branch (not sure it's worth 
fixing on the aging 5 branch).  The test fails on PowerPC/Linux:

(gdb) b param-5.c:26
Breakpoint 1 at 0x10000510: file param-5.c, line 26.
(gdb) run
Starting program: /nfs/tron/work/botcazou/gcc-head/powerpc-linux-gnu/param-5 

Breakpoint 1, foo (
    str=<error reading variable: Cannot access memory at address 0xffffffc8>, 
    count=0) at param-5.c:26
26        count--;  /* BREAK */
(gdb) bt
#0  foo (
    str=<error reading variable: Cannot access memory at address 0xffffffc8>, 
    count=0) at param-5.c:26
#1  0x1000050c in foo (
    str=<error reading variable: value has been optimized out>, count=1)
    at param-5.c:24
#2  0x10000590 in main () at param-5.c:33


2016-06-22  Eric Botcazou  <ebotcazou@adacore.com>

	* function.c (assign_parm_setup_reg): Prevent sharing in another case.


2016-06-22  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc.dg/guality/param-5.c: New test.

Comments

Jakub Jelinek June 22, 2016, 1:22 p.m. UTC | #1
On Wed, Jun 22, 2016 at 03:16:20PM +0200, Eric Botcazou wrote:
> /* { 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));

Do you really need the memset in there to reproduce it?
Wouldn't asm volatile ("" : : "r" (&a[0]) : "memory");
or something similar be enough?  Or if you need to clear something,
clear much smaller part of the array?

	Jakub
Eric Botcazou June 22, 2016, 2:25 p.m. UTC | #2
> Do you really need the memset in there to reproduce it?
> Wouldn't asm volatile ("" : : "r" (&a[0]) : "memory");
> or something similar be enough?  Or if you need to clear something,
> clear much smaller part of the array?

Probably only the 128 first bytes, will change that.
diff mbox

Patch

Index: function.c
===================================================================
--- function.c	(revision 237677)
+++ function.c	(working copy)
@@ -3314,6 +3314,8 @@  assign_parm_setup_reg (struct assign_par
 	  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_par
 			     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_par
 	  did_conversion = true;
 	}
       else
-	emit_move_insn (parmreg, rtl);
+	emit_move_insn (MEM_P (parmreg) ? copy_rtx (parmreg) : parmreg, rtl);
 
       rtl = parmreg;