diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-10-05 19:24:38 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-10-05 19:24:38 +0000 |
commit | eee0ea7cd086b41148cf831169438366f271034b (patch) | |
tree | f6eec448c0e3da89f23b49565a93609752d5a0a2 /gcc/ipa-split.c | |
parent | 9e14cc4093355ee260305a3e10479a6a38eecb59 (diff) | |
download | gcc-eee0ea7cd086b41148cf831169438366f271034b.tar.gz |
PR debug/54519
* ipa-split.c (split_function): Add debug args and
debug source and normal stmts for args_to_skip which are
gimple regs.
* tree-inline.c (copy_debug_stmt): When inlining, adjust
source debug bind stmts to debug binds of corresponding
DEBUG_EXPR_DECL.
* gcc.dg/guality/pr54519-1.c: New test.
* gcc.dg/guality/pr54519-2.c: New test.
* gcc.dg/guality/pr54519-3.c: New test.
* gcc.dg/guality/pr54519-4.c: New test.
* gcc.dg/guality/pr54519-5.c: New test.
* gcc.dg/guality/pr54519-6.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@192139 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ipa-split.c')
-rw-r--r-- | gcc/ipa-split.c | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/gcc/ipa-split.c b/gcc/ipa-split.c index e1d1c4928e6..6750c11381a 100644 --- a/gcc/ipa-split.c +++ b/gcc/ipa-split.c @@ -1059,6 +1059,7 @@ split_function (struct split_point *split_point) gimple last_stmt = NULL; unsigned int i; tree arg, ddef; + VEC(tree, gc) **debug_args = NULL; if (dump_file) { @@ -1232,6 +1233,83 @@ split_function (struct split_point *split_point) gimple_set_block (call, DECL_INITIAL (current_function_decl)); VEC_free (tree, heap, args_to_pass); + /* For optimized away parameters, add on the caller side + before the call + DEBUG D#X => parm_Y(D) + stmts and associate D#X with parm in decl_debug_args_lookup + vector to say for debug info that if parameter parm had been passed, + it would have value parm_Y(D). */ + if (args_to_skip) + for (parm = DECL_ARGUMENTS (current_function_decl), num = 0; + parm; parm = DECL_CHAIN (parm), num++) + if (bitmap_bit_p (args_to_skip, num) + && is_gimple_reg (parm)) + { + tree ddecl; + gimple def_temp; + + /* This needs to be done even without MAY_HAVE_DEBUG_STMTS, + otherwise if it didn't exist before, we'd end up with + different SSA_NAME_VERSIONs between -g and -g0. */ + arg = get_or_create_ssa_default_def (cfun, parm); + if (!MAY_HAVE_DEBUG_STMTS) + continue; + + if (debug_args == NULL) + debug_args = decl_debug_args_insert (node->symbol.decl); + ddecl = make_node (DEBUG_EXPR_DECL); + DECL_ARTIFICIAL (ddecl) = 1; + TREE_TYPE (ddecl) = TREE_TYPE (parm); + DECL_MODE (ddecl) = DECL_MODE (parm); + VEC_safe_push (tree, gc, *debug_args, DECL_ORIGIN (parm)); + VEC_safe_push (tree, gc, *debug_args, ddecl); + def_temp = gimple_build_debug_bind (ddecl, unshare_expr (arg), + call); + gsi_insert_after (&gsi, def_temp, GSI_NEW_STMT); + } + /* And on the callee side, add + DEBUG D#Y s=> parm + DEBUG var => D#Y + stmts to the first bb where var is a VAR_DECL created for the + optimized away parameter in DECL_INITIAL block. This hints + in the debug info that var (whole DECL_ORIGIN is the parm PARM_DECL) + is optimized away, but could be looked up at the call site + as value of D#X there. */ + if (debug_args != NULL) + { + unsigned int i; + tree var, vexpr; + gimple_stmt_iterator cgsi; + gimple def_temp; + + push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl)); + var = BLOCK_VARS (DECL_INITIAL (node->symbol.decl)); + i = VEC_length (tree, *debug_args); + cgsi = gsi_after_labels (single_succ (ENTRY_BLOCK_PTR)); + do + { + i -= 2; + while (var != NULL_TREE + && DECL_ABSTRACT_ORIGIN (var) + != VEC_index (tree, *debug_args, i)) + var = TREE_CHAIN (var); + if (var == NULL_TREE) + break; + vexpr = make_node (DEBUG_EXPR_DECL); + parm = VEC_index (tree, *debug_args, i); + DECL_ARTIFICIAL (vexpr) = 1; + TREE_TYPE (vexpr) = TREE_TYPE (parm); + DECL_MODE (vexpr) = DECL_MODE (parm); + def_temp = gimple_build_debug_source_bind (vexpr, parm, + NULL); + gsi_insert_before (&cgsi, def_temp, GSI_SAME_STMT); + def_temp = gimple_build_debug_bind (var, vexpr, NULL); + gsi_insert_before (&cgsi, def_temp, GSI_SAME_STMT); + } + while (i); + pop_cfun (); + } + /* We avoid address being taken on any variable used by split part, so return slot optimization is always possible. Moreover this is required to make DECL_BY_REFERENCE work. */ |