]> gcc.gnu.org Git - gcc.git/commit
analyzer: restore input_location (PR 93349)
authorDavid Malcolm <dmalcolm@redhat.com>
Thu, 23 Jan 2020 23:28:54 +0000 (18:28 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Mon, 27 Jan 2020 16:42:20 +0000 (11:42 -0500)
commit2fbea4190e76a59c4880727cf84706fe083c00ae
treefe0fe8d25ca5b1fcb6128a1b1d98b809e9d4796f
parentf89e844f9c589d1717248597641d25d81a4acb41
analyzer: restore input_location (PR 93349)

PR analyzer/93349 reports an ICE in IPA pass: simdclone for
some input files when -fanalyzer is supplied, with:
  error: location references block not in block tree

The root cause is that the analyzer touches input_location in some
places (to make it easier to track down which source construct the
analyzer can't handle in the case of an analyzer ICE) and fails to reset
it.  For the ICE in question, this sets input_location to a location_t
that references some arbitrary block (specifically, that of the last
statement to be analyzed, within the original CFG of whichever is the
last such function to be analyzed).

Later, within omp-simd-clone.c, input_location is used by gimplify_expr
(called via gimplify_and_add), which has:

14492       if (!gimple_seq_empty_p (*pre_p))
14493 annotate_all_with_location_after (*pre_p, pre_last_gsi, input_location);

thus using whatever the value of input_location is, leading
to statements that reference some arbitrary block in the original CFG.
For the reproducer, this happens to be a block in the CFG for the
original function, rather than that of the clone, but in general it
could be some arbitrary other function in the TU.

This code appears to assume that input_location has some arbitrary
value *not* in the block tree, which is potentially violated by the
analyzer's changes to input_location.

This patch adds a save and restore of input_location at the top-level
function of the analyzer, fixing the ICE.

gcc/analyzer/ChangeLog:
PR analyzer/93349
* engine.cc (run_checkers): Save and restore input_location.

gcc/testsuite/ChangeLog:
PR analyzer/93349
* gcc.dg/analyzer/torture/pr93349.c: New test.
gcc/analyzer/ChangeLog
gcc/analyzer/engine.cc
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/analyzer/torture/pr93349.c [new file with mode: 0644]
This page took 0.058861 seconds and 5 git commands to generate.