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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |compile-time-hog
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2017-11-13
                 CC|                            |jakub at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  I suspect UBSAN creates a large number of branches and
-Wduplicated-branches isn't very effective.  In fact it looks quadratic given
we do

128       if (warn_duplicated_branches)
129         walk_tree_without_duplicates (&DECL_SAVED_TREE (fndecl),
130                                       do_warn_duplicated_branches_r, NULL);

and do_warn_duplicated_branches_r does itself

  /* Compute the hash of the then branch.  */
  inchash::hash hstate0 (0);
  inchash::add_expr (thenb, hstate0);
  hashval_t h0 = hstate0.end ();
...
      && !walk_tree_without_duplicates (&thenb, expr_from_macro_expansion_r,
                                        NULL)

thus we process each tree (in COND_EXPRs) a quadratic amount of times.
inchash is very likely also not avoiding walking duplicates multiple times,
as SAVE_EXPR is tcc_expression it even walks those multiple times.

As a band-aid I suggest to limit the depth we walk here somehow...

Reply via email to