From: Eric Botcazou Date: Mon, 29 May 2023 07:48:14 +0000 (+0200) Subject: Fix incorrect SLOC inherited by induction variable increment X-Git-Tag: basepoints/gcc-15~8782 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=89903c8b24c7883b4a400365706e7804298cc523;p=thirdparty%2Fgcc.git 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. --- diff --git a/gcc/tree-ssa-loop-manip.cc b/gcc/tree-ssa-loop-manip.cc index f336d2224334..b2d3dcf406d4 100644 --- a/gcc/tree-ssa-loop-manip.cc +++ b/gcc/tree-ssa-loop-manip.cc @@ -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);