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:38:31 +0000 (14:38 +0200)
commit68aea7801848f978f8b5461807dfd3b7a504da1e
tree20bb03cb2a203a743a67ee81ce329e8b89bc3cc5
parent769c324424500a3d20de7417f62a4e7bce345775
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.

(cherry picked from commit fdbaab2dc886f78a1e75512eeee0faa17e77c862)
gcc/gimple-ssa-warn-access.cc