diff options
author | Jakub Jelinek <jakub@redhat.com> | 2011-06-22 12:41:58 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2011-06-22 12:41:58 +0200 |
commit | ddb555ed5129279c1bbe74574507ad67fff22e5e (patch) | |
tree | 084c46b58471b676de4f37c5db720c691779a0e7 /gcc/ipa-prop.c | |
parent | ccdc216414a902642b358b80f9aaa14bb7ce192b (diff) | |
download | gcc-ddb555ed5129279c1bbe74574507ad67fff22e5e.zip gcc-ddb555ed5129279c1bbe74574507ad67fff22e5e.tar.gz gcc-ddb555ed5129279c1bbe74574507ad67fff22e5e.tar.bz2 |
re PR debug/47858 (IPA-SRA decreases quality of debug info)
PR debug/47858
* gimple.h (enum gimple_debug_subcode): Add GIMPLE_DEBUG_SOURCE_BIND.
(gimple_build_debug_source_bind_stat): New prototype.
(gimple_build_debug_source_bind): Define.
(gimple_debug_source_bind_p, gimple_debug_source_bind_get_var,
gimple_debug_source_bind_get_value,
gimple_debug_source_bind_get_value_ptr,
gimple_debug_source_bind_set_var,
gimple_debug_source_bind_set_value): New inlines.
* gimple.c (gimple_build_debug_source_bind_stat): New function.
* gimple-pretty-print.c (dump_gimple_debug): Handle
GIMPLE_DEBUG_SOURCE_BIND.
* sese.c (rename_uses): Handle gimple_debug_source_bind_p.
* tree-ssa-dce.c (mark_stmt_if_obviously_necessary): Likewise.
* tree-parloops.c (eliminate_local_variables,
separate_decls_in_region): Likewise.
(separate_decls_in_region_debug): Renamed from
separate_decls_in_region_debug_bind. Handle
gimple_debug_source_bind_p.
* tree.h (decl_debug_args_lookup, decl_debug_args_insert): New
prototypes.
(DECL_HAS_DEBUG_ARGS_P): Define.
(struct tree_function_decl): Add has_debug_args_flag field.
* tree.c (debug_args_for_decl): New variable.
(decl_debug_args_lookup, decl_debug_args_insert): New functions.
* tree-into-ssa.c (mark_def_sites): Handle uses in debug stmts.
(rewrite_debug_stmt_uses): New function.
(rewrite_stmt): Use it to rewrite debug stmt uses.
* rtl.def (DEBUG_PARAMETER_REF): New.
* rtl.h (DEBUG_PARAMETER_REF_DECL): Define.
* cselib.c (rtx_equal_for_cselib_1, cselib_hash_rtx): Handle
DEBUG_PARAMETER_REF.
* rtl.c (rtx_equal_p_cb, rtx_equal_p, iterative_hash_rtx): Likewise.
* print-rtl.c (print_rtx): Likewise.
* tree-sra.c (sra_ipa_reset_debug_stmts): Prefer replacing of
SSA_NAMEs with DEBUG_EXPR_DECLs initialized in source bind
debug stmts in the first bb.
* tree-inline.c (remap_ssa_name): If remapping default def
of a PARM_DECL fails, map to a DEBUG_EXPR_DECL set in
a source bind debug stmt.
(remap_gimple_stmt): Handle gimple_debug_source_bind_p.
(maybe_move_debug_stmts_to_successors): Likewise.
(copy_debug_stmt): Likewise. Avoid shadowing a variable.
(tree_function_versioning): If DECL_HAS_DEBUG_ARGS_P, copy
debug args vector from old_decl to new_decl.
* ipa-prop.c (ipa_modify_call_arguments): For optimized away
or modified parameters, add debug bind stmts before call
setting DEBUG_EXPR_DECL which is remembered in debug args
vector.
* cfgexpand.c (expand_call_stmt): Call expand_debug_expr
on DECL_DEBUG_EXPRs from debug args vector.
(expand_debug_source_expr): New function.
(expand_debug_locations): Use it for source bind insns.
(expand_gimple_basic_block): Handle gimple_debug_source_bind_p.
* var-tracking.c (prepare_call_arguments): Add debug args
to call_arguments if any.
* dwarf2out.c (dwarf_stack_op_name, size_of_loc_descr,
output_loc_operands, output_loc_operands_raw,
resolve_addr_in_expr, compare_loc_operands): Handle
DW_OP_GNU_parameter_ref.
(get_ref_die_offset, parameter_ref_descriptor): New functions.
(mem_loc_descriptor): Handle DEBUG_PARAMETER_REF.
(gen_subprogram_die): Handle parameters identified by
DEBUG_PARAMETER_REF.
* dwarf2.h (enum dwarf_location_atom): Add DW_OP_GNU_parameter_ref.
From-SVN: r175288
Diffstat (limited to 'gcc/ipa-prop.c')
-rw-r--r-- | gcc/ipa-prop.c | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index 10c11d4..aec1920 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -1,5 +1,5 @@ /* Interprocedural analyses. - Copyright (C) 2005, 2007, 2008, 2009, 2010 + Copyright (C) 2005, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. This file is part of GCC. @@ -2393,6 +2393,7 @@ ipa_modify_call_arguments (struct cgraph_edge *cs, gimple stmt, ipa_parm_adjustment_vec adjustments) { VEC(tree, heap) *vargs; + VEC(tree, gc) **debug_args = NULL; gimple new_stmt; gimple_stmt_iterator gsi; tree callee_decl; @@ -2400,6 +2401,7 @@ ipa_modify_call_arguments (struct cgraph_edge *cs, gimple stmt, len = VEC_length (ipa_parm_adjustment_t, adjustments); vargs = VEC_alloc (tree, heap, len); + callee_decl = !cs ? gimple_call_fndecl (stmt) : cs->callee->decl; gsi = gsi_for_stmt (stmt); for (i = 0; i < len; i++) @@ -2490,6 +2492,42 @@ ipa_modify_call_arguments (struct cgraph_edge *cs, gimple stmt, NULL, true, GSI_SAME_STMT); VEC_quick_push (tree, vargs, expr); } + if (!adj->copy_param && MAY_HAVE_DEBUG_STMTS) + { + unsigned int ix; + tree ddecl = NULL_TREE, origin = DECL_ORIGIN (adj->base), arg; + gimple def_temp; + + arg = gimple_call_arg (stmt, adj->base_index); + if (!useless_type_conversion_p (TREE_TYPE (origin), TREE_TYPE (arg))) + { + if (!fold_convertible_p (TREE_TYPE (origin), arg)) + continue; + arg = fold_convert_loc (gimple_location (stmt), + TREE_TYPE (origin), arg); + } + if (debug_args == NULL) + debug_args = decl_debug_args_insert (callee_decl); + for (ix = 0; VEC_iterate (tree, *debug_args, ix, ddecl); ix += 2) + if (ddecl == origin) + { + ddecl = VEC_index (tree, *debug_args, ix + 1); + break; + } + if (ddecl == NULL) + { + ddecl = make_node (DEBUG_EXPR_DECL); + DECL_ARTIFICIAL (ddecl) = 1; + TREE_TYPE (ddecl) = TREE_TYPE (origin); + DECL_MODE (ddecl) = DECL_MODE (origin); + + VEC_safe_push (tree, gc, *debug_args, origin); + VEC_safe_push (tree, gc, *debug_args, ddecl); + } + def_temp = gimple_build_debug_bind (ddecl, unshare_expr (arg), + stmt); + gsi_insert_before (&gsi, def_temp, GSI_SAME_STMT); + } } if (dump_file && (dump_flags & TDF_DETAILS)) @@ -2498,7 +2536,6 @@ ipa_modify_call_arguments (struct cgraph_edge *cs, gimple stmt, print_gimple_stmt (dump_file, gsi_stmt (gsi), 0, 0); } - callee_decl = !cs ? gimple_call_fndecl (stmt) : cs->callee->decl; new_stmt = gimple_build_call_vec (callee_decl, vargs); VEC_free (tree, heap, vargs); if (gimple_call_lhs (stmt)) |