Commit ffdc40a9 by Eric Botcazou Committed by Eric Botcazou

tree-cfg.c (gimple_make_forwarder_block): Propagate location info on phi nodes if possible.

	* tree-cfg.c (gimple_make_forwarder_block): Propagate location info on
	phi nodes if possible.
	* tree-scalar-evolution.c (final_value_replacement_loop): Propagate
	location info on the newly created statement.
	* tree-ssa-loop-manip.c (create_iv): Propagate location info on the
	newly created increment if needed.

From-SVN: r273131
parent 8d21ff60
2019-07-03 Eric Botcazou <ebotcazou@adacore.com>
* tree-cfg.c (gimple_make_forwarder_block): Propagate location info on
phi nodes if possible.
* tree-scalar-evolution.c (final_value_replacement_loop): Propagate
location info on the newly created statement.
* tree-ssa-loop-manip.c (create_iv): Propagate location info on the
newly created increment if needed.
2019-07-04 Jakub Jelinek <jakub@redhat.com> 2019-07-04 Jakub Jelinek <jakub@redhat.com>
PR middle-end/78884 PR middle-end/78884
......
...@@ -5756,6 +5756,7 @@ gimple_make_forwarder_block (edge fallthru) ...@@ -5756,6 +5756,7 @@ gimple_make_forwarder_block (edge fallthru)
basic_block dummy, bb; basic_block dummy, bb;
tree var; tree var;
gphi_iterator gsi; gphi_iterator gsi;
bool forward_location_p;
dummy = fallthru->src; dummy = fallthru->src;
bb = fallthru->dest; bb = fallthru->dest;
...@@ -5763,6 +5764,9 @@ gimple_make_forwarder_block (edge fallthru) ...@@ -5763,6 +5764,9 @@ gimple_make_forwarder_block (edge fallthru)
if (single_pred_p (bb)) if (single_pred_p (bb))
return; return;
/* We can forward location info if we have only one predecessor. */
forward_location_p = single_pred_p (dummy);
/* If we redirected a branch we must create new PHI nodes at the /* If we redirected a branch we must create new PHI nodes at the
start of BB. */ start of BB. */
for (gsi = gsi_start_phis (dummy); !gsi_end_p (gsi); gsi_next (&gsi)) for (gsi = gsi_start_phis (dummy); !gsi_end_p (gsi); gsi_next (&gsi))
...@@ -5774,7 +5778,8 @@ gimple_make_forwarder_block (edge fallthru) ...@@ -5774,7 +5778,8 @@ gimple_make_forwarder_block (edge fallthru)
new_phi = create_phi_node (var, bb); new_phi = create_phi_node (var, bb);
gimple_phi_set_result (phi, copy_ssa_name (var, phi)); gimple_phi_set_result (phi, copy_ssa_name (var, phi));
add_phi_arg (new_phi, gimple_phi_result (phi), fallthru, add_phi_arg (new_phi, gimple_phi_result (phi), fallthru,
UNKNOWN_LOCATION); forward_location_p
? gimple_phi_arg_location (phi, 0) : UNKNOWN_LOCATION);
} }
/* Add the arguments we have stored on edges. */ /* Add the arguments we have stored on edges. */
......
...@@ -3680,6 +3680,8 @@ final_value_replacement_loop (struct loop *loop) ...@@ -3680,6 +3680,8 @@ final_value_replacement_loop (struct loop *loop)
true, GSI_SAME_STMT); true, GSI_SAME_STMT);
gassign *ass = gimple_build_assign (rslt, def); gassign *ass = gimple_build_assign (rslt, def);
gimple_set_location (ass,
gimple_phi_arg_location (phi, exit->dest_idx));
gsi_insert_before (&gsi, ass, GSI_SAME_STMT); gsi_insert_before (&gsi, ass, GSI_SAME_STMT);
if (dump_file) if (dump_file)
{ {
......
...@@ -126,10 +126,22 @@ create_iv (tree base, tree step, tree var, struct loop *loop, ...@@ -126,10 +126,22 @@ create_iv (tree base, tree step, tree var, struct loop *loop,
gsi_insert_seq_on_edge_immediate (pe, stmts); gsi_insert_seq_on_edge_immediate (pe, stmts);
stmt = gimple_build_assign (va, incr_op, vb, step); stmt = gimple_build_assign (va, incr_op, vb, step);
/* Prevent the increment from inheriting a bogus location if it is not put
immediately after a statement whose location is known. */
if (after) if (after)
gsi_insert_after (incr_pos, stmt, GSI_NEW_STMT); {
if (gsi_end_p (*incr_pos))
{
edge e = single_succ_edge (gsi_bb (*incr_pos));
gimple_set_location (stmt, e->goto_locus);
}
gsi_insert_after (incr_pos, stmt, GSI_NEW_STMT);
}
else else
gsi_insert_before (incr_pos, stmt, GSI_NEW_STMT); {
gimple_set_location (stmt, gimple_location (gsi_stmt (*incr_pos)));
gsi_insert_before (incr_pos, stmt, GSI_NEW_STMT);
}
initial = force_gimple_operand (base, &stmts, true, var); initial = force_gimple_operand (base, &stmts, true, var);
if (stmts) if (stmts)
......
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