]> git.ipfire.org Git - thirdparty/gcc.git/commit
SSA immediate use iterator checking
authorRichard Biener <rguenther@suse.de>
Mon, 3 Nov 2025 13:04:55 +0000 (14:04 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 6 Nov 2025 13:56:13 +0000 (14:56 +0100)
commite82a29a9a7e6d5a2f5e8c873ae19703048a6fcba
treedddc9c7fa9ce8c3b68cca33944737c4ce67189af
parent9ded9b80c111559ece589197a17d6e7e512dd449
SSA immediate use iterator checking

The following implements additional checking around
SSA immediate use iteration.  Specifically this prevents

 - any nesting of FOR_EACH_IMM_USE_STMT inside another iteration
   via FOR_EACH_IMM_USE_STMT or FOR_EACH_IMM_USE_FAST when iterating
   on the same SSA name

 - modification (for now unlinking of immediate uses) of a SSA
   immediate use list when a fast iteration of the immediate uses
   of the SSA name is active

 - modification (for now unlinking of immediate uses) of the immediate
   use list outside of the block of uses for the currently active stmt
   of an ongoing FOR_EACH_IMM_USE_STMT of the SSA name

To implement this additional bookkeeping members are put into the
SSA name structure when ENABLE_GIMPLE_CHECKING is active.  I have
kept the existing consistency checking of the fast iterator.

* ssa-iterators.h (imm_use_iterator::name): Add.
(delink_imm_use): When in a FOR_EACH_IMM_USE_STMT iteration
enforce we only remove uses from the current stmt.
(end_imm_use_stmt_traverse): Reset current stmt.
(first_imm_use_stmt): Assert no FOR_EACH_IMM_USE_STMT on
var is in progress.  Set the current stmt.
(next_imm_use_stmt): Set the current stmt.
(auto_end_imm_use_fast_traverse): New, lower iteration
depth upon destruction.
(first_readonly_imm_use): Bump the iteration depth.
* tree-core.h (tree_ssa_name::active_iterated_stmt,
tree_ssa_name::fast_iteration_depth): New members when
ENABLE_GIMPLE_CHECKING.
* tree-ssanames.cc (make_ssa_name_fn): Initialize
immediate use verifier bookkeeping members.
gcc/ssa-iterators.h
gcc/tree-core.h
gcc/tree-ssanames.cc