Commit 74725f46 by Tom de Vries Committed by Tom de Vries

[debug] Handle debug references to skipped params

When compiling guality/vla-1.c with -O3 -g, vla a in f1 is optimized away, but
f1 still contains a debug expression describing the upper bound of the vla
(D.1914):
...
     __attribute__((noinline))
     f1 (intD.6 iD.1900)
     {
       <bb 2>
       saved_stack.1_2 = __builtin_stack_save ();
       # DEBUG BEGIN_STMT
       # DEBUG D#3 => i_1(D) + 1
       # DEBUG D#2 => (long intD.8) D#3
       # DEBUG D#1 => D#2 + -1
       # DEBUG D.1914 => (sizetype) D#1
...

Then f1 is cloned to a version f1.constprop with no parameters, eliminating
parameter i, and 'DEBUG D#3 => i_1(D) + 1' turns into 'D#3 => NULL'.

This patch fixes that by defining debug expressions for default defs of
eliminated parameters in remap_ssa_name:
...
     __attribute__((noinline))
     f1.constprop ()
     {
       intD.6 iD.1949;

       <bb 3>
       # DEBUG D#8 s=> iD.1900
       # DEBUG iD.1949 => D#8

       <bb 2>
+      # DEBUG D#6 s=> iD.1949
       saved_stack.1_1 = __builtin_stack_save ();
       # DEBUG BEGIN_STMT
-      # DEBUG D#3 => NULL
+      # DEBUG D#3 => D#6 + 1
       # DEBUG D#2 => (long intD.8) D#3
       # DEBUG D#1 => D#2 + -1
       # DEBUG D.1951 => (sizetype) D#1
...

Bootstrapped and reg-tested on x86_64.

2018-07-09  Tom de Vries  <tdevries@suse.de>

	* cfgexpand.c (expand_debug_source_expr): Handle VAR_DECL.
	* tree-inline.c (remap_ssa_name): Handle default def ssa_name mapping
	onto VAR_DECL with abstract origin.

	* gcc.dg/vla-1.c: New test.

From-SVN: r262510
parent d2c8944b
2018-07-09 Tom de Vries <tdevries@suse.de>
* cfgexpand.c (expand_debug_source_expr): Handle VAR_DECL.
* tree-inline.c (remap_ssa_name): Handle default def ssa_name mapping
onto VAR_DECL with abstract origin.
2018-07-07 Jim Wilson <jimw@sifive.com>
* config/riscv/riscv.c (TARGET_CUSTOM_FUNCTION_DESCRIPTORS): New.
......
......@@ -5141,6 +5141,10 @@ expand_debug_source_expr (tree exp)
switch (TREE_CODE (exp))
{
case VAR_DECL:
if (DECL_ABSTRACT_ORIGIN (exp))
return expand_debug_source_expr (DECL_ABSTRACT_ORIGIN (exp));
break;
case PARM_DECL:
{
mode = DECL_MODE (exp);
......
2018-07-09 Tom de Vries <tdevries@suse.de>
* gcc.dg/vla-1.c: New test.
2018-07-07 Tom de Vries <tdevries@suse.de>
* gcc.misc-tests/options.exp (check_for_all_options): Clean up dump
......
/* { dg-do compile } */
/* { dg-options "-g -O3 -fdump-tree-optimized -fvar-tracking-assignments -fno-selective-scheduling -fno-selective-scheduling2" } */
int __attribute__((noinline))
f1 (int i)
{
char a[i + 1];
char b[i + 2];
b[1] = 3;
a[0] = 5;
return a[0] + b[1];
}
int
main ()
{
volatile int j;
int x = 5;
j = f1 (x);
return 0;
}
/* One debug source bind is generated for the parameter, and two to describe the
sizes of a and b. */
/* { dg-final { scan-tree-dump-times " s=> i" 3 "optimized" } } */
......@@ -208,7 +208,8 @@ remap_ssa_name (tree name, copy_body_data *id)
n = id->decl_map->get (val);
if (n != NULL)
val = *n;
if (TREE_CODE (val) != PARM_DECL)
if (TREE_CODE (val) != PARM_DECL
&& !(VAR_P (val) && DECL_ABSTRACT_ORIGIN (val)))
{
processing_debug_stmt = -1;
return name;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment