]> git.ipfire.org Git - thirdparty/gcc.git/commit
analyzer: fix issues with phi handling
authorDavid Malcolm <dmalcolm@redhat.com>
Wed, 21 Jul 2021 21:24:08 +0000 (17:24 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Wed, 21 Jul 2021 21:24:08 +0000 (17:24 -0400)
commite0a7a6752dad7848eb4b29b826a551c0992256ec
tree81a2f099b94604fbc59132682e0e095a89d8b96f
parent6bbad96cd44774bc199b256dbf4260b25b87c7db
analyzer: fix issues with phi handling

The analyzer's state purging code was overzealously purging state
for ssa names that might be used within phi nodes, leading to
false positives from -Wanalyzer-use-of-uninitialized-value.

This patch updates phi handling in the analyzer to fix these issues.

gcc/analyzer/ChangeLog:
* region-model.cc (region_model::handle_phi): Add "old_state"
param and use it.
(region_model::update_for_phis): Update so that all of the phi
stmts are effectively handled simultaneously, rather than in
order.
* region-model.h (region_model::handle_phi): Add "old_state"
param.
* state-purge.cc (self_referential_phi_p): Replace with...
(name_used_by_phis_p): ...this new function.
(state_purge_per_ssa_name::process_point): Update to use the
above, so that all phi stmts at a basic block are effectively
considered simultaneously, and only consider the phi arguments for
the pertinent in-edge.
* supergraph.cc (cfg_superedge::get_phi_arg_idx): New.
(cfg_superedge::get_phi_arg): Use the above.
* supergraph.h (cfg_superedge::get_phi_arg_idx): New decl.

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/explode-2.c: Remove xfail.
* gcc.dg/analyzer/explode-2a.c: Remove expected leak warning on
while stmt.
* gcc.dg/analyzer/phi-2.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/analyzer/region-model.cc
gcc/analyzer/region-model.h
gcc/analyzer/state-purge.cc
gcc/analyzer/supergraph.cc
gcc/analyzer/supergraph.h
gcc/testsuite/gcc.dg/analyzer/explode-2.c
gcc/testsuite/gcc.dg/analyzer/explode-2a.c
gcc/testsuite/gcc.dg/analyzer/phi-2.c [new file with mode: 0644]