]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fix unsafe stmt modifications in FOR_EACH_IMM_USE_STMT
authorRichard Biener <rguenther@suse.de>
Mon, 3 Nov 2025 12:59:36 +0000 (13:59 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 5 Nov 2025 08:32:51 +0000 (09:32 +0100)
commitb9457ed89cd84c609482a6d808e1bbdbe2cd84ac
tree05b0aabd620b0eda122ca0b27bf55a15bbeea1b5
parente5b355e45dbfc314b0a96cc7d27af000e06b75f1
Fix unsafe stmt modifications in FOR_EACH_IMM_USE_STMT

The following fixes path isolation changing the immediate use list of
an SSA name that is currently iterated over via FOR_EACH_IMM_USE_STMT.
This happens when it duplicates a BB within this and creates/modifies
stmts that contain SSA uses of the name and calls update_stmt which
re-builds SSA operands, including removal of SSA uses and re-inserting
them.  This is not safe as that might cause missed iterated uses but
more importantly could cause the 'next' use to be removed.

For the case in question the fix is to collect interesting uses in
a vec and do the processing outside of the FOR_EACH_IMM_USE_STMT
iteration.

* gimple-ssa-isolate-paths.cc (check_loadstore): Set
the volatile flag on the stmt manually.
(find_implicit_erroneous_behavior): Move code transform
outside of FOR_EACH_IMM_USE_STMT iteration.
gcc/gimple-ssa-isolate-paths.cc