Skip to content

Commit 7c4f8ae

Browse files
rguenthRichard Biener
authored andcommitted
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.
1 parent 07a2b1a commit 7c4f8ae

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

gcc/tree-ssa-forwprop.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -925,12 +925,10 @@ forward_propagate_addr_expr_1 (tree name, tree def_rhs,
925925
static bool
926926
forward_propagate_addr_expr (tree name, tree rhs, bool parent_single_use_p)
927927
{
928-
imm_use_iterator iter;
929-
gimple *use_stmt;
930928
bool all = true;
931929
bool single_use_p = parent_single_use_p && has_single_use (name);
932930

933-
FOR_EACH_IMM_USE_STMT (use_stmt, iter, name)
931+
for (gimple *use_stmt : gather_imm_use_stmts (name))
934932
{
935933
bool result;
936934
tree use_rhs;

0 commit comments

Comments
 (0)