https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122589
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
This shows an issue with gsi_replace_with_seq with regard to debug stmts. We
do
void
gsi_replace_with_seq (gimple_stmt_iterator *gsi, gimple_seq seq,
bool update_eh_info)
{
gimple_stmt_iterator seqi;
gimple *last;
if (gimple_seq_empty_p (seq))
{
gsi_remove (gsi, true);
return;
}
seqi = gsi_last (seq);
last = gsi_stmt (seqi);
gsi_remove (&seqi, false); <--- A
gsi_insert_seq_before (gsi, seq, GSI_SAME_STMT);
gsi_replace (gsi, last, update_eh_info); <--- B
so remove the last stmt from the sequence to be able to use gsi_replace.
We use 'false' to indicate non-permanent removal, but gsi_remove does
/* ??? Do we want to do this for non-permanent operation? */
if (gimple_code (stmt) != GIMPLE_PHI)
insert_debug_temps_for_defs (i);
and that wipes off _4 from
# DEBUG xpos => _3 + _4
inserting a debug temp for it.