Fix incorrect SLOC inherited by induction variable increment

This extends the condition to more cases involving debug instructions.

gcc/
	* tree-ssa-loop-manip.cc (create_iv): Try harder to find a SLOC to
	put onto the increment when it is inserted after the position.
This commit is contained in:
Eric Botcazou 2023-05-29 09:48:14 +02:00
parent 3fa303becd
commit 89903c8b24

View file

@ -131,10 +131,10 @@ create_iv (tree base, tree_code incr_op, tree step, tree var, class loop *loop,
immediately after a statement whose location is known. */
if (after)
{
if (gsi_end_p (*incr_pos)
|| (is_gimple_debug (gsi_stmt (*incr_pos))
&& gsi_bb (*incr_pos)
&& gsi_end_p (gsi_last_nondebug_bb (gsi_bb (*incr_pos)))))
gimple_stmt_iterator gsi = *incr_pos;
if (!gsi_end_p (gsi))
gsi_next_nondebug (&gsi);
if (gsi_end_p (gsi))
{
edge e = single_succ_edge (gsi_bb (*incr_pos));
gimple_set_location (stmt, e->goto_locus);