From ffdc40a90faec54d29af76b994c52790685a8e58 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Fri, 5 Jul 2019 08:28:36 +0000 Subject: [PATCH] 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 --- gcc/ChangeLog | 9 +++++++++ gcc/tree-cfg.c | 7 ++++++- gcc/tree-scalar-evolution.c | 2 ++ gcc/tree-ssa-loop-manip.c | 16 ++++++++++++++-- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5145487d3b7..e6740b6b54c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2019-07-03 Eric Botcazou + + * 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 PR middle-end/78884 diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index a585efea3d8..0396aa9bdd3 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 81f70f193d9..b1c15dc11ba 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 7db4f093503..f072418909b 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) -- 2.30.2