Commit 3fd48b12 by Eric Botcazou Committed by Eric Botcazou

re PR debug/53927 (wrong value for DW_AT_static_link)

	PR debug/53927
	* function.c (instantiate_decls): Process the saved static chain.
	(expand_function_start): If not optimizing, save the static chain
	onto the stack.
	* tree-nested.c (convert_all_function_calls): Always create the static
	chain for nested functions if not optimizing.

From-SVN: r211308
parent 9b7a11e1
2014-06-06 Eric Botcazou <ebotcazou@adacore.com> 2014-06-06 Eric Botcazou <ebotcazou@adacore.com>
PR debug/53927
* function.c (instantiate_decls): Process the saved static chain.
(expand_function_start): If not optimizing, save the static chain
onto the stack.
* tree-nested.c (convert_all_function_calls): Always create the static
chain for nested functions if not optimizing.
2014-06-06 Eric Botcazou <ebotcazou@adacore.com>
* tree-cfg.c (make_edges) <GIMPLE_RETURN>: Put a location on the edge. * tree-cfg.c (make_edges) <GIMPLE_RETURN>: Put a location on the edge.
2014-06-06 Richard Biener <rguenther@suse.de> 2014-06-06 Richard Biener <rguenther@suse.de>
......
...@@ -1877,6 +1877,11 @@ instantiate_decls (tree fndecl) ...@@ -1877,6 +1877,11 @@ instantiate_decls (tree fndecl)
} }
} }
/* Process the saved static chain if it exists. */
decl = DECL_STRUCT_FUNCTION (fndecl)->static_chain_decl;
if (decl && DECL_HAS_VALUE_EXPR_P (decl))
instantiate_decl_rtl (DECL_RTL (DECL_VALUE_EXPR (decl)));
/* Now process all variables defined in the function or its subblocks. */ /* Now process all variables defined in the function or its subblocks. */
instantiate_decls_1 (DECL_INITIAL (fndecl)); instantiate_decls_1 (DECL_INITIAL (fndecl));
...@@ -4811,6 +4816,20 @@ expand_function_start (tree subr) ...@@ -4811,6 +4816,20 @@ expand_function_start (tree subr)
if (MEM_P (chain) if (MEM_P (chain)
&& reg_mentioned_p (arg_pointer_rtx, XEXP (chain, 0))) && reg_mentioned_p (arg_pointer_rtx, XEXP (chain, 0)))
set_dst_reg_note (insn, REG_EQUIV, chain, local); set_dst_reg_note (insn, REG_EQUIV, chain, local);
/* If we aren't optimizing, save the static chain onto the stack. */
if (!optimize)
{
tree saved_static_chain_decl
= build_decl (DECL_SOURCE_LOCATION (parm), VAR_DECL,
DECL_NAME (parm), TREE_TYPE (parm));
rtx saved_static_chain_rtx
= assign_stack_local (Pmode, GET_MODE_SIZE (Pmode), 0);
SET_DECL_RTL (saved_static_chain_decl, saved_static_chain_rtx);
emit_move_insn (saved_static_chain_rtx, chain);
SET_DECL_VALUE_EXPR (parm, saved_static_chain_decl);
DECL_HAS_VALUE_EXPR_P (parm) = 1;
}
} }
/* If the function receives a non-local goto, then store the /* If the function receives a non-local goto, then store the
......
...@@ -2220,11 +2220,21 @@ convert_all_function_calls (struct nesting_info *root) ...@@ -2220,11 +2220,21 @@ convert_all_function_calls (struct nesting_info *root)
struct nesting_info *n; struct nesting_info *n;
/* First, optimistically clear static_chain for all decls that haven't /* First, optimistically clear static_chain for all decls that haven't
used the static chain already for variable access. */ used the static chain already for variable access. But always create
it if not optimizing. This makes it possible to reconstruct the static
nesting tree at run time and thus to resolve up-level references from
within the debugger. */
FOR_EACH_NEST_INFO (n, root) FOR_EACH_NEST_INFO (n, root)
{ {
tree decl = n->context; tree decl = n->context;
if (!n->outer || (!n->chain_decl && !n->chain_field)) if (!optimize)
{
if (n->inner)
(void) get_frame_type (n);
if (n->outer)
(void) get_chain_decl (n);
}
else if (!n->outer || (!n->chain_decl && !n->chain_field))
{ {
DECL_STATIC_CHAIN (decl) = 0; DECL_STATIC_CHAIN (decl) = 0;
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
......
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