summaryrefslogtreecommitdiff
path: root/gcc/gimplify.c
diff options
context:
space:
mode:
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2006-06-13 08:55:40 +0000
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2006-06-13 08:55:40 +0000
commit0c2f12e9e92e5f3a706b22d3f39ace202734852c (patch)
tree05d681245e58a72d16cb2087bd700186752c60c2 /gcc/gimplify.c
parentec469632f7417286c3cd183f9d84dee8d9469baa (diff)
downloadgcc-0c2f12e9e92e5f3a706b22d3f39ace202734852c.tar.gz
PR debug/26754
* gimplify.c (declare_tmp_vars): Rename into declare_vars. Add debug_info parameter. Chain the vars to the BLOCK instead of the BIND_EXPR if debug info are requested for them. (pop_gimplify_context): Adjust for above change. (gimple_add_tmp_var): Likewise. * tree-gimple.h (declare_tmp_vars): Rename into declare_vars. Add bool parameter. * tree-nested.c (convert_nonlocal_reference): Adjust for above change. (convert_local_reference): Likewise. (get_local_debug_decl): Set DECL_IGNORED_P on the original variable. (finalize_nesting_tree_1): Request that debug info be emitted for debug_var_chain. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@114605 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r--gcc/gimplify.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 17fc560fd30..08c5caa63d9 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -180,7 +180,7 @@ pop_gimplify_context (tree body)
DECL_GIMPLE_FORMAL_TEMP_P (t) = 0;
if (body)
- declare_tmp_vars (c->temps, body);
+ declare_vars (c->temps, body, false);
else
record_vars (c->temps);
@@ -645,15 +645,16 @@ get_initialized_tmp_var (tree val, tree *pre_p, tree *post_p)
return internal_get_tmp_var (val, pre_p, post_p, false);
}
-/* Declares all the variables in VARS in SCOPE. */
+/* Declares all the variables in VARS in SCOPE. If DEBUG_INFO is
+ true, generate debug info for them; otherwise don't. */
void
-declare_tmp_vars (tree vars, tree scope)
+declare_vars (tree vars, tree scope, bool debug_info)
{
tree last = vars;
if (last)
{
- tree temps;
+ tree temps, block;
/* C99 mode puts the default 'return 0;' for main outside the outer
braces. So drill down until we find an actual scope. */
@@ -663,8 +664,27 @@ declare_tmp_vars (tree vars, tree scope)
gcc_assert (TREE_CODE (scope) == BIND_EXPR);
temps = nreverse (last);
- TREE_CHAIN (last) = BIND_EXPR_VARS (scope);
- BIND_EXPR_VARS (scope) = temps;
+
+ block = BIND_EXPR_BLOCK (scope);
+ if (!block || !debug_info)
+ {
+ TREE_CHAIN (last) = BIND_EXPR_VARS (scope);
+ BIND_EXPR_VARS (scope) = temps;
+ }
+ else
+ {
+ /* We need to attach the nodes both to the BIND_EXPR and to its
+ associated BLOCK for debugging purposes. The key point here
+ is that the BLOCK_VARS of the BIND_EXPR_BLOCK of a BIND_EXPR
+ is a subchain of the BIND_EXPR_VARS of the BIND_EXPR. */
+ if (BLOCK_VARS (block))
+ BLOCK_VARS (block) = chainon (BLOCK_VARS (block), temps);
+ else
+ {
+ BIND_EXPR_VARS (scope) = chainon (BIND_EXPR_VARS (scope), temps);
+ BLOCK_VARS (block) = temps;
+ }
+ }
}
}
@@ -694,7 +714,7 @@ gimple_add_tmp_var (tree tmp)
else if (cfun)
record_vars (tmp);
else
- declare_tmp_vars (tmp, DECL_SAVED_TREE (current_function_decl));
+ declare_vars (tmp, DECL_SAVED_TREE (current_function_decl), false);
}
/* Determines whether to assign a locus to the statement STMT. */