Skip to content

Commit

Permalink
Add source_location support to PHI arguments.
Browse files Browse the repository at this point in the history
2009-07-29  Andrew MacLeod  <amacleod@redhat.com>

	PR debug 26475
	* tree-into-ssa.c (insert_phi_nodes_for, rewrite_add_phi_arguments): Set
	location for phi arguments.
	(rewrite_update_phi_arguments): Find locations for reaching defs.
	* tree-ssa-threadupdate.c (create_edge_and_update_destination_phis):
	Add location to add_phi_arg calls.
	* tree-loop-districbution.c (update_phis_for_loop_copy): Add locations.
	* tree-ssa-loop-manip.c (create_iv, add_exit_phis_edge,
	split_loop_exit_edge, tree_transform_and_unroll_loop): Add locations.
	* tree-tailcall.c (add_successor_phi_arg, eliminate_tail_call,
	create_tailcall_accumulator, tree_optimize_tail_calls_1): Add locations.
	* tree.h (struct phi_arg_d): Add location_t to PHI arguments.
	* tree-phinodes.c (make_phi_node): Initialize location.
	(resize_phi_node): Initialize location to UNKNOWN_LOCATION.
	(add_phi_arg): Add location parameter.
	(remove_phi_arg_num): Move location when moving phi argument.
	* omp-low.c (expand_parallel_call, expand_omp_for_static_chunk): Set 
	location.
	* tree-vect-loop-manip.c (slpeel_update_phis_for_duplicate_loop,
	slpeel_update_phi_nodes_for_guard1,
	slpeel_update_phi_nodes_for_guard2,
	slpeel_tree_duplicate_loop_to_edge_cfg, set_prologue_iterations,
	vect_loop_versioning): Set locations.
	* tree-parloops.c (create_phi_for_local_result,
	transform_to_exit_first_loop, create_parallel_loop): Add locations.
	* gimple-pretty-print.c (dump_gimple_phi): Dump lineno's if present.
	* tree-vect-loop.c (get_initial_def_for_induction,
	vect_create_epilog_for_reduction, vect_finalize_reduction): Add
	locations.
	* tree-flow-inline.h (gimple_phi_arg_location): New.  Return locus.
	(gimple_phi_arg_location_from_edge): New.  Return locus from an edge.
	(gimple_phi_arg_set_location): New.  Set locus.
	(gimple_phi_arg_has_location): New.  Check for locus.
	(redirect_edge_var_map_location): New.  Return locus from var_map.
	* tree-vect-data-refs.c (vect_setup_realignment): Set location.
	* tree-ssa-phiopt.c (conditional_replacement): Set locus when
	combining PHI arguments.
	(cond_store_replacement): Set location.
	* cfgexpand.c (gimple_assign_rhs_to_tree): Transfer locus if possible.
	* grpahite.c (add_loop_exit_phis, add_guard_exit_phis,
	scop_add_exit_phis_edge): Add locations.
	* tree-cfgcleanup.c (remove_forwarder_block,
	remove_forwarder_block_with_phi): Add locations.
	* tree-ssa-pre.c (insert_into_preds_of_block): Add locations.
	* tree-predcom.c (initialize_root_vars, initialize_root_vars_lm): Add
	locations.
	* tree-ssa-dce.c (forward_edge_to_pdom): Add locations.
	* tree-ssa.c (redirect_edge_var_map_add, ssa_redirect_edge,
	flush_pending_stmts): Add source location.
	* lambda-code.c (perfect_nestify): Maintain location stack with argument
	stack to preserve locations.
	* tree-vect-stmts.c (vectorizable_load): Add location.
	* tree-inline.c (copy_phis_for_bb): Copy locus.
	(setup_one_parameter): Add call locus to inlined parameter stmts.
	(initialize_inlined_parameters): Pass in call location as parameter
	assignment locus.
	(tree_function_versioning): Pass location to setup_one_parameter.
	* tree-ssa-phiprop.c (phiprop_insert_phi): Set locations.
	* tree-outof-ssa.c (struct _elim_graph): Add source_location vecs for
	copy and edge lists.
	(insert_partition_copy_on_edge, insert_value_copy_on_edge,
	insert_rtx_to_part_on_edge, insert_part_to_rtx_on_edge): Provide a 
	locus parameter and override the stmt default if provided.
	(new_elim_graph, clear_elim_graph, delete_elim_graph,
	elim_graph_add_edge, elim_graph_remove_succ_edge,
	FOR_EACH_ELIM_GRAPH_SUCC, FOR_EACH_ELIM_GRAPH_PRED, eliminate_build,
	elim_forward, elim_unvisited_predecessor, elim_backward, elim_create,
	eliminate_phi):  Add locus info in elimination graph for each edge and
	value copy.
	(insert_backedge_copies): Copy locus if present.
	* tree-flow.h (struct _edge_var_map): Add locus field.
	* tree-switch_conversions.c (fix_phi_nodes): Add locations.
	* tree-cfg.c (reinstall_phi_args, gimple_make_forwarder_block,
	add_phi_args_after_copy_edge, gimple_lv_adjust_loop_header_phi): Add 
	locations.
	* ipa-struct-reorg.c (make_edge_and_fix_phis_of_dest): Add locations.
	


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@150267 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
amacleod committed Jul 30, 2009
1 parent 465afad commit efbcb6d
Show file tree
Hide file tree
Showing 32 changed files with 424 additions and 109 deletions.
79 changes: 79 additions & 0 deletions gcc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,82 @@
2009-07-30 Andrew MacLeod <amacleod@redhat.com>

PR debug/26475
* tree-into-ssa.c (insert_phi_nodes_for, rewrite_add_phi_arguments): Set
location for phi arguments.
(rewrite_update_phi_arguments): Find locations for reaching defs.
* tree-ssa-threadupdate.c (create_edge_and_update_destination_phis):
Add location to add_phi_arg calls.
* tree-loop-districbution.c (update_phis_for_loop_copy): Add locations.
* tree-ssa-loop-manip.c (create_iv, add_exit_phis_edge,
split_loop_exit_edge, tree_transform_and_unroll_loop): Add locations.
* tree-tailcall.c (add_successor_phi_arg, eliminate_tail_call,
create_tailcall_accumulator, tree_optimize_tail_calls_1): Add locations.
* tree.h (struct phi_arg_d): Add location_t to PHI arguments.
* tree-phinodes.c (make_phi_node): Initialize location.
(resize_phi_node): Initialize location to UNKNOWN_LOCATION.
(add_phi_arg): Add location parameter.
(remove_phi_arg_num): Move location when moving phi argument.
* omp-low.c (expand_parallel_call, expand_omp_for_static_chunk): Set
location.
* tree-vect-loop-manip.c (slpeel_update_phis_for_duplicate_loop,
slpeel_update_phi_nodes_for_guard1,
slpeel_update_phi_nodes_for_guard2,
slpeel_tree_duplicate_loop_to_edge_cfg, set_prologue_iterations,
vect_loop_versioning): Set locations.
* tree-parloops.c (create_phi_for_local_result,
transform_to_exit_first_loop, create_parallel_loop): Add locations.
* gimple-pretty-print.c (dump_gimple_phi): Dump lineno's if present.
* tree-vect-loop.c (get_initial_def_for_induction,
vect_create_epilog_for_reduction, vect_finalize_reduction): Add
locations.
* tree-flow-inline.h (gimple_phi_arg_location): New. Return locus.
(gimple_phi_arg_location_from_edge): New. Return locus from an edge.
(gimple_phi_arg_set_location): New. Set locus.
(gimple_phi_arg_has_location): New. Check for locus.
(redirect_edge_var_map_location): New. Return locus from var_map.
* tree-vect-data-refs.c (vect_setup_realignment): Set location.
* tree-ssa-phiopt.c (conditional_replacement): Set locus when
combining PHI arguments.
(cond_store_replacement): Set location.
* cfgexpand.c (gimple_assign_rhs_to_tree): Transfer locus if possible.
* grpahite.c (add_loop_exit_phis, add_guard_exit_phis,
scop_add_exit_phis_edge): Add locations.
* tree-cfgcleanup.c (remove_forwarder_block,
remove_forwarder_block_with_phi): Add locations.
* tree-ssa-pre.c (insert_into_preds_of_block): Add locations.
* tree-predcom.c (initialize_root_vars, initialize_root_vars_lm): Add
locations.
* tree-ssa-dce.c (forward_edge_to_pdom): Add locations.
* tree-ssa.c (redirect_edge_var_map_add, ssa_redirect_edge,
flush_pending_stmts): Add source location.
* lambda-code.c (perfect_nestify): Maintain location stack with argument
stack to preserve locations.
* tree-vect-stmts.c (vectorizable_load): Add location.
* tree-inline.c (copy_phis_for_bb): Copy locus.
(setup_one_parameter): Add call locus to inlined parameter stmts.
(initialize_inlined_parameters): Pass in call location as parameter
assignment locus.
(tree_function_versioning): Pass location to setup_one_parameter.
* tree-ssa-phiprop.c (phiprop_insert_phi): Set locations.
* tree-outof-ssa.c (struct _elim_graph): Add source_location vecs for
copy and edge lists.
(insert_partition_copy_on_edge, insert_value_copy_on_edge,
insert_rtx_to_part_on_edge, insert_part_to_rtx_on_edge): Provide a
locus parameter and override the stmt default if provided.
(new_elim_graph, clear_elim_graph, delete_elim_graph,
elim_graph_add_edge, elim_graph_remove_succ_edge,
FOR_EACH_ELIM_GRAPH_SUCC, FOR_EACH_ELIM_GRAPH_PRED, eliminate_build,
elim_forward, elim_unvisited_predecessor, elim_backward, elim_create,
eliminate_phi): Add locus info in elimination graph for each edge and
value copy.
(insert_backedge_copies): Copy locus if present.
* tree-flow.h (struct _edge_var_map): Add locus field.
* tree-switch_conversions.c (fix_phi_nodes): Add locations.
* tree-cfg.c (reinstall_phi_args, gimple_make_forwarder_block,
add_phi_args_after_copy_edge, gimple_lv_adjust_loop_header_phi): Add
locations.
* ipa-struct-reorg.c (make_edge_and_fix_phis_of_dest): Add locations.

2009-07-30 Martin Jambor <mjambor@suse.cz>

PR tree-optimization/40570
Expand Down
3 changes: 3 additions & 0 deletions gcc/cfgexpand.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ gimple_assign_rhs_to_tree (gimple stmt)
else
gcc_unreachable ();

if (gimple_has_location (stmt) && CAN_HAVE_LOCATION_P (t))
SET_EXPR_LOCATION (t, gimple_location (stmt));

return t;
}

Expand Down
16 changes: 16 additions & 0 deletions gcc/gimple-pretty-print.c
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,22 @@ dump_gimple_phi (pretty_printer *buffer, gimple phi, int spc, int flags)
}
for (i = 0; i < gimple_phi_num_args (phi); i++)
{
if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
{
expanded_location xloc;

xloc = expand_location (gimple_phi_arg_location (phi, i));
pp_character (buffer, '[');
if (xloc.file)
{
pp_string (buffer, xloc.file);
pp_string (buffer, " : ");
}
pp_decimal_int (buffer, xloc.line);
pp_string (buffer, ":");
pp_decimal_int (buffer, xloc.column);
pp_string (buffer, "] ");
}
dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
false);
pp_character (buffer, '(');
Expand Down
10 changes: 5 additions & 5 deletions gcc/graphite.c
Original file line number Diff line number Diff line change
Expand Up @@ -4555,7 +4555,7 @@ add_loop_exit_phis (void **slot, void *s)
tree res = create_new_def_for (gimple_phi_result (phi), phi,
gimple_phi_result_ptr (phi));

add_phi_arg (phi, new_name, single_pred_edge (bb));
add_phi_arg (phi, new_name, single_pred_edge (bb), UNKNOWN_LOCATION);

entry->new_name = res;
*slot = entry;
Expand Down Expand Up @@ -4617,8 +4617,8 @@ add_guard_exit_phis (void **slot, void *s)
tree res = create_new_def_for (gimple_phi_result (phi), phi,
gimple_phi_result_ptr (phi));

add_phi_arg (phi, name1, true_edge);
add_phi_arg (phi, name2, false_edge);
add_phi_arg (phi, name1, true_edge, UNKNOWN_LOCATION);
add_phi_arg (phi, name2, false_edge, UNKNOWN_LOCATION);

entry->new_name = res;
*slot = entry;
Expand Down Expand Up @@ -5141,8 +5141,8 @@ scop_add_exit_phis_edge (basic_block exit, tree use, edge false_e, edge true_e)

create_new_def_for (gimple_phi_result (phi), phi,
gimple_phi_result_ptr (phi));
add_phi_arg (phi, use, false_e);
add_phi_arg (phi, use, true_e);
add_phi_arg (phi, use, false_e, UNKNOWN_LOCATION);
add_phi_arg (phi, use, true_e, UNKNOWN_LOCATION);
}

/* Add phi nodes for VAR that is used in LIVEIN. Phi nodes are
Expand Down
2 changes: 1 addition & 1 deletion gcc/ipa-struct-reorg.c
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ make_edge_and_fix_phis_of_dest (basic_block bb, edge e)
{
gimple phi = gsi_stmt (si);
arg = PHI_ARG_DEF_FROM_EDGE (phi, e);
add_phi_arg (phi, arg, new_e);
add_phi_arg (phi, arg, new_e, gimple_phi_arg_location_from_edge (phi, e));
}

return new_e;
Expand Down
12 changes: 11 additions & 1 deletion gcc/lambda-code.c
Original file line number Diff line number Diff line change
Expand Up @@ -2343,6 +2343,10 @@ can_convert_to_perfect_nest (struct loop *loop)
return false;
}


DEF_VEC_I(source_location);
DEF_VEC_ALLOC_I(source_location,heap);

/* Transform the loop nest into a perfect nest, if possible.
LOOP is the loop nest to transform into a perfect nest
LBOUNDS are the lower bounds for the loops to transform
Expand Down Expand Up @@ -2400,6 +2404,7 @@ perfect_nestify (struct loop *loop,
gimple stmt;
tree oldivvar, ivvar, ivvarinced;
VEC(tree,heap) *phis = NULL;
VEC(source_location,heap) *locations = NULL;
htab_t replacements = NULL;

/* Create the new loop. */
Expand All @@ -2412,8 +2417,11 @@ perfect_nestify (struct loop *loop,
{
phi = gsi_stmt (bsi);
VEC_reserve (tree, heap, phis, 2);
VEC_reserve (source_location, heap, locations, 1);
VEC_quick_push (tree, phis, PHI_RESULT (phi));
VEC_quick_push (tree, phis, PHI_ARG_DEF (phi, 0));
VEC_quick_push (source_location, locations,
gimple_phi_arg_location (phi, 0));
}
e = redirect_edge_and_branch (single_succ_edge (preheaderbb), headerbb);

Expand All @@ -2426,10 +2434,12 @@ perfect_nestify (struct loop *loop,
{
tree def;
tree phiname;
source_location locus;
def = VEC_pop (tree, phis);
phiname = VEC_pop (tree, phis);
locus = VEC_pop (source_location, locations);
phi = create_phi_node (phiname, preheaderbb);
add_phi_arg (phi, def, single_pred_edge (preheaderbb));
add_phi_arg (phi, def, single_pred_edge (preheaderbb), locus);
}
flush_pending_stmts (e);
VEC_free (tree, heap, phis);
Expand Down
18 changes: 12 additions & 6 deletions gcc/omp-low.c
Original file line number Diff line number Diff line change
Expand Up @@ -3013,8 +3013,8 @@ expand_parallel_call (struct omp_region *region, basic_block bb,
{
gimple phi = create_phi_node (tmp_join, bb);
SSA_NAME_DEF_STMT (tmp_join) = phi;
add_phi_arg (phi, tmp_then, e_then);
add_phi_arg (phi, tmp_else, e_else);
add_phi_arg (phi, tmp_then, e_then, UNKNOWN_LOCATION);
add_phi_arg (phi, tmp_else, e_else, UNKNOWN_LOCATION);
}

val = tmp_join;
Expand Down Expand Up @@ -4508,6 +4508,7 @@ expand_omp_for_static_chunk (struct omp_region *region, struct omp_for_data *fd)
gsi_next (&psi), ++i)
{
gimple nphi;
source_location locus;

phi = gsi_stmt (psi);
t = gimple_phi_result (phi);
Expand All @@ -4516,12 +4517,15 @@ expand_omp_for_static_chunk (struct omp_region *region, struct omp_for_data *fd)
SSA_NAME_DEF_STMT (t) = nphi;

t = PHI_ARG_DEF_FROM_EDGE (phi, se);
locus = gimple_phi_arg_location_from_edge (phi, se);

/* A special case -- fd->loop.v is not yet computed in
iter_part_bb, we need to use v_extra instead. */
if (t == fd->loop.v)
t = v_extra;
add_phi_arg (nphi, t, ene);
add_phi_arg (nphi, redirect_edge_var_map_def (vm), re);
add_phi_arg (nphi, t, ene, locus);
locus = redirect_edge_var_map_location (vm);
add_phi_arg (nphi, redirect_edge_var_map_def (vm), re, locus);
}
gcc_assert (!gsi_end_p (psi) && i == VEC_length (edge_var_map, head));
redirect_edge_var_map_clear (re);
Expand All @@ -4536,8 +4540,10 @@ expand_omp_for_static_chunk (struct omp_region *region, struct omp_for_data *fd)
/* Make phi node for trip. */
phi = create_phi_node (trip_main, iter_part_bb);
SSA_NAME_DEF_STMT (trip_main) = phi;
add_phi_arg (phi, trip_back, single_succ_edge (trip_update_bb));
add_phi_arg (phi, trip_init, single_succ_edge (entry_bb));
add_phi_arg (phi, trip_back, single_succ_edge (trip_update_bb),
UNKNOWN_LOCATION);
add_phi_arg (phi, trip_init, single_succ_edge (entry_bb),
UNKNOWN_LOCATION);
}

set_immediate_dominator (CDI_DOMINATORS, trip_update_bb, cont_bb);
Expand Down
10 changes: 6 additions & 4 deletions gcc/tree-cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -2886,7 +2886,7 @@ reinstall_phi_args (edge new_edge, edge old_edge)

gcc_assert (result == gimple_phi_result (phi));

add_phi_arg (phi, arg, new_edge);
add_phi_arg (phi, arg, new_edge, redirect_edge_var_map_location (vm));
}

redirect_edge_var_map_clear (old_edge);
Expand Down Expand Up @@ -4840,7 +4840,8 @@ gimple_make_forwarder_block (edge fallthru)
new_phi = create_phi_node (var, bb);
SSA_NAME_DEF_STMT (var) = new_phi;
gimple_phi_set_result (phi, make_ssa_name (SSA_NAME_VAR (var), phi));
add_phi_arg (new_phi, gimple_phi_result (phi), fallthru);
add_phi_arg (new_phi, gimple_phi_result (phi), fallthru,
UNKNOWN_LOCATION);
}

/* Add the arguments we have stored on edges. */
Expand Down Expand Up @@ -5239,7 +5240,8 @@ add_phi_args_after_copy_edge (edge e_copy)
phi = gsi_stmt (psi);
phi_copy = gsi_stmt (psi_copy);
def = PHI_ARG_DEF_FROM_EDGE (phi, e);
add_phi_arg (phi_copy, def, e_copy);
add_phi_arg (phi_copy, def, e_copy,
gimple_phi_arg_location_from_edge (phi, e));
}
}

Expand Down Expand Up @@ -7058,7 +7060,7 @@ gimple_lv_adjust_loop_header_phi (basic_block first, basic_block second,
phi1 = gsi_stmt (psi1);
phi2 = gsi_stmt (psi2);
def = PHI_ARG_DEF (phi2, e2->dest_idx);
add_phi_arg (phi1, def, e);
add_phi_arg (phi1, def, e, gimple_phi_arg_location_from_edge (phi2, e2));
}
}

Expand Down
7 changes: 5 additions & 2 deletions gcc/tree-cfgcleanup.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,8 @@ remove_forwarder_block (basic_block bb)
gsi_next (&gsi))
{
gimple phi = gsi_stmt (gsi);
add_phi_arg (phi, gimple_phi_arg_def (phi, succ->dest_idx), s);
source_location l = gimple_phi_arg_location_from_edge (phi, succ);
add_phi_arg (phi, gimple_phi_arg_def (phi, succ->dest_idx), s, l);
}
}
}
Expand Down Expand Up @@ -744,6 +745,7 @@ remove_forwarder_block_with_phi (basic_block bb)
{
gimple phi = gsi_stmt (gsi);
tree def = gimple_phi_arg_def (phi, succ->dest_idx);
source_location locus = gimple_phi_arg_location_from_edge (phi, succ);

if (TREE_CODE (def) == SSA_NAME)
{
Expand All @@ -763,12 +765,13 @@ remove_forwarder_block_with_phi (basic_block bb)
if (def == old_arg)
{
def = new_arg;
locus = redirect_edge_var_map_location (vm);
break;
}
}
}

add_phi_arg (phi, def, s);
add_phi_arg (phi, def, s, locus);
}

redirect_edge_var_map_clear (e);
Expand Down
41 changes: 41 additions & 0 deletions gcc/tree-flow-inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,39 @@ gimple_phi_arg_edge (gimple gs, size_t i)
return EDGE_PRED (gimple_bb (gs), i);
}

/* Return the source location of gimple argument I of phi node GS. */

static inline source_location
gimple_phi_arg_location (gimple gs, size_t i)
{
return gimple_phi_arg (gs, i)->locus;
}

/* Return the source location of the argument on edge E of phi node GS. */

static inline source_location
gimple_phi_arg_location_from_edge (gimple gs, edge e)
{
return gimple_phi_arg (gs, e->dest_idx)->locus;
}

/* Set the source location of gimple argument I of phi node GS to LOC. */

static inline void
gimple_phi_arg_set_location (gimple gs, size_t i, source_location loc)
{
gimple_phi_arg (gs, i)->locus = loc;
}

/* Return TRUE if argument I of phi node GS has a location record. */

static inline bool
gimple_phi_arg_has_location (gimple gs, size_t i)
{
return gimple_phi_arg_location (gs, i) != UNKNOWN_LOCATION;
}


/* Return the PHI nodes for basic block BB, or NULL if there are no
PHI nodes. */
static inline gimple_seq
Expand Down Expand Up @@ -1196,6 +1229,14 @@ redirect_edge_var_map_result (edge_var_map *v)
return v->result;
}

/* Given an edge_var_map V, return the PHI arg location. */

static inline source_location
redirect_edge_var_map_location (edge_var_map *v)
{
return v->locus;
}


/* Return an SSA_NAME node for variable VAR defined in statement STMT
in function cfun. */
Expand Down
Loading

0 comments on commit efbcb6d

Please sign in to comment.