]> git.ipfire.org Git - thirdparty/gcc.git/commit
Use gather_imm_use_stmts instead of FOR_EACH_IMM_USE_STMT in forwprop
authorRichard Biener <rguenther@suse.de>
Mon, 3 Nov 2025 13:43:39 +0000 (14:43 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 5 Nov 2025 08:34:09 +0000 (09:34 +0100)
commit7c4f8ae20cc09e8732739ac839c845ba8c2991c0
tree4982a459fb892909323881e8c5e60c64b217e0a9
parent07a2b1a40cfe3e695eef970e98cc5f682a0b79a7
Use gather_imm_use_stmts instead of FOR_EACH_IMM_USE_STMT in forwprop

The following fixes forwprop using FOR_EACH_IMM_USE_STMT to iterate
over stmts and then eventually removing the active stmt, releasing
its defs.  This can cause debug stmt insertion with a RHS referencing
the SSA name we iterate over, adding to its immediate use list
but also adjusting all other debug stmts refering to the released
SSA name, updating those.  And those can refer to the original
iterated over variable.

In the end the destructive behavior of update_stmt is a problem
here, which unlinks all uses of a stmt and then links in the
newly computed ones instead of leaving those in place that are.

The solution is to not rely on FOR_EACH_IMM_USE_STMT to iterate
over stmt uses without duplicates.

* tree-ssa-forwprop.cc (forward_propagate_addr_expr):
Use gather_imm_use_stmts instead of FOR_EACH_IMM_USE_STMT.
gcc/tree-ssa-forwprop.cc