Hi,
there is a trick in the gimplifier to alleviate some annoying effects of the
gimplification on the debug info (for -O0 when var-tracking is not enabled but
it's done unconditionally):
/* Try to alleviate the effects of the gimplification creating artificial
temporaries (see for example is_gimple_reg_rhs) on the debug info. */
if (!gimplify_ctxp->into_ssa
&& TREE_CODE (*from_p) == VAR_DECL
&& DECL_IGNORED_P (*from_p)
&& DECL_P (*to_p)
&& !DECL_IGNORED_P (*to_p))
{
if (!DECL_NAME (*from_p) && DECL_NAME (*to_p))
DECL_NAME (*from_p)
= create_tmp_var_name (IDENTIFIER_POINTER (DECL_NAME (*to_p)));
DECL_HAS_DEBUG_EXPR_P (*from_p) = 1;
SET_DECL_DEBUG_EXPR (*from_p, *to_p);
}
We have a large Ada testcase for which this creates a GC hazard in LTO mode
because this creates a DECL_DEBUG_EXPR link between a parent and a nested
function, which badly interacts with a DECL_VALUE_EXPR link created during
unnesting (it's the known GC issue with circular references through hash
tables in GC memory).
Therefore the attached patch restricts the trick to local variables only.
That's transparent, modulo a benign tweak to gcc.dg/vect/vec-scal-opt.c
because of the DECL_NAME change.
Tested on x86_64-suse-linux, OK for the mainline?
2015-06-02 Eric Botcazou <ebotca...@adacore.com>
* gimplify.c (gimplify_modify_expr): Do not create a DECL_DEBUG_EXPR if
the target doesn't belong to the current function.
2015-06-02 Eric Botcazou <ebotca...@adacore.com>
* gcc.dg/vect/vec-scal-opt.c: Adjust regexp.
--
Eric Botcazou
Index: testsuite/gcc.dg/vect/vec-scal-opt.c
===================================================================
--- testsuite/gcc.dg/vect/vec-scal-opt.c (revision 224011)
+++ testsuite/gcc.dg/vect/vec-scal-opt.c (working copy)
@@ -19,4 +19,4 @@ int main (int argc, char *argv[]) {
return vidx(short, r1, 0);
}
-/* { dg-final { scan-tree-dump-times ">> k.\[0-9_\]*" 1 "veclower21" } } */
+/* { dg-final { scan-tree-dump-times ">> _\[0-9\]*" 1 "veclower21" } } */
Index: gimplify.c
===================================================================
--- gimplify.c (revision 224011)
+++ gimplify.c (working copy)
@@ -4707,12 +4707,14 @@ gimplify_modify_expr (tree *expr_p, gimp
return gimplify_modify_expr_complex_part (expr_p, pre_p, want_value);
/* Try to alleviate the effects of the gimplification creating artificial
- temporaries (see for example is_gimple_reg_rhs) on the debug info. */
+ temporaries (see for example is_gimple_reg_rhs) on the debug info, but
+ make sure not to create DECL_DEBUG_EXPR links across functions. */
if (!gimplify_ctxp->into_ssa
&& TREE_CODE (*from_p) == VAR_DECL
&& DECL_IGNORED_P (*from_p)
&& DECL_P (*to_p)
- && !DECL_IGNORED_P (*to_p))
+ && !DECL_IGNORED_P (*to_p)
+ && decl_function_context (*to_p) == current_function_decl)
{
if (!DECL_NAME (*from_p) && DECL_NAME (*to_p))
DECL_NAME (*from_p)