[Bug analyzer/96653] -Wanalyzer-too-complex on very large switch statement

2020-09-16 Thread dmalcolm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96653

--- Comment #7 from David Malcolm  ---
(which is within my rough goal of -fanalyzer doubling your compile time in
return for more warnings)

[Bug analyzer/96653] -Wanalyzer-too-complex on very large switch statement

2020-09-16 Thread dmalcolm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96653

--- Comment #6 from David Malcolm  ---
With a release build:

$ hyperfine -L ana "","-fanalyzer" "./xgcc -B. -S pr96653.c -O1 {ana}"
Benchmark #1: ./xgcc -B. -S pr96653.c -O1 
  Time (mean ± σ): 127.3 ms ±   0.7 ms[User: 111.3 ms, System: 14.8 ms]
  Range (min … max):   126.1 ms … 128.7 ms23 runs

Benchmark #2: ./xgcc -B. -S pr96653.c -O1 -fanalyzer
  Time (mean ± σ): 246.3 ms ±   1.2 ms[User: 221.9 ms, System: 22.6 ms]
  Range (min … max):   244.5 ms … 248.7 ms12 runs

Summary
  './xgcc -B. -S pr96653.c -O1 ' ran
1.94 ± 0.01 times faster than './xgcc -B. -S pr96653.c -O1 -fanalyzer'

[Bug analyzer/96653] -Wanalyzer-too-complex on very large switch statement

2020-09-16 Thread dmalcolm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96653

David Malcolm  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|ASSIGNED|RESOLVED

--- Comment #5 from David Malcolm  ---
(In reply to David Malcolm from comment #3)
> The compile-time/memory blow-up should be fixed by above commit.
> 
> However, I had to add -Wno-analyzer-too-complex to the testcase.  Keeping
> this bug open to track that (updating bug title accordingly).

This is fixed by r11-3247-gfd111c419d146ee47c7df9a36a535e8d843d4802; marking as
resolved.

[Bug analyzer/96653] -Wanalyzer-too-complex on very large switch statement

2020-09-16 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96653

--- Comment #4 from CVS Commits  ---
The master branch has been updated by David Malcolm :

https://gcc.gnu.org/g:fd111c419d146ee47c7df9a36a535e8d843d4802

commit r11-3247-gfd111c419d146ee47c7df9a36a535e8d843d4802
Author: David Malcolm 
Date:   Wed Sep 16 09:22:06 2020 -0400

analyzer: fix state explosions due to SCC bug

Debugging the state explosion of the very large switch statement in
gcc.dg/analyzer/pr96653.c showed that the worklist was failing to
order the exploded nodes correctly; the in-edges at the join point
after the switch were not getting processed together, but were instead
being rocessed in smaller batches, bloating the exploded graph until the
per-point limit was reached.

The root cause turned out to be a bug in creating the strongly-connected
components for the supergraph: the code was considering interprocedural
edges as well as intraprocedural edges, leading to unpredictable
misorderings of the SCC and worklist, leading to bloating of the
exploded graph.

This patch fixes the SCC creation so it only considers intraprocedural
edges within the supergraph.  It also tweaks worklist::key_t::cmp to
give higher precedence to call_string over differences within a
supernode, since enodes with different call_strings can't be merges.
In practise, none of my test cases were affected by this latter change,
though it seems to be the right thing to do.

With this patch, the very large switch statement in
gcc.dg/analyzer/pr96653.c is handled in a single call to
exploded_graph::maybe_process_run_of_before_supernode_enodes:
   merged 358 in-enodes into 2 out-enode(s) at SN: 402
and that testcase no longer hits the per-program-point limits.

gcc/analyzer/ChangeLog:
* engine.cc (strongly_connected_components::strong_connect): Only
consider intraprocedural edges when creating SCCs.
(worklist::key_t::cmp): Add comment.  Treat call_string
differences as more important than differences of program_point
within a supernode.

gcc/testsuite/ChangeLog:
PR analyzer/96653
* gcc.dg/analyzer/loop-0-up-to-n-by-1-with-iter-obj.c: Update
expected number of exploded nodes.
* gcc.dg/analyzer/malloc-vs-local-1a.c: Update expected number
of exploded nodes.
* gcc.dg/analyzer/pr96653.c: Remove -Wno-analyzer-too-complex.

[Bug analyzer/96653] -Wanalyzer-too-complex on very large switch statement

2020-09-14 Thread dmalcolm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96653

David Malcolm  changed:

   What|Removed |Added

Summary|Compile time and memory hog |-Wanalyzer-too-complex on
   |w/ -O1 -fanalyzer   |very large switch statement

--- Comment #3 from David Malcolm  ---
The compile-time/memory blow-up should be fixed by above commit.

However, I had to add -Wno-analyzer-too-complex to the testcase.  Keeping this
bug open to track that (updating bug title accordingly).