Avoid random stmt order result in pass_waccess::use_after_inval_p
authorRichard Biener <rguenther@suse.de>
Wed, 15 Mar 2023 10:41:20 +0000 (11:41 +0100)
committerRichard Biener <rguenther@suse.de>
Thu, 16 Mar 2023 07:30:05 +0000 (08:30 +0100)
commitadb70c2d1060b3e8d410b45c698796c5d88818b3
tree7867c3888f33b8e87c0d5f4222392592a9fc8881
parentaf4f68166602938796f34cd4e515cb97f2f113c0
Avoid random stmt order result in pass_waccess::use_after_inval_p

use_after_inval_p uses stmt UIDs to speed up repeated dominance
checks within a basic-block but it fails to assign UIDs to PHIs
which means compares with PHIs in the same block get a random
result.

The following factors renumber_gimple_stmt_uids to expose a new
renumber_gimple_stmt_uids_in_block we can share.

But since we rely on processing even earlier PHIs to follow
pointer adjustments (we look at those even if earlier) the patch
also moves PHI handling out of the use_after_inval_p guard.
This then also fixes PR109141.

PR tree-optimization/109141
* tree-dfa.h (renumber_gimple_stmt_uids_in_block): New.
* tree-dfa.cc (renumber_gimple_stmt_uids_in_block): Split
out from ...
(renumber_gimple_stmt_uids): ... here and
(renumber_gimple_stmt_uids_in_blocks): ... here.
* gimple-ssa-warn-access.cc (pass_waccess::use_after_inval_p):
Use renumber_gimple_stmt_uids_in_block to also assign UIDs
to PHIs.
(pass_waccess::check_pointer_uses): Process all PHIs.
gcc/gimple-ssa-warn-access.cc
gcc/tree-dfa.cc
gcc/tree-dfa.h