Hi! Honza reported today on IRC that we spent (again) significant time of empty file compilation computing preprocessor *_MAX/*_MIN etc. macros. In 2010 I've added lazy computation for these, only when they are first used except for -dD, but reserved just 12 entries for those, as only FLT/DBL/LDBL prefixed macros (4 times for each kind) were needed at that point. In 2016 for PR32187 Joseph has added a bunch of other kinds and because there is no space in the array reserved for those, they are evaluated right away, which is quite expensive.
The following patch makes them lazy again. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2018-01-26 Jakub Jelinek <ja...@redhat.com> * c-cppbuiltin.c (c_cpp_builtins): Use ggc_strdup for the fp_suffix argument. (lazy_hex_fp_values): Allow up to 36 lazy hex fp values rather than just 12. (builtin_define_with_hex_fp_value): Likewise. * include/cpplib.h (enum cpp_builtin_type): Change BT_LAST_USER from BT_FIRST_USER + 31 to BT_FIRST_USER + 63. --- gcc/c-family/c-cppbuiltin.c.jj 2018-01-03 10:20:21.369538150 +0100 +++ gcc/c-family/c-cppbuiltin.c 2018-01-26 11:01:15.266648197 +0100 @@ -1124,8 +1124,8 @@ c_cpp_builtins (cpp_reader *pfile) floatn_nx_types[i].extended ? "X" : ""); sprintf (csuffix, "F%d%s", floatn_nx_types[i].n, floatn_nx_types[i].extended ? "x" : ""); - builtin_define_float_constants (prefix, csuffix, "%s", csuffix, - FLOATN_NX_TYPE_NODE (i)); + builtin_define_float_constants (prefix, ggc_strdup (csuffix), "%s", + csuffix, FLOATN_NX_TYPE_NODE (i)); } /* For decfloat.h. */ @@ -1571,7 +1571,7 @@ struct GTY(()) lazy_hex_fp_value_struct int digits; const char *fp_suffix; }; -static GTY(()) struct lazy_hex_fp_value_struct lazy_hex_fp_values[12]; +static GTY(()) struct lazy_hex_fp_value_struct lazy_hex_fp_values[36]; static GTY(()) int lazy_hex_fp_value_count; static bool @@ -1616,7 +1616,7 @@ builtin_define_with_hex_fp_value (const char dec_str[64], buf[256], buf1[128], buf2[64]; /* This is very expensive, so if possible expand them lazily. */ - if (lazy_hex_fp_value_count < 12 + if (lazy_hex_fp_value_count < 36 && flag_dump_macros == 0 && !cpp_get_options (parse_in)->traditional) { --- libcpp/include/cpplib.h.jj 2018-01-18 21:11:59.890207215 +0100 +++ libcpp/include/cpplib.h 2018-01-26 10:58:10.249699482 +0100 @@ -719,7 +719,7 @@ enum cpp_builtin_type BT_COUNTER, /* `__COUNTER__' */ BT_HAS_ATTRIBUTE, /* `__has_attribute__(x)' */ BT_FIRST_USER, /* User defined builtin macros. */ - BT_LAST_USER = BT_FIRST_USER + 31 + BT_LAST_USER = BT_FIRST_USER + 63 }; #define CPP_HASHNODE(HNODE) ((cpp_hashnode *) (HNODE)) Jakub