]> git.ipfire.org Git - thirdparty/gcc.git/commit
tree-optimization/109539 - restrict PHI handling in access diagnostics
authorRichard Biener <rguenther@suse.de>
Tue, 18 Apr 2023 09:49:48 +0000 (11:49 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 18 Apr 2023 12:37:18 +0000 (14:37 +0200)
commitfdbaab2dc886f78a1e75512eeee0faa17e77c862
tree52e624137f67c8f49857d3ffe1273cfe643ebc94
parentcb5c71d16d0fb47638498365f5c857ce7c673eaf
tree-optimization/109539 - restrict PHI handling in access diagnostics

Access diagnostics visits the SSA def-use chains to diagnose things like
dangling pointer uses.  When that runs into PHIs it tries to prove
all incoming pointers of which one is the currently visited use are
related to decide whether to keep looking for the PHI def uses.
That turns out to be overly optimistic and thus costly.  The following
scraps the existing handling for simply requiring that we eventually
visit all incoming pointers of the PHI during the def-use chain
analysis and only then process uses of the PHI def.

Note this handles backedges of natural loops optimistically, diagnosing
the first iteration.  There's gcc.dg/Wuse-after-free-2.c containing
a testcase requiring this.

PR tree-optimization/109539
* gimple-ssa-warn-access.cc (pass_waccess::check_pointer_uses):
Re-implement pointer relatedness for PHIs.
gcc/gimple-ssa-warn-access.cc