analyzer: improvements to logging/dumping
authorDavid Malcolm <dmalcolm@redhat.com>
Fri, 21 Feb 2020 14:28:55 +0000 (09:28 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Wed, 26 Feb 2020 11:57:22 +0000 (06:57 -0500)
commit67fa274cd635ec3c8af635294b67f09e45e3c56a
tree5e4a3b45327dc89b6d8791fa236a6c48cb7c0b46
parentce25177f505ea75b3c0833c3f3f0072b97ee1b44
analyzer: improvements to logging/dumping

This patch adds various information to -fdump-analyzer and
-fdump-analyzer-stderr to make it easier to track down
problems with state explosions in the exploded_graph.

It logs the number of unprocessed nodes in the worklist, for
the case where the upper limit on exploded nodes is reached.

It prints:
[a] a bar chart showing the number of exploded nodes by function, and

[b] bar charts for each function showing the number of exploded nodes
    per supernode/BB, and

[c] bar charts for each function showing the number of excess exploded
    nodes per supernode/BB beyond the limit
    (--param=analyzer-max-enodes-per-program-point), where that limit
    was reached

I've found these helpful in finding exactly where we fail to consolidate
state, leading to state explosions and false negatives due to the
thresholds being reached.

The patch also adds a "superedge::dump" member function I found myself
needing.

gcc/ChangeLog:
* Makefile.in (ANALYZER_OBJS): Add analyzer/bar-chart.o.

gcc/analyzer/ChangeLog:
* bar-chart.cc: New file.
* bar-chart.h: New file.
* engine.cc: Include "analyzer/bar-chart.h".
(stats::log): Only log the m_num_nodes kinds that are non-zero.
(stats::dump): Likewise when dumping.
(stats::get_total_enodes): New.
(exploded_graph::get_or_create_node): Increment the per-point-data
m_excess_enodes when hitting the per-program-point limit on
enodes.
(exploded_graph::print_bar_charts): New.
(exploded_graph::log_stats): Log the number of unprocessed enodes
in the worklist.  Call print_bar_charts.
(exploded_graph::dump_stats): Print the number of unprocessed
enodes in the worklist.
* exploded-graph.h (stats::get_total_enodes): New decl.
(struct per_program_point_data): Add field m_excess_enodes.
(exploded_graph::print_bar_charts): New decl.
* supergraph.cc (superedge::dump): New.
(superedge::dump): New.
* supergraph.h (supernode::get_function): New.
(superedge::dump): New decl.
(superedge::dump): New decl.
gcc/ChangeLog
gcc/Makefile.in
gcc/analyzer/ChangeLog
gcc/analyzer/bar-chart.cc [new file with mode: 0644]
gcc/analyzer/bar-chart.h [new file with mode: 0644]
gcc/analyzer/engine.cc
gcc/analyzer/exploded-graph.h
gcc/analyzer/supergraph.cc
gcc/analyzer/supergraph.h