+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>
PR middle-end/78884
basic_block dummy, bb;
tree var;
gphi_iterator gsi;
+ bool forward_location_p;
dummy = fallthru->src;
bb = fallthru->dest;
if (single_pred_p (bb))
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
start of BB. */
for (gsi = gsi_start_phis (dummy); !gsi_end_p (gsi); gsi_next (&gsi))
new_phi = create_phi_node (var, bb);
gimple_phi_set_result (phi, copy_ssa_name (var, phi));
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. */
true, GSI_SAME_STMT);
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);
if (dump_file)
{
gsi_insert_seq_on_edge_immediate (pe, stmts);
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)
- 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
- 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);
if (stmts)