aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/tree-cfg.c7
-rw-r--r--gcc/tree-scalar-evolution.c2
-rw-r--r--gcc/tree-ssa-loop-manip.c16
4 files changed, 31 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5145487..e6740b6 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+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
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index a585efe..0396aa9 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -5756,6 +5756,7 @@ gimple_make_forwarder_block (edge fallthru)
basic_block dummy, bb;
tree var;
gphi_iterator gsi;
+ bool forward_location_p;
dummy = fallthru->src;
bb = fallthru->dest;
@@ -5763,6 +5764,9 @@ gimple_make_forwarder_block (edge fallthru)
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))
@@ -5774,7 +5778,8 @@ gimple_make_forwarder_block (edge fallthru)
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. */
diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c
index 81f70f1..b1c15dc 100644
--- a/gcc/tree-scalar-evolution.c
+++ b/gcc/tree-scalar-evolution.c
@@ -3680,6 +3680,8 @@ final_value_replacement_loop (struct loop *loop)
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)
{
diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c
index 7db4f09..f072418 100644
--- a/gcc/tree-ssa-loop-manip.c
+++ b/gcc/tree-ssa-loop-manip.c
@@ -126,10 +126,22 @@ create_iv (tree base, tree step, tree var, struct loop *loop,
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)