https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125294

            Bug ID: 125294
           Summary: -fanalyzer increases compile time by several orders of
                    magnitude
           Product: gcc
           Version: 16.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: andres at anarazel dot de
  Target Milestone: ---

Created attachment 64449
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64449&action=edit
Reproducer

Hi,

While setting up -fanalyzer to find bugs in postgres, I noticed that the
overall build time with -fanalyzer was dominated by a handful of files.

Some of them are huge complicated files, but others aren't that big.  E.g. for
the attached stem_UTF_8_serbian.i I see compile times < 0.01s without
-fanalyzer, and ~120s with -fanalyzer.

andres@alap6:/srv/dev/build/m$ gcc-16 -ftime-report -ftime-report-details -c -o
/dev/null stem_UTF_8_serbian.i 

Time variable                                  wall           GGC
 phase setup                        :   0.00 (  3%)  1976k ( 13%)
 phase parsing                      :   0.03 ( 49%)  7452k ( 50%)
 phase opt and generate             :   0.03 ( 48%)  5392k ( 36%)
 preprocessing                      :   0.01 ( 13%)  1115k (  8%)
 lexical analysis                   :   0.01 ( 10%)     0  (  0%)
 `- preprocessing                   :   0.01 ( 13%)  1115k (  8%)
 parser (global)                    :   0.01 ( 22%)  5187k ( 35%)
 expand                             :   0.00 (  3%)  1342k (  9%)
 integrated RA                      :   0.01 (  9%)   576k (  4%)
 TOTAL                              :   0.06           14M


andres@alap6:/srv/dev/build/m$ gcc-16 -ftime-report -ftime-report-details
-fanalyzer -c -o /dev/null stem_UTF_8_serbian.i 

Time variable                                  wall           GGC
 phase setup                        :   0.00 (  0%)  1976k ( 13%)
 phase parsing                      :   0.03 (  0%)  7452k ( 50%)
 phase opt and generate             : 119.24 (100%)  5408k ( 36%)
 callgraph optimization             :   0.00 (  0%)     0  (  0%)
 `- analyzer                        :   0.77 (  1%)     0  (  0%)
 callgraph ipa passes               : 119.21 (100%)   435k (  3%)
 preprocessing                      :   0.01 (  0%)  1115k (  8%)
 lexical analysis                   :   0.01 (  0%)     0  (  0%)
 `- preprocessing                   :   0.01 (  0%)  1115k (  8%)
 parser (global)                    :   0.01 (  0%)  5188k ( 35%)
 expand                             :   0.00 (  0%)  1342k (  9%)
 analyzer                           :   0.77 (  1%)  3352  (  0%)
 `- analyzer: processing worklist   : 118.44 ( 99%)    13k (  0%)
 analyzer: processing worklist      : 118.44 ( 99%)    13k (  0%)
 TOTAL                              : 119.27           14M

Of course that's with -O0, where non-analyzer gcc doesn't need to do much, but
it's not much slower with -O3 at 0.155s...

I suspect there's some unfortunate quadratic growth going on due to the number
of variables and case statements in that file.


I manually reduced the attached reproducer to remove a bunch of include related
cruft that seems unrelated to the matter, otherwise the .i file was on the too
large side.


Greetings,

Andres

Reply via email to