2020-03-24 Jakub Jelinek <jakub@redhat.com>
+ PR debug/94285
+ * tree-ssa-loop-manip.c (create_iv): If after, set stmt location to
+ e->goto_locus even if gsi_bb (*incr_pos) contains only debug stmts.
+ If not after and at *incr_pos is a debug stmt, set stmt location to
+ location of next non-debug stmt after it if any.
+
PR debug/94283
* tree-if-conv.c (ifcvt_local_dce): For gimple debug stmts, just set
GF_PLF_2, but don't add them to worklist. Don't add an assigment to
immediately after a statement whose location is known. */
if (after)
{
- if (gsi_end_p (*incr_pos))
+ 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)))))
{
edge e = single_succ_edge (gsi_bb (*incr_pos));
gimple_set_location (stmt, e->goto_locus);
}
else
{
- if (!gsi_end_p (*incr_pos))
- gimple_set_location (stmt, gimple_location (gsi_stmt (*incr_pos)));
+ gimple_stmt_iterator gsi = *incr_pos;
+ if (!gsi_end_p (gsi) && is_gimple_debug (gsi_stmt (gsi)))
+ gsi_next_nondebug (&gsi);
+ if (!gsi_end_p (gsi))
+ gimple_set_location (stmt, gimple_location (gsi_stmt (gsi)));
gsi_insert_before (incr_pos, stmt, GSI_NEW_STMT);
}