From: Tom de Vries Date: Fri, 13 Jul 2018 10:08:37 +0000 (+0000) Subject: [debug] Reuse debug exprs generated in remap_ssa_name X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bdaa2c546bee30f44c39076d2b75a349ab84adf9;p=gcc.git [debug] Reuse debug exprs generated in remap_ssa_name When compiling gcc.dg/vla-1.c with -O3 -g, vla a and b in f1 are optimized away, and f1 is cloned to a version f1.constprop with no parameters, eliminating parameter i. Debug info is generated to describe the sizes of a and b, but that process generates debug expressions that are not reused. Fix the duplication by saving and reusing the generated debug expressions in remap_ssa_name. Concretely: reuse D#7 here instead of generating D#8: ... __attribute__((noinline)) f1.constprop () { intD.6 iD.1935; # DEBUG D#10 s=> iD.1897 # DEBUG iD.1935 => D#10 - # DEBUG D#8 s=> iD.1935 # DEBUG D#7 s=> iD.1935 saved_stack.2_1 = __builtin_stack_save (); # DEBUG BEGIN_STMT # DEBUG D#6 => D#7 + 1 # DEBUG D#5 => (long intD.8) D#6 # DEBUG D#4 => D#5 + -1 # DEBUG D.1937 => (sizetype) D#4 # DEBUG a.0D.1942 => NULL # DEBUG BEGIN_STMT - # DEBUG D#3 => D#8 + 2 + # DEBUG D#3 => D#7 + 2 # DEBUG D#2 => (long intD.8) D#3 # DEBUG D#1 => D#2 + -1 # DEBUG D.1944 => (sizetype) D#1 # DEBUG b.1D.1949 => NULL ... Bootstrapped and reg-tested on x86_64. 2018-07-13 Tom de Vries * tree-inline.c (remap_ssa_name): Save and reuse debug exprs generated in remap_ssa_name. * gcc.dg/vla-1.c: Update. From-SVN: r262628 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b97ebca58c7..3f70e46d193 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2018-07-13 Tom de Vries + + * tree-inline.c (remap_ssa_name): Save and reuse debug exprs generated + in remap_ssa_name. + 2018-07-13 Jackson Woodruff * config/aarch64/aarch64.c (aarch64_operands_adjust_ok_for_ldpstp): Use diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fd47f3d4c27..49ca6c527dd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2018-07-13 Tom de Vries + + * gcc.dg/vla-1.c: Update. + 2018-07-13 Tom de Vries * gcc.src/maintainers.exp: New file. diff --git a/gcc/testsuite/gcc.dg/vla-1.c b/gcc/testsuite/gcc.dg/vla-1.c index 56437ae44de..902166cb18c 100644 --- a/gcc/testsuite/gcc.dg/vla-1.c +++ b/gcc/testsuite/gcc.dg/vla-1.c @@ -20,6 +20,7 @@ main () return 0; } -/* One debug source bind is generated for the parameter, and two to describe the +/* One debug source bind is generated for the parameter, and one to describe the sizes of a and b. */ -/* { dg-final { scan-tree-dump-times " s=> i" 3 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " s=> i" 2 "optimized" } } */ + diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 45aba8171a6..6a16ce546cb 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -214,12 +214,16 @@ remap_ssa_name (tree name, copy_body_data *id) processing_debug_stmt = -1; return name; } + n = id->decl_map->get (val); + if (n && TREE_CODE (*n) == DEBUG_EXPR_DECL) + return *n; def_temp = gimple_build_debug_source_bind (vexpr, val, NULL); DECL_ARTIFICIAL (vexpr) = 1; TREE_TYPE (vexpr) = TREE_TYPE (name); SET_DECL_MODE (vexpr, DECL_MODE (SSA_NAME_VAR (name))); gsi = gsi_after_labels (single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun))); gsi_insert_before (&gsi, def_temp, GSI_SAME_STMT); + insert_decl_map (id, val, vexpr); return vexpr; }