aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-into-ssa.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2011-06-22 10:41:58 +0000
committerJakub Jelinek <jakub@redhat.com>2011-06-22 10:41:58 +0000
commitdd3b6ecbe4807f45bcb180552b2c8688142c3159 (patch)
tree084c46b58471b676de4f37c5db720c691779a0e7 /gcc/tree-into-ssa.c
parent97523d126b202df4263c1274556549743d7bf245 (diff)
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. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@175288 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-into-ssa.c')
-rw-r--r--gcc/tree-into-ssa.c98
1 files changed, 90 insertions, 8 deletions
diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c
index f138e5b72c9..0db9085f053 100644
--- a/gcc/tree-into-ssa.c
+++ b/gcc/tree-into-ssa.c
@@ -1,5 +1,5 @@
/* Rewrite a program in Normal form into SSA.
- Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
+ Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.
Contributed by Diego Novillo <dnovillo@redhat.com>
@@ -745,7 +745,17 @@ mark_def_sites (basic_block bb, gimple stmt, bitmap kills)
set_rewrite_uses (stmt, false);
if (is_gimple_debug (stmt))
- return;
+ {
+ FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_USE)
+ {
+ tree sym = USE_FROM_PTR (use_p);
+ gcc_assert (DECL_P (sym));
+ set_rewrite_uses (stmt, true);
+ }
+ if (rewrite_uses_p (stmt))
+ SET_BIT (interesting_blocks, bb->index);
+ return;
+ }
/* If a variable is used before being set, then the variable is live
across a block boundary, so mark it live-on-entry to BB. */
@@ -1279,6 +1289,73 @@ get_reaching_def (tree var)
}
+/* Helper function for rewrite_stmt. Rewrite uses in a debug stmt. */
+
+static void
+rewrite_debug_stmt_uses (gimple stmt)
+{
+ use_operand_p use_p;
+ ssa_op_iter iter;
+ bool update = false;
+
+ FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_USE)
+ {
+ tree var = USE_FROM_PTR (use_p), def = NULL_TREE;
+ gcc_assert (DECL_P (var));
+ if (var_ann (var) == NULL)
+ {
+ if (TREE_CODE (var) == PARM_DECL && single_succ_p (ENTRY_BLOCK_PTR))
+ {
+ gimple_stmt_iterator gsi
+ = gsi_after_labels (single_succ (ENTRY_BLOCK_PTR));
+ int lim;
+ /* Search a few source bind stmts at the start of first bb to
+ see if a DEBUG_EXPR_DECL can't be reused. */
+ for (lim = 32;
+ !gsi_end_p (gsi) && lim > 0;
+ gsi_next (&gsi), lim--)
+ {
+ gimple gstmt = gsi_stmt (gsi);
+ if (!gimple_debug_source_bind_p (gstmt))
+ break;
+ if (gimple_debug_source_bind_get_value (gstmt) == var)
+ {
+ def = gimple_debug_source_bind_get_var (gstmt);
+ if (TREE_CODE (def) == DEBUG_EXPR_DECL)
+ break;
+ else
+ def = NULL_TREE;
+ }
+ }
+ /* If not, add a new source bind stmt. */
+ if (def == NULL_TREE)
+ {
+ gimple def_temp;
+ def = make_node (DEBUG_EXPR_DECL);
+ def_temp = gimple_build_debug_source_bind (def, var, NULL);
+ DECL_ARTIFICIAL (def) = 1;
+ TREE_TYPE (def) = TREE_TYPE (var);
+ DECL_MODE (def) = DECL_MODE (var);
+ gsi = gsi_after_labels (single_succ (ENTRY_BLOCK_PTR));
+ gsi_insert_before (&gsi, def_temp, GSI_SAME_STMT);
+ }
+ update = true;
+ }
+ }
+ else
+ def = get_current_def (var);
+ if (def == NULL)
+ {
+ gimple_debug_bind_reset_value (stmt);
+ update_stmt (stmt);
+ return;
+ }
+ SET_USE (use_p, def);
+ }
+ if (update)
+ update_stmt (stmt);
+}
+
/* SSA Rewriting Step 2. Rewrite every variable used in each statement in
the block with its immediate reaching definitions. Update the current
definition of a variable when a new real or virtual definition is found. */
@@ -1306,12 +1383,17 @@ rewrite_stmt (gimple_stmt_iterator si)
/* Step 1. Rewrite USES in the statement. */
if (rewrite_uses_p (stmt))
- FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_USE)
- {
- tree var = USE_FROM_PTR (use_p);
- gcc_assert (DECL_P (var));
- SET_USE (use_p, get_reaching_def (var));
- }
+ {
+ if (is_gimple_debug (stmt))
+ rewrite_debug_stmt_uses (stmt);
+ else
+ FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_USE)
+ {
+ tree var = USE_FROM_PTR (use_p);
+ gcc_assert (DECL_P (var));
+ SET_USE (use_p, get_reaching_def (var));
+ }
+ }
/* Step 2. Register the statement's DEF operands. */
if (register_defs_p (stmt))