]> git.ipfire.org Git - thirdparty/gcc.git/commit
analyzer: fix skipping of debug stmts [PR113253]
authorDavid Malcolm <dmalcolm@redhat.com>
Wed, 31 Jan 2024 23:26:26 +0000 (18:26 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Wed, 31 Jan 2024 23:26:26 +0000 (18:26 -0500)
commitcc7aebff74d8967563fd9af5cb958dfcc8c111e8
tree5211ec1fdeca761d5468b62620fdc25c2688ef8c
parentd22d1a9346f27db41459738c6eb404f8f0956e6f
analyzer: fix skipping of debug stmts [PR113253]

PR analyzer/113253 reports a case where the analyzer output varied
with and without -g enabled.

The root cause was that debug stmts were in the
FOR_EACH_IMM_USE_FAST list for SSA names, leading to the analyzer's
state purging logic differing between the -g and non-debugging cases,
and thus leading to differences in the exploration of the user's code.

Fix by skipping such stmts in the state-purging logic, and removing
debug stmts when constructing the supergraph.

gcc/analyzer/ChangeLog:
PR analyzer/113253
* region-model.cc (region_model::on_stmt_pre): Add gcc_unreachable
for debug statements.
* state-purge.cc
(state_purge_per_ssa_name::state_purge_per_ssa_name): Skip any
debug stmts in the FOR_EACH_IMM_USE_FAST list.
* supergraph.cc (supergraph::supergraph): Don't add debug stmts
to the supernodes.

gcc/testsuite/ChangeLog:
PR analyzer/113253
* gcc.dg/analyzer/deref-before-check-pr113253.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/analyzer/region-model.cc
gcc/analyzer/state-purge.cc
gcc/analyzer/supergraph.cc
gcc/testsuite/gcc.dg/analyzer/deref-before-check-pr113253.c [new file with mode: 0644]