LCOV - code coverage report
Current view: top level - gcc - opts.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 88.4 % 1786 1578
Test Date: 2025-06-21 16:26:05 Functions: 98.2 % 57 56
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* Command line option handling.
       2                 :             :    Copyright (C) 2002-2025 Free Software Foundation, Inc.
       3                 :             :    Contributed by Neil Booth.
       4                 :             : 
       5                 :             : This file is part of GCC.
       6                 :             : 
       7                 :             : GCC is free software; you can redistribute it and/or modify it under
       8                 :             : the terms of the GNU General Public License as published by the Free
       9                 :             : Software Foundation; either version 3, or (at your option) any later
      10                 :             : version.
      11                 :             : 
      12                 :             : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      13                 :             : WARRANTY; without even the implied warranty of MERCHANTABILITY or
      14                 :             : FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      15                 :             : for more details.
      16                 :             : 
      17                 :             : You should have received a copy of the GNU General Public License
      18                 :             : along with GCC; see the file COPYING3.  If not see
      19                 :             : <http://www.gnu.org/licenses/>.  */
      20                 :             : 
      21                 :             : #include "config.h"
      22                 :             : #include "system.h"
      23                 :             : #include "intl.h"
      24                 :             : #include "coretypes.h"
      25                 :             : #include "opts.h"
      26                 :             : #include "tm.h"
      27                 :             : #include "flags.h"
      28                 :             : #include "diagnostic.h"
      29                 :             : #include "opts-diagnostic.h"
      30                 :             : #include "insn-attr-common.h"
      31                 :             : #include "common/common-target.h"
      32                 :             : #include "spellcheck.h"
      33                 :             : #include "opt-suggestions.h"
      34                 :             : #include "diagnostic-color.h"
      35                 :             : #include "diagnostic-format.h"
      36                 :             : #include "version.h"
      37                 :             : #include "selftest.h"
      38                 :             : #include "file-prefix-map.h"
      39                 :             : 
      40                 :             : /* In this file all option sets are explicit.  */
      41                 :             : #undef OPTION_SET_P
      42                 :             : 
      43                 :             : /* Set by -fcanon-prefix-map.  */
      44                 :             : bool flag_canon_prefix_map;
      45                 :             : 
      46                 :             : /* Set by finish_options when flag_stack_protector was set only because of
      47                 :             :    -fhardened.  Yuck.  */
      48                 :             : bool flag_stack_protector_set_by_fhardened_p;
      49                 :             : 
      50                 :             : static void set_Wstrict_aliasing (struct gcc_options *opts, int onoff);
      51                 :             : 
      52                 :             : /* Names of fundamental debug info formats indexed by enum
      53                 :             :    debug_info_type.  */
      54                 :             : 
      55                 :             : const char *const debug_type_names[] =
      56                 :             : {
      57                 :             :   "none", "dwarf-2", "vms", "ctf", "btf", "codeview"
      58                 :             : };
      59                 :             : 
      60                 :             : /* Bitmasks of fundamental debug info formats indexed by enum
      61                 :             :    debug_info_type.  */
      62                 :             : 
      63                 :             : static uint32_t debug_type_masks[] =
      64                 :             : {
      65                 :             :   NO_DEBUG, DWARF2_DEBUG, VMS_DEBUG,
      66                 :             :   CTF_DEBUG, BTF_DEBUG, CODEVIEW_DEBUG
      67                 :             : };
      68                 :             : 
      69                 :             : /* Names of the set of debug formats requested by user.  Updated and accessed
      70                 :             :    via debug_set_names.  */
      71                 :             : 
      72                 :             : static char df_set_names[sizeof "none dwarf-2 vms ctf btf codeview"];
      73                 :             : 
      74                 :             : /* Get enum debug_info_type of the specified debug format, for error messages.
      75                 :             :    Can be used only for individual debug format types.  */
      76                 :             : 
      77                 :             : enum debug_info_type
      78                 :           0 : debug_set_to_format (uint32_t debug_info_set)
      79                 :             : {
      80                 :           0 :   int idx = 0;
      81                 :           0 :   enum debug_info_type dinfo_type = DINFO_TYPE_NONE;
      82                 :             :   /* Find first set bit.  */
      83                 :           0 :   if (debug_info_set)
      84                 :           0 :     idx = exact_log2 (debug_info_set & - debug_info_set);
      85                 :             :   /* Check that only one bit is set, if at all.  This function is meant to be
      86                 :             :      used only for vanilla debug_info_set bitmask values, i.e. for individual
      87                 :             :      debug format types upto DINFO_TYPE_MAX.  */
      88                 :           0 :   gcc_assert ((debug_info_set & (debug_info_set - 1)) == 0);
      89                 :           0 :   dinfo_type = (enum debug_info_type)idx;
      90                 :           0 :   gcc_assert (dinfo_type <= DINFO_TYPE_MAX);
      91                 :           0 :   return dinfo_type;
      92                 :             : }
      93                 :             : 
      94                 :             : /* Get the number of debug formats enabled for output.  */
      95                 :             : 
      96                 :             : unsigned int
      97                 :          12 : debug_set_count (uint32_t w_symbols)
      98                 :             : {
      99                 :          12 :   unsigned int count = 0;
     100                 :          18 :   while (w_symbols)
     101                 :             :     {
     102                 :           6 :       ++ count;
     103                 :           6 :       w_symbols &= ~ (w_symbols & - w_symbols);
     104                 :             :     }
     105                 :          12 :   return count;
     106                 :             : }
     107                 :             : 
     108                 :             : /* Get the names of the debug formats enabled for output.  */
     109                 :             : 
     110                 :             : const char *
     111                 :          12 : debug_set_names (uint32_t w_symbols)
     112                 :             : {
     113                 :          12 :   uint32_t df_mask = 0;
     114                 :             :   /* Reset the string to be returned.  */
     115                 :          12 :   memset (df_set_names, 0, sizeof (df_set_names));
     116                 :             :   /* Get the popcount.  */
     117                 :          12 :   int num_set_df = debug_set_count (w_symbols);
     118                 :             :   /* Iterate over the debug formats.  Add name string for those enabled.  */
     119                 :          18 :   for (int i = DINFO_TYPE_NONE; i <= DINFO_TYPE_MAX; i++)
     120                 :             :     {
     121                 :          18 :       df_mask = debug_type_masks[i];
     122                 :          18 :       if (w_symbols & df_mask)
     123                 :             :         {
     124                 :           6 :           strcat (df_set_names, debug_type_names[i]);
     125                 :           6 :           num_set_df--;
     126                 :           6 :           if (num_set_df)
     127                 :           0 :             strcat (df_set_names, " ");
     128                 :             :           else
     129                 :             :             break;
     130                 :             :         }
     131                 :          12 :       else if (!w_symbols)
     132                 :             :         {
     133                 :             :           /* No debug formats enabled.  */
     134                 :           6 :           gcc_assert (i == DINFO_TYPE_NONE);
     135                 :           6 :           strcat (df_set_names, debug_type_names[i]);
     136                 :           6 :           break;
     137                 :             :         }
     138                 :             :     }
     139                 :          12 :   return df_set_names;
     140                 :             : }
     141                 :             : 
     142                 :             : /* Return TRUE iff BTF debug info is enabled.  */
     143                 :             : 
     144                 :             : bool
     145                 :      105162 : btf_debuginfo_p ()
     146                 :             : {
     147                 :      105162 :   return (write_symbols & BTF_DEBUG);
     148                 :             : }
     149                 :             : 
     150                 :             : /* Return TRUE iff BTF with CO-RE debug info is enabled.  */
     151                 :             : 
     152                 :             : bool
     153                 :         189 : btf_with_core_debuginfo_p ()
     154                 :             : {
     155                 :         189 :   return (write_symbols & BTF_WITH_CORE_DEBUG);
     156                 :             : }
     157                 :             : 
     158                 :             : /* Return TRUE iff CTF debug info is enabled.  */
     159                 :             : 
     160                 :             : bool
     161                 :         437 : ctf_debuginfo_p ()
     162                 :             : {
     163                 :         437 :   return (write_symbols & CTF_DEBUG);
     164                 :             : }
     165                 :             : 
     166                 :             : /* Return TRUE iff CodeView debug info is enabled.  */
     167                 :             : 
     168                 :             : bool
     169                 :         443 : codeview_debuginfo_p ()
     170                 :             : {
     171                 :         443 :   return (write_symbols & CODEVIEW_DEBUG);
     172                 :             : }
     173                 :             : 
     174                 :             : /* Return TRUE iff dwarf2 debug info is enabled.  */
     175                 :             : 
     176                 :             : bool
     177                 :    45257051 : dwarf_debuginfo_p (struct gcc_options *opts)
     178                 :             : {
     179                 :    45257051 :   return (opts->x_write_symbols & DWARF2_DEBUG);
     180                 :             : }
     181                 :             : 
     182                 :             : /* Return true iff the debug info format is to be generated based on DWARF
     183                 :             :    DIEs (like CTF and BTF debug info formats).  */
     184                 :             : 
     185                 :     4762703 : bool dwarf_based_debuginfo_p ()
     186                 :             : {
     187                 :     4762703 :   return ((write_symbols & CTF_DEBUG)
     188                 :     4761001 :           || (write_symbols & BTF_DEBUG)
     189                 :     9523317 :           || (write_symbols & CODEVIEW_DEBUG));
     190                 :             : }
     191                 :             : 
     192                 :             : /* All flag uses below need to explicitely reference the option sets
     193                 :             :    to operate on.  */
     194                 :             : #define global_options DO_NOT_USE
     195                 :             : #define global_options_set DO_NOT_USE
     196                 :             : 
     197                 :             : /* Parse the -femit-struct-debug-detailed option value
     198                 :             :    and set the flag variables. */
     199                 :             : 
     200                 :             : #define MATCH( prefix, string ) \
     201                 :             :   ((strncmp (prefix, string, sizeof prefix - 1) == 0) \
     202                 :             :    ? ((string += sizeof prefix - 1), 1) : 0)
     203                 :             : 
     204                 :             : void
     205                 :          42 : set_struct_debug_option (struct gcc_options *opts, location_t loc,
     206                 :             :                          const char *spec)
     207                 :             : {
     208                 :             :   /* various labels for comparison */
     209                 :          58 :   static const char dfn_lbl[] = "dfn:", dir_lbl[] = "dir:", ind_lbl[] = "ind:";
     210                 :          58 :   static const char ord_lbl[] = "ord:", gen_lbl[] = "gen:";
     211                 :          58 :   static const char none_lbl[] = "none", any_lbl[] = "any";
     212                 :          58 :   static const char base_lbl[] = "base", sys_lbl[] = "sys";
     213                 :             : 
     214                 :          58 :   enum debug_struct_file files = DINFO_STRUCT_FILE_ANY;
     215                 :             :   /* Default is to apply to as much as possible. */
     216                 :          58 :   enum debug_info_usage usage = DINFO_USAGE_NUM_ENUMS;
     217                 :          58 :   int ord = 1, gen = 1;
     218                 :             : 
     219                 :             :   /* What usage? */
     220                 :          58 :   if (MATCH (dfn_lbl, spec))
     221                 :             :     usage = DINFO_USAGE_DFN;
     222                 :          58 :   else if (MATCH (dir_lbl, spec))
     223                 :             :     usage = DINFO_USAGE_DIR_USE;
     224                 :          42 :   else if (MATCH (ind_lbl, spec))
     225                 :           8 :     usage = DINFO_USAGE_IND_USE;
     226                 :             : 
     227                 :             :   /* Generics or not? */
     228                 :          58 :   if (MATCH (ord_lbl, spec))
     229                 :             :     gen = 0;
     230                 :          50 :   else if (MATCH (gen_lbl, spec))
     231                 :           8 :     ord = 0;
     232                 :             : 
     233                 :             :   /* What allowable environment? */
     234                 :          58 :   if (MATCH (none_lbl, spec))
     235                 :             :     files = DINFO_STRUCT_FILE_NONE;
     236                 :          54 :   else if (MATCH (any_lbl, spec))
     237                 :             :     files = DINFO_STRUCT_FILE_ANY;
     238                 :          42 :   else if (MATCH (sys_lbl, spec))
     239                 :             :     files = DINFO_STRUCT_FILE_SYS;
     240                 :          30 :   else if (MATCH (base_lbl, spec))
     241                 :             :     files = DINFO_STRUCT_FILE_BASE;
     242                 :             :   else
     243                 :           0 :     error_at (loc,
     244                 :             :               "argument %qs to %<-femit-struct-debug-detailed%> "
     245                 :             :               "not recognized",
     246                 :             :               spec);
     247                 :             : 
     248                 :             :   /* Effect the specification. */
     249                 :          58 :   if (usage == DINFO_USAGE_NUM_ENUMS)
     250                 :             :     {
     251                 :          34 :       if (ord)
     252                 :             :         {
     253                 :          34 :           opts->x_debug_struct_ordinary[DINFO_USAGE_DFN] = files;
     254                 :          34 :           opts->x_debug_struct_ordinary[DINFO_USAGE_DIR_USE] = files;
     255                 :          34 :           opts->x_debug_struct_ordinary[DINFO_USAGE_IND_USE] = files;
     256                 :             :         }
     257                 :          34 :       if (gen)
     258                 :             :         {
     259                 :          34 :           opts->x_debug_struct_generic[DINFO_USAGE_DFN] = files;
     260                 :          34 :           opts->x_debug_struct_generic[DINFO_USAGE_DIR_USE] = files;
     261                 :          34 :           opts->x_debug_struct_generic[DINFO_USAGE_IND_USE] = files;
     262                 :             :         }
     263                 :             :     }
     264                 :             :   else
     265                 :             :     {
     266                 :          24 :       if (ord)
     267                 :          16 :         opts->x_debug_struct_ordinary[usage] = files;
     268                 :          24 :       if (gen)
     269                 :          16 :         opts->x_debug_struct_generic[usage] = files;
     270                 :             :     }
     271                 :             : 
     272                 :          58 :   if (*spec == ',')
     273                 :          16 :     set_struct_debug_option (opts, loc, spec+1);
     274                 :             :   else
     275                 :             :     {
     276                 :             :       /* No more -femit-struct-debug-detailed specifications.
     277                 :             :          Do final checks. */
     278                 :          42 :       if (*spec != '\0')
     279                 :           0 :         error_at (loc,
     280                 :             :                   "argument %qs to %<-femit-struct-debug-detailed%> unknown",
     281                 :             :                   spec);
     282                 :          42 :       if (opts->x_debug_struct_ordinary[DINFO_USAGE_DIR_USE]
     283                 :          42 :                 < opts->x_debug_struct_ordinary[DINFO_USAGE_IND_USE]
     284                 :          42 :           || opts->x_debug_struct_generic[DINFO_USAGE_DIR_USE]
     285                 :          42 :                 < opts->x_debug_struct_generic[DINFO_USAGE_IND_USE])
     286                 :           0 :         error_at (loc,
     287                 :             :                   "%<-femit-struct-debug-detailed=dir:...%> must allow "
     288                 :             :                   "at least as much as "
     289                 :             :                   "%<-femit-struct-debug-detailed=ind:...%>");
     290                 :             :     }
     291                 :          42 : }
     292                 :             : 
     293                 :             : /* Strip off a legitimate source ending from the input string NAME of
     294                 :             :    length LEN.  Rather than having to know the names used by all of
     295                 :             :    our front ends, we strip off an ending of a period followed by
     296                 :             :    up to fource characters.  (C++ uses ".cpp".)  */
     297                 :             : 
     298                 :             : void
     299                 :        1387 : strip_off_ending (char *name, int len)
     300                 :             : {
     301                 :        1387 :   int i;
     302                 :        1525 :   for (i = 2; i < 5 && len > i; i++)
     303                 :             :     {
     304                 :        1525 :       if (name[len - i] == '.')
     305                 :             :         {
     306                 :        1387 :           name[len - i] = '\0';
     307                 :        1387 :           break;
     308                 :             :         }
     309                 :             :     }
     310                 :        1387 : }
     311                 :             : 
     312                 :             : /* Find the base name of a path, stripping off both directories and
     313                 :             :    a single final extension. */
     314                 :             : int
     315                 :      285194 : base_of_path (const char *path, const char **base_out)
     316                 :             : {
     317                 :      285194 :   const char *base = path;
     318                 :      285194 :   const char *dot = 0;
     319                 :      285194 :   const char *p = path;
     320                 :      285194 :   char c = *p;
     321                 :    21816276 :   while (c)
     322                 :             :     {
     323                 :    21531082 :       if (IS_DIR_SEPARATOR (c))
     324                 :             :         {
     325                 :     2444205 :           base = p + 1;
     326                 :     2444205 :           dot = 0;
     327                 :             :         }
     328                 :    19086877 :       else if (c == '.')
     329                 :      495190 :         dot = p;
     330                 :    21531082 :       c = *++p;
     331                 :             :     }
     332                 :      285194 :   if (!dot)
     333                 :         421 :     dot = p;
     334                 :      285194 :   *base_out = base;
     335                 :      285194 :   return dot - base;
     336                 :             : }
     337                 :             : 
     338                 :             : /* What to print when a switch has no documentation.  */
     339                 :             : static const char undocumented_msg[] = N_("This option lacks documentation.");
     340                 :             : static const char use_diagnosed_msg[] = N_("Uses of this option are diagnosed.");
     341                 :             : 
     342                 :             : typedef char *char_p; /* For DEF_VEC_P.  */
     343                 :             : 
     344                 :             : static void set_debug_level (uint32_t dinfo, int extended,
     345                 :             :                              const char *arg, struct gcc_options *opts,
     346                 :             :                              struct gcc_options *opts_set,
     347                 :             :                              location_t loc);
     348                 :             : static void set_fast_math_flags (struct gcc_options *opts, int set);
     349                 :             : static void decode_d_option (const char *arg, struct gcc_options *opts,
     350                 :             :                              location_t loc, diagnostic_context *dc);
     351                 :             : static void set_unsafe_math_optimizations_flags (struct gcc_options *opts,
     352                 :             :                                                  int set);
     353                 :             : static void enable_warning_as_error (const char *arg, int value,
     354                 :             :                                      unsigned int lang_mask,
     355                 :             :                                      const struct cl_option_handlers *handlers,
     356                 :             :                                      struct gcc_options *opts,
     357                 :             :                                      struct gcc_options *opts_set,
     358                 :             :                                      location_t loc,
     359                 :             :                                      diagnostic_context *dc);
     360                 :             : 
     361                 :             : /* Handle a back-end option; arguments and return value as for
     362                 :             :    handle_option.  */
     363                 :             : 
     364                 :             : bool
     365                 :     1245941 : target_handle_option (struct gcc_options *opts,
     366                 :             :                       struct gcc_options *opts_set,
     367                 :             :                       const struct cl_decoded_option *decoded,
     368                 :             :                       unsigned int lang_mask ATTRIBUTE_UNUSED, int kind,
     369                 :             :                       location_t loc,
     370                 :             :                       const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED,
     371                 :             :                       diagnostic_context *dc, void (*) (void))
     372                 :             : {
     373                 :     1245941 :   gcc_assert (dc == global_dc);
     374                 :     1245941 :   gcc_assert (kind == DK_UNSPECIFIED);
     375                 :     1245941 :   return targetm_common.handle_option (opts, opts_set, decoded, loc);
     376                 :             : }
     377                 :             : 
     378                 :             : /* Add comma-separated strings to a char_p vector.  */
     379                 :             : 
     380                 :             : static void
     381                 :         102 : add_comma_separated_to_vector (void **pvec, const char *arg)
     382                 :             : {
     383                 :         102 :   char *tmp;
     384                 :         102 :   char *r;
     385                 :         102 :   char *w;
     386                 :         102 :   char *token_start;
     387                 :         102 :   vec<char_p> *v = (vec<char_p> *) *pvec;
     388                 :             : 
     389                 :         102 :   vec_check_alloc (v, 1);
     390                 :             : 
     391                 :             :   /* We never free this string.  */
     392                 :         102 :   tmp = xstrdup (arg);
     393                 :             : 
     394                 :         102 :   r = tmp;
     395                 :         102 :   w = tmp;
     396                 :         102 :   token_start = tmp;
     397                 :             : 
     398                 :        1227 :   while (*r != '\0')
     399                 :             :     {
     400                 :        1125 :       if (*r == ',')
     401                 :             :         {
     402                 :          20 :           *w++ = '\0';
     403                 :          20 :           ++r;
     404                 :          20 :           v->safe_push (token_start);
     405                 :          20 :           token_start = w;
     406                 :             :         }
     407                 :        1125 :       if (*r == '\\' && r[1] == ',')
     408                 :             :         {
     409                 :           0 :           *w++ = ',';
     410                 :           0 :           r += 2;
     411                 :             :         }
     412                 :             :       else
     413                 :        1125 :         *w++ = *r++;
     414                 :             :     }
     415                 :             : 
     416                 :         102 :   *w = '\0';
     417                 :         102 :   if (*token_start != '\0')
     418                 :         102 :     v->safe_push (token_start);
     419                 :             : 
     420                 :         102 :   *pvec = v;
     421                 :         102 : }
     422                 :             : 
     423                 :             : /* Initialize opts_obstack.  */
     424                 :             : 
     425                 :             : void
     426                 :      594366 : init_opts_obstack (void)
     427                 :             : {
     428                 :      594366 :   gcc_obstack_init (&opts_obstack);
     429                 :      594366 : }
     430                 :             : 
     431                 :             : /* Initialize OPTS and OPTS_SET before using them in parsing options.  */
     432                 :             : 
     433                 :             : void
     434                 :    47539115 : init_options_struct (struct gcc_options *opts, struct gcc_options *opts_set)
     435                 :             : {
     436                 :             :   /* Ensure that opts_obstack has already been initialized by the time
     437                 :             :      that we initialize any gcc_options instances (PR jit/68446).  */
     438                 :    47539115 :   gcc_assert (opts_obstack.chunk_size > 0);
     439                 :             : 
     440                 :    47539115 :   *opts = global_options_init;
     441                 :             : 
     442                 :    47539115 :   if (opts_set)
     443                 :      581344 :     memset (opts_set, 0, sizeof (*opts_set));
     444                 :             : 
     445                 :             :   /* Initialize whether `char' is signed.  */
     446                 :    47539115 :   opts->x_flag_signed_char = DEFAULT_SIGNED_CHAR;
     447                 :             : 
     448                 :             :   /* Initialize target_flags before default_options_optimization
     449                 :             :      so the latter can modify it.  */
     450                 :    47539115 :   opts->x_target_flags = targetm_common.default_target_flags;
     451                 :             : 
     452                 :             :   /* Some targets have ABI-specified unwind tables.  */
     453                 :    47539115 :   opts->x_flag_unwind_tables = targetm_common.unwind_tables_default;
     454                 :             : 
     455                 :             :   /* Some targets have other target-specific initialization.  */
     456                 :    47539115 :   targetm_common.option_init_struct (opts);
     457                 :    47539115 : }
     458                 :             : 
     459                 :             : /* If indicated by the optimization level LEVEL (-Os if SIZE is set,
     460                 :             :    -Ofast if FAST is set, -Og if DEBUG is set), apply the option DEFAULT_OPT
     461                 :             :    to OPTS and OPTS_SET, diagnostic context DC, location LOC, with language
     462                 :             :    mask LANG_MASK and option handlers HANDLERS.  */
     463                 :             : 
     464                 :             : static void
     465                 :    72912371 : maybe_default_option (struct gcc_options *opts,
     466                 :             :                       struct gcc_options *opts_set,
     467                 :             :                       const struct default_options *default_opt,
     468                 :             :                       int level, bool size, bool fast, bool debug,
     469                 :             :                       unsigned int lang_mask,
     470                 :             :                       const struct cl_option_handlers *handlers,
     471                 :             :                       location_t loc,
     472                 :             :                       diagnostic_context *dc)
     473                 :             : {
     474                 :    72912371 :   const struct cl_option *option = &cl_options[default_opt->opt_index];
     475                 :    72912371 :   bool enabled;
     476                 :             : 
     477                 :    72912371 :   if (size)
     478                 :     1786071 :     gcc_assert (level == 2);
     479                 :    72912371 :   if (fast)
     480                 :       72709 :     gcc_assert (level == 3);
     481                 :    72912371 :   if (debug)
     482                 :       89845 :     gcc_assert (level == 1);
     483                 :             : 
     484                 :    72912371 :   switch (default_opt->levels)
     485                 :             :     {
     486                 :             :     case OPT_LEVELS_ALL:
     487                 :             :       enabled = true;
     488                 :             :       break;
     489                 :             : 
     490                 :           0 :     case OPT_LEVELS_0_ONLY:
     491                 :           0 :       enabled = (level == 0);
     492                 :           0 :       break;
     493                 :             : 
     494                 :    17155852 :     case OPT_LEVELS_1_PLUS:
     495                 :    17155852 :       enabled = (level >= 1);
     496                 :    17155852 :       break;
     497                 :             : 
     498                 :           0 :     case OPT_LEVELS_1_PLUS_SPEED_ONLY:
     499                 :           0 :       enabled = (level >= 1 && !size && !debug);
     500                 :             :       break;
     501                 :             : 
     502                 :     9190635 :     case OPT_LEVELS_1_PLUS_NOT_DEBUG:
     503                 :     9190635 :       enabled = (level >= 1 && !debug);
     504                 :     9190635 :       break;
     505                 :             : 
     506                 :    24508360 :     case OPT_LEVELS_2_PLUS:
     507                 :    24508360 :       enabled = (level >= 2);
     508                 :    24508360 :       break;
     509                 :             : 
     510                 :     7352508 :     case OPT_LEVELS_2_PLUS_SPEED_ONLY:
     511                 :     7352508 :       enabled = (level >= 2 && !size && !debug);
     512                 :             :       break;
     513                 :             : 
     514                 :    11028762 :     case OPT_LEVELS_3_PLUS:
     515                 :    11028762 :       enabled = (level >= 3);
     516                 :    11028762 :       break;
     517                 :             : 
     518                 :           0 :     case OPT_LEVELS_3_PLUS_AND_SIZE:
     519                 :           0 :       enabled = (level >= 3 || size);
     520                 :           0 :       break;
     521                 :             : 
     522                 :             :     case OPT_LEVELS_SIZE:
     523                 :             :       enabled = size;
     524                 :             :       break;
     525                 :             : 
     526                 :     1838127 :     case OPT_LEVELS_FAST:
     527                 :     1838127 :       enabled = fast;
     528                 :     1838127 :       break;
     529                 :             : 
     530                 :           0 :     case OPT_LEVELS_NONE:
     531                 :           0 :     default:
     532                 :           0 :       gcc_unreachable ();
     533                 :             :     }
     534                 :             : 
     535                 :    63721736 :   if (enabled)
     536                 :    48053939 :     handle_generated_option (opts, opts_set, default_opt->opt_index,
     537                 :    48053939 :                              default_opt->arg, default_opt->value,
     538                 :             :                              lang_mask, DK_UNSPECIFIED, loc,
     539                 :             :                              handlers, true, dc);
     540                 :    24858432 :   else if (default_opt->arg == NULL
     541                 :    24858432 :            && !option->cl_reject_negative
     542                 :    23674934 :            && !(option->flags & CL_PARAMS))
     543                 :    20752434 :     handle_generated_option (opts, opts_set, default_opt->opt_index,
     544                 :    20752434 :                              default_opt->arg, !default_opt->value,
     545                 :             :                              lang_mask, DK_UNSPECIFIED, loc,
     546                 :             :                              handlers, true, dc);
     547                 :    72912371 : }
     548                 :             : 
     549                 :             : /* As indicated by the optimization level LEVEL (-Os if SIZE is set,
     550                 :             :    -Ofast if FAST is set), apply the options in array DEFAULT_OPTS to
     551                 :             :    OPTS and OPTS_SET, diagnostic context DC, location LOC, with
     552                 :             :    language mask LANG_MASK and option handlers HANDLERS.  */
     553                 :             : 
     554                 :             : static void
     555                 :     1225418 : maybe_default_options (struct gcc_options *opts,
     556                 :             :                        struct gcc_options *opts_set,
     557                 :             :                        const struct default_options *default_opts,
     558                 :             :                        int level, bool size, bool fast, bool debug,
     559                 :             :                        unsigned int lang_mask,
     560                 :             :                        const struct cl_option_handlers *handlers,
     561                 :             :                        location_t loc,
     562                 :             :                        diagnostic_context *dc)
     563                 :             : {
     564                 :     1225418 :   size_t i;
     565                 :             : 
     566                 :    74137789 :   for (i = 0; default_opts[i].levels != OPT_LEVELS_NONE; i++)
     567                 :    72912371 :     maybe_default_option (opts, opts_set, &default_opts[i],
     568                 :             :                           level, size, fast, debug,
     569                 :             :                           lang_mask, handlers, loc, dc);
     570                 :     1225418 : }
     571                 :             : 
     572                 :             : /* Table of options enabled by default at different levels.
     573                 :             :    Please keep this list sorted by level and alphabetized within
     574                 :             :    each level; this makes it easier to keep the documentation
     575                 :             :    in sync.  */
     576                 :             : 
     577                 :             : static const struct default_options default_options_table[] =
     578                 :             :   {
     579                 :             :     /* -O1 and -Og optimizations.  */
     580                 :             :     { OPT_LEVELS_1_PLUS, OPT_fcombine_stack_adjustments, NULL, 1 },
     581                 :             :     { OPT_LEVELS_1_PLUS, OPT_fcompare_elim, NULL, 1 },
     582                 :             :     { OPT_LEVELS_1_PLUS, OPT_fcprop_registers, NULL, 1 },
     583                 :             :     { OPT_LEVELS_1_PLUS, OPT_fdefer_pop, NULL, 1 },
     584                 :             :     { OPT_LEVELS_1_PLUS, OPT_fforward_propagate, NULL, 1 },
     585                 :             :     { OPT_LEVELS_1_PLUS, OPT_fguess_branch_probability, NULL, 1 },
     586                 :             :     { OPT_LEVELS_1_PLUS, OPT_fipa_profile, NULL, 1 },
     587                 :             :     { OPT_LEVELS_1_PLUS, OPT_fipa_pure_const, NULL, 1 },
     588                 :             :     { OPT_LEVELS_1_PLUS, OPT_fipa_reference, NULL, 1 },
     589                 :             :     { OPT_LEVELS_1_PLUS, OPT_fipa_reference_addressable, NULL, 1 },
     590                 :             :     { OPT_LEVELS_1_PLUS, OPT_fmerge_constants, NULL, 1 },
     591                 :             :     { OPT_LEVELS_1_PLUS, OPT_fomit_frame_pointer, NULL, 1 },
     592                 :             :     { OPT_LEVELS_1_PLUS, OPT_freorder_blocks, NULL, 1 },
     593                 :             :     { OPT_LEVELS_1_PLUS, OPT_fshrink_wrap, NULL, 1 },
     594                 :             :     { OPT_LEVELS_1_PLUS, OPT_fsplit_wide_types, NULL, 1 },
     595                 :             :     { OPT_LEVELS_1_PLUS, OPT_fthread_jumps, NULL, 1 },
     596                 :             :     { OPT_LEVELS_1_PLUS, OPT_ftree_builtin_call_dce, NULL, 1 },
     597                 :             :     { OPT_LEVELS_1_PLUS, OPT_ftree_ccp, NULL, 1 },
     598                 :             :     { OPT_LEVELS_1_PLUS, OPT_ftree_ch, NULL, 1 },
     599                 :             :     { OPT_LEVELS_1_PLUS, OPT_ftree_coalesce_vars, NULL, 1 },
     600                 :             :     { OPT_LEVELS_1_PLUS, OPT_ftree_copy_prop, NULL, 1 },
     601                 :             :     { OPT_LEVELS_1_PLUS, OPT_ftree_dce, NULL, 1 },
     602                 :             :     { OPT_LEVELS_1_PLUS, OPT_ftree_dominator_opts, NULL, 1 },
     603                 :             :     { OPT_LEVELS_1_PLUS, OPT_ftree_fre, NULL, 1 },
     604                 :             :     { OPT_LEVELS_1_PLUS, OPT_ftree_sink, NULL, 1 },
     605                 :             :     { OPT_LEVELS_1_PLUS, OPT_ftree_slsr, NULL, 1 },
     606                 :             :     { OPT_LEVELS_1_PLUS, OPT_ftree_ter, NULL, 1 },
     607                 :             :     { OPT_LEVELS_1_PLUS, OPT_fvar_tracking, NULL, 1 },
     608                 :             : 
     609                 :             :     /* -O1 (and not -Og) optimizations.  */
     610                 :             :     { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fbit_tests, NULL, 1 },
     611                 :             :     { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fbranch_count_reg, NULL, 1 },
     612                 :             : #if DELAY_SLOTS
     613                 :             :     { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fdelayed_branch, NULL, 1 },
     614                 :             : #endif
     615                 :             :     { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fdse, NULL, 1 },
     616                 :             :     { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fif_conversion, NULL, 1 },
     617                 :             :     { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fif_conversion2, NULL, 1 },
     618                 :             :     { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_finline_functions_called_once, NULL, 1 },
     619                 :             :     { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fjump_tables, NULL, 1 },
     620                 :             :     { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fmove_loop_invariants, NULL, 1 },
     621                 :             :     { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fmove_loop_stores, NULL, 1 },
     622                 :             :     { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fssa_phiopt, NULL, 1 },
     623                 :             :     { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fipa_modref, NULL, 1 },
     624                 :             :     { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_ftree_bit_ccp, NULL, 1 },
     625                 :             :     { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_ftree_dse, NULL, 1 },
     626                 :             :     { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_ftree_pta, NULL, 1 },
     627                 :             :     { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_ftree_sra, NULL, 1 },
     628                 :             : 
     629                 :             :     /* -O2 and -Os optimizations.  */
     630                 :             :     { OPT_LEVELS_2_PLUS, OPT_fcaller_saves, NULL, 1 },
     631                 :             :     { OPT_LEVELS_2_PLUS, OPT_fcode_hoisting, NULL, 1 },
     632                 :             :     { OPT_LEVELS_2_PLUS, OPT_fcrossjumping, NULL, 1 },
     633                 :             :     { OPT_LEVELS_2_PLUS, OPT_fcse_follow_jumps, NULL, 1 },
     634                 :             :     { OPT_LEVELS_2_PLUS, OPT_fdevirtualize, NULL, 1 },
     635                 :             :     { OPT_LEVELS_2_PLUS, OPT_fdevirtualize_speculatively, NULL, 1 },
     636                 :             :     { OPT_LEVELS_2_PLUS, OPT_fexpensive_optimizations, NULL, 1 },
     637                 :             :     { OPT_LEVELS_2_PLUS, OPT_fext_dce, NULL, 1 },
     638                 :             :     { OPT_LEVELS_2_PLUS, OPT_fgcse, NULL, 1 },
     639                 :             :     { OPT_LEVELS_2_PLUS, OPT_fhoist_adjacent_loads, NULL, 1 },
     640                 :             :     { OPT_LEVELS_2_PLUS, OPT_findirect_inlining, NULL, 1 },
     641                 :             :     { OPT_LEVELS_2_PLUS, OPT_finline_small_functions, NULL, 1 },
     642                 :             :     { OPT_LEVELS_2_PLUS, OPT_fipa_bit_cp, NULL, 1 },
     643                 :             :     { OPT_LEVELS_2_PLUS, OPT_fipa_cp, NULL, 1 },
     644                 :             :     { OPT_LEVELS_2_PLUS, OPT_fipa_icf, NULL, 1 },
     645                 :             :     { OPT_LEVELS_2_PLUS, OPT_fipa_ra, NULL, 1 },
     646                 :             :     { OPT_LEVELS_2_PLUS, OPT_fipa_sra, NULL, 1 },
     647                 :             :     { OPT_LEVELS_2_PLUS, OPT_fipa_vrp, NULL, 1 },
     648                 :             :     { OPT_LEVELS_2_PLUS, OPT_fisolate_erroneous_paths_dereference, NULL, 1 },
     649                 :             :     { OPT_LEVELS_2_PLUS, OPT_flra_remat, NULL, 1 },
     650                 :             :     { OPT_LEVELS_2_PLUS, OPT_foptimize_sibling_calls, NULL, 1 },
     651                 :             :     { OPT_LEVELS_2_PLUS, OPT_fpartial_inlining, NULL, 1 },
     652                 :             :     { OPT_LEVELS_2_PLUS, OPT_fpeephole2, NULL, 1 },
     653                 :             :     { OPT_LEVELS_2_PLUS, OPT_freorder_functions, NULL, 1 },
     654                 :             :     { OPT_LEVELS_2_PLUS, OPT_frerun_cse_after_loop, NULL, 1 },
     655                 :             : #ifdef INSN_SCHEDULING
     656                 :             :     { OPT_LEVELS_2_PLUS, OPT_fschedule_insns2, NULL, 1 },
     657                 :             : #endif
     658                 :             :     { OPT_LEVELS_2_PLUS, OPT_fstrict_aliasing, NULL, 1 },
     659                 :             :     { OPT_LEVELS_2_PLUS, OPT_fstore_merging, NULL, 1 },
     660                 :             :     { OPT_LEVELS_2_PLUS, OPT_ftree_pre, NULL, 1 },
     661                 :             :     { OPT_LEVELS_2_PLUS, OPT_ftree_switch_conversion, NULL, 1 },
     662                 :             :     { OPT_LEVELS_2_PLUS, OPT_ftree_tail_merge, NULL, 1 },
     663                 :             :     { OPT_LEVELS_2_PLUS, OPT_ftree_vrp, NULL, 1 },
     664                 :             :     { OPT_LEVELS_2_PLUS, OPT_fvect_cost_model_, NULL,
     665                 :             :       VECT_COST_MODEL_VERY_CHEAP },
     666                 :             :     { OPT_LEVELS_2_PLUS, OPT_finline_functions, NULL, 1 },
     667                 :             :     { OPT_LEVELS_2_PLUS, OPT_ftree_loop_distribute_patterns, NULL, 1 },
     668                 :             :     { OPT_LEVELS_2_PLUS, OPT_foptimize_crc, NULL, 1 },
     669                 :             :     { OPT_LEVELS_2_PLUS, OPT_flate_combine_instructions, NULL, 1 },
     670                 :             : 
     671                 :             :     /* -O2 and above optimizations, but not -Os or -Og.  */
     672                 :             :     { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_falign_functions, NULL, 1 },
     673                 :             :     { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_falign_jumps, NULL, 1 },
     674                 :             :     { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_falign_labels, NULL, 1 },
     675                 :             :     { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_falign_loops, NULL, 1 },
     676                 :             :     { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_foptimize_strlen, NULL, 1 },
     677                 :             :     { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_freorder_blocks_algorithm_, NULL,
     678                 :             :       REORDER_BLOCKS_ALGORITHM_STC },
     679                 :             :     { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_ftree_loop_vectorize, NULL, 1 },
     680                 :             :     { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_ftree_slp_vectorize, NULL, 1 },
     681                 :             :     { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_fopenmp_target_simd_clone_, NULL,
     682                 :             :       OMP_TARGET_SIMD_CLONE_NOHOST },
     683                 :             : #ifdef INSN_SCHEDULING
     684                 :             :   /* Only run the pre-regalloc scheduling pass if optimizing for speed.  */
     685                 :             :     { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_fschedule_insns, NULL, 1 },
     686                 :             : #endif
     687                 :             : 
     688                 :             :     /* -O3 and -Os optimizations.  */
     689                 :             : 
     690                 :             :     /* -O3 optimizations.  */
     691                 :             :     { OPT_LEVELS_3_PLUS, OPT_fgcse_after_reload, NULL, 1 },
     692                 :             :     { OPT_LEVELS_3_PLUS, OPT_fipa_cp_clone, NULL, 1 },
     693                 :             :     { OPT_LEVELS_3_PLUS, OPT_floop_interchange, NULL, 1 },
     694                 :             :     { OPT_LEVELS_3_PLUS, OPT_floop_unroll_and_jam, NULL, 1 },
     695                 :             :     { OPT_LEVELS_3_PLUS, OPT_fpeel_loops, NULL, 1 },
     696                 :             :     { OPT_LEVELS_3_PLUS, OPT_fpredictive_commoning, NULL, 1 },
     697                 :             :     { OPT_LEVELS_3_PLUS, OPT_fsplit_loops, NULL, 1 },
     698                 :             :     { OPT_LEVELS_3_PLUS, OPT_fsplit_paths, NULL, 1 },
     699                 :             :     { OPT_LEVELS_3_PLUS, OPT_ftree_loop_distribution, NULL, 1 },
     700                 :             :     { OPT_LEVELS_3_PLUS, OPT_ftree_partial_pre, NULL, 1 },
     701                 :             :     { OPT_LEVELS_3_PLUS, OPT_funswitch_loops, NULL, 1 },
     702                 :             :     { OPT_LEVELS_3_PLUS, OPT_fvect_cost_model_, NULL, VECT_COST_MODEL_DYNAMIC },
     703                 :             :     { OPT_LEVELS_3_PLUS, OPT_fversion_loops_for_strides, NULL, 1 },
     704                 :             : 
     705                 :             :     /* -O3 parameters.  */
     706                 :             :     { OPT_LEVELS_3_PLUS, OPT__param_max_inline_insns_auto_, NULL, 30 },
     707                 :             :     { OPT_LEVELS_3_PLUS, OPT__param_early_inlining_insns_, NULL, 14 },
     708                 :             :     { OPT_LEVELS_3_PLUS, OPT__param_inline_heuristics_hint_percent_, NULL, 600 },
     709                 :             :     { OPT_LEVELS_3_PLUS, OPT__param_inline_min_speedup_, NULL, 15 },
     710                 :             :     { OPT_LEVELS_3_PLUS, OPT__param_max_inline_insns_single_, NULL, 200 },
     711                 :             : 
     712                 :             :     /* -Ofast adds optimizations to -O3.  */
     713                 :             :     { OPT_LEVELS_FAST, OPT_ffast_math, NULL, 1 },
     714                 :             :     { OPT_LEVELS_FAST, OPT_fallow_store_data_races, NULL, 1 },
     715                 :             :     { OPT_LEVELS_FAST, OPT_fsemantic_interposition, NULL, 0 },
     716                 :             : 
     717                 :             :     { OPT_LEVELS_NONE, 0, NULL, 0 }
     718                 :             :   };
     719                 :             : 
     720                 :             : /* Default the options in OPTS and OPTS_SET based on the optimization
     721                 :             :    settings in DECODED_OPTIONS and DECODED_OPTIONS_COUNT.  */
     722                 :             : void
     723                 :      612709 : default_options_optimization (struct gcc_options *opts,
     724                 :             :                               struct gcc_options *opts_set,
     725                 :             :                               struct cl_decoded_option *decoded_options,
     726                 :             :                               unsigned int decoded_options_count,
     727                 :             :                               location_t loc,
     728                 :             :                               unsigned int lang_mask,
     729                 :             :                               const struct cl_option_handlers *handlers,
     730                 :             :                               diagnostic_context *dc)
     731                 :             : {
     732                 :      612709 :   unsigned int i;
     733                 :      612709 :   int opt2;
     734                 :      612709 :   bool openacc_mode = false;
     735                 :             : 
     736                 :             :   /* Scan to see what optimization level has been specified.  That will
     737                 :             :      determine the default value of many flags.  */
     738                 :    10223501 :   for (i = 1; i < decoded_options_count; i++)
     739                 :             :     {
     740                 :     9610792 :       struct cl_decoded_option *opt = &decoded_options[i];
     741                 :     9610792 :       switch (opt->opt_index)
     742                 :             :         {
     743                 :      545003 :         case OPT_O:
     744                 :      545003 :           if (*opt->arg == '\0')
     745                 :             :             {
     746                 :       13926 :               opts->x_optimize = 1;
     747                 :       13926 :               opts->x_optimize_size = 0;
     748                 :       13926 :               opts->x_optimize_fast = 0;
     749                 :       13926 :               opts->x_optimize_debug = 0;
     750                 :             :             }
     751                 :             :           else
     752                 :             :             {
     753                 :      531077 :               const int optimize_val = integral_argument (opt->arg);
     754                 :      531077 :               if (optimize_val == -1)
     755                 :           0 :                 error_at (loc, "argument to %<-O%> should be a non-negative "
     756                 :             :                                "integer, %<g%>, %<s%>, %<z%> or %<fast%>");
     757                 :             :               else
     758                 :             :                 {
     759                 :      531077 :                   opts->x_optimize = optimize_val;
     760                 :      531077 :                   if ((unsigned int) opts->x_optimize > 255)
     761                 :           3 :                     opts->x_optimize = 255;
     762                 :      531077 :                   opts->x_optimize_size = 0;
     763                 :      531077 :                   opts->x_optimize_fast = 0;
     764                 :      531077 :                   opts->x_optimize_debug = 0;
     765                 :             :                 }
     766                 :             :             }
     767                 :             :           break;
     768                 :             : 
     769                 :       15141 :         case OPT_Os:
     770                 :       15141 :           opts->x_optimize_size = 1;
     771                 :             : 
     772                 :             :           /* Optimizing for size forces optimize to be 2.  */
     773                 :       15141 :           opts->x_optimize = 2;
     774                 :       15141 :           opts->x_optimize_fast = 0;
     775                 :       15141 :           opts->x_optimize_debug = 0;
     776                 :       15141 :           break;
     777                 :             : 
     778                 :          14 :         case OPT_Oz:
     779                 :          14 :           opts->x_optimize_size = 2;
     780                 :             : 
     781                 :             :           /* Optimizing for size forces optimize to be 2.  */
     782                 :          14 :           opts->x_optimize = 2;
     783                 :          14 :           opts->x_optimize_fast = 0;
     784                 :          14 :           opts->x_optimize_debug = 0;
     785                 :          14 :           break;
     786                 :             : 
     787                 :         698 :         case OPT_Ofast:
     788                 :             :           /* -Ofast only adds flags to -O3.  */
     789                 :         698 :           opts->x_optimize_size = 0;
     790                 :         698 :           opts->x_optimize = 3;
     791                 :         698 :           opts->x_optimize_fast = 1;
     792                 :         698 :           opts->x_optimize_debug = 0;
     793                 :         698 :           break;
     794                 :             : 
     795                 :         779 :         case OPT_Og:
     796                 :             :           /* -Og selects optimization level 1.  */
     797                 :         779 :           opts->x_optimize_size = 0;
     798                 :         779 :           opts->x_optimize = 1;
     799                 :         779 :           opts->x_optimize_fast = 0;
     800                 :         779 :           opts->x_optimize_debug = 1;
     801                 :         779 :           break;
     802                 :             : 
     803                 :       25032 :         case OPT_fopenacc:
     804                 :       25032 :           if (opt->value)
     805                 :     9610792 :             openacc_mode = true;
     806                 :             :           break;
     807                 :             : 
     808                 :             :         default:
     809                 :             :           /* Ignore other options in this prescan.  */
     810                 :             :           break;
     811                 :             :         }
     812                 :             :     }
     813                 :             : 
     814                 :      612709 :   maybe_default_options (opts, opts_set, default_options_table,
     815                 :      612709 :                          opts->x_optimize, opts->x_optimize_size,
     816                 :      612709 :                          opts->x_optimize_fast, opts->x_optimize_debug,
     817                 :             :                          lang_mask, handlers, loc, dc);
     818                 :             : 
     819                 :             :   /* -O2 param settings.  */
     820                 :      612709 :   opt2 = (opts->x_optimize >= 2);
     821                 :             : 
     822                 :      612709 :   if (openacc_mode)
     823                 :        3324 :     SET_OPTION_IF_UNSET (opts, opts_set, flag_ipa_pta, true);
     824                 :             : 
     825                 :             :   /* Track fields in field-sensitive alias analysis.  */
     826                 :      612709 :   if (opt2)
     827                 :      470464 :     SET_OPTION_IF_UNSET (opts, opts_set, param_max_fields_for_field_sensitive,
     828                 :             :                          100);
     829                 :             : 
     830                 :      612709 :   if (opts->x_optimize_size)
     831                 :             :     /* We want to crossjump as much as possible.  */
     832                 :       15009 :     SET_OPTION_IF_UNSET (opts, opts_set, param_min_crossjump_insns, 1);
     833                 :             : 
     834                 :             :   /* Restrict the amount of work combine does at -Og while retaining
     835                 :             :      most of its useful transforms.  */
     836                 :      612709 :   if (opts->x_optimize_debug)
     837                 :         755 :     SET_OPTION_IF_UNSET (opts, opts_set, param_max_combine_insns, 2);
     838                 :             : 
     839                 :             :   /* Allow default optimizations to be specified on a per-machine basis.  */
     840                 :      612709 :   maybe_default_options (opts, opts_set,
     841                 :             :                          targetm_common.option_optimization_table,
     842                 :             :                          opts->x_optimize, opts->x_optimize_size,
     843                 :      612709 :                          opts->x_optimize_fast, opts->x_optimize_debug,
     844                 :             :                          lang_mask, handlers, loc, dc);
     845                 :      612709 : }
     846                 :             : 
     847                 :             : /* Control IPA optimizations based on different live patching LEVEL.  */
     848                 :             : static void
     849                 :          20 : control_options_for_live_patching (struct gcc_options *opts,
     850                 :             :                                    struct gcc_options *opts_set,
     851                 :             :                                    enum live_patching_level level,
     852                 :             :                                    location_t loc)
     853                 :             : {
     854                 :          20 :   gcc_assert (level > LIVE_PATCHING_NONE);
     855                 :             : 
     856                 :          20 :   switch (level)
     857                 :             :     {
     858                 :           3 :     case LIVE_PATCHING_INLINE_ONLY_STATIC:
     859                 :             : #define LIVE_PATCHING_OPTION "-flive-patching=inline-only-static"
     860                 :           3 :       if (opts_set->x_flag_ipa_cp_clone && opts->x_flag_ipa_cp_clone)
     861                 :           0 :         error_at (loc, "%qs is incompatible with %qs",
     862                 :             :                   "-fipa-cp-clone", LIVE_PATCHING_OPTION);
     863                 :             :       else
     864                 :           3 :         opts->x_flag_ipa_cp_clone = 0;
     865                 :             : 
     866                 :           3 :       if (opts_set->x_flag_ipa_sra && opts->x_flag_ipa_sra)
     867                 :           0 :         error_at (loc, "%qs is incompatible with %qs",
     868                 :             :                   "-fipa-sra", LIVE_PATCHING_OPTION);
     869                 :             :       else
     870                 :           3 :         opts->x_flag_ipa_sra = 0;
     871                 :             : 
     872                 :           3 :       if (opts_set->x_flag_partial_inlining && opts->x_flag_partial_inlining)
     873                 :           0 :         error_at (loc, "%qs is incompatible with %qs",
     874                 :             :                   "-fpartial-inlining", LIVE_PATCHING_OPTION);
     875                 :             :       else
     876                 :           3 :         opts->x_flag_partial_inlining = 0;
     877                 :             : 
     878                 :           3 :       if (opts_set->x_flag_ipa_cp && opts->x_flag_ipa_cp)
     879                 :           0 :         error_at (loc, "%qs is incompatible with %qs",
     880                 :             :                   "-fipa-cp", LIVE_PATCHING_OPTION);
     881                 :             :       else
     882                 :           3 :         opts->x_flag_ipa_cp = 0;
     883                 :             : 
     884                 :             :       /* FALLTHROUGH.  */
     885                 :          20 :     case LIVE_PATCHING_INLINE_CLONE:
     886                 :             : #undef LIVE_PATCHING_OPTION
     887                 :             : #define LIVE_PATCHING_OPTION "-flive-patching=inline-only-static|inline-clone"
     888                 :             :       /* live patching should disable whole-program optimization.  */
     889                 :          20 :       if (opts_set->x_flag_whole_program && opts->x_flag_whole_program)
     890                 :           1 :         error_at (loc, "%qs is incompatible with %qs",
     891                 :             :                   "-fwhole-program", LIVE_PATCHING_OPTION);
     892                 :             :       else
     893                 :          19 :         opts->x_flag_whole_program = 0;
     894                 :             : 
     895                 :             :       /* visibility change should be excluded by !flag_whole_program
     896                 :             :          && !in_lto_p && !flag_ipa_cp_clone && !flag_ipa_sra
     897                 :             :          && !flag_partial_inlining.  */
     898                 :             : 
     899                 :          20 :       if (opts_set->x_flag_ipa_pta && opts->x_flag_ipa_pta)
     900                 :           0 :         error_at (loc, "%qs is incompatible with %qs",
     901                 :             :                   "-fipa-pta", LIVE_PATCHING_OPTION);
     902                 :             :       else
     903                 :          20 :         opts->x_flag_ipa_pta = 0;
     904                 :             : 
     905                 :          20 :       if (opts_set->x_flag_ipa_reference && opts->x_flag_ipa_reference)
     906                 :           0 :         error_at (loc, "%qs is incompatible with %qs",
     907                 :             :                   "-fipa-reference", LIVE_PATCHING_OPTION);
     908                 :             :       else
     909                 :          20 :         opts->x_flag_ipa_reference = 0;
     910                 :             : 
     911                 :          20 :       if (opts_set->x_flag_ipa_ra && opts->x_flag_ipa_ra)
     912                 :           0 :         error_at (loc, "%qs is incompatible with %qs",
     913                 :             :                   "-fipa-ra", LIVE_PATCHING_OPTION);
     914                 :             :       else
     915                 :          20 :         opts->x_flag_ipa_ra = 0;
     916                 :             : 
     917                 :          20 :       if (opts_set->x_flag_ipa_icf && opts->x_flag_ipa_icf)
     918                 :           0 :         error_at (loc, "%qs is incompatible with %qs",
     919                 :             :                   "-fipa-icf", LIVE_PATCHING_OPTION);
     920                 :             :       else
     921                 :          20 :         opts->x_flag_ipa_icf = 0;
     922                 :             : 
     923                 :          20 :       if (opts_set->x_flag_ipa_icf_functions && opts->x_flag_ipa_icf_functions)
     924                 :           0 :         error_at (loc, "%qs is incompatible with %qs",
     925                 :             :                   "-fipa-icf-functions", LIVE_PATCHING_OPTION);
     926                 :             :       else
     927                 :          20 :         opts->x_flag_ipa_icf_functions = 0;
     928                 :             : 
     929                 :          20 :       if (opts_set->x_flag_ipa_icf_variables && opts->x_flag_ipa_icf_variables)
     930                 :           0 :         error_at (loc, "%qs is incompatible with %qs",
     931                 :             :                   "-fipa-icf-variables", LIVE_PATCHING_OPTION);
     932                 :             :       else
     933                 :          20 :         opts->x_flag_ipa_icf_variables = 0;
     934                 :             : 
     935                 :          20 :       if (opts_set->x_flag_ipa_bit_cp && opts->x_flag_ipa_bit_cp)
     936                 :           0 :         error_at (loc, "%qs is incompatible with %qs",
     937                 :             :                   "-fipa-bit-cp", LIVE_PATCHING_OPTION);
     938                 :             :       else
     939                 :          20 :         opts->x_flag_ipa_bit_cp = 0;
     940                 :             : 
     941                 :          20 :       if (opts_set->x_flag_ipa_vrp && opts->x_flag_ipa_vrp)
     942                 :           0 :         error_at (loc, "%qs is incompatible with %qs",
     943                 :             :                   "-fipa-vrp", LIVE_PATCHING_OPTION);
     944                 :             :       else
     945                 :          20 :         opts->x_flag_ipa_vrp = 0;
     946                 :             : 
     947                 :          20 :       if (opts_set->x_flag_ipa_pure_const && opts->x_flag_ipa_pure_const)
     948                 :           0 :         error_at (loc, "%qs is incompatible with %qs",
     949                 :             :                   "-fipa-pure-const", LIVE_PATCHING_OPTION);
     950                 :             :       else
     951                 :          20 :         opts->x_flag_ipa_pure_const = 0;
     952                 :             : 
     953                 :          20 :       if (opts_set->x_flag_ipa_modref && opts->x_flag_ipa_modref)
     954                 :           0 :         error_at (loc,
     955                 :             :                   "%<-fipa-modref%> is incompatible with %qs",
     956                 :             :                   LIVE_PATCHING_OPTION);
     957                 :             :       else
     958                 :          20 :         opts->x_flag_ipa_modref = 0;
     959                 :             : 
     960                 :             :       /* FIXME: disable unreachable code removal.  */
     961                 :             : 
     962                 :             :       /* discovery of functions/variables with no address taken.  */
     963                 :          20 :       if (opts_set->x_flag_ipa_reference_addressable
     964                 :           0 :           && opts->x_flag_ipa_reference_addressable)
     965                 :           0 :         error_at (loc, "%qs is incompatible with %qs",
     966                 :             :                   "-fipa-reference-addressable", LIVE_PATCHING_OPTION);
     967                 :             :       else
     968                 :          20 :         opts->x_flag_ipa_reference_addressable = 0;
     969                 :             : 
     970                 :             :       /* ipa stack alignment propagation.  */
     971                 :          20 :       if (opts_set->x_flag_ipa_stack_alignment
     972                 :           0 :           && opts->x_flag_ipa_stack_alignment)
     973                 :           0 :         error_at (loc, "%qs is incompatible with %qs",
     974                 :             :                   "-fipa-stack-alignment", LIVE_PATCHING_OPTION);
     975                 :             :       else
     976                 :          20 :         opts->x_flag_ipa_stack_alignment = 0;
     977                 :          20 :       break;
     978                 :           0 :     default:
     979                 :           0 :       gcc_unreachable ();
     980                 :             :     }
     981                 :             : 
     982                 :             : #undef LIVE_PATCHING_OPTION
     983                 :          20 : }
     984                 :             : 
     985                 :             : /* --help option argument if set.  */
     986                 :             : vec<const char *> help_option_arguments;
     987                 :             : 
     988                 :             : /* Return the string name describing a sanitizer argument which has been
     989                 :             :    provided on the command line and has set this particular flag.  */
     990                 :             : const char *
     991                 :         208 : find_sanitizer_argument (struct gcc_options *opts, unsigned int flags)
     992                 :             : {
     993                 :         706 :   for (int i = 0; sanitizer_opts[i].name != NULL; ++i)
     994                 :             :     {
     995                 :             :       /* Need to find the sanitizer_opts element which:
     996                 :             :          a) Could have set the flags requested.
     997                 :             :          b) Has been set on the command line.
     998                 :             : 
     999                 :             :          Can have (a) without (b) if the flag requested is e.g.
    1000                 :             :          SANITIZE_ADDRESS, since both -fsanitize=address and
    1001                 :             :          -fsanitize=kernel-address set this flag.
    1002                 :             : 
    1003                 :             :          Can have (b) without (a) by requesting more than one sanitizer on the
    1004                 :             :          command line.  */
    1005                 :         706 :       if ((sanitizer_opts[i].flag & opts->x_flag_sanitize)
    1006                 :             :           != sanitizer_opts[i].flag)
    1007                 :         352 :         continue;
    1008                 :         354 :       if ((sanitizer_opts[i].flag & flags) != flags)
    1009                 :         146 :         continue;
    1010                 :             :       return sanitizer_opts[i].name;
    1011                 :             :     }
    1012                 :             :   return NULL;
    1013                 :             : }
    1014                 :             : 
    1015                 :             : 
    1016                 :             : /* Report an error to the user about sanitizer options they have requested
    1017                 :             :    which have set conflicting flags.
    1018                 :             : 
    1019                 :             :    LEFT and RIGHT indicate sanitizer flags which conflict with each other, this
    1020                 :             :    function reports an error if both have been set in OPTS->x_flag_sanitize and
    1021                 :             :    ensures the error identifies the requested command line options that have
    1022                 :             :    set these flags.  */
    1023                 :             : static void
    1024                 :     3676254 : report_conflicting_sanitizer_options (struct gcc_options *opts, location_t loc,
    1025                 :             :                                       unsigned int left, unsigned int right)
    1026                 :             : {
    1027                 :     3676254 :   unsigned int left_seen = (opts->x_flag_sanitize & left);
    1028                 :     3676254 :   unsigned int right_seen = (opts->x_flag_sanitize & right);
    1029                 :     3676254 :   if (left_seen && right_seen)
    1030                 :             :     {
    1031                 :         104 :       const char* left_arg = find_sanitizer_argument (opts, left_seen);
    1032                 :         104 :       const char* right_arg = find_sanitizer_argument (opts, right_seen);
    1033                 :         104 :       gcc_assert (left_arg && right_arg);
    1034                 :         104 :       error_at (loc,
    1035                 :             :                 "%<-fsanitize=%s%> is incompatible with %<-fsanitize=%s%>",
    1036                 :             :                 left_arg, right_arg);
    1037                 :             :     }
    1038                 :     3676254 : }
    1039                 :             : 
    1040                 :             : /* Validate from OPTS and OPTS_SET that when -fipa-reorder-for-locality is
    1041                 :             :    enabled no explicit -flto-partition is also passed as the locality cloning
    1042                 :             :    pass uses its own partitioning scheme.  */
    1043                 :             : 
    1044                 :             : static void
    1045                 :      612709 : validate_ipa_reorder_locality_lto_partition (struct gcc_options *opts,
    1046                 :             :                                              struct gcc_options *opts_set)
    1047                 :             : {
    1048                 :      612709 :   static bool validated_p = false;
    1049                 :             : 
    1050                 :      612709 :   if (opts_set->x_flag_lto_partition)
    1051                 :             :     {
    1052                 :       14825 :       if (opts->x_flag_ipa_reorder_for_locality && !validated_p)
    1053                 :           0 :         error ("%<-fipa-reorder-for-locality%> is incompatible with"
    1054                 :             :                " an explicit %qs option", "-flto-partition");
    1055                 :             :     }
    1056                 :      612709 :   validated_p = true;
    1057                 :      612709 : }
    1058                 :             : 
    1059                 :             : /* After all options at LOC have been read into OPTS and OPTS_SET,
    1060                 :             :    finalize settings of those options and diagnose incompatible
    1061                 :             :    combinations.  */
    1062                 :             : void
    1063                 :      612709 : finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
    1064                 :             :                 location_t loc)
    1065                 :             : {
    1066                 :      612709 :   if (opts->x_dump_base_name
    1067                 :      610016 :       && ! opts->x_dump_base_name_prefixed)
    1068                 :             :     {
    1069                 :             :       const char *sep = opts->x_dump_base_name;
    1070                 :             : 
    1071                 :     3789769 :       for (; *sep; sep++)
    1072                 :     3529090 :         if (IS_DIR_SEPARATOR (*sep))
    1073                 :             :           break;
    1074                 :             : 
    1075                 :      282388 :       if (*sep)
    1076                 :             :         /* If dump_base_path contains subdirectories, don't prepend
    1077                 :             :            anything.  */;
    1078                 :      260679 :       else if (opts->x_dump_dir_name)
    1079                 :             :         /* We have a DUMP_DIR_NAME, prepend that.  */
    1080                 :      103899 :         opts->x_dump_base_name = opts_concat (opts->x_dump_dir_name,
    1081                 :             :                                               opts->x_dump_base_name, NULL);
    1082                 :             : 
    1083                 :             :       /* It is definitely prefixed now.  */
    1084                 :      282388 :       opts->x_dump_base_name_prefixed = true;
    1085                 :             :     }
    1086                 :             : 
    1087                 :             :   /* Handle related options for unit-at-a-time, toplevel-reorder, and
    1088                 :             :      section-anchors.  */
    1089                 :      612709 :   if (!opts->x_flag_unit_at_a_time)
    1090                 :             :     {
    1091                 :           4 :       if (opts->x_flag_section_anchors && opts_set->x_flag_section_anchors)
    1092                 :           0 :         error_at (loc, "section anchors must be disabled when unit-at-a-time "
    1093                 :             :                   "is disabled");
    1094                 :           4 :       opts->x_flag_section_anchors = 0;
    1095                 :           4 :       if (opts->x_flag_toplevel_reorder == 1)
    1096                 :           0 :         error_at (loc, "toplevel reorder must be disabled when unit-at-a-time "
    1097                 :             :                   "is disabled");
    1098                 :           4 :       opts->x_flag_toplevel_reorder = 0;
    1099                 :             :     }
    1100                 :             : 
    1101                 :             :   /* -fself-test depends on the state of the compiler prior to
    1102                 :             :      compiling anything.  Ideally it should be run on an empty source
    1103                 :             :      file.  However, in case we get run with actual source, assume
    1104                 :             :      -fsyntax-only which will inhibit any compiler initialization
    1105                 :             :      which may confuse the self tests.  */
    1106                 :      612709 :   if (opts->x_flag_self_test)
    1107                 :           5 :     opts->x_flag_syntax_only = 1;
    1108                 :             : 
    1109                 :      612709 :   if (opts->x_flag_tm && opts->x_flag_non_call_exceptions)
    1110                 :           3 :     sorry ("transactional memory is not supported with non-call exceptions");
    1111                 :             : 
    1112                 :             :   /* Unless the user has asked for section anchors, we disable toplevel
    1113                 :             :      reordering at -O0 to disable transformations that might be surprising
    1114                 :             :      to end users and to get -fno-toplevel-reorder tested.  */
    1115                 :      612709 :   if (!opts->x_optimize
    1116                 :      114255 :       && opts->x_flag_toplevel_reorder == 2
    1117                 :      114035 :       && !(opts->x_flag_section_anchors && opts_set->x_flag_section_anchors))
    1118                 :             :     {
    1119                 :      114035 :       opts->x_flag_toplevel_reorder = 0;
    1120                 :      114035 :       opts->x_flag_section_anchors = 0;
    1121                 :             :     }
    1122                 :      612709 :   if (!opts->x_flag_toplevel_reorder)
    1123                 :             :     {
    1124                 :      133750 :       if (opts->x_flag_section_anchors && opts_set->x_flag_section_anchors)
    1125                 :           0 :         error_at (loc, "section anchors must be disabled when toplevel reorder"
    1126                 :             :                   " is disabled");
    1127                 :      133750 :       opts->x_flag_section_anchors = 0;
    1128                 :             :     }
    1129                 :             : 
    1130                 :      612709 :   if (opts->x_flag_hardened)
    1131                 :             :     {
    1132                 :          91 :       if (!opts_set->x_flag_auto_var_init)
    1133                 :          87 :         opts->x_flag_auto_var_init = AUTO_INIT_ZERO;
    1134                 :           4 :       else if (opts->x_flag_auto_var_init != AUTO_INIT_ZERO)
    1135                 :           4 :         warning_at (loc, OPT_Whardened,
    1136                 :             :                     "%<-ftrivial-auto-var-init=zero%> is not enabled by "
    1137                 :             :                     "%<-fhardened%> because it was specified on the command "
    1138                 :             :                     "line");
    1139                 :             :     }
    1140                 :             : 
    1141                 :      612709 :   if (!opts->x_flag_opts_finished)
    1142                 :             :     {
    1143                 :             :       /* We initialize opts->x_flag_pie to -1 so that targets can set a
    1144                 :             :          default value.  */
    1145                 :      285081 :       if (opts->x_flag_pie == -1)
    1146                 :             :         {
    1147                 :             :           /* We initialize opts->x_flag_pic to -1 so that we can tell if
    1148                 :             :              -fpic, -fPIC, -fno-pic or -fno-PIC is used.  */
    1149                 :      263381 :           if (opts->x_flag_pic == -1)
    1150                 :      254346 :             opts->x_flag_pie = (opts->x_flag_hardened
    1151                 :      254346 :                                 ? /*-fPIE*/ 2 : DEFAULT_FLAG_PIE);
    1152                 :             :           else
    1153                 :        9035 :             opts->x_flag_pie = 0;
    1154                 :             :         }
    1155                 :             :       /* If -fPIE or -fpie is used, turn on PIC.  */
    1156                 :      285081 :       if (opts->x_flag_pie)
    1157                 :         261 :         opts->x_flag_pic = opts->x_flag_pie;
    1158                 :      284820 :       else if (opts->x_flag_pic == -1)
    1159                 :      275785 :         opts->x_flag_pic = 0;
    1160                 :      285081 :       if (opts->x_flag_pic && !opts->x_flag_pie)
    1161                 :        8897 :         opts->x_flag_shlib = 1;
    1162                 :      285081 :       opts->x_flag_opts_finished = true;
    1163                 :             :     }
    1164                 :             : 
    1165                 :             :   /* We initialize opts->x_flag_stack_protect to -1 so that targets
    1166                 :             :      can set a default value.  With --enable-default-ssp or -fhardened
    1167                 :             :      the default is -fstack-protector-strong.  */
    1168                 :      612709 :   if (opts->x_flag_stack_protect == -1)
    1169                 :             :     {
    1170                 :             :       /* This should check FRAME_GROWS_DOWNWARD, but on some targets it's
    1171                 :             :          defined in such a way that it uses flag_stack_protect which can't
    1172                 :             :          be used here.  Moreover, some targets like BPF don't support
    1173                 :             :          -fstack-protector at all but we don't know that here.  So remember
    1174                 :             :          that flag_stack_protect was set at the behest of -fhardened.  */
    1175                 :      283804 :       if (opts->x_flag_hardened)
    1176                 :             :         {
    1177                 :          87 :           opts->x_flag_stack_protect = SPCT_FLAG_STRONG;
    1178                 :          87 :           flag_stack_protector_set_by_fhardened_p = true;
    1179                 :             :         }
    1180                 :             :       else
    1181                 :      283717 :         opts->x_flag_stack_protect = DEFAULT_FLAG_SSP;
    1182                 :             :     }
    1183                 :      328905 :   else if (opts->x_flag_hardened
    1184                 :           4 :            && opts->x_flag_stack_protect != SPCT_FLAG_STRONG)
    1185                 :           4 :     warning_at (UNKNOWN_LOCATION, OPT_Whardened,
    1186                 :             :                 "%<-fstack-protector-strong%> is not enabled by "
    1187                 :             :                 "%<-fhardened%> because it was specified on the command "
    1188                 :             :                 "line");
    1189                 :             : 
    1190                 :      612709 :   if (opts->x_optimize == 0)
    1191                 :             :     {
    1192                 :             :       /* Inlining does not work if not optimizing,
    1193                 :             :          so force it not to be done.  */
    1194                 :      114255 :       opts->x_warn_inline = 0;
    1195                 :      114255 :       opts->x_flag_no_inline = 1;
    1196                 :             :     }
    1197                 :             : 
    1198                 :             :   /* At -O0 or -Og, turn __builtin_unreachable into a trap.  */
    1199                 :      612709 :   if (!opts->x_optimize || opts->x_optimize_debug)
    1200                 :      115010 :     SET_OPTION_IF_UNSET (opts, opts_set, flag_unreachable_traps, true);
    1201                 :             : 
    1202                 :             :   /* Pipelining of outer loops is only possible when general pipelining
    1203                 :             :      capabilities are requested.  */
    1204                 :      612709 :   if (!opts->x_flag_sel_sched_pipelining)
    1205                 :      612657 :     opts->x_flag_sel_sched_pipelining_outer_loops = 0;
    1206                 :             : 
    1207                 :      612709 :   if (opts->x_flag_conserve_stack)
    1208                 :             :     {
    1209                 :          30 :       SET_OPTION_IF_UNSET (opts, opts_set, param_large_stack_frame, 100);
    1210                 :          30 :       SET_OPTION_IF_UNSET (opts, opts_set, param_stack_frame_growth, 40);
    1211                 :             :     }
    1212                 :             : 
    1213                 :      612709 :   if (opts->x_flag_lto)
    1214                 :             :     {
    1215                 :             : #ifdef ENABLE_LTO
    1216                 :      175734 :       opts->x_flag_generate_lto = 1;
    1217                 :             : 
    1218                 :             :       /* When generating IL, do not operate in whole-program mode.
    1219                 :             :          Otherwise, symbols will be privatized too early, causing link
    1220                 :             :          errors later.  */
    1221                 :      175734 :       opts->x_flag_whole_program = 0;
    1222                 :             : #else
    1223                 :             :       error_at (loc, "LTO support has not been enabled in this configuration");
    1224                 :             : #endif
    1225                 :      175734 :       if (!opts->x_flag_fat_lto_objects
    1226                 :       21945 :           && (!HAVE_LTO_PLUGIN
    1227                 :       21945 :               || (opts_set->x_flag_use_linker_plugin
    1228                 :       20014 :                   && !opts->x_flag_use_linker_plugin)))
    1229                 :             :         {
    1230                 :        8528 :           if (opts_set->x_flag_fat_lto_objects)
    1231                 :           0 :             error_at (loc, "%<-fno-fat-lto-objects%> are supported only with "
    1232                 :             :                       "linker plugin");
    1233                 :        8528 :           opts->x_flag_fat_lto_objects = 1;
    1234                 :             :         }
    1235                 :             : 
    1236                 :             :       /* -gsplit-dwarf isn't compatible with LTO, see PR88389.  */
    1237                 :      175734 :       if (opts->x_dwarf_split_debug_info)
    1238                 :             :         {
    1239                 :           1 :           inform (loc, "%<-gsplit-dwarf%> is not supported with LTO,"
    1240                 :             :                   " disabling");
    1241                 :           1 :           opts->x_dwarf_split_debug_info = 0;
    1242                 :             :         }
    1243                 :             :     }
    1244                 :             : 
    1245                 :             :   /* We initialize opts->x_flag_split_stack to -1 so that targets can set a
    1246                 :             :      default value if they choose based on other options.  */
    1247                 :      612709 :   if (opts->x_flag_split_stack == -1)
    1248                 :      283391 :     opts->x_flag_split_stack = 0;
    1249                 :      329318 :   else if (opts->x_flag_split_stack)
    1250                 :             :     {
    1251                 :        1718 :       if (!targetm_common.supports_split_stack (true, opts))
    1252                 :             :         {
    1253                 :           0 :           error_at (loc, "%<-fsplit-stack%> is not supported by "
    1254                 :             :                     "this compiler configuration");
    1255                 :           0 :           opts->x_flag_split_stack = 0;
    1256                 :             :         }
    1257                 :             :     }
    1258                 :             : 
    1259                 :             :   /* If stack splitting is turned on, and the user did not explicitly
    1260                 :             :      request function partitioning, turn off partitioning, as it
    1261                 :             :      confuses the linker when trying to handle partitioned split-stack
    1262                 :             :      code that calls a non-split-stack functions.  But if partitioning
    1263                 :             :      was turned on explicitly just hope for the best.  */
    1264                 :      612709 :   if (opts->x_flag_split_stack
    1265                 :        1718 :       && opts->x_flag_reorder_blocks_and_partition)
    1266                 :        1280 :     SET_OPTION_IF_UNSET (opts, opts_set, flag_reorder_blocks_and_partition, 0);
    1267                 :             : 
    1268                 :      612709 :   if (opts->x_flag_reorder_blocks_and_partition)
    1269                 :      469227 :     SET_OPTION_IF_UNSET (opts, opts_set, flag_reorder_functions, 1);
    1270                 :             : 
    1271                 :      612709 :   validate_ipa_reorder_locality_lto_partition (opts, opts_set);
    1272                 :             : 
    1273                 :             :   /* The -gsplit-dwarf option requires -ggnu-pubnames.  */
    1274                 :      612709 :   if (opts->x_dwarf_split_debug_info)
    1275                 :         308 :     opts->x_debug_generate_pub_sections = 2;
    1276                 :             : 
    1277                 :      612709 :   if ((opts->x_flag_sanitize
    1278                 :      612709 :        & (SANITIZE_USER_ADDRESS | SANITIZE_KERNEL_ADDRESS)) == 0)
    1279                 :             :     {
    1280                 :      609698 :       if (opts->x_flag_sanitize & SANITIZE_POINTER_COMPARE)
    1281                 :           0 :         error_at (loc,
    1282                 :             :                   "%<-fsanitize=pointer-compare%> must be combined with "
    1283                 :             :                   "%<-fsanitize=address%> or %<-fsanitize=kernel-address%>");
    1284                 :      609698 :       if (opts->x_flag_sanitize & SANITIZE_POINTER_SUBTRACT)
    1285                 :           0 :         error_at (loc,
    1286                 :             :                   "%<-fsanitize=pointer-subtract%> must be combined with "
    1287                 :             :                   "%<-fsanitize=address%> or %<-fsanitize=kernel-address%>");
    1288                 :             :     }
    1289                 :             : 
    1290                 :             :   /* Address sanitizers conflict with the thread sanitizer.  */
    1291                 :      612709 :   report_conflicting_sanitizer_options (opts, loc, SANITIZE_THREAD,
    1292                 :             :                                         SANITIZE_ADDRESS);
    1293                 :      612709 :   report_conflicting_sanitizer_options (opts, loc, SANITIZE_THREAD,
    1294                 :             :                                         SANITIZE_HWADDRESS);
    1295                 :             :   /* The leak sanitizer conflicts with the thread sanitizer.  */
    1296                 :      612709 :   report_conflicting_sanitizer_options (opts, loc, SANITIZE_LEAK,
    1297                 :             :                                         SANITIZE_THREAD);
    1298                 :             : 
    1299                 :             :   /* No combination of HWASAN and ASAN work together.  */
    1300                 :      612709 :   report_conflicting_sanitizer_options (opts, loc,
    1301                 :             :                                         SANITIZE_HWADDRESS, SANITIZE_ADDRESS);
    1302                 :             : 
    1303                 :             :   /* The userspace and kernel address sanitizers conflict with each other.  */
    1304                 :      612709 :   report_conflicting_sanitizer_options (opts, loc, SANITIZE_USER_HWADDRESS,
    1305                 :             :                                         SANITIZE_KERNEL_HWADDRESS);
    1306                 :      612709 :   report_conflicting_sanitizer_options (opts, loc, SANITIZE_USER_ADDRESS,
    1307                 :             :                                         SANITIZE_KERNEL_ADDRESS);
    1308                 :             : 
    1309                 :             :   /* Check error recovery for -fsanitize-recover option.  */
    1310                 :    20832106 :   for (int i = 0; sanitizer_opts[i].name != NULL; ++i)
    1311                 :    20219397 :     if ((opts->x_flag_sanitize_recover & sanitizer_opts[i].flag)
    1312                 :    14700992 :         && !sanitizer_opts[i].can_recover)
    1313                 :          40 :       error_at (loc, "%<-fsanitize-recover=%s%> is not supported",
    1314                 :             :                 sanitizer_opts[i].name);
    1315                 :             : 
    1316                 :             :   /* Check -fsanitize-trap option.  */
    1317                 :    20832106 :   for (int i = 0; sanitizer_opts[i].name != NULL; ++i)
    1318                 :    20219397 :     if ((opts->x_flag_sanitize_trap & sanitizer_opts[i].flag)
    1319                 :        4357 :         && !sanitizer_opts[i].can_trap
    1320                 :             :         /* Allow -fsanitize-trap=all or -fsanitize-trap=undefined
    1321                 :             :            to set flag_sanitize_trap & SANITIZE_VPTR bit which will
    1322                 :             :            effectively disable -fsanitize=vptr, just disallow
    1323                 :             :            explicit -fsanitize-trap=vptr.  */
    1324                 :         183 :         && sanitizer_opts[i].flag != SANITIZE_VPTR)
    1325                 :           0 :       error_at (loc, "%<-fsanitize-trap=%s%> is not supported",
    1326                 :             :                 sanitizer_opts[i].name);
    1327                 :             : 
    1328                 :             :   /* When instrumenting the pointers, we don't want to remove
    1329                 :             :      the null pointer checks.  */
    1330                 :      612709 :   if (opts->x_flag_sanitize & (SANITIZE_NULL | SANITIZE_NONNULL_ATTRIBUTE
    1331                 :             :                                 | SANITIZE_RETURNS_NONNULL_ATTRIBUTE))
    1332                 :        1642 :     opts->x_flag_delete_null_pointer_checks = 0;
    1333                 :             : 
    1334                 :             :   /* Aggressive compiler optimizations may cause false negatives.  */
    1335                 :      612709 :   if (opts->x_flag_sanitize & ~(SANITIZE_LEAK | SANITIZE_UNREACHABLE))
    1336                 :        7456 :     opts->x_flag_aggressive_loop_optimizations = 0;
    1337                 :             : 
    1338                 :             :   /* Enable -fsanitize-address-use-after-scope if either address sanitizer is
    1339                 :             :      enabled.  */
    1340                 :      612709 :   if (opts->x_flag_sanitize
    1341                 :      612709 :       & (SANITIZE_USER_ADDRESS | SANITIZE_USER_HWADDRESS))
    1342                 :        3379 :     SET_OPTION_IF_UNSET (opts, opts_set, flag_sanitize_address_use_after_scope,
    1343                 :             :                          true);
    1344                 :             : 
    1345                 :             :   /* Force -fstack-reuse=none in case -fsanitize-address-use-after-scope
    1346                 :             :      is enabled.  */
    1347                 :      612709 :   if (opts->x_flag_sanitize_address_use_after_scope)
    1348                 :             :     {
    1349                 :        3345 :       if (opts->x_flag_stack_reuse != SR_NONE
    1350                 :        3337 :           && opts_set->x_flag_stack_reuse != SR_NONE)
    1351                 :           0 :         error_at (loc,
    1352                 :             :                   "%<-fsanitize-address-use-after-scope%> requires "
    1353                 :             :                   "%<-fstack-reuse=none%> option");
    1354                 :             : 
    1355                 :        3345 :       opts->x_flag_stack_reuse = SR_NONE;
    1356                 :             :     }
    1357                 :             : 
    1358                 :      612709 :   if ((opts->x_flag_sanitize & SANITIZE_USER_ADDRESS) && opts->x_flag_tm)
    1359                 :           0 :     sorry ("transactional memory is not supported with %<-fsanitize=address%>");
    1360                 :             : 
    1361                 :      612709 :   if ((opts->x_flag_sanitize & SANITIZE_KERNEL_ADDRESS) && opts->x_flag_tm)
    1362                 :           0 :     sorry ("transactional memory is not supported with "
    1363                 :             :            "%<-fsanitize=kernel-address%>");
    1364                 :             : 
    1365                 :             :   /* Currently live patching is not support for LTO.  */
    1366                 :      612709 :   if (opts->x_flag_live_patching == LIVE_PATCHING_INLINE_ONLY_STATIC && opts->x_flag_lto)
    1367                 :           1 :     sorry ("live patching (with %qs) is not supported with LTO",
    1368                 :             :            "inline-only-static");
    1369                 :             : 
    1370                 :             :   /* Currently vtable verification is not supported for LTO */
    1371                 :      612709 :   if (opts->x_flag_vtable_verify && opts->x_flag_lto)
    1372                 :           0 :     sorry ("vtable verification is not supported with LTO");
    1373                 :             : 
    1374                 :             :   /* Control IPA optimizations based on different -flive-patching level.  */
    1375                 :      612709 :   if (opts->x_flag_live_patching)
    1376                 :          20 :     control_options_for_live_patching (opts, opts_set,
    1377                 :             :                                        opts->x_flag_live_patching,
    1378                 :             :                                        loc);
    1379                 :             : 
    1380                 :             :   /* Allow cunroll to grow size accordingly.  */
    1381                 :      612709 :   if (!opts_set->x_flag_cunroll_grow_size)
    1382                 :      612709 :     opts->x_flag_cunroll_grow_size
    1383                 :     1225418 :       = (opts->x_flag_unroll_loops
    1384                 :      157132 :          || opts->x_flag_peel_loops
    1385                 :     1225418 :          || opts->x_optimize >= 3);
    1386                 :             : 
    1387                 :             :   /* Use a frontend provided default for the complex eval method.  */
    1388                 :      612709 :   if (!opts_set->x_flag_complex_method)
    1389                 :      609812 :     opts->x_flag_complex_method = opts->x_flag_default_complex_method;
    1390                 :             : 
    1391                 :             :   /* Use -fvect-cost-model=cheap instead of -fvect-cost-mode=very-cheap
    1392                 :             :      by default with explicit -ftree-{loop,slp}-vectorize.  */
    1393                 :      612709 :   if (opts->x_optimize == 2
    1394                 :      442255 :       && (opts_set->x_flag_tree_loop_vectorize
    1395                 :      442196 :           || opts_set->x_flag_tree_vectorize))
    1396                 :      328980 :     SET_OPTION_IF_UNSET (opts, opts_set, flag_vect_cost_model,
    1397                 :             :                          VECT_COST_MODEL_CHEAP);
    1398                 :             : 
    1399                 :      612709 :   if (opts->x_flag_gtoggle)
    1400                 :             :     {
    1401                 :             :       /* Make sure to process -gtoggle only once.  */
    1402                 :         616 :       opts->x_flag_gtoggle = false;
    1403                 :         616 :       if (opts->x_debug_info_level == DINFO_LEVEL_NONE)
    1404                 :             :         {
    1405                 :         368 :           opts->x_debug_info_level = DINFO_LEVEL_NORMAL;
    1406                 :             : 
    1407                 :         368 :           if (opts->x_write_symbols == NO_DEBUG)
    1408                 :         368 :             opts->x_write_symbols = PREFERRED_DEBUGGING_TYPE;
    1409                 :             :         }
    1410                 :             :       else
    1411                 :         248 :         opts->x_debug_info_level = DINFO_LEVEL_NONE;
    1412                 :             :     }
    1413                 :             : 
    1414                 :      612709 :   if (!opts_set->x_debug_nonbind_markers_p)
    1415                 :      612677 :     opts->x_debug_nonbind_markers_p
    1416                 :      612677 :       = (opts->x_optimize
    1417                 :      498422 :          && opts->x_debug_info_level >= DINFO_LEVEL_NORMAL
    1418                 :       50954 :          && (dwarf_debuginfo_p (opts) || codeview_debuginfo_p ())
    1419                 :     1276299 :          && !(opts->x_flag_selective_scheduling
    1420                 :       50945 :               || opts->x_flag_selective_scheduling2));
    1421                 :             : 
    1422                 :             :   /* We know which debug output will be used so we can set flag_var_tracking
    1423                 :             :      and flag_var_tracking_uninit if the user has not specified them.  */
    1424                 :      612709 :   if (opts->x_debug_info_level < DINFO_LEVEL_NORMAL
    1425                 :      612709 :       || (!dwarf_debuginfo_p (opts) && !codeview_debuginfo_p ())
    1426                 :             :       /* We have not yet initialized debug hooks so match that to check
    1427                 :             :          whether we're only doing DWARF2_LINENO_DEBUGGING_INFO.  */
    1428                 :             : #ifndef DWARF2_DEBUGGING_INFO
    1429                 :             :       || true
    1430                 :             : #endif
    1431                 :             :      )
    1432                 :             :     {
    1433                 :      554999 :       if ((opts_set->x_flag_var_tracking && opts->x_flag_var_tracking == 1)
    1434                 :      554983 :           || (opts_set->x_flag_var_tracking_uninit
    1435                 :           0 :               && opts->x_flag_var_tracking_uninit == 1))
    1436                 :             :         {
    1437                 :          16 :           if (opts->x_debug_info_level < DINFO_LEVEL_NORMAL)
    1438                 :          15 :             warning_at (UNKNOWN_LOCATION, 0,
    1439                 :             :                         "variable tracking requested, but useless unless "
    1440                 :             :                         "producing debug info");
    1441                 :             :           else
    1442                 :           1 :             warning_at (UNKNOWN_LOCATION, 0,
    1443                 :             :                         "variable tracking requested, but not supported "
    1444                 :             :                         "by this debug format");
    1445                 :             :         }
    1446                 :      554999 :       opts->x_flag_var_tracking = 0;
    1447                 :      554999 :       opts->x_flag_var_tracking_uninit = 0;
    1448                 :      554999 :       opts->x_flag_var_tracking_assignments = 0;
    1449                 :             :     }
    1450                 :             : 
    1451                 :             :   /* One could use EnabledBy, but it would lead to a circular dependency.  */
    1452                 :      612709 :   if (!opts_set->x_flag_var_tracking_uninit)
    1453                 :      612709 :     opts->x_flag_var_tracking_uninit = opts->x_flag_var_tracking;
    1454                 :             : 
    1455                 :      612709 :   if (!opts_set->x_flag_var_tracking_assignments)
    1456                 :      612635 :     opts->x_flag_var_tracking_assignments
    1457                 :     1225270 :       = (opts->x_flag_var_tracking
    1458                 :     1225270 :          && !(opts->x_flag_selective_scheduling
    1459                 :       50941 :               || opts->x_flag_selective_scheduling2));
    1460                 :             : 
    1461                 :      612709 :   if (opts->x_flag_var_tracking_assignments_toggle)
    1462                 :           0 :     opts->x_flag_var_tracking_assignments
    1463                 :           0 :       = !opts->x_flag_var_tracking_assignments;
    1464                 :             : 
    1465                 :      612709 :   if (opts->x_flag_var_tracking_assignments && !opts->x_flag_var_tracking)
    1466                 :           2 :     opts->x_flag_var_tracking = opts->x_flag_var_tracking_assignments = -1;
    1467                 :             : 
    1468                 :      612709 :   if (opts->x_flag_var_tracking_assignments
    1469                 :       50948 :       && (opts->x_flag_selective_scheduling
    1470                 :       50948 :           || opts->x_flag_selective_scheduling2))
    1471                 :           5 :     warning_at (loc, 0,
    1472                 :             :                 "var-tracking-assignments changes selective scheduling");
    1473                 :             : 
    1474                 :      612709 :   if (opts->x_flag_syntax_only)
    1475                 :             :     {
    1476                 :         298 :       opts->x_write_symbols = NO_DEBUG;
    1477                 :         298 :       opts->x_profile_flag = 0;
    1478                 :             :     }
    1479                 :             : 
    1480                 :      612709 :   if (opts->x_warn_strict_flex_arrays)
    1481                 :          13 :     if (opts->x_flag_strict_flex_arrays == 0)
    1482                 :             :       {
    1483                 :           4 :         opts->x_warn_strict_flex_arrays = 0;
    1484                 :           4 :         warning_at (UNKNOWN_LOCATION, 0,
    1485                 :             :                     "%<-Wstrict-flex-arrays%> is ignored when"
    1486                 :             :                     " %<-fstrict-flex-arrays%> is not present");
    1487                 :             :       }
    1488                 :             : 
    1489                 :      612709 :   diagnose_options (opts, opts_set, loc);
    1490                 :      612709 : }
    1491                 :             : 
    1492                 :             : /* The function diagnoses incompatible combinations for provided options
    1493                 :             :    (OPTS and OPTS_SET) at a given LOCation.  The function is called both
    1494                 :             :    when command line is parsed (after the target optimization hook) and
    1495                 :             :    when an optimize/target attribute (or pragma) is used.  */
    1496                 :             : 
    1497                 :      897686 : void diagnose_options (gcc_options *opts, gcc_options *opts_set,
    1498                 :             :                        location_t loc)
    1499                 :             : {
    1500                 :             :   /* The optimization to partition hot and cold basic blocks into separate
    1501                 :             :      sections of the .o and executable files does not work (currently)
    1502                 :             :      with exception handling.  This is because there is no support for
    1503                 :             :      generating unwind info.  If opts->x_flag_exceptions is turned on
    1504                 :             :      we need to turn off the partitioning optimization.  */
    1505                 :             : 
    1506                 :      897686 :   enum unwind_info_type ui_except
    1507                 :      897686 :     = targetm_common.except_unwind_info (opts);
    1508                 :             : 
    1509                 :      897686 :   if (opts->x_flag_exceptions
    1510                 :      253426 :       && opts->x_flag_reorder_blocks_and_partition
    1511                 :       85813 :       && (ui_except == UI_SJLJ || ui_except >= UI_TARGET))
    1512                 :             :     {
    1513                 :           0 :       if (opts_set->x_flag_reorder_blocks_and_partition)
    1514                 :           0 :         inform (loc,
    1515                 :             :                 "%<-freorder-blocks-and-partition%> does not work "
    1516                 :             :                 "with exceptions on this architecture");
    1517                 :           0 :       opts->x_flag_reorder_blocks_and_partition = 0;
    1518                 :           0 :       opts->x_flag_reorder_blocks = 1;
    1519                 :             :     }
    1520                 :             : 
    1521                 :             :   /* If user requested unwind info, then turn off the partitioning
    1522                 :             :      optimization.  */
    1523                 :             : 
    1524                 :      897686 :   if (opts->x_flag_unwind_tables
    1525                 :      613560 :       && !targetm_common.unwind_tables_default
    1526                 :      613560 :       && opts->x_flag_reorder_blocks_and_partition
    1527                 :      467363 :       && (ui_except == UI_SJLJ || ui_except >= UI_TARGET))
    1528                 :             :     {
    1529                 :           0 :       if (opts_set->x_flag_reorder_blocks_and_partition)
    1530                 :           0 :         inform (loc,
    1531                 :             :                 "%<-freorder-blocks-and-partition%> does not support "
    1532                 :             :                 "unwind info on this architecture");
    1533                 :           0 :       opts->x_flag_reorder_blocks_and_partition = 0;
    1534                 :           0 :       opts->x_flag_reorder_blocks = 1;
    1535                 :             :     }
    1536                 :             : 
    1537                 :             :   /* If the target requested unwind info, then turn off the partitioning
    1538                 :             :      optimization with a different message.  Likewise, if the target does not
    1539                 :             :      support named sections.  */
    1540                 :             : 
    1541                 :      897686 :   if (opts->x_flag_reorder_blocks_and_partition
    1542                 :      608818 :       && (!targetm_common.have_named_sections
    1543                 :      608818 :           || (opts->x_flag_unwind_tables
    1544                 :      467363 :               && targetm_common.unwind_tables_default
    1545                 :           0 :               && (ui_except == UI_SJLJ || ui_except >= UI_TARGET))))
    1546                 :             :     {
    1547                 :           0 :       if (opts_set->x_flag_reorder_blocks_and_partition)
    1548                 :           0 :         inform (loc,
    1549                 :             :                 "%<-freorder-blocks-and-partition%> does not work "
    1550                 :             :                 "on this architecture");
    1551                 :           0 :       opts->x_flag_reorder_blocks_and_partition = 0;
    1552                 :           0 :       opts->x_flag_reorder_blocks = 1;
    1553                 :             :     }
    1554                 :             : 
    1555                 :             : 
    1556                 :      897686 : }
    1557                 :             : 
    1558                 :             : #define LEFT_COLUMN     27
    1559                 :             : 
    1560                 :             : /* Output ITEM, of length ITEM_WIDTH, in the left column,
    1561                 :             :    followed by word-wrapped HELP in a second column.  */
    1562                 :             : static void
    1563                 :       35164 : wrap_help (const char *help,
    1564                 :             :            const char *item,
    1565                 :             :            unsigned int item_width,
    1566                 :             :            unsigned int columns)
    1567                 :             : {
    1568                 :       35164 :   unsigned int col_width = LEFT_COLUMN;
    1569                 :       35164 :   unsigned int remaining, room, len;
    1570                 :             : 
    1571                 :       35164 :   remaining = strlen (help);
    1572                 :             : 
    1573                 :       60699 :   do
    1574                 :             :     {
    1575                 :       60699 :       room = columns - 3 - MAX (col_width, item_width);
    1576                 :       60699 :       if (room > columns)
    1577                 :           0 :         room = 0;
    1578                 :       60699 :       len = remaining;
    1579                 :             : 
    1580                 :       60699 :       if (room < len)
    1581                 :             :         {
    1582                 :             :           unsigned int i;
    1583                 :             : 
    1584                 :     1143241 :           for (i = 0; help[i]; i++)
    1585                 :             :             {
    1586                 :     1143241 :               if (i >= room && len != remaining)
    1587                 :             :                 break;
    1588                 :     1117706 :               if (help[i] == ' ')
    1589                 :             :                 len = i;
    1590                 :      949528 :               else if ((help[i] == '-' || help[i] == '/')
    1591                 :        3901 :                        && help[i + 1] != ' '
    1592                 :        3901 :                        && i > 0 && ISALPHA (help[i - 1]))
    1593                 :     1117706 :                 len = i + 1;
    1594                 :             :             }
    1595                 :             :         }
    1596                 :             : 
    1597                 :       60699 :       printf ("  %-*.*s %.*s\n", col_width, item_width, item, len, help);
    1598                 :       60699 :       item_width = 0;
    1599                 :      146524 :       while (help[len] == ' ')
    1600                 :       25126 :         len++;
    1601                 :       60699 :       help += len;
    1602                 :       60699 :       remaining -= len;
    1603                 :             :     }
    1604                 :       60699 :   while (remaining);
    1605                 :       35164 : }
    1606                 :             : 
    1607                 :             : /* Data structure used to print list of valid option values.  */
    1608                 :             : 
    1609                 :             : class option_help_tuple
    1610                 :             : {
    1611                 :             : public:
    1612                 :          14 :   option_help_tuple (int code, vec<const char *> values):
    1613                 :          14 :     m_code (code), m_values (values)
    1614                 :             :   {}
    1615                 :             : 
    1616                 :             :   /* Code of an option.  */
    1617                 :             :   int m_code;
    1618                 :             : 
    1619                 :             :   /* List of possible values.  */
    1620                 :             :   vec<const char *> m_values;
    1621                 :             : };
    1622                 :             : 
    1623                 :             : /* Print help for a specific front-end, etc.  */
    1624                 :             : static void
    1625                 :         157 : print_filtered_help (unsigned int include_flags,
    1626                 :             :                      unsigned int exclude_flags,
    1627                 :             :                      unsigned int any_flags,
    1628                 :             :                      unsigned int columns,
    1629                 :             :                      struct gcc_options *opts,
    1630                 :             :                      unsigned int lang_mask)
    1631                 :             : {
    1632                 :         157 :   unsigned int i;
    1633                 :         157 :   const char *help;
    1634                 :         157 :   bool found = false;
    1635                 :         157 :   bool displayed = false;
    1636                 :         157 :   char new_help[256];
    1637                 :             : 
    1638                 :         157 :   if (!opts->x_help_printed)
    1639                 :          95 :     opts->x_help_printed = XCNEWVAR (char, cl_options_count);
    1640                 :             : 
    1641                 :         157 :   if (!opts->x_help_enum_printed)
    1642                 :          95 :     opts->x_help_enum_printed = XCNEWVAR (char, cl_enums_count);
    1643                 :             : 
    1644                 :         157 :   auto_vec<option_help_tuple> help_tuples;
    1645                 :             : 
    1646                 :      382923 :   for (i = 0; i < cl_options_count; i++)
    1647                 :             :     {
    1648                 :      382766 :       const struct cl_option *option = cl_options + i;
    1649                 :      382766 :       unsigned int len;
    1650                 :      382766 :       const char *opt;
    1651                 :      382766 :       const char *tab;
    1652                 :             : 
    1653                 :      382766 :       if (include_flags == 0
    1654                 :      375452 :           || ((option->flags & include_flags) != include_flags))
    1655                 :             :         {
    1656                 :      335821 :           if ((option->flags & any_flags) == 0)
    1657                 :      332740 :             continue;
    1658                 :             :         }
    1659                 :             : 
    1660                 :             :       /* Skip unwanted switches.  */
    1661                 :       50026 :       if ((option->flags & exclude_flags) != 0)
    1662                 :        9527 :         continue;
    1663                 :             : 
    1664                 :             :       /* The driver currently prints its own help text.  */
    1665                 :       40499 :       if ((option->flags & CL_DRIVER) != 0
    1666                 :         810 :           && (option->flags & (((1U << cl_lang_count) - 1)
    1667                 :         716 :                                | CL_COMMON | CL_TARGET)) == 0)
    1668                 :          94 :         continue;
    1669                 :             : 
    1670                 :             :       /* If an option contains a language specification,
    1671                 :             :          exclude it from common unless all languages are present.  */
    1672                 :       40405 :       if ((include_flags & CL_COMMON)
    1673                 :        4705 :           && !(option->flags & CL_DRIVER)
    1674                 :        4325 :           && (option->flags & CL_LANG_ALL)
    1675                 :         135 :           && (option->flags & CL_LANG_ALL) != CL_LANG_ALL)
    1676                 :         135 :         continue;
    1677                 :             : 
    1678                 :       40270 :       found = true;
    1679                 :             :       /* Skip switches that have already been printed.  */
    1680                 :       40270 :       if (opts->x_help_printed[i])
    1681                 :        5098 :         continue;
    1682                 :             : 
    1683                 :       35172 :       opts->x_help_printed[i] = true;
    1684                 :             : 
    1685                 :       35172 :       help = option->help;
    1686                 :       35172 :       if (help == NULL)
    1687                 :             :         {
    1688                 :        1338 :           if (exclude_flags & CL_UNDOCUMENTED)
    1689                 :           8 :             continue;
    1690                 :             : 
    1691                 :             :           help = undocumented_msg;
    1692                 :             :         }
    1693                 :             : 
    1694                 :             :       /* Get the translation.  */
    1695                 :       35164 :       help = _(help);
    1696                 :             : 
    1697                 :       35164 :       if (option->alias_target < N_OPTS
    1698                 :        1361 :           && cl_options [option->alias_target].help)
    1699                 :             :         {
    1700                 :        1332 :           const struct cl_option *target = cl_options + option->alias_target;
    1701                 :        1332 :           if (option->help == NULL)
    1702                 :             :             {
    1703                 :             :               /* The option is undocumented but is an alias for an option that
    1704                 :             :                  is documented.  If the option has alias arguments, then its
    1705                 :             :                  purpose is to provide certain arguments to the other option, so
    1706                 :             :                  inform the reader of this.  Otherwise, point the reader to the
    1707                 :             :                  other option in preference to the former.  */
    1708                 :             : 
    1709                 :         772 :               if (option->alias_arg)
    1710                 :             :                 {
    1711                 :         103 :                   if (option->neg_alias_arg)
    1712                 :          83 :                     snprintf (new_help, sizeof new_help,
    1713                 :          83 :                               _("Same as %s%s (or, in negated form, %s%s)."),
    1714                 :             :                               target->opt_text, option->alias_arg,
    1715                 :          83 :                               target->opt_text, option->neg_alias_arg);
    1716                 :             :                   else
    1717                 :          20 :                     snprintf (new_help, sizeof new_help,
    1718                 :          20 :                               _("Same as %s%s."),
    1719                 :          20 :                               target->opt_text, option->alias_arg);
    1720                 :             :                 }
    1721                 :             :               else
    1722                 :         669 :                 snprintf (new_help, sizeof new_help,
    1723                 :         669 :                           _("Same as %s."),
    1724                 :         669 :                           target->opt_text);
    1725                 :             :             }
    1726                 :             :           else
    1727                 :             :             {
    1728                 :             :               /* For documented options with aliases, mention the aliased
    1729                 :             :                  option's name for reference.  */
    1730                 :         560 :               snprintf (new_help, sizeof new_help,
    1731                 :         560 :                         _("%s  Same as %s."),
    1732                 :         560 :                         help, cl_options [option->alias_target].opt_text);
    1733                 :             :             }
    1734                 :             : 
    1735                 :             :           help = new_help;
    1736                 :             :         }
    1737                 :             : 
    1738                 :       35164 :       if (option->warn_message)
    1739                 :             :         {
    1740                 :             :           /* Mention that the use of the option will trigger a warning.  */
    1741                 :          42 :           if (help == new_help)
    1742                 :          42 :             snprintf (new_help + strlen (new_help),
    1743                 :          42 :                       sizeof new_help - strlen (new_help),
    1744                 :             :                       "  %s", _(use_diagnosed_msg));
    1745                 :             :           else
    1746                 :           0 :             snprintf (new_help, sizeof new_help,
    1747                 :             :                       "%s  %s", help, _(use_diagnosed_msg));
    1748                 :             : 
    1749                 :             :           help = new_help;
    1750                 :             :         }
    1751                 :             : 
    1752                 :             :       /* Find the gap between the name of the
    1753                 :             :          option and its descriptive text.  */
    1754                 :       35164 :       tab = strchr (help, '\t');
    1755                 :       35164 :       if (tab)
    1756                 :             :         {
    1757                 :        1622 :           len = tab - help;
    1758                 :        1622 :           opt = help;
    1759                 :        1622 :           help = tab + 1;
    1760                 :             :         }
    1761                 :             :       else
    1762                 :             :         {
    1763                 :       33542 :           opt = option->opt_text;
    1764                 :       33542 :           len = strlen (opt);
    1765                 :             :         }
    1766                 :             : 
    1767                 :             :       /* With the -Q option enabled we change the descriptive text associated
    1768                 :             :          with an option to be an indication of its current setting.  */
    1769                 :       35164 :       if (!opts->x_quiet_flag)
    1770                 :             :         {
    1771                 :        2468 :           void *flag_var = option_flag_var (i, opts);
    1772                 :             : 
    1773                 :        2468 :           if (len < (LEFT_COLUMN + 2))
    1774                 :        2196 :             strcpy (new_help, "\t\t");
    1775                 :             :           else
    1776                 :         272 :             strcpy (new_help, "\t");
    1777                 :             : 
    1778                 :             :           /* Set to print whether the option is enabled or disabled,
    1779                 :             :              or, if it's an alias for another option, the name of
    1780                 :             :              the aliased option.  */
    1781                 :        2468 :           bool print_state = false;
    1782                 :             : 
    1783                 :        2468 :           if (flag_var != NULL
    1784                 :        2258 :               && option->var_type != CLVC_DEFER)
    1785                 :             :             {
    1786                 :             :               /* If OPTION is only available for a specific subset
    1787                 :             :                  of languages other than this one, mention them.  */
    1788                 :        2258 :               bool avail_for_lang = true;
    1789                 :        2258 :               if (unsigned langset = option->flags & CL_LANG_ALL)
    1790                 :             :                 {
    1791                 :        1284 :                   if (!(langset & lang_mask))
    1792                 :             :                     {
    1793                 :         467 :                       avail_for_lang = false;
    1794                 :         467 :                       strcat (new_help, _("[available in "));
    1795                 :        7472 :                       for (unsigned i = 0, n = 0; (1U << i) < CL_LANG_ALL; ++i)
    1796                 :        7005 :                         if (langset & (1U << i))
    1797                 :             :                           {
    1798                 :         801 :                             if (n++)
    1799                 :         334 :                               strcat (new_help, ", ");
    1800                 :         801 :                             strcat (new_help, lang_names[i]);
    1801                 :             :                           }
    1802                 :         467 :                       strcat (new_help, "]");
    1803                 :             :                     }
    1804                 :             :                 }
    1805                 :         467 :               if (!avail_for_lang)
    1806                 :             :                 ; /* Print nothing else if the option is not available
    1807                 :             :                      in the current language.  */
    1808                 :        1791 :               else if (option->flags & CL_JOINED)
    1809                 :             :                 {
    1810                 :         149 :                   if (option->var_type == CLVC_STRING)
    1811                 :             :                     {
    1812                 :          10 :                       if (* (const char **) flag_var != NULL)
    1813                 :           8 :                         snprintf (new_help + strlen (new_help),
    1814                 :           8 :                                   sizeof (new_help) - strlen (new_help),
    1815                 :             :                                   "%s", * (const char **) flag_var);
    1816                 :             :                     }
    1817                 :         139 :                   else if (option->var_type == CLVC_ENUM)
    1818                 :             :                     {
    1819                 :          47 :                       const struct cl_enum *e = &cl_enums[option->var_enum];
    1820                 :          47 :                       int value;
    1821                 :          47 :                       const char *arg = NULL;
    1822                 :             : 
    1823                 :          47 :                       value = e->get (flag_var);
    1824                 :          47 :                       enum_value_to_arg (e->values, &arg, value, lang_mask);
    1825                 :          47 :                       if (arg == NULL)
    1826                 :           8 :                         arg = _("[default]");
    1827                 :          47 :                       snprintf (new_help + strlen (new_help),
    1828                 :          47 :                                 sizeof (new_help) - strlen (new_help),
    1829                 :             :                                 "%s", arg);
    1830                 :             :                     }
    1831                 :             :                   else
    1832                 :             :                     {
    1833                 :          92 :                       if (option->cl_host_wide_int)
    1834                 :          24 :                         sprintf (new_help + strlen (new_help),
    1835                 :          24 :                                  _("%llu bytes"), (unsigned long long)
    1836                 :             :                                  *(unsigned HOST_WIDE_INT *) flag_var);
    1837                 :             :                       else
    1838                 :          68 :                         sprintf (new_help + strlen (new_help),
    1839                 :             :                                  "%i", * (int *) flag_var);
    1840                 :             :                     }
    1841                 :             :                 }
    1842                 :             :               else
    1843                 :             :                 print_state = true;
    1844                 :             :             }
    1845                 :             :           else
    1846                 :             :             /* When there is no argument, print the option state only
    1847                 :             :                if the option takes no argument.  */
    1848                 :         210 :             print_state = !(option->flags & CL_JOINED);
    1849                 :             : 
    1850                 :         824 :           if (print_state)
    1851                 :             :             {
    1852                 :        1834 :               if (option->alias_target < N_OPTS
    1853                 :             :                   && option->alias_target != OPT_SPECIAL_warn_removed
    1854                 :             :                   && option->alias_target != OPT_SPECIAL_ignore
    1855                 :             :                   && option->alias_target != OPT_SPECIAL_input_file
    1856                 :             :                   && option->alias_target != OPT_SPECIAL_program_name
    1857                 :             :                   && option->alias_target != OPT_SPECIAL_unknown)
    1858                 :             :                 {
    1859                 :         154 :                   const struct cl_option *target
    1860                 :         154 :                     = &cl_options[option->alias_target];
    1861                 :         308 :                   sprintf (new_help + strlen (new_help), "%s%s",
    1862                 :         154 :                            target->opt_text,
    1863                 :         154 :                            option->alias_arg ? option->alias_arg : "");
    1864                 :             :                 }
    1865                 :        1680 :               else if (option->alias_target == OPT_SPECIAL_ignore)
    1866                 :          12 :                 strcat (new_help, ("[ignored]"));
    1867                 :             :               else
    1868                 :             :                 {
    1869                 :             :                   /* Print the state for an on/off option.  */
    1870                 :        1668 :                   int ena = option_enabled (i, lang_mask, opts);
    1871                 :        1668 :                   if (ena > 0)
    1872                 :         761 :                     strcat (new_help, _("[enabled]"));
    1873                 :         907 :                   else if (ena == 0)
    1874                 :         802 :                     strcat (new_help, _("[disabled]"));
    1875                 :             :                 }
    1876                 :             :             }
    1877                 :             : 
    1878                 :             :           help = new_help;
    1879                 :             :         }
    1880                 :             : 
    1881                 :       35164 :       if (option->range_max != -1 && tab == NULL)
    1882                 :             :         {
    1883                 :        7568 :           char b[128];
    1884                 :        7568 :           snprintf (b, sizeof (b), "<%d,%d>", option->range_min,
    1885                 :             :                     option->range_max);
    1886                 :        7568 :           opt = concat (opt, b, NULL);
    1887                 :        7568 :           len += strlen (b);
    1888                 :             :         }
    1889                 :             : 
    1890                 :       35164 :       wrap_help (help, opt, len, columns);
    1891                 :       35164 :       displayed = true;
    1892                 :             : 
    1893                 :       35164 :       if (option->var_type == CLVC_ENUM
    1894                 :         986 :           && opts->x_help_enum_printed[option->var_enum] != 2)
    1895                 :         986 :         opts->x_help_enum_printed[option->var_enum] = 1;
    1896                 :             :       else
    1897                 :             :         {
    1898                 :       34178 :           vec<const char *> option_values
    1899                 :       34178 :             = targetm_common.get_valid_option_values (i, NULL);
    1900                 :       34192 :           if (!option_values.is_empty ())
    1901                 :          14 :             help_tuples.safe_push (option_help_tuple (i, option_values));
    1902                 :             :         }
    1903                 :             :     }
    1904                 :             : 
    1905                 :         157 :   if (! found)
    1906                 :             :     {
    1907                 :           9 :       unsigned int langs = include_flags & CL_LANG_ALL;
    1908                 :             : 
    1909                 :           9 :       if (langs == 0)
    1910                 :           0 :         printf (_(" No options with the desired characteristics were found\n"));
    1911                 :             :       else
    1912                 :             :         {
    1913                 :             :           unsigned int i;
    1914                 :             : 
    1915                 :             :           /* PR 31349: Tell the user how to see all of the
    1916                 :             :              options supported by a specific front end.  */
    1917                 :         144 :           for (i = 0; (1U << i) < CL_LANG_ALL; i ++)
    1918                 :         135 :             if ((1U << i) & langs)
    1919                 :           9 :               printf (_(" None found.  Use --help=%s to show *all* the options supported by the %s front-end.\n"),
    1920                 :           9 :                       lang_names[i], lang_names[i]);
    1921                 :             :         }
    1922                 :             : 
    1923                 :             :     }
    1924                 :         148 :   else if (! displayed)
    1925                 :           0 :     printf (_(" All options with the desired characteristics have already been displayed\n"));
    1926                 :             : 
    1927                 :         157 :   putchar ('\n');
    1928                 :             : 
    1929                 :             :   /* Print details of enumerated option arguments, if those
    1930                 :             :      enumerations have help text headings provided.  If no help text
    1931                 :             :      is provided, presume that the possible values are listed in the
    1932                 :             :      help text for the relevant options.  */
    1933                 :       12874 :   for (i = 0; i < cl_enums_count; i++)
    1934                 :             :     {
    1935                 :       12717 :       unsigned int j, pos;
    1936                 :             : 
    1937                 :       12717 :       if (opts->x_help_enum_printed[i] != 1)
    1938                 :       10997 :         continue;
    1939                 :        1720 :       if (cl_enums[i].help == NULL)
    1940                 :        1622 :         continue;
    1941                 :          98 :       printf ("  %s\n    ", _(cl_enums[i].help));
    1942                 :          98 :       pos = 4;
    1943                 :         455 :       for (j = 0; cl_enums[i].values[j].arg != NULL; j++)
    1944                 :             :         {
    1945                 :         357 :           unsigned int len = strlen (cl_enums[i].values[j].arg);
    1946                 :             : 
    1947                 :         357 :           if (pos > 4 && pos + 1 + len <= columns)
    1948                 :             :             {
    1949                 :         258 :               printf (" %s", cl_enums[i].values[j].arg);
    1950                 :         258 :               pos += 1 + len;
    1951                 :             :             }
    1952                 :             :           else
    1953                 :             :             {
    1954                 :           1 :               if (pos > 4)
    1955                 :             :                 {
    1956                 :           1 :                   printf ("\n    ");
    1957                 :           1 :                   pos = 4;
    1958                 :             :                 }
    1959                 :          99 :               printf ("%s", cl_enums[i].values[j].arg);
    1960                 :          99 :               pos += len;
    1961                 :             :             }
    1962                 :             :         }
    1963                 :          98 :       printf ("\n\n");
    1964                 :          98 :       opts->x_help_enum_printed[i] = 2;
    1965                 :             :     }
    1966                 :             : 
    1967                 :         171 :   for (unsigned i = 0; i < help_tuples.length (); i++)
    1968                 :             :     {
    1969                 :          14 :       const struct cl_option *option = cl_options + help_tuples[i].m_code;
    1970                 :          14 :       printf (_("  Known valid arguments for %s option:\n   "),
    1971                 :          14 :               option->opt_text);
    1972                 :        1211 :       for (unsigned j = 0; j < help_tuples[i].m_values.length (); j++)
    1973                 :        1197 :         printf (" %s", help_tuples[i].m_values[j]);
    1974                 :          14 :       printf ("\n\n");
    1975                 :             :     }
    1976                 :         157 : }
    1977                 :             : 
    1978                 :             : /* Display help for a specified type of option.
    1979                 :             :    The options must have ALL of the INCLUDE_FLAGS set
    1980                 :             :    ANY of the flags in the ANY_FLAGS set
    1981                 :             :    and NONE of the EXCLUDE_FLAGS set.  The current option state is in
    1982                 :             :    OPTS; LANG_MASK is used for interpreting enumerated option state.  */
    1983                 :             : static void
    1984                 :         157 : print_specific_help (unsigned int include_flags,
    1985                 :             :                      unsigned int exclude_flags,
    1986                 :             :                      unsigned int any_flags,
    1987                 :             :                      struct gcc_options *opts,
    1988                 :             :                      unsigned int lang_mask)
    1989                 :             : {
    1990                 :         157 :   unsigned int all_langs_mask = (1U << cl_lang_count) - 1;
    1991                 :         157 :   const char * description = NULL;
    1992                 :         157 :   const char * descrip_extra = "";
    1993                 :         157 :   size_t i;
    1994                 :         157 :   unsigned int flag;
    1995                 :             : 
    1996                 :             :   /* Sanity check: Make sure that we do not have more
    1997                 :             :      languages than we have bits available to enumerate them.  */
    1998                 :         157 :   gcc_assert ((1U << cl_lang_count) <= CL_MIN_OPTION_CLASS);
    1999                 :             : 
    2000                 :             :   /* If we have not done so already, obtain
    2001                 :             :      the desired maximum width of the output.  */
    2002                 :         157 :   if (opts->x_help_columns == 0)
    2003                 :             :     {
    2004                 :          95 :       opts->x_help_columns = get_terminal_width ();
    2005                 :          95 :       if (opts->x_help_columns == INT_MAX)
    2006                 :             :         /* Use a reasonable default.  */
    2007                 :          57 :         opts->x_help_columns = 80;
    2008                 :             :     }
    2009                 :             : 
    2010                 :             :   /* Decide upon the title for the options that we are going to display.  */
    2011                 :        3611 :   for (i = 0, flag = 1; flag <= CL_MAX_OPTION_CLASS; flag <<= 1, i ++)
    2012                 :             :     {
    2013                 :        3454 :       switch (flag & include_flags)
    2014                 :             :         {
    2015                 :             :         case 0:
    2016                 :             :         case CL_DRIVER:
    2017                 :             :           break;
    2018                 :             : 
    2019                 :           7 :         case CL_TARGET:
    2020                 :           7 :           description = _("The following options are target specific");
    2021                 :           7 :           break;
    2022                 :          11 :         case CL_WARNING:
    2023                 :          11 :           description = _("The following options control compiler warning messages");
    2024                 :          11 :           break;
    2025                 :          10 :         case CL_OPTIMIZATION:
    2026                 :          10 :           description = _("The following options control optimizations");
    2027                 :          10 :           break;
    2028                 :           5 :         case CL_COMMON:
    2029                 :           5 :           description = _("The following options are language-independent");
    2030                 :           5 :           break;
    2031                 :          63 :         case CL_PARAMS:
    2032                 :          63 :           description = _("The following options control parameters");
    2033                 :          63 :           break;
    2034                 :          53 :         default:
    2035                 :          53 :           if (i >= cl_lang_count)
    2036                 :             :             break;
    2037                 :          53 :           if (exclude_flags & all_langs_mask)
    2038                 :          45 :             description = _("The following options are specific to just the language ");
    2039                 :             :           else
    2040                 :           8 :             description = _("The following options are supported by the language ");
    2041                 :          53 :           descrip_extra = lang_names [i];
    2042                 :          53 :           break;
    2043                 :             :         }
    2044                 :             :     }
    2045                 :             : 
    2046                 :         157 :   if (description == NULL)
    2047                 :             :     {
    2048                 :           9 :       if (any_flags == 0)
    2049                 :             :         {
    2050                 :           6 :           if (include_flags & CL_UNDOCUMENTED)
    2051                 :           2 :             description = _("The following options are not documented");
    2052                 :           4 :           else if (include_flags & CL_SEPARATE)
    2053                 :           2 :             description = _("The following options take separate arguments");
    2054                 :           2 :           else if (include_flags & CL_JOINED)
    2055                 :           2 :             description = _("The following options take joined arguments");
    2056                 :             :           else
    2057                 :             :             {
    2058                 :           0 :               internal_error ("unrecognized %<include_flags 0x%x%> passed "
    2059                 :             :                               "to %<print_specific_help%>",
    2060                 :             :                               include_flags);
    2061                 :             :               return;
    2062                 :             :             }
    2063                 :             :         }
    2064                 :             :       else
    2065                 :             :         {
    2066                 :           3 :           if (any_flags & all_langs_mask)
    2067                 :           3 :             description = _("The following options are language-related");
    2068                 :             :           else
    2069                 :           0 :             description = _("The following options are language-independent");
    2070                 :             :         }
    2071                 :             :     }
    2072                 :             : 
    2073                 :         157 :   printf ("%s%s:\n", description, descrip_extra);
    2074                 :         157 :   print_filtered_help (include_flags, exclude_flags, any_flags,
    2075                 :             :                        opts->x_help_columns, opts, lang_mask);
    2076                 :             : }
    2077                 :             : 
    2078                 :             : /* Enable FDO-related flags.  */
    2079                 :             : 
    2080                 :             : static void
    2081                 :         151 : enable_fdo_optimizations (struct gcc_options *opts,
    2082                 :             :                           struct gcc_options *opts_set,
    2083                 :             :                           int value)
    2084                 :             : {
    2085                 :         151 :   SET_OPTION_IF_UNSET (opts, opts_set, flag_branch_probabilities, value);
    2086                 :         151 :   SET_OPTION_IF_UNSET (opts, opts_set, flag_profile_values, value);
    2087                 :         151 :   SET_OPTION_IF_UNSET (opts, opts_set, flag_unroll_loops, value);
    2088                 :         151 :   SET_OPTION_IF_UNSET (opts, opts_set, flag_peel_loops, value);
    2089                 :         151 :   SET_OPTION_IF_UNSET (opts, opts_set, flag_tracer, value);
    2090                 :         151 :   SET_OPTION_IF_UNSET (opts, opts_set, flag_value_profile_transformations,
    2091                 :             :                        value);
    2092                 :         151 :   SET_OPTION_IF_UNSET (opts, opts_set, flag_inline_functions, value);
    2093                 :         151 :   SET_OPTION_IF_UNSET (opts, opts_set, flag_ipa_cp, value);
    2094                 :         151 :   if (value)
    2095                 :             :     {
    2096                 :         151 :       SET_OPTION_IF_UNSET (opts, opts_set, flag_ipa_cp_clone, 1);
    2097                 :         151 :       SET_OPTION_IF_UNSET (opts, opts_set, flag_ipa_bit_cp, 1);
    2098                 :             :     }
    2099                 :         151 :   SET_OPTION_IF_UNSET (opts, opts_set, flag_predictive_commoning, value);
    2100                 :         151 :   SET_OPTION_IF_UNSET (opts, opts_set, flag_split_loops, value);
    2101                 :         151 :   SET_OPTION_IF_UNSET (opts, opts_set, flag_unswitch_loops, value);
    2102                 :         151 :   SET_OPTION_IF_UNSET (opts, opts_set, flag_gcse_after_reload, value);
    2103                 :         151 :   SET_OPTION_IF_UNSET (opts, opts_set, flag_tree_loop_vectorize, value);
    2104                 :         151 :   SET_OPTION_IF_UNSET (opts, opts_set, flag_tree_slp_vectorize, value);
    2105                 :         151 :   SET_OPTION_IF_UNSET (opts, opts_set, flag_version_loops_for_strides, value);
    2106                 :         151 :   SET_OPTION_IF_UNSET (opts, opts_set, flag_vect_cost_model,
    2107                 :             :                        VECT_COST_MODEL_DYNAMIC);
    2108                 :         151 :   SET_OPTION_IF_UNSET (opts, opts_set, flag_tree_loop_distribute_patterns,
    2109                 :             :                        value);
    2110                 :         151 :   SET_OPTION_IF_UNSET (opts, opts_set, flag_loop_interchange, value);
    2111                 :         151 :   SET_OPTION_IF_UNSET (opts, opts_set, flag_unroll_jam, value);
    2112                 :         151 :   SET_OPTION_IF_UNSET (opts, opts_set, flag_tree_loop_distribution, value);
    2113                 :         151 :   SET_OPTION_IF_UNSET (opts, opts_set, flag_optimize_crc, value);
    2114                 :         151 : }
    2115                 :             : 
    2116                 :             : /* -f{,no-}sanitize{,-recover}= suboptions.  */
    2117                 :             : const struct sanitizer_opts_s sanitizer_opts[] =
    2118                 :             : {
    2119                 :             : #define SANITIZER_OPT(name, flags, recover, trap) \
    2120                 :             :     { #name, flags, sizeof #name - 1, recover, trap }
    2121                 :             :   SANITIZER_OPT (address, (SANITIZE_ADDRESS | SANITIZE_USER_ADDRESS), true,
    2122                 :             :                  false),
    2123                 :             :   SANITIZER_OPT (hwaddress, (SANITIZE_HWADDRESS | SANITIZE_USER_HWADDRESS),
    2124                 :             :                  true, false),
    2125                 :             :   SANITIZER_OPT (kernel-address, (SANITIZE_ADDRESS | SANITIZE_KERNEL_ADDRESS),
    2126                 :             :                  true, false),
    2127                 :             :   SANITIZER_OPT (kernel-hwaddress,
    2128                 :             :                  (SANITIZE_HWADDRESS | SANITIZE_KERNEL_HWADDRESS),
    2129                 :             :                  true, false),
    2130                 :             :   SANITIZER_OPT (pointer-compare, SANITIZE_POINTER_COMPARE, true, false),
    2131                 :             :   SANITIZER_OPT (pointer-subtract, SANITIZE_POINTER_SUBTRACT, true, false),
    2132                 :             :   SANITIZER_OPT (thread, SANITIZE_THREAD, false, false),
    2133                 :             :   SANITIZER_OPT (leak, SANITIZE_LEAK, false, false),
    2134                 :             :   SANITIZER_OPT (shift, SANITIZE_SHIFT, true, true),
    2135                 :             :   SANITIZER_OPT (shift-base, SANITIZE_SHIFT_BASE, true, true),
    2136                 :             :   SANITIZER_OPT (shift-exponent, SANITIZE_SHIFT_EXPONENT, true, true),
    2137                 :             :   SANITIZER_OPT (integer-divide-by-zero, SANITIZE_DIVIDE, true, true),
    2138                 :             :   SANITIZER_OPT (undefined, SANITIZE_UNDEFINED, true, true),
    2139                 :             :   SANITIZER_OPT (unreachable, SANITIZE_UNREACHABLE, false, true),
    2140                 :             :   SANITIZER_OPT (vla-bound, SANITIZE_VLA, true, true),
    2141                 :             :   SANITIZER_OPT (return, SANITIZE_RETURN, false, true),
    2142                 :             :   SANITIZER_OPT (null, SANITIZE_NULL, true, true),
    2143                 :             :   SANITIZER_OPT (signed-integer-overflow, SANITIZE_SI_OVERFLOW, true, true),
    2144                 :             :   SANITIZER_OPT (bool, SANITIZE_BOOL, true, true),
    2145                 :             :   SANITIZER_OPT (enum, SANITIZE_ENUM, true, true),
    2146                 :             :   SANITIZER_OPT (float-divide-by-zero, SANITIZE_FLOAT_DIVIDE, true, true),
    2147                 :             :   SANITIZER_OPT (float-cast-overflow, SANITIZE_FLOAT_CAST, true, true),
    2148                 :             :   SANITIZER_OPT (bounds, SANITIZE_BOUNDS, true, true),
    2149                 :             :   SANITIZER_OPT (bounds-strict, SANITIZE_BOUNDS | SANITIZE_BOUNDS_STRICT, true,
    2150                 :             :                  true),
    2151                 :             :   SANITIZER_OPT (alignment, SANITIZE_ALIGNMENT, true, true),
    2152                 :             :   SANITIZER_OPT (nonnull-attribute, SANITIZE_NONNULL_ATTRIBUTE, true, true),
    2153                 :             :   SANITIZER_OPT (returns-nonnull-attribute, SANITIZE_RETURNS_NONNULL_ATTRIBUTE,
    2154                 :             :                  true, true),
    2155                 :             :   SANITIZER_OPT (object-size, SANITIZE_OBJECT_SIZE, true, true),
    2156                 :             :   SANITIZER_OPT (vptr, SANITIZE_VPTR, true, false),
    2157                 :             :   SANITIZER_OPT (pointer-overflow, SANITIZE_POINTER_OVERFLOW, true, true),
    2158                 :             :   SANITIZER_OPT (builtin, SANITIZE_BUILTIN, true, true),
    2159                 :             :   SANITIZER_OPT (shadow-call-stack, SANITIZE_SHADOW_CALL_STACK, false, false),
    2160                 :             :   SANITIZER_OPT (all, ~0U, true, true),
    2161                 :             : #undef SANITIZER_OPT
    2162                 :             :   { NULL, 0U, 0UL, false, false }
    2163                 :             : };
    2164                 :             : 
    2165                 :             : /* -fzero-call-used-regs= suboptions.  */
    2166                 :             : const struct zero_call_used_regs_opts_s zero_call_used_regs_opts[] =
    2167                 :             : {
    2168                 :             : #define ZERO_CALL_USED_REGS_OPT(name, flags) \
    2169                 :             :     { #name, flags }
    2170                 :             :   ZERO_CALL_USED_REGS_OPT (skip, zero_regs_flags::SKIP),
    2171                 :             :   ZERO_CALL_USED_REGS_OPT (used-gpr-arg, zero_regs_flags::USED_GPR_ARG),
    2172                 :             :   ZERO_CALL_USED_REGS_OPT (used-gpr, zero_regs_flags::USED_GPR),
    2173                 :             :   ZERO_CALL_USED_REGS_OPT (used-arg, zero_regs_flags::USED_ARG),
    2174                 :             :   ZERO_CALL_USED_REGS_OPT (used, zero_regs_flags::USED),
    2175                 :             :   ZERO_CALL_USED_REGS_OPT (all-gpr-arg, zero_regs_flags::ALL_GPR_ARG),
    2176                 :             :   ZERO_CALL_USED_REGS_OPT (all-gpr, zero_regs_flags::ALL_GPR),
    2177                 :             :   ZERO_CALL_USED_REGS_OPT (all-arg, zero_regs_flags::ALL_ARG),
    2178                 :             :   ZERO_CALL_USED_REGS_OPT (all, zero_regs_flags::ALL),
    2179                 :             :   ZERO_CALL_USED_REGS_OPT (leafy-gpr-arg, zero_regs_flags::LEAFY_GPR_ARG),
    2180                 :             :   ZERO_CALL_USED_REGS_OPT (leafy-gpr, zero_regs_flags::LEAFY_GPR),
    2181                 :             :   ZERO_CALL_USED_REGS_OPT (leafy-arg, zero_regs_flags::LEAFY_ARG),
    2182                 :             :   ZERO_CALL_USED_REGS_OPT (leafy, zero_regs_flags::LEAFY),
    2183                 :             : #undef ZERO_CALL_USED_REGS_OPT
    2184                 :             :   {NULL, 0U}
    2185                 :             : };
    2186                 :             : 
    2187                 :             : /* A struct for describing a run of chars within a string.  */
    2188                 :             : 
    2189                 :             : class string_fragment
    2190                 :             : {
    2191                 :             : public:
    2192                 :           6 :   string_fragment (const char *start, size_t len)
    2193                 :           6 :   : m_start (start), m_len (len) {}
    2194                 :             : 
    2195                 :             :   const char *m_start;
    2196                 :             :   size_t m_len;
    2197                 :             : };
    2198                 :             : 
    2199                 :             : /* Specialization of edit_distance_traits for string_fragment,
    2200                 :             :    for use by get_closest_sanitizer_option.  */
    2201                 :             : 
    2202                 :             : template <>
    2203                 :             : struct edit_distance_traits<const string_fragment &>
    2204                 :             : {
    2205                 :           6 :   static size_t get_length (const string_fragment &fragment)
    2206                 :             :   {
    2207                 :           6 :     return fragment.m_len;
    2208                 :             :   }
    2209                 :             : 
    2210                 :           6 :   static const char *get_string (const string_fragment &fragment)
    2211                 :             :   {
    2212                 :           6 :     return fragment.m_start;
    2213                 :             :   }
    2214                 :             : };
    2215                 :             : 
    2216                 :             : /* Given ARG, an unrecognized sanitizer option, return the best
    2217                 :             :    matching sanitizer option, or NULL if there isn't one.
    2218                 :             :    OPTS is array of candidate sanitizer options.
    2219                 :             :    CODE is OPT_fsanitize_, OPT_fsanitize_recover_ or OPT_fsanitize_trap_.
    2220                 :             :    VALUE is non-zero for the regular form of the option, zero
    2221                 :             :    for the "no-" form (e.g. "-fno-sanitize-recover=").  */
    2222                 :             : 
    2223                 :             : static const char *
    2224                 :           6 : get_closest_sanitizer_option (const string_fragment &arg,
    2225                 :             :                               const struct sanitizer_opts_s *opts,
    2226                 :             :                               enum opt_code code, int value)
    2227                 :             : {
    2228                 :           6 :   best_match <const string_fragment &, const char*> bm (arg);
    2229                 :         204 :   for (int i = 0; opts[i].name != NULL; ++i)
    2230                 :             :     {
    2231                 :             :       /* -fsanitize=all is not valid, so don't offer it.  */
    2232                 :         198 :       if (code == OPT_fsanitize_
    2233                 :         165 :           && opts[i].flag == ~0U
    2234                 :           5 :           && value)
    2235                 :           4 :         continue;
    2236                 :             : 
    2237                 :             :       /* For -fsanitize-recover= (and not -fno-sanitize-recover=),
    2238                 :             :          don't offer the non-recoverable options.  */
    2239                 :         194 :       if (code == OPT_fsanitize_recover_
    2240                 :          33 :           && !opts[i].can_recover
    2241                 :           5 :           && value)
    2242                 :           5 :         continue;
    2243                 :             : 
    2244                 :             :       /* For -fsanitize-trap= (and not -fno-sanitize-trap=),
    2245                 :             :          don't offer the non-trapping options.  */
    2246                 :         189 :       if (code == OPT_fsanitize_trap_
    2247                 :           0 :           && !opts[i].can_trap
    2248                 :           0 :           && value)
    2249                 :           0 :         continue;
    2250                 :             : 
    2251                 :         189 :       bm.consider (opts[i].name);
    2252                 :             :     }
    2253                 :           6 :   return bm.get_best_meaningful_candidate ();
    2254                 :             : }
    2255                 :             : 
    2256                 :             : /* Parse comma separated sanitizer suboptions from P for option SCODE,
    2257                 :             :    adjust previous FLAGS and return new ones.  If COMPLAIN is false,
    2258                 :             :    don't issue diagnostics.  */
    2259                 :             : 
    2260                 :             : unsigned int
    2261                 :       18710 : parse_sanitizer_options (const char *p, location_t loc, int scode,
    2262                 :             :                          unsigned int flags, int value, bool complain)
    2263                 :             : {
    2264                 :       18710 :   enum opt_code code = (enum opt_code) scode;
    2265                 :             : 
    2266                 :       19643 :   while (*p != 0)
    2267                 :             :     {
    2268                 :       19643 :       size_t len, i;
    2269                 :       19643 :       bool found = false;
    2270                 :       19643 :       const char *comma = strchr (p, ',');
    2271                 :             : 
    2272                 :       19643 :       if (comma == NULL)
    2273                 :       18710 :         len = strlen (p);
    2274                 :             :       else
    2275                 :         933 :         len = comma - p;
    2276                 :       19643 :       if (len == 0)
    2277                 :             :         {
    2278                 :           0 :           p = comma + 1;
    2279                 :           0 :           continue;
    2280                 :             :         }
    2281                 :             : 
    2282                 :             :       /* Check to see if the string matches an option class name.  */
    2283                 :      179344 :       for (i = 0; sanitizer_opts[i].name != NULL; ++i)
    2284                 :      179338 :         if (len == sanitizer_opts[i].len
    2285                 :       28199 :             && memcmp (p, sanitizer_opts[i].name, len) == 0)
    2286                 :             :           {
    2287                 :             :             /* Handle both -fsanitize and -fno-sanitize cases.  */
    2288                 :       19637 :             if (value && sanitizer_opts[i].flag == ~0U)
    2289                 :             :               {
    2290                 :          42 :                 if (code == OPT_fsanitize_)
    2291                 :             :                   {
    2292                 :           3 :                     if (complain)
    2293                 :           3 :                       error_at (loc, "%<-fsanitize=all%> option is not valid");
    2294                 :             :                   }
    2295                 :          39 :                 else if (code == OPT_fsanitize_recover_)
    2296                 :          13 :                   flags |= ~(SANITIZE_THREAD | SANITIZE_LEAK
    2297                 :             :                              | SANITIZE_UNREACHABLE | SANITIZE_RETURN
    2298                 :             :                              | SANITIZE_SHADOW_CALL_STACK);
    2299                 :             :                 else /* if (code == OPT_fsanitize_trap_) */
    2300                 :          26 :                   flags |= (SANITIZE_UNDEFINED
    2301                 :             :                             | SANITIZE_UNDEFINED_NONDEFAULT);
    2302                 :             :               }
    2303                 :       18358 :             else if (value)
    2304                 :             :               {
    2305                 :             :                 /* Do not enable -fsanitize-recover=unreachable and
    2306                 :             :                    -fsanitize-recover=return if -fsanitize-recover=undefined
    2307                 :             :                    is selected.  */
    2308                 :       18358 :                 if (code == OPT_fsanitize_recover_
    2309                 :         404 :                     && sanitizer_opts[i].flag == SANITIZE_UNDEFINED)
    2310                 :          40 :                   flags |= (SANITIZE_UNDEFINED
    2311                 :             :                             & ~(SANITIZE_UNREACHABLE | SANITIZE_RETURN));
    2312                 :       18318 :                 else if (code == OPT_fsanitize_trap_
    2313                 :         176 :                          && sanitizer_opts[i].flag == SANITIZE_VPTR)
    2314                 :           0 :                   error_at (loc, "%<-fsanitize-trap=%s%> is not supported",
    2315                 :             :                             sanitizer_opts[i].name);
    2316                 :             :                 else
    2317                 :       18318 :                   flags |= sanitizer_opts[i].flag;
    2318                 :             :               }
    2319                 :             :             else
    2320                 :             :               {
    2321                 :        1237 :                 flags &= ~sanitizer_opts[i].flag;
    2322                 :             :                 /* Don't always clear SANITIZE_ADDRESS if it was previously
    2323                 :             :                    set: -fsanitize=address -fno-sanitize=kernel-address should
    2324                 :             :                    leave SANITIZE_ADDRESS set.  */
    2325                 :        1237 :                 if (flags & (SANITIZE_KERNEL_ADDRESS | SANITIZE_USER_ADDRESS))
    2326                 :         731 :                   flags |= SANITIZE_ADDRESS;
    2327                 :             :               }
    2328                 :             :             found = true;
    2329                 :             :             break;
    2330                 :             :           }
    2331                 :             : 
    2332                 :       19643 :       if (! found && complain)
    2333                 :             :         {
    2334                 :           6 :           const char *hint
    2335                 :           6 :             = get_closest_sanitizer_option (string_fragment (p, len),
    2336                 :             :                                             sanitizer_opts, code, value);
    2337                 :             : 
    2338                 :           6 :           const char *suffix;
    2339                 :           6 :           if (code == OPT_fsanitize_recover_)
    2340                 :             :             suffix = "-recover";
    2341                 :           5 :           else if (code == OPT_fsanitize_trap_)
    2342                 :             :             suffix = "-trap";
    2343                 :             :           else
    2344                 :           5 :             suffix = "";
    2345                 :             : 
    2346                 :           6 :           if (hint)
    2347                 :           4 :             error_at (loc,
    2348                 :             :                       "unrecognized argument to %<-f%ssanitize%s=%> "
    2349                 :             :                       "option: %q.*s; did you mean %qs?",
    2350                 :             :                       value ? "" : "no-",
    2351                 :             :                       suffix, (int) len, p, hint);
    2352                 :             :           else
    2353                 :           3 :             error_at (loc,
    2354                 :             :                       "unrecognized argument to %<-f%ssanitize%s=%> option: "
    2355                 :             :                       "%q.*s", value ? "" : "no-",
    2356                 :             :                       suffix, (int) len, p);
    2357                 :             :         }
    2358                 :             : 
    2359                 :       19643 :       if (comma == NULL)
    2360                 :             :         break;
    2361                 :         933 :       p = comma + 1;
    2362                 :             :     }
    2363                 :       18710 :   return flags;
    2364                 :             : }
    2365                 :             : 
    2366                 :             : /* Parse string values of no_sanitize attribute passed in VALUE.
    2367                 :             :    Values are separated with comma.  */
    2368                 :             : 
    2369                 :             : unsigned int
    2370                 :         281 : parse_no_sanitize_attribute (char *value)
    2371                 :             : {
    2372                 :         281 :   unsigned int flags = 0;
    2373                 :         281 :   unsigned int i;
    2374                 :         281 :   char *q = strtok (value, ",");
    2375                 :             : 
    2376                 :        1072 :   while (q != NULL)
    2377                 :             :     {
    2378                 :        6128 :       for (i = 0; sanitizer_opts[i].name != NULL; ++i)
    2379                 :        6108 :         if (strcmp (sanitizer_opts[i].name, q) == 0)
    2380                 :             :           {
    2381                 :         490 :             flags |= sanitizer_opts[i].flag;
    2382                 :         490 :             if (sanitizer_opts[i].flag == SANITIZE_UNDEFINED)
    2383                 :          57 :               flags |= SANITIZE_UNDEFINED_NONDEFAULT;
    2384                 :             :             break;
    2385                 :             :           }
    2386                 :             : 
    2387                 :         510 :       if (sanitizer_opts[i].name == NULL)
    2388                 :          20 :         warning (OPT_Wattributes,
    2389                 :             :                  "%qs attribute directive ignored", q);
    2390                 :             : 
    2391                 :         510 :       q = strtok (NULL, ",");
    2392                 :             :     }
    2393                 :             : 
    2394                 :         281 :   return flags;
    2395                 :             : }
    2396                 :             : 
    2397                 :             : /* Parse -fzero-call-used-regs suboptions from ARG, return the FLAGS.  */
    2398                 :             : 
    2399                 :             : unsigned int
    2400                 :          77 : parse_zero_call_used_regs_options (const char *arg)
    2401                 :             : {
    2402                 :          77 :   unsigned int flags = 0;
    2403                 :             : 
    2404                 :             :   /* Check to see if the string matches a sub-option name.  */
    2405                 :         459 :   for (unsigned int i = 0; zero_call_used_regs_opts[i].name != NULL; ++i)
    2406                 :         459 :     if (strcmp (arg, zero_call_used_regs_opts[i].name) == 0)
    2407                 :             :       {
    2408                 :          77 :         flags = zero_call_used_regs_opts[i].flag;
    2409                 :          77 :         break;
    2410                 :             :       }
    2411                 :             : 
    2412                 :          77 :   if (!flags)
    2413                 :           0 :     error ("unrecognized argument to %<-fzero-call-used-regs=%>: %qs", arg);
    2414                 :             : 
    2415                 :          77 :   return flags;
    2416                 :             : }
    2417                 :             : 
    2418                 :             : /* Parse -falign-NAME format for a FLAG value.  Return individual
    2419                 :             :    parsed integer values into RESULT_VALUES array.  If REPORT_ERROR is
    2420                 :             :    set, print error message at LOC location.  */
    2421                 :             : 
    2422                 :             : bool
    2423                 :      351607 : parse_and_check_align_values (const char *flag,
    2424                 :             :                               const char *name,
    2425                 :             :                               auto_vec<unsigned> &result_values,
    2426                 :             :                               bool report_error,
    2427                 :             :                               location_t loc)
    2428                 :             : {
    2429                 :      351607 :   char *str = xstrdup (flag);
    2430                 :     1172014 :   for (char *p = strtok (str, ":"); p; p = strtok (NULL, ":"))
    2431                 :             :     {
    2432                 :      820407 :       char *end;
    2433                 :      820407 :       int v = strtol (p, &end, 10);
    2434                 :      820407 :       if (*end != '\0' || v < 0)
    2435                 :             :         {
    2436                 :           0 :           if (report_error)
    2437                 :           0 :             error_at (loc, "invalid arguments for %<-falign-%s%> option: %qs",
    2438                 :             :                       name, flag);
    2439                 :             : 
    2440                 :           0 :           return false;
    2441                 :             :         }
    2442                 :             : 
    2443                 :      820407 :       result_values.safe_push ((unsigned)v);
    2444                 :             :     }
    2445                 :             : 
    2446                 :      351607 :   free (str);
    2447                 :             : 
    2448                 :             :   /* Check that we have a correct number of values.  */
    2449                 :      703214 :   if (result_values.is_empty () || result_values.length () > 4)
    2450                 :             :     {
    2451                 :           0 :       if (report_error)
    2452                 :           0 :         error_at (loc, "invalid number of arguments for %<-falign-%s%> "
    2453                 :             :                   "option: %qs", name, flag);
    2454                 :           0 :       return false;
    2455                 :             :     }
    2456                 :             : 
    2457                 :     1172013 :   for (unsigned i = 0; i < result_values.length (); i++)
    2458                 :      820407 :     if (result_values[i] > MAX_CODE_ALIGN_VALUE)
    2459                 :             :       {
    2460                 :           1 :         if (report_error)
    2461                 :           1 :           error_at (loc, "%<-falign-%s%> is not between 0 and %d",
    2462                 :             :                     name, MAX_CODE_ALIGN_VALUE);
    2463                 :           1 :         return false;
    2464                 :             :       }
    2465                 :             : 
    2466                 :             :   return true;
    2467                 :             : }
    2468                 :             : 
    2469                 :             : /* Check that alignment value FLAG for -falign-NAME is valid at a given
    2470                 :             :    location LOC. OPT_STR points to the stored -falign-NAME=argument and
    2471                 :             :    OPT_FLAG points to the associated -falign-NAME on/off flag.  */
    2472                 :             : 
    2473                 :             : static void
    2474                 :          20 : check_alignment_argument (location_t loc, const char *flag, const char *name,
    2475                 :             :                           int *opt_flag, const char **opt_str)
    2476                 :             : {
    2477                 :          20 :   auto_vec<unsigned> align_result;
    2478                 :          20 :   parse_and_check_align_values (flag, name, align_result, true, loc);
    2479                 :             : 
    2480                 :          40 :   if (align_result.length() >= 1 && align_result[0] == 0)
    2481                 :             :     {
    2482                 :           0 :       *opt_flag = 1;
    2483                 :           0 :       *opt_str = NULL;
    2484                 :             :     }
    2485                 :          20 : }
    2486                 :             : 
    2487                 :             : /* Parse argument of -fpatchable-function-entry option ARG and store
    2488                 :             :    corresponding values to PATCH_AREA_SIZE and PATCH_AREA_START.
    2489                 :             :    If REPORT_ERROR is set to true, generate error for a problematic
    2490                 :             :    option arguments.  */
    2491                 :             : 
    2492                 :             : void
    2493                 :     1735642 : parse_and_check_patch_area (const char *arg, bool report_error,
    2494                 :             :                             HOST_WIDE_INT *patch_area_size,
    2495                 :             :                             HOST_WIDE_INT *patch_area_start)
    2496                 :             : {
    2497                 :     1735642 :   *patch_area_size = 0;
    2498                 :     1735642 :   *patch_area_start = 0;
    2499                 :             : 
    2500                 :     1735642 :   if (arg == NULL)
    2501                 :             :     return;
    2502                 :             : 
    2503                 :         115 :   char *patch_area_arg = xstrdup (arg);
    2504                 :         115 :   char *comma = strchr (patch_area_arg, ',');
    2505                 :         115 :   if (comma)
    2506                 :             :     {
    2507                 :          52 :       *comma = '\0';
    2508                 :          52 :       *patch_area_size = integral_argument (patch_area_arg);
    2509                 :          52 :       *patch_area_start = integral_argument (comma + 1);
    2510                 :             :     }
    2511                 :             :   else
    2512                 :          63 :     *patch_area_size = integral_argument (patch_area_arg);
    2513                 :             : 
    2514                 :         115 :   if (*patch_area_size < 0
    2515                 :         115 :       || *patch_area_size > USHRT_MAX
    2516                 :         107 :       || *patch_area_start < 0
    2517                 :         107 :       || *patch_area_start > USHRT_MAX
    2518                 :          99 :       || *patch_area_size < *patch_area_start)
    2519                 :          16 :     if (report_error)
    2520                 :           8 :       error ("invalid arguments for %<-fpatchable-function-entry%>");
    2521                 :             : 
    2522                 :         115 :   free (patch_area_arg);
    2523                 :             : }
    2524                 :             : 
    2525                 :             : /* Print options enabled by -fhardened.  Keep this in sync with the manual!  */
    2526                 :             : 
    2527                 :             : static void
    2528                 :           1 : print_help_hardened ()
    2529                 :             : {
    2530                 :           1 :   printf ("%s\n", "The following options are enabled by -fhardened:");
    2531                 :             :   /* Unfortunately, I can't seem to use targetm.fortify_source_default_level
    2532                 :             :      here.  */
    2533                 :           1 :   printf ("  %s\n", "-D_FORTIFY_SOURCE=3 (or =2 for glibc < 2.35)");
    2534                 :           1 :   printf ("  %s\n", "-D_GLIBCXX_ASSERTIONS");
    2535                 :           1 :   printf ("  %s\n", "-ftrivial-auto-var-init=zero");
    2536                 :             : #ifdef HAVE_LD_PIE
    2537                 :           1 :   printf ("  %s  %s\n", "-fPIE", "-pie");
    2538                 :             : #endif
    2539                 :           1 :   if (HAVE_LD_NOW_SUPPORT)
    2540                 :           1 :     printf ("  %s\n", "-Wl,-z,now");
    2541                 :           1 :   if (HAVE_LD_RELRO_SUPPORT)
    2542                 :           1 :     printf ("  %s\n", "-Wl,-z,relro");
    2543                 :           1 :   printf ("  %s\n", "-fstack-protector-strong");
    2544                 :           1 :   printf ("  %s\n", "-fstack-clash-protection");
    2545                 :           1 :   printf ("  %s\n", "-fcf-protection=full");
    2546                 :           1 :   putchar ('\n');
    2547                 :           1 : }
    2548                 :             : 
    2549                 :             : /* Print help when OPT__help_ is set.  */
    2550                 :             : 
    2551                 :             : void
    2552                 :          98 : print_help (struct gcc_options *opts, unsigned int lang_mask,
    2553                 :             :             const char *help_option_argument)
    2554                 :             : {
    2555                 :          98 :   const char *a = help_option_argument;
    2556                 :          98 :   unsigned int include_flags = 0;
    2557                 :             :   /* Note - by default we include undocumented options when listing
    2558                 :             :      specific classes.  If you only want to see documented options
    2559                 :             :      then add ",^undocumented" to the --help= option.  E.g.:
    2560                 :             : 
    2561                 :             :      --help=target,^undocumented  */
    2562                 :          98 :   unsigned int exclude_flags = 0;
    2563                 :             : 
    2564                 :          98 :   if (lang_mask == CL_DRIVER)
    2565                 :           0 :     return;
    2566                 :             : 
    2567                 :             :   /* Walk along the argument string, parsing each word in turn.
    2568                 :             :      The format is:
    2569                 :             :      arg = [^]{word}[,{arg}]
    2570                 :             :      word = {optimizers|target|warnings|undocumented|
    2571                 :             :      params|common|<language>}  */
    2572                 :         108 :   while (*a != 0)
    2573                 :             :     {
    2574                 :         108 :       static const struct
    2575                 :             :         {
    2576                 :             :           const char *string;
    2577                 :             :           unsigned int flag;
    2578                 :             :         }
    2579                 :             :       specifics[] =
    2580                 :             :         {
    2581                 :             :             { "optimizers", CL_OPTIMIZATION },
    2582                 :             :             { "target", CL_TARGET },
    2583                 :             :             { "warnings", CL_WARNING },
    2584                 :             :             { "undocumented", CL_UNDOCUMENTED },
    2585                 :             :             { "params", CL_PARAMS },
    2586                 :             :             { "joined", CL_JOINED },
    2587                 :             :             { "separate", CL_SEPARATE },
    2588                 :             :             { "common", CL_COMMON },
    2589                 :             :             { NULL, 0 }
    2590                 :             :         };
    2591                 :         108 :       unsigned int *pflags;
    2592                 :         108 :       const char *comma;
    2593                 :         108 :       unsigned int lang_flag, specific_flag;
    2594                 :         108 :       unsigned int len;
    2595                 :         108 :       unsigned int i;
    2596                 :             : 
    2597                 :         108 :       if (*a == '^')
    2598                 :             :         {
    2599                 :           8 :           ++a;
    2600                 :           8 :           if (*a == '\0')
    2601                 :             :             {
    2602                 :           1 :               error ("missing argument to %qs", "--help=^");
    2603                 :           1 :               break;
    2604                 :             :             }
    2605                 :             :           pflags = &exclude_flags;
    2606                 :             :         }
    2607                 :             :       else
    2608                 :             :         pflags = &include_flags;
    2609                 :             : 
    2610                 :         107 :       comma = strchr (a, ',');
    2611                 :         107 :       if (comma == NULL)
    2612                 :          97 :         len = strlen (a);
    2613                 :             :       else
    2614                 :          10 :         len = comma - a;
    2615                 :         107 :       if (len == 0)
    2616                 :             :         {
    2617                 :           0 :           a = comma + 1;
    2618                 :           0 :           continue;
    2619                 :             :         }
    2620                 :             : 
    2621                 :             :       /* Check to see if the string matches an option class name.  */
    2622                 :         530 :       for (i = 0, specific_flag = 0; specifics[i].string != NULL; i++)
    2623                 :         523 :         if (strncasecmp (a, specifics[i].string, len) == 0)
    2624                 :             :           {
    2625                 :         100 :             specific_flag = specifics[i].flag;
    2626                 :         100 :             break;
    2627                 :             :           }
    2628                 :             : 
    2629                 :             :       /* Check to see if the string matches a language name.
    2630                 :             :          Note - we rely upon the alpha-sorted nature of the entries in
    2631                 :             :          the lang_names array, specifically that shorter names appear
    2632                 :             :          before their longer variants.  (i.e. C before C++).  That way
    2633                 :             :          when we are attempting to match --help=c for example we will
    2634                 :             :          match with C first and not C++.  */
    2635                 :        1627 :       for (i = 0, lang_flag = 0; i < cl_lang_count; i++)
    2636                 :        1528 :         if (strncasecmp (a, lang_names[i], len) == 0)
    2637                 :             :           {
    2638                 :           8 :             lang_flag = 1U << i;
    2639                 :           8 :             break;
    2640                 :             :           }
    2641                 :             : 
    2642                 :         107 :       if (specific_flag != 0)
    2643                 :             :         {
    2644                 :         100 :           if (lang_flag == 0)
    2645                 :          98 :             *pflags |= specific_flag;
    2646                 :             :           else
    2647                 :             :             {
    2648                 :             :               /* The option's argument matches both the start of a
    2649                 :             :                  language name and the start of an option class name.
    2650                 :             :                  We have a special case for when the user has
    2651                 :             :                  specified "--help=c", but otherwise we have to issue
    2652                 :             :                  a warning.  */
    2653                 :           2 :               if (strncasecmp (a, "c", len) == 0)
    2654                 :           2 :                 *pflags |= lang_flag;
    2655                 :             :               else
    2656                 :           0 :                 warning (0,
    2657                 :             :                          "%<--help%> argument %q.*s is ambiguous, "
    2658                 :             :                          "please be more specific",
    2659                 :             :                          len, a);
    2660                 :             :             }
    2661                 :             :         }
    2662                 :           7 :       else if (lang_flag != 0)
    2663                 :           6 :         *pflags |= lang_flag;
    2664                 :           1 :       else if (strncasecmp (a, "hardened", len) == 0)
    2665                 :           1 :         print_help_hardened ();
    2666                 :             :       else
    2667                 :           0 :         warning (0,
    2668                 :             :                  "unrecognized argument to %<--help=%> option: %q.*s",
    2669                 :             :                  len, a);
    2670                 :             : 
    2671                 :         107 :       if (comma == NULL)
    2672                 :             :         break;
    2673                 :          10 :       a = comma + 1;
    2674                 :             :     }
    2675                 :             : 
    2676                 :             :   /* We started using PerFunction/Optimization for parameters and
    2677                 :             :      a warning.  We should exclude these from optimization options.  */
    2678                 :          98 :   if (include_flags & CL_OPTIMIZATION)
    2679                 :           7 :     exclude_flags |= CL_WARNING;
    2680                 :          98 :   if (!(include_flags & CL_PARAMS))
    2681                 :          38 :     exclude_flags |= CL_PARAMS;
    2682                 :             : 
    2683                 :          98 :   if (include_flags)
    2684                 :          94 :     print_specific_help (include_flags, exclude_flags, 0, opts,
    2685                 :             :                          lang_mask);
    2686                 :             : }
    2687                 :             : 
    2688                 :             : /* Handle target- and language-independent options.  Return zero to
    2689                 :             :    generate an "unknown option" message.  Only options that need
    2690                 :             :    extra handling need to be listed here; if you simply want
    2691                 :             :    DECODED->value assigned to a variable, it happens automatically.  */
    2692                 :             : 
    2693                 :             : bool
    2694                 :    78400029 : common_handle_option (struct gcc_options *opts,
    2695                 :             :                       struct gcc_options *opts_set,
    2696                 :             :                       const struct cl_decoded_option *decoded,
    2697                 :             :                       unsigned int lang_mask, int kind ATTRIBUTE_UNUSED,
    2698                 :             :                       location_t loc,
    2699                 :             :                       const struct cl_option_handlers *handlers,
    2700                 :             :                       diagnostic_context *dc,
    2701                 :             :                       void (*target_option_override_hook) (void))
    2702                 :             : {
    2703                 :    78400029 :   size_t scode = decoded->opt_index;
    2704                 :    78400029 :   const char *arg = decoded->arg;
    2705                 :    78400029 :   HOST_WIDE_INT value = decoded->value;
    2706                 :    78400029 :   enum opt_code code = (enum opt_code) scode;
    2707                 :             : 
    2708                 :    78400029 :   gcc_assert (decoded->canonical_option_num_elements <= 2);
    2709                 :             : 
    2710                 :    78400029 :   switch (code)
    2711                 :             :     {
    2712                 :           7 :     case OPT__help:
    2713                 :           7 :       {
    2714                 :           7 :         unsigned int all_langs_mask = (1U << cl_lang_count) - 1;
    2715                 :           7 :         unsigned int undoc_mask;
    2716                 :           7 :         unsigned int i;
    2717                 :             : 
    2718                 :           7 :         if (lang_mask == CL_DRIVER)
    2719                 :             :           break;
    2720                 :             : 
    2721                 :           0 :         undoc_mask = ((opts->x_verbose_flag | opts->x_extra_warnings)
    2722                 :           3 :                       ? 0
    2723                 :             :                       : CL_UNDOCUMENTED);
    2724                 :           3 :         target_option_override_hook ();
    2725                 :             :         /* First display any single language specific options.  */
    2726                 :          51 :         for (i = 0; i < cl_lang_count; i++)
    2727                 :          45 :           print_specific_help
    2728                 :          45 :             (1U << i, (all_langs_mask & (~ (1U << i))) | undoc_mask, 0, opts,
    2729                 :             :              lang_mask);
    2730                 :             :         /* Next display any multi language specific options.  */
    2731                 :           3 :         print_specific_help (0, undoc_mask, all_langs_mask, opts, lang_mask);
    2732                 :             :         /* Then display any remaining, non-language options.  */
    2733                 :          24 :         for (i = CL_MIN_OPTION_CLASS; i <= CL_MAX_OPTION_CLASS; i <<= 1)
    2734                 :          18 :           if (i != CL_DRIVER)
    2735                 :          15 :             print_specific_help (i, undoc_mask, 0, opts, lang_mask);
    2736                 :           3 :         opts->x_exit_after_options = true;
    2737                 :           3 :         break;
    2738                 :             :       }
    2739                 :             : 
    2740                 :           0 :     case OPT__target_help:
    2741                 :           0 :       if (lang_mask == CL_DRIVER)
    2742                 :             :         break;
    2743                 :             : 
    2744                 :           0 :       target_option_override_hook ();
    2745                 :           0 :       print_specific_help (CL_TARGET, 0, 0, opts, lang_mask);
    2746                 :           0 :       opts->x_exit_after_options = true;
    2747                 :           0 :       break;
    2748                 :             : 
    2749                 :         196 :     case OPT__help_:
    2750                 :         196 :       {
    2751                 :         196 :         help_option_arguments.safe_push (arg);
    2752                 :         196 :         opts->x_exit_after_options = true;
    2753                 :         196 :         break;
    2754                 :             :       }
    2755                 :             : 
    2756                 :          78 :     case OPT__version:
    2757                 :          78 :       if (lang_mask == CL_DRIVER)
    2758                 :             :         break;
    2759                 :             : 
    2760                 :           0 :       opts->x_exit_after_options = true;
    2761                 :           0 :       break;
    2762                 :             : 
    2763                 :             :     case OPT__completion_:
    2764                 :             :       break;
    2765                 :             : 
    2766                 :       17461 :     case OPT_fsanitize_:
    2767                 :       17461 :       opts_set->x_flag_sanitize = true;
    2768                 :       17461 :       opts->x_flag_sanitize
    2769                 :       17461 :         = parse_sanitizer_options (arg, loc, code,
    2770                 :             :                                    opts->x_flag_sanitize, value, true);
    2771                 :             : 
    2772                 :             :       /* Kernel ASan implies normal ASan but does not yet support
    2773                 :             :          all features.  */
    2774                 :       17461 :       if (opts->x_flag_sanitize & SANITIZE_KERNEL_ADDRESS)
    2775                 :             :         {
    2776                 :         366 :           SET_OPTION_IF_UNSET (opts, opts_set,
    2777                 :             :                                param_asan_instrumentation_with_call_threshold,
    2778                 :             :                                0);
    2779                 :         366 :           SET_OPTION_IF_UNSET (opts, opts_set, param_asan_globals, 0);
    2780                 :         366 :           SET_OPTION_IF_UNSET (opts, opts_set, param_asan_stack, 0);
    2781                 :         366 :           SET_OPTION_IF_UNSET (opts, opts_set, param_asan_protect_allocas, 0);
    2782                 :         366 :           SET_OPTION_IF_UNSET (opts, opts_set, param_asan_use_after_return, 0);
    2783                 :             :         }
    2784                 :       17461 :       if (opts->x_flag_sanitize & SANITIZE_KERNEL_HWADDRESS)
    2785                 :             :         {
    2786                 :          56 :           SET_OPTION_IF_UNSET (opts, opts_set,
    2787                 :             :                                param_hwasan_instrument_stack, 0);
    2788                 :          56 :           SET_OPTION_IF_UNSET (opts, opts_set,
    2789                 :             :                                param_hwasan_random_frame_tag, 0);
    2790                 :          56 :           SET_OPTION_IF_UNSET (opts, opts_set,
    2791                 :             :                                param_hwasan_instrument_allocas, 0);
    2792                 :             :         }
    2793                 :             :       break;
    2794                 :             : 
    2795                 :        1047 :     case OPT_fsanitize_recover_:
    2796                 :        1047 :       opts->x_flag_sanitize_recover
    2797                 :        1047 :         = parse_sanitizer_options (arg, loc, code,
    2798                 :             :                                    opts->x_flag_sanitize_recover, value, true);
    2799                 :        1047 :       break;
    2800                 :             : 
    2801                 :         202 :     case OPT_fsanitize_trap_:
    2802                 :         202 :       opts->x_flag_sanitize_trap
    2803                 :         202 :         = parse_sanitizer_options (arg, loc, code,
    2804                 :             :                                    opts->x_flag_sanitize_trap, value, true);
    2805                 :         202 :       break;
    2806                 :             : 
    2807                 :             :     case OPT_fasan_shadow_offset_:
    2808                 :             :       /* Deferred.  */
    2809                 :             :       break;
    2810                 :             : 
    2811                 :          68 :     case OPT_fsanitize_address_use_after_scope:
    2812                 :          68 :       opts->x_flag_sanitize_address_use_after_scope = value;
    2813                 :          68 :       break;
    2814                 :             : 
    2815                 :           6 :     case OPT_fsanitize_recover:
    2816                 :           6 :       if (value)
    2817                 :           0 :         opts->x_flag_sanitize_recover
    2818                 :           0 :           |= (SANITIZE_UNDEFINED | SANITIZE_UNDEFINED_NONDEFAULT)
    2819                 :             :              & ~(SANITIZE_UNREACHABLE | SANITIZE_RETURN);
    2820                 :             :       else
    2821                 :           6 :         opts->x_flag_sanitize_recover
    2822                 :           6 :           &= ~(SANITIZE_UNDEFINED | SANITIZE_UNDEFINED_NONDEFAULT);
    2823                 :             :       break;
    2824                 :             : 
    2825                 :         236 :     case OPT_fsanitize_trap:
    2826                 :         236 :       if (value)
    2827                 :         236 :         opts->x_flag_sanitize_trap
    2828                 :         236 :           |= (SANITIZE_UNDEFINED | SANITIZE_UNDEFINED_NONDEFAULT);
    2829                 :             :       else
    2830                 :           0 :         opts->x_flag_sanitize_trap
    2831                 :           0 :           &= ~(SANITIZE_UNDEFINED | SANITIZE_UNDEFINED_NONDEFAULT);
    2832                 :             :       break;
    2833                 :             : 
    2834                 :             :     case OPT_O:
    2835                 :             :     case OPT_Os:
    2836                 :             :     case OPT_Ofast:
    2837                 :             :     case OPT_Og:
    2838                 :             :     case OPT_Oz:
    2839                 :             :       /* Currently handled in a prescan.  */
    2840                 :             :       break;
    2841                 :             : 
    2842                 :         100 :     case OPT_Wattributes_:
    2843                 :         100 :       if (lang_mask == CL_DRIVER)
    2844                 :             :         break;
    2845                 :             : 
    2846                 :         100 :       if (value)
    2847                 :             :         {
    2848                 :           0 :           error_at (loc, "arguments ignored for %<-Wattributes=%>; use "
    2849                 :             :                     "%<-Wno-attributes=%> instead");
    2850                 :           0 :           break;
    2851                 :             :         }
    2852                 :         100 :       else if (arg[strlen (arg) - 1] == ',')
    2853                 :             :         {
    2854                 :           0 :           error_at (loc, "trailing %<,%> in arguments for "
    2855                 :             :                     "%<-Wno-attributes=%>");
    2856                 :           0 :           break;
    2857                 :             :         }
    2858                 :             : 
    2859                 :         100 :       add_comma_separated_to_vector (&opts->x_flag_ignored_attributes, arg);
    2860                 :         100 :       break;
    2861                 :             : 
    2862                 :        4330 :     case OPT_Werror:
    2863                 :        4330 :       dc->set_warning_as_error_requested (value);
    2864                 :        4330 :       break;
    2865                 :             : 
    2866                 :        7031 :     case OPT_Werror_:
    2867                 :        7031 :       if (lang_mask == CL_DRIVER)
    2868                 :             :         break;
    2869                 :             : 
    2870                 :        7031 :       enable_warning_as_error (arg, value, lang_mask, handlers,
    2871                 :             :                                opts, opts_set, loc, dc);
    2872                 :        7031 :       break;
    2873                 :             : 
    2874                 :           9 :     case OPT_Wfatal_errors:
    2875                 :           9 :       dc->m_fatal_errors = value;
    2876                 :           9 :       break;
    2877                 :             : 
    2878                 :          12 :     case OPT_Wstack_usage_:
    2879                 :          12 :       opts->x_flag_stack_usage_info = value != -1;
    2880                 :          12 :       break;
    2881                 :             : 
    2882                 :          57 :     case OPT_Wstrict_aliasing:
    2883                 :          57 :       set_Wstrict_aliasing (opts, value);
    2884                 :          57 :       break;
    2885                 :             : 
    2886                 :          15 :     case OPT_Wstrict_overflow:
    2887                 :          30 :       opts->x_warn_strict_overflow = (value
    2888                 :          15 :                                       ? (int) WARN_STRICT_OVERFLOW_CONDITIONAL
    2889                 :             :                                       : 0);
    2890                 :          15 :       break;
    2891                 :             : 
    2892                 :          33 :     case OPT_Wsystem_headers:
    2893                 :          33 :       dc->m_warn_system_headers = value;
    2894                 :          33 :       break;
    2895                 :             : 
    2896                 :           0 :     case OPT_aux_info:
    2897                 :           0 :       opts->x_flag_gen_aux_info = 1;
    2898                 :           0 :       break;
    2899                 :             : 
    2900                 :        1602 :     case OPT_d:
    2901                 :        1602 :       decode_d_option (arg, opts, loc, dc);
    2902                 :        1602 :       break;
    2903                 :             : 
    2904                 :             :     case OPT_fcall_used_:
    2905                 :             :     case OPT_fcall_saved_:
    2906                 :             :       /* Deferred.  */
    2907                 :             :       break;
    2908                 :             : 
    2909                 :             :     case OPT_fdbg_cnt_:
    2910                 :             :       /* Deferred.  */
    2911                 :             :       break;
    2912                 :             : 
    2913                 :             :     case OPT_fdebug_prefix_map_:
    2914                 :             :     case OPT_ffile_prefix_map_:
    2915                 :             :     case OPT_fprofile_prefix_map_:
    2916                 :             :       /* Deferred.  */
    2917                 :             :       break;
    2918                 :             : 
    2919                 :           0 :     case OPT_fcanon_prefix_map:
    2920                 :           0 :       flag_canon_prefix_map = value;
    2921                 :           0 :       break;
    2922                 :             : 
    2923                 :           1 :     case OPT_fcallgraph_info:
    2924                 :           1 :       opts->x_flag_callgraph_info = CALLGRAPH_INFO_NAKED;
    2925                 :           1 :       break;
    2926                 :             : 
    2927                 :           0 :     case OPT_fcallgraph_info_:
    2928                 :           0 :       {
    2929                 :           0 :         char *my_arg, *p;
    2930                 :           0 :         my_arg = xstrdup (arg);
    2931                 :           0 :         p = strtok (my_arg, ",");
    2932                 :           0 :         while (p)
    2933                 :             :           {
    2934                 :           0 :             if (strcmp (p, "su") == 0)
    2935                 :             :               {
    2936                 :           0 :                 opts->x_flag_callgraph_info |= CALLGRAPH_INFO_STACK_USAGE;
    2937                 :           0 :                 opts->x_flag_stack_usage_info = true;
    2938                 :             :               }
    2939                 :           0 :             else if (strcmp (p, "da") == 0)
    2940                 :           0 :               opts->x_flag_callgraph_info |= CALLGRAPH_INFO_DYNAMIC_ALLOC;
    2941                 :             :             else
    2942                 :             :               return 0;
    2943                 :           0 :             p = strtok (NULL, ",");
    2944                 :             :           }
    2945                 :           0 :         free (my_arg);
    2946                 :             :       }
    2947                 :           0 :       break;
    2948                 :             : 
    2949                 :         418 :     case OPT_fdiagnostics_show_location_:
    2950                 :         418 :       dc->set_prefixing_rule ((diagnostic_prefixing_rule_t) value);
    2951                 :         418 :       break;
    2952                 :             : 
    2953                 :      265981 :     case OPT_fdiagnostics_show_caret:
    2954                 :      265981 :       dc->m_source_printing.enabled = value;
    2955                 :      265981 :       break;
    2956                 :             : 
    2957                 :      265981 :     case OPT_fdiagnostics_show_event_links:
    2958                 :      265981 :       dc->m_source_printing.show_event_links_p = value;
    2959                 :      265981 :       break;
    2960                 :             : 
    2961                 :           1 :     case OPT_fdiagnostics_show_labels:
    2962                 :           1 :       dc->m_source_printing.show_labels_p = value;
    2963                 :           1 :       break;
    2964                 :             : 
    2965                 :      265981 :     case OPT_fdiagnostics_show_line_numbers:
    2966                 :      265981 :       dc->m_source_printing.show_line_numbers_p = value;
    2967                 :      265981 :       break;
    2968                 :             : 
    2969                 :      531722 :     case OPT_fdiagnostics_color_:
    2970                 :      531722 :       diagnostic_color_init (dc, value);
    2971                 :      531722 :       break;
    2972                 :             : 
    2973                 :      525226 :     case OPT_fdiagnostics_urls_:
    2974                 :      525226 :       diagnostic_urls_init (dc, value);
    2975                 :      525226 :       break;
    2976                 :             : 
    2977                 :         133 :     case OPT_fdiagnostics_format_:
    2978                 :         133 :         {
    2979                 :         133 :           const char *basename = (opts->x_dump_base_name ? opts->x_dump_base_name
    2980                 :             :                                   : opts->x_main_input_basename);
    2981                 :         133 :           gcc_assert (dc);
    2982                 :         133 :           diagnostic_output_format_init (*dc,
    2983                 :             :                                          opts->x_main_input_filename, basename,
    2984                 :             :                                          (enum diagnostics_output_format)value,
    2985                 :         133 :                                          opts->x_flag_diagnostics_json_formatting);
    2986                 :         133 :           break;
    2987                 :             :         }
    2988                 :             : 
    2989                 :          11 :     case OPT_fdiagnostics_add_output_:
    2990                 :          11 :       handle_OPT_fdiagnostics_add_output_ (*opts, *dc, arg, loc);
    2991                 :          11 :       break;
    2992                 :             : 
    2993                 :          14 :     case OPT_fdiagnostics_set_output_:
    2994                 :          14 :       handle_OPT_fdiagnostics_set_output_ (*opts, *dc, arg, loc);
    2995                 :          14 :       break;
    2996                 :             : 
    2997                 :      584903 :     case OPT_fdiagnostics_text_art_charset_:
    2998                 :      584903 :       dc->set_text_art_charset ((enum diagnostic_text_art_charset)value);
    2999                 :      584903 :       break;
    3000                 :             : 
    3001                 :           4 :     case OPT_fdiagnostics_parseable_fixits:
    3002                 :           4 :       dc->set_extra_output_kind (value
    3003                 :             :                                  ? EXTRA_DIAGNOSTIC_OUTPUT_fixits_v1
    3004                 :             :                                  : EXTRA_DIAGNOSTIC_OUTPUT_none);
    3005                 :           4 :       break;
    3006                 :             : 
    3007                 :          28 :     case OPT_fdiagnostics_column_unit_:
    3008                 :          28 :       dc->m_column_unit = (enum diagnostics_column_unit)value;
    3009                 :          28 :       break;
    3010                 :             : 
    3011                 :          12 :     case OPT_fdiagnostics_column_origin_:
    3012                 :          12 :       dc->m_column_origin = value;
    3013                 :          12 :       break;
    3014                 :             : 
    3015                 :           4 :     case OPT_fdiagnostics_escape_format_:
    3016                 :           4 :       dc->set_escape_format ((enum diagnostics_escape_format)value);
    3017                 :           4 :       break;
    3018                 :             : 
    3019                 :           5 :     case OPT_fdiagnostics_show_highlight_colors:
    3020                 :           5 :       dc->set_show_highlight_colors (value);
    3021                 :           5 :       break;
    3022                 :             : 
    3023                 :           0 :     case OPT_fdiagnostics_show_cwe:
    3024                 :           0 :       dc->set_show_cwe (value);
    3025                 :           0 :       break;
    3026                 :             : 
    3027                 :           0 :     case OPT_fdiagnostics_show_rules:
    3028                 :           0 :       dc->set_show_rules (value);
    3029                 :           0 :       break;
    3030                 :             : 
    3031                 :      295708 :     case OPT_fdiagnostics_path_format_:
    3032                 :      295708 :       dc->set_path_format ((enum diagnostic_path_format)value);
    3033                 :      295708 :       break;
    3034                 :             : 
    3035                 :          76 :     case OPT_fdiagnostics_show_path_depths:
    3036                 :          76 :       dc->set_show_path_depths (value);
    3037                 :          76 :       break;
    3038                 :             : 
    3039                 :          54 :     case OPT_fdiagnostics_show_option:
    3040                 :          54 :       dc->set_show_option_requested (value);
    3041                 :          54 :       break;
    3042                 :             : 
    3043                 :           1 :     case OPT_fdiagnostics_minimum_margin_width_:
    3044                 :           1 :       dc->m_source_printing.min_margin_width = value;
    3045                 :           1 :       break;
    3046                 :             : 
    3047                 :             :     case OPT_fdump_:
    3048                 :             :       /* Deferred.  */
    3049                 :             :       break;
    3050                 :             : 
    3051                 :      614122 :     case OPT_ffast_math:
    3052                 :      614122 :       set_fast_math_flags (opts, value);
    3053                 :      614122 :       break;
    3054                 :             : 
    3055                 :         366 :     case OPT_funsafe_math_optimizations:
    3056                 :         366 :       set_unsafe_math_optimizations_flags (opts, value);
    3057                 :         366 :       break;
    3058                 :             : 
    3059                 :             :     case OPT_ffixed_:
    3060                 :             :       /* Deferred.  */
    3061                 :             :       break;
    3062                 :             : 
    3063                 :           9 :     case OPT_finline_limit_:
    3064                 :           9 :       SET_OPTION_IF_UNSET (opts, opts_set, param_max_inline_insns_single,
    3065                 :             :                            value / 2);
    3066                 :           9 :       SET_OPTION_IF_UNSET (opts, opts_set, param_max_inline_insns_auto,
    3067                 :             :                            value / 2);
    3068                 :             :       break;
    3069                 :             : 
    3070                 :           1 :     case OPT_finstrument_functions_exclude_function_list_:
    3071                 :           1 :       add_comma_separated_to_vector
    3072                 :           1 :         (&opts->x_flag_instrument_functions_exclude_functions, arg);
    3073                 :           1 :       break;
    3074                 :             : 
    3075                 :           1 :     case OPT_finstrument_functions_exclude_file_list_:
    3076                 :           1 :       add_comma_separated_to_vector
    3077                 :           1 :         (&opts->x_flag_instrument_functions_exclude_files, arg);
    3078                 :           1 :       break;
    3079                 :             : 
    3080                 :      101666 :     case OPT_fmessage_length_:
    3081                 :      101666 :       pp_set_line_maximum_length (dc->get_reference_printer (), value);
    3082                 :      101666 :       diagnostic_set_caret_max_width (dc, value);
    3083                 :      101666 :       break;
    3084                 :             : 
    3085                 :             :     case OPT_fopt_info:
    3086                 :             :     case OPT_fopt_info_:
    3087                 :             :       /* Deferred.  */
    3088                 :             :       break;
    3089                 :             : 
    3090                 :             :     case OPT_foffload_options_:
    3091                 :             :       /* Deferred.  */
    3092                 :             :       break;
    3093                 :             : 
    3094                 :           0 :     case OPT_foffload_abi_:
    3095                 :           0 :     case OPT_foffload_abi_host_opts_:
    3096                 :             : #ifdef ACCEL_COMPILER
    3097                 :             :       /* Handled in the 'mkoffload's.  */
    3098                 :             : #else
    3099                 :           0 :       error_at (loc,
    3100                 :             :                 "%qs option can be specified only for offload compiler",
    3101                 :             :                 (code == OPT_foffload_abi_) ? "-foffload-abi"
    3102                 :             :                                             : "-foffload-abi-host-opts");
    3103                 :             : #endif
    3104                 :           0 :       break;
    3105                 :             : 
    3106                 :           1 :     case OPT_fpack_struct_:
    3107                 :           1 :       if (value <= 0 || (value & (value - 1)) || value > 16)
    3108                 :           0 :         error_at (loc,
    3109                 :             :                   "structure alignment must be a small power of two, not %wu",
    3110                 :             :                   value);
    3111                 :             :       else
    3112                 :           1 :         opts->x_initial_max_fld_align = value;
    3113                 :             :       break;
    3114                 :             : 
    3115                 :             :     case OPT_fplugin_:
    3116                 :             :     case OPT_fplugin_arg_:
    3117                 :             :       /* Deferred.  */
    3118                 :             :       break;
    3119                 :             : 
    3120                 :           0 :     case OPT_fprofile_use_:
    3121                 :           0 :       opts->x_profile_data_prefix = xstrdup (arg);
    3122                 :           0 :       opts->x_flag_profile_use = true;
    3123                 :           0 :       value = true;
    3124                 :             :       /* No break here - do -fprofile-use processing. */
    3125                 :             :       /* FALLTHRU */
    3126                 :         151 :     case OPT_fprofile_use:
    3127                 :         151 :       enable_fdo_optimizations (opts, opts_set, value);
    3128                 :         151 :       SET_OPTION_IF_UNSET (opts, opts_set, flag_profile_reorder_functions,
    3129                 :             :                            value);
    3130                 :             :         /* Indirect call profiling should do all useful transformations
    3131                 :             :            speculative devirtualization does.  */
    3132                 :         151 :       if (opts->x_flag_value_profile_transformations)
    3133                 :         151 :         SET_OPTION_IF_UNSET (opts, opts_set, flag_devirtualize_speculatively,
    3134                 :             :                              false);
    3135                 :             :       break;
    3136                 :             : 
    3137                 :           0 :     case OPT_fauto_profile_:
    3138                 :           0 :       opts->x_auto_profile_file = xstrdup (arg);
    3139                 :           0 :       opts->x_flag_auto_profile = true;
    3140                 :           0 :       value = true;
    3141                 :             :       /* No break here - do -fauto-profile processing. */
    3142                 :             :       /* FALLTHRU */
    3143                 :           0 :     case OPT_fauto_profile:
    3144                 :           0 :       enable_fdo_optimizations (opts, opts_set, value);
    3145                 :           0 :       SET_OPTION_IF_UNSET (opts, opts_set, flag_profile_correction, value);
    3146                 :             :       break;
    3147                 :             : 
    3148                 :           2 :     case OPT_fprofile_generate_:
    3149                 :           2 :       opts->x_profile_data_prefix = xstrdup (arg);
    3150                 :           2 :       value = true;
    3151                 :             :       /* No break here - do -fprofile-generate processing. */
    3152                 :             :       /* FALLTHRU */
    3153                 :         252 :     case OPT_fprofile_generate:
    3154                 :         252 :       SET_OPTION_IF_UNSET (opts, opts_set, profile_arc_flag, value);
    3155                 :         252 :       SET_OPTION_IF_UNSET (opts, opts_set, flag_profile_values, value);
    3156                 :         252 :       SET_OPTION_IF_UNSET (opts, opts_set, flag_inline_functions, value);
    3157                 :         252 :       SET_OPTION_IF_UNSET (opts, opts_set, flag_ipa_bit_cp, value);
    3158                 :             :       break;
    3159                 :             : 
    3160                 :           2 :     case OPT_fprofile_info_section:
    3161                 :           2 :       opts->x_profile_info_section = ".gcov_info";
    3162                 :           2 :       break;
    3163                 :             : 
    3164                 :          36 :     case OPT_fpatchable_function_entry_:
    3165                 :          36 :       {
    3166                 :          36 :         HOST_WIDE_INT patch_area_size, patch_area_start;
    3167                 :          36 :         parse_and_check_patch_area (arg, true, &patch_area_size,
    3168                 :             :                                     &patch_area_start);
    3169                 :             :       }
    3170                 :          36 :       break;
    3171                 :             : 
    3172                 :             :     case OPT_ftree_vectorize:
    3173                 :             :       /* Automatically sets -ftree-loop-vectorize and
    3174                 :             :          -ftree-slp-vectorize.  Nothing more to do here.  */
    3175                 :             :       break;
    3176                 :          77 :     case OPT_fzero_call_used_regs_:
    3177                 :          77 :       opts->x_flag_zero_call_used_regs
    3178                 :          77 :         = parse_zero_call_used_regs_options (arg);
    3179                 :          77 :       break;
    3180                 :             : 
    3181                 :       12862 :     case OPT_fshow_column:
    3182                 :       12862 :       dc->m_show_column = value;
    3183                 :       12862 :       break;
    3184                 :             : 
    3185                 :           0 :     case OPT_frandom_seed:
    3186                 :             :       /* The real switch is -fno-random-seed.  */
    3187                 :           0 :       if (value)
    3188                 :             :         return false;
    3189                 :             :       /* Deferred.  */
    3190                 :             :       break;
    3191                 :             : 
    3192                 :             :     case OPT_frandom_seed_:
    3193                 :             :       /* Deferred.  */
    3194                 :             :       break;
    3195                 :             : 
    3196                 :             :     case OPT_fsched_verbose_:
    3197                 :             : #ifdef INSN_SCHEDULING
    3198                 :             :       /* Handled with Var in common.opt.  */
    3199                 :             :       break;
    3200                 :             : #else
    3201                 :             :       return false;
    3202                 :             : #endif
    3203                 :             : 
    3204                 :           1 :     case OPT_fsched_stalled_insns_:
    3205                 :           1 :       opts->x_flag_sched_stalled_insns = value;
    3206                 :           1 :       if (opts->x_flag_sched_stalled_insns == 0)
    3207                 :           1 :         opts->x_flag_sched_stalled_insns = -1;
    3208                 :             :       break;
    3209                 :             : 
    3210                 :           0 :     case OPT_fsched_stalled_insns_dep_:
    3211                 :           0 :       opts->x_flag_sched_stalled_insns_dep = value;
    3212                 :           0 :       break;
    3213                 :             : 
    3214                 :          60 :     case OPT_fstack_check_:
    3215                 :          60 :       if (!strcmp (arg, "no"))
    3216                 :           0 :         opts->x_flag_stack_check = NO_STACK_CHECK;
    3217                 :          60 :       else if (!strcmp (arg, "generic"))
    3218                 :             :         /* This is the old stack checking method.  */
    3219                 :          27 :         opts->x_flag_stack_check = STACK_CHECK_BUILTIN
    3220                 :             :                            ? FULL_BUILTIN_STACK_CHECK
    3221                 :             :                            : GENERIC_STACK_CHECK;
    3222                 :          33 :       else if (!strcmp (arg, "specific"))
    3223                 :             :         /* This is the new stack checking method.  */
    3224                 :          33 :         opts->x_flag_stack_check = STACK_CHECK_BUILTIN
    3225                 :             :                            ? FULL_BUILTIN_STACK_CHECK
    3226                 :             :                            : STACK_CHECK_STATIC_BUILTIN
    3227                 :             :                              ? STATIC_BUILTIN_STACK_CHECK
    3228                 :             :                              : GENERIC_STACK_CHECK;
    3229                 :             :       else
    3230                 :           0 :         warning_at (loc, 0, "unknown stack check parameter %qs", arg);
    3231                 :             :       break;
    3232                 :             : 
    3233                 :           1 :     case OPT_fstack_limit:
    3234                 :             :       /* The real switch is -fno-stack-limit.  */
    3235                 :           1 :       if (value)
    3236                 :             :         return false;
    3237                 :             :       /* Deferred.  */
    3238                 :             :       break;
    3239                 :             : 
    3240                 :             :     case OPT_fstack_limit_register_:
    3241                 :             :     case OPT_fstack_limit_symbol_:
    3242                 :             :       /* Deferred.  */
    3243                 :             :       break;
    3244                 :             : 
    3245                 :         558 :     case OPT_fstack_usage:
    3246                 :         558 :       opts->x_flag_stack_usage = value;
    3247                 :         558 :       opts->x_flag_stack_usage_info = value != 0;
    3248                 :         558 :       break;
    3249                 :             : 
    3250                 :      126287 :     case OPT_g:
    3251                 :      126287 :       set_debug_level (NO_DEBUG, DEFAULT_GDB_EXTENSIONS, arg, opts, opts_set,
    3252                 :             :                        loc);
    3253                 :      126287 :       break;
    3254                 :             : 
    3255                 :           0 :     case OPT_gcodeview:
    3256                 :           0 :       set_debug_level (CODEVIEW_DEBUG, false, arg, opts, opts_set, loc);
    3257                 :           0 :       if (opts->x_debug_info_level < DINFO_LEVEL_NORMAL)
    3258                 :           0 :         opts->x_debug_info_level = DINFO_LEVEL_NORMAL;
    3259                 :             :       break;
    3260                 :             : 
    3261                 :         198 :     case OPT_gbtf:
    3262                 :         198 :       set_debug_level (BTF_DEBUG, false, arg, opts, opts_set, loc);
    3263                 :             :       /* set the debug level to level 2, but if already at level 3,
    3264                 :             :          don't lower it.  */
    3265                 :         198 :       if (opts->x_debug_info_level < DINFO_LEVEL_NORMAL)
    3266                 :         198 :         opts->x_debug_info_level = DINFO_LEVEL_NORMAL;
    3267                 :             :       break;
    3268                 :             : 
    3269                 :         717 :     case OPT_gctf:
    3270                 :         717 :       set_debug_level (CTF_DEBUG, false, arg, opts, opts_set, loc);
    3271                 :             :       /* CTF generation feeds off DWARF dies.  For optimal CTF, switch debug
    3272                 :             :          info level to 2.  If off or at level 1, set it to level 2, but if
    3273                 :             :          already at level 3, don't lower it.  */
    3274                 :         717 :       if (opts->x_debug_info_level < DINFO_LEVEL_NORMAL
    3275                 :         711 :           && opts->x_ctf_debug_info_level > CTFINFO_LEVEL_NONE)
    3276                 :         709 :         opts->x_debug_info_level = DINFO_LEVEL_NORMAL;
    3277                 :             :       break;
    3278                 :             : 
    3279                 :         277 :     case OPT_gdwarf:
    3280                 :         277 :       if (arg && strlen (arg) != 0)
    3281                 :             :         {
    3282                 :           0 :           error_at (loc, "%<-gdwarf%s%> is ambiguous; "
    3283                 :             :                     "use %<-gdwarf-%s%> for DWARF version "
    3284                 :             :                     "or %<-gdwarf%> %<-g%s%> for debug level", arg, arg, arg);
    3285                 :           0 :           break;
    3286                 :             :         }
    3287                 :             :       else
    3288                 :         277 :         value = opts->x_dwarf_version;
    3289                 :             : 
    3290                 :             :       /* FALLTHRU */
    3291                 :        4851 :     case OPT_gdwarf_:
    3292                 :        4851 :       if (value < 2 || value > 5)
    3293                 :           0 :         error_at (loc, "dwarf version %wu is not supported", value);
    3294                 :             :       else
    3295                 :        4851 :         opts->x_dwarf_version = value;
    3296                 :        4851 :       set_debug_level (DWARF2_DEBUG, false, "", opts, opts_set, loc);
    3297                 :        4851 :       break;
    3298                 :             : 
    3299                 :          20 :     case OPT_ggdb:
    3300                 :          20 :       set_debug_level (NO_DEBUG, 2, arg, opts, opts_set, loc);
    3301                 :          20 :       break;
    3302                 :             : 
    3303                 :           0 :     case OPT_gvms:
    3304                 :           0 :       set_debug_level (VMS_DEBUG, false, arg, opts, opts_set, loc);
    3305                 :           0 :       break;
    3306                 :             : 
    3307                 :             :     case OPT_gz:
    3308                 :             :     case OPT_gz_:
    3309                 :             :       /* Handled completely via specs.  */
    3310                 :             :       break;
    3311                 :             : 
    3312                 :       62711 :     case OPT_pedantic_errors:
    3313                 :       62711 :       dc->m_pedantic_errors = 1;
    3314                 :       62711 :       control_warning_option (OPT_Wpedantic, DK_ERROR, NULL, value,
    3315                 :             :                               loc, lang_mask,
    3316                 :             :                               handlers, opts, opts_set,
    3317                 :             :                               dc);
    3318                 :       62711 :       break;
    3319                 :             : 
    3320                 :       24893 :     case OPT_flto:
    3321                 :       24893 :       opts->x_flag_lto = value ? "" : NULL;
    3322                 :       24893 :       break;
    3323                 :             : 
    3324                 :           3 :     case OPT_flto_:
    3325                 :           3 :       if (strcmp (arg, "none") != 0
    3326                 :           3 :           && strcmp (arg, "jobserver") != 0
    3327                 :           3 :           && strcmp (arg, "auto") != 0
    3328                 :           1 :           && atoi (arg) == 0)
    3329                 :           1 :         error_at (loc,
    3330                 :             :                   "unrecognized argument to %<-flto=%> option: %qs", arg);
    3331                 :             :       break;
    3332                 :             : 
    3333                 :       43493 :     case OPT_w:
    3334                 :       43493 :       dc->m_inhibit_warnings = true;
    3335                 :       43493 :       break;
    3336                 :             : 
    3337                 :          45 :     case OPT_fmax_errors_:
    3338                 :          45 :       dc->set_max_errors (value);
    3339                 :          45 :       break;
    3340                 :             : 
    3341                 :             :     case OPT_fuse_ld_bfd:
    3342                 :             :     case OPT_fuse_ld_gold:
    3343                 :             :     case OPT_fuse_ld_lld:
    3344                 :             :     case OPT_fuse_ld_mold:
    3345                 :             :     case OPT_fuse_linker_plugin:
    3346                 :             :       /* No-op. Used by the driver and passed to us because it starts with f.*/
    3347                 :             :       break;
    3348                 :             : 
    3349                 :         432 :     case OPT_fwrapv:
    3350                 :         432 :       if (value)
    3351                 :         426 :         opts->x_flag_trapv = 0;
    3352                 :             :       break;
    3353                 :             : 
    3354                 :         134 :     case OPT_ftrapv:
    3355                 :         134 :       if (value)
    3356                 :         134 :         opts->x_flag_wrapv = 0;
    3357                 :             :       break;
    3358                 :             : 
    3359                 :         216 :     case OPT_fstrict_overflow:
    3360                 :         216 :       opts->x_flag_wrapv = !value;
    3361                 :         216 :       opts->x_flag_wrapv_pointer = !value;
    3362                 :         216 :       if (!value)
    3363                 :          62 :         opts->x_flag_trapv = 0;
    3364                 :             :       break;
    3365                 :             : 
    3366                 :      613183 :     case OPT_fipa_icf:
    3367                 :      613183 :       opts->x_flag_ipa_icf_functions = value;
    3368                 :      613183 :       opts->x_flag_ipa_icf_variables = value;
    3369                 :      613183 :       break;
    3370                 :             : 
    3371                 :           2 :     case OPT_falign_loops_:
    3372                 :           2 :       check_alignment_argument (loc, arg, "loops",
    3373                 :             :                                 &opts->x_flag_align_loops,
    3374                 :             :                                 &opts->x_str_align_loops);
    3375                 :           2 :       break;
    3376                 :             : 
    3377                 :           2 :     case OPT_falign_jumps_:
    3378                 :           2 :       check_alignment_argument (loc, arg, "jumps",
    3379                 :             :                                 &opts->x_flag_align_jumps,
    3380                 :             :                                 &opts->x_str_align_jumps);
    3381                 :           2 :       break;
    3382                 :             : 
    3383                 :           3 :     case OPT_falign_labels_:
    3384                 :           3 :       check_alignment_argument (loc, arg, "labels",
    3385                 :             :                                 &opts->x_flag_align_labels,
    3386                 :             :                                 &opts->x_str_align_labels);
    3387                 :           3 :       break;
    3388                 :             : 
    3389                 :          13 :     case OPT_falign_functions_:
    3390                 :          13 :       check_alignment_argument (loc, arg, "functions",
    3391                 :             :                                 &opts->x_flag_align_functions,
    3392                 :             :                                 &opts->x_str_align_functions);
    3393                 :          13 :       break;
    3394                 :             : 
    3395                 :          12 :     case OPT_ftabstop_:
    3396                 :             :       /* It is documented that we silently ignore silly values.  */
    3397                 :          12 :       if (value >= 1 && value <= 100)
    3398                 :           8 :         dc->m_tabstop = value;
    3399                 :             :       break;
    3400                 :             : 
    3401                 :          12 :     case OPT_freport_bug:
    3402                 :          12 :       dc->set_report_bug (value);
    3403                 :          12 :       break;
    3404                 :             : 
    3405                 :           0 :     case OPT_fmultiflags:
    3406                 :           0 :       gcc_checking_assert (lang_mask == CL_DRIVER);
    3407                 :             :       break;
    3408                 :             : 
    3409                 :    72764979 :     default:
    3410                 :             :       /* If the flag was handled in a standard way, assume the lack of
    3411                 :             :          processing here is intentional.  */
    3412                 :    72764979 :       gcc_assert (option_flag_var (scode, opts));
    3413                 :             :       break;
    3414                 :             :     }
    3415                 :             : 
    3416                 :    78400028 :   common_handle_option_auto (opts, opts_set, decoded, lang_mask, kind,
    3417                 :             :                              loc, handlers, dc);
    3418                 :    78400028 :   return true;
    3419                 :             : }
    3420                 :             : 
    3421                 :             : /* Used to set the level of strict aliasing warnings in OPTS,
    3422                 :             :    when no level is specified (i.e., when -Wstrict-aliasing, and not
    3423                 :             :    -Wstrict-aliasing=level was given).
    3424                 :             :    ONOFF is assumed to take value 1 when -Wstrict-aliasing is specified,
    3425                 :             :    and 0 otherwise.  After calling this function, wstrict_aliasing will be
    3426                 :             :    set to the default value of -Wstrict_aliasing=level, currently 3.  */
    3427                 :             : static void
    3428                 :          57 : set_Wstrict_aliasing (struct gcc_options *opts, int onoff)
    3429                 :             : {
    3430                 :          57 :   gcc_assert (onoff == 0 || onoff == 1);
    3431                 :          57 :   if (onoff != 0)
    3432                 :          56 :     opts->x_warn_strict_aliasing = 3;
    3433                 :             :   else
    3434                 :           1 :     opts->x_warn_strict_aliasing = 0;
    3435                 :          57 : }
    3436                 :             : 
    3437                 :             : /* The following routines are useful in setting all the flags that
    3438                 :             :    -ffast-math and -fno-fast-math imply.  */
    3439                 :             : static void
    3440                 :      614122 : set_fast_math_flags (struct gcc_options *opts, int set)
    3441                 :             : {
    3442                 :      614122 :   if (!opts->frontend_set_flag_unsafe_math_optimizations)
    3443                 :             :     {
    3444                 :      614122 :       opts->x_flag_unsafe_math_optimizations = set;
    3445                 :      614122 :       set_unsafe_math_optimizations_flags (opts, set);
    3446                 :             :     }
    3447                 :      614122 :   if (!opts->frontend_set_flag_finite_math_only)
    3448                 :      614122 :     opts->x_flag_finite_math_only = set;
    3449                 :      614122 :   if (!opts->frontend_set_flag_errno_math)
    3450                 :      563527 :     opts->x_flag_errno_math = !set;
    3451                 :      614122 :   if (set)
    3452                 :             :     {
    3453                 :        1967 :       if (opts->frontend_set_flag_excess_precision == EXCESS_PRECISION_DEFAULT)
    3454                 :        1967 :         opts->x_flag_excess_precision
    3455                 :        1967 :           = set ? EXCESS_PRECISION_FAST : EXCESS_PRECISION_DEFAULT;
    3456                 :        1967 :       if (!opts->frontend_set_flag_signaling_nans)
    3457                 :        1967 :         opts->x_flag_signaling_nans = 0;
    3458                 :        1967 :       if (!opts->frontend_set_flag_rounding_math)
    3459                 :        1967 :         opts->x_flag_rounding_math = 0;
    3460                 :        1967 :       if (!opts->frontend_set_flag_complex_method)
    3461                 :        1967 :         opts->x_flag_complex_method = 0;
    3462                 :             :     }
    3463                 :      614122 : }
    3464                 :             : 
    3465                 :             : /* When -funsafe-math-optimizations is set the following
    3466                 :             :    flags are set as well.  */
    3467                 :             : static void
    3468                 :      614488 : set_unsafe_math_optimizations_flags (struct gcc_options *opts, int set)
    3469                 :             : {
    3470                 :      614488 :   if (!opts->frontend_set_flag_trapping_math)
    3471                 :      614488 :     opts->x_flag_trapping_math = !set;
    3472                 :      614488 :   if (!opts->frontend_set_flag_signed_zeros)
    3473                 :      614488 :     opts->x_flag_signed_zeros = !set;
    3474                 :      614488 :   if (!opts->frontend_set_flag_associative_math)
    3475                 :      583550 :     opts->x_flag_associative_math = set;
    3476                 :      614488 :   if (!opts->frontend_set_flag_reciprocal_math)
    3477                 :      614488 :     opts->x_flag_reciprocal_math = set;
    3478                 :      614488 : }
    3479                 :             : 
    3480                 :             : /* Return true iff flags in OPTS are set as if -ffast-math.  */
    3481                 :             : bool
    3482                 :    46719687 : fast_math_flags_set_p (const struct gcc_options *opts)
    3483                 :             : {
    3484                 :    46719687 :   return (!opts->x_flag_trapping_math
    3485                 :      948373 :           && opts->x_flag_unsafe_math_optimizations
    3486                 :      941177 :           && opts->x_flag_finite_math_only
    3487                 :      941113 :           && !opts->x_flag_signed_zeros
    3488                 :      941099 :           && !opts->x_flag_errno_math
    3489                 :    47660782 :           && opts->x_flag_excess_precision == EXCESS_PRECISION_FAST);
    3490                 :             : }
    3491                 :             : 
    3492                 :             : /* Return true iff flags are set as if -ffast-math but using the flags stored
    3493                 :             :    in the struct cl_optimization structure.  */
    3494                 :             : bool
    3495                 :        1240 : fast_math_flags_struct_set_p (struct cl_optimization *opt)
    3496                 :             : {
    3497                 :        1240 :   return (!opt->x_flag_trapping_math
    3498                 :          27 :           && opt->x_flag_unsafe_math_optimizations
    3499                 :          19 :           && opt->x_flag_finite_math_only
    3500                 :          19 :           && !opt->x_flag_signed_zeros
    3501                 :        1259 :           && !opt->x_flag_errno_math);
    3502                 :             : }
    3503                 :             : 
    3504                 :             : /* Handle a debug output -g switch for options OPTS
    3505                 :             :    (OPTS_SET->x_write_symbols storing whether a debug format was passed
    3506                 :             :    explicitly), location LOC.  EXTENDED is true or false to support
    3507                 :             :    extended output (2 is special and means "-ggdb" was given).  */
    3508                 :             : static void
    3509                 :      132073 : set_debug_level (uint32_t dinfo, int extended, const char *arg,
    3510                 :             :                  struct gcc_options *opts, struct gcc_options *opts_set,
    3511                 :             :                  location_t loc)
    3512                 :             : {
    3513                 :      132073 :   if (dinfo == NO_DEBUG)
    3514                 :             :     {
    3515                 :      126307 :       if (opts->x_write_symbols == NO_DEBUG)
    3516                 :             :         {
    3517                 :      110051 :           opts->x_write_symbols = PREFERRED_DEBUGGING_TYPE;
    3518                 :             : 
    3519                 :      110051 :           if (extended == 2)
    3520                 :             :             {
    3521                 :             : #if defined DWARF2_DEBUGGING_INFO || defined DWARF2_LINENO_DEBUGGING_INFO
    3522                 :      110051 :               if (opts->x_write_symbols & CTF_DEBUG)
    3523                 :             :                 opts->x_write_symbols |= DWARF2_DEBUG;
    3524                 :             :               else
    3525                 :      110051 :                 opts->x_write_symbols = DWARF2_DEBUG;
    3526                 :             : #endif
    3527                 :             :             }
    3528                 :             : 
    3529                 :      110051 :           if (opts->x_write_symbols == NO_DEBUG)
    3530                 :             :             warning_at (loc, 0, "target system does not support debug output");
    3531                 :             :         }
    3532                 :       16256 :       else if ((opts->x_write_symbols & CTF_DEBUG)
    3533                 :       16222 :                || (opts->x_write_symbols & BTF_DEBUG)
    3534                 :       16222 :                || (opts->x_write_symbols & CODEVIEW_DEBUG))
    3535                 :             :         {
    3536                 :          34 :           opts->x_write_symbols |= DWARF2_DEBUG;
    3537                 :          34 :           opts_set->x_write_symbols |= DWARF2_DEBUG;
    3538                 :             :         }
    3539                 :             :     }
    3540                 :             :   else
    3541                 :             :     {
    3542                 :             :       /* Make and retain the choice if both CTF and DWARF debug info are to
    3543                 :             :          be generated.  */
    3544                 :        5766 :       if (((dinfo == DWARF2_DEBUG) || (dinfo == CTF_DEBUG))
    3545                 :        5568 :           && ((opts->x_write_symbols == (DWARF2_DEBUG|CTF_DEBUG))
    3546                 :             :               || (opts->x_write_symbols == DWARF2_DEBUG)
    3547                 :             :               || (opts->x_write_symbols == CTF_DEBUG)))
    3548                 :             :         {
    3549                 :         122 :           opts->x_write_symbols |= dinfo;
    3550                 :         122 :           opts_set->x_write_symbols |= dinfo;
    3551                 :             :         }
    3552                 :             :       /* However, CTF and BTF are not allowed together at this time.  */
    3553                 :        5644 :       else if (((dinfo == DWARF2_DEBUG) || (dinfo == BTF_DEBUG))
    3554                 :        4933 :                && ((opts->x_write_symbols == (DWARF2_DEBUG|BTF_DEBUG))
    3555                 :             :                    || (opts->x_write_symbols == DWARF2_DEBUG)
    3556                 :             :                    || (opts->x_write_symbols == BTF_DEBUG)))
    3557                 :             :         {
    3558                 :           0 :           opts->x_write_symbols |= dinfo;
    3559                 :           0 :           opts_set->x_write_symbols |= dinfo;
    3560                 :             :         }
    3561                 :             :       else
    3562                 :             :         {
    3563                 :             :           /* Does it conflict with an already selected debug format?  */
    3564                 :        5644 :           if (opts_set->x_write_symbols != NO_DEBUG
    3565                 :           0 :               && opts->x_write_symbols != NO_DEBUG
    3566                 :           0 :               && dinfo != opts->x_write_symbols)
    3567                 :             :             {
    3568                 :           0 :               gcc_assert (debug_set_count (dinfo) <= 1);
    3569                 :           0 :               error_at (loc, "debug format %qs conflicts with prior selection",
    3570                 :           0 :                         debug_type_names[debug_set_to_format (dinfo)]);
    3571                 :             :             }
    3572                 :        5644 :           opts->x_write_symbols = dinfo;
    3573                 :        5644 :           opts_set->x_write_symbols = dinfo;
    3574                 :             :         }
    3575                 :             :     }
    3576                 :             : 
    3577                 :      132073 :   if (dinfo != BTF_DEBUG)
    3578                 :             :     {
    3579                 :             :       /* A debug flag without a level defaults to level 2.
    3580                 :             :          If off or at level 1, set it to level 2, but if already
    3581                 :             :          at level 3, don't lower it.  */
    3582                 :      131875 :       if (*arg == '\0')
    3583                 :             :         {
    3584                 :      126514 :           if (dinfo == CTF_DEBUG)
    3585                 :         715 :             opts->x_ctf_debug_info_level = CTFINFO_LEVEL_NORMAL;
    3586                 :      125799 :           else if (opts->x_debug_info_level < DINFO_LEVEL_NORMAL)
    3587                 :      112041 :             opts->x_debug_info_level = DINFO_LEVEL_NORMAL;
    3588                 :             :         }
    3589                 :             :       else
    3590                 :             :         {
    3591                 :        5361 :           int argval = integral_argument (arg);
    3592                 :        5361 :           if (argval == -1)
    3593                 :           0 :             error_at (loc, "unrecognized debug output level %qs", arg);
    3594                 :        5361 :           else if (argval > 3)
    3595                 :           0 :             error_at (loc, "debug output level %qs is too high", arg);
    3596                 :             :           else
    3597                 :             :             {
    3598                 :        5361 :               if (dinfo == CTF_DEBUG)
    3599                 :           2 :                 opts->x_ctf_debug_info_level
    3600                 :           2 :                   = (enum ctf_debug_info_levels) argval;
    3601                 :             :               else
    3602                 :        5359 :                 opts->x_debug_info_level = (enum debug_info_levels) argval;
    3603                 :             :             }
    3604                 :             :         }
    3605                 :             :     }
    3606                 :         198 :   else if (*arg != '\0')
    3607                 :           0 :     error_at (loc, "unrecognized btf debug output level %qs", arg);
    3608                 :      132073 : }
    3609                 :             : 
    3610                 :             : /* Arrange to dump core on error for diagnostic context DC.  (The
    3611                 :             :    regular error message is still printed first, except in the case of
    3612                 :             :    abort ().)  */
    3613                 :             : 
    3614                 :             : static void
    3615                 :          13 : setup_core_dumping (diagnostic_context *dc)
    3616                 :             : {
    3617                 :             : #ifdef SIGABRT
    3618                 :          13 :   signal (SIGABRT, SIG_DFL);
    3619                 :             : #endif
    3620                 :             : #if defined(HAVE_SETRLIMIT)
    3621                 :          13 :   {
    3622                 :          13 :     struct rlimit rlim;
    3623                 :          13 :     if (getrlimit (RLIMIT_CORE, &rlim) != 0)
    3624                 :           0 :       fatal_error (input_location, "getting core file size maximum limit: %m");
    3625                 :          13 :     rlim.rlim_cur = rlim.rlim_max;
    3626                 :          13 :     if (setrlimit (RLIMIT_CORE, &rlim) != 0)
    3627                 :           0 :       fatal_error (input_location,
    3628                 :             :                    "setting core file size limit to maximum: %m");
    3629                 :             :   }
    3630                 :             : #endif
    3631                 :          13 :   dc->set_abort_on_error (true);
    3632                 :          13 : }
    3633                 :             : 
    3634                 :             : /* Parse a -d<ARG> command line switch for OPTS, location LOC,
    3635                 :             :    diagnostic context DC.  */
    3636                 :             : 
    3637                 :             : static void
    3638                 :        1602 : decode_d_option (const char *arg, struct gcc_options *opts,
    3639                 :             :                  location_t loc, diagnostic_context *dc)
    3640                 :             : {
    3641                 :        1602 :   int c;
    3642                 :             : 
    3643                 :        3204 :   while (*arg)
    3644                 :        1602 :     switch (c = *arg++)
    3645                 :             :       {
    3646                 :         669 :       case 'A':
    3647                 :         669 :         opts->x_flag_debug_asm = 1;
    3648                 :         669 :         break;
    3649                 :         123 :       case 'p':
    3650                 :         123 :         opts->x_flag_print_asm_name = 1;
    3651                 :         123 :         break;
    3652                 :           5 :       case 'P':
    3653                 :           5 :         opts->x_flag_dump_rtl_in_asm = 1;
    3654                 :           5 :         opts->x_flag_print_asm_name = 1;
    3655                 :           5 :         break;
    3656                 :          10 :       case 'x':
    3657                 :          10 :         opts->x_rtl_dump_and_exit = 1;
    3658                 :          10 :         break;
    3659                 :             :       case 'D': /* These are handled by the preprocessor.  */
    3660                 :             :       case 'I':
    3661                 :             :       case 'M':
    3662                 :             :       case 'N':
    3663                 :             :       case 'U':
    3664                 :             :         break;
    3665                 :          13 :       case 'H':
    3666                 :          13 :         setup_core_dumping (dc);
    3667                 :          13 :         break;
    3668                 :           4 :       case 'a':
    3669                 :           4 :         opts->x_flag_dump_all_passed = true;
    3670                 :           4 :         break;
    3671                 :             : 
    3672                 :           0 :       default:
    3673                 :           0 :           warning_at (loc, 0, "unrecognized gcc debugging option: %c", c);
    3674                 :           0 :         break;
    3675                 :             :       }
    3676                 :        1602 : }
    3677                 :             : 
    3678                 :             : /* Enable (or disable if VALUE is 0) a warning option ARG (language
    3679                 :             :    mask LANG_MASK, option handlers HANDLERS) as an error for option
    3680                 :             :    structures OPTS and OPTS_SET, diagnostic context DC (possibly
    3681                 :             :    NULL), location LOC.  This is used by -Werror=.  */
    3682                 :             : 
    3683                 :             : static void
    3684                 :        7031 : enable_warning_as_error (const char *arg, int value, unsigned int lang_mask,
    3685                 :             :                          const struct cl_option_handlers *handlers,
    3686                 :             :                          struct gcc_options *opts,
    3687                 :             :                          struct gcc_options *opts_set,
    3688                 :             :                          location_t loc, diagnostic_context *dc)
    3689                 :             : {
    3690                 :        7031 :   char *new_option;
    3691                 :        7031 :   int option_index;
    3692                 :             : 
    3693                 :        7031 :   new_option = XNEWVEC (char, strlen (arg) + 2);
    3694                 :        7031 :   new_option[0] = 'W';
    3695                 :        7031 :   strcpy (new_option + 1, arg);
    3696                 :        7031 :   option_index = find_opt (new_option, lang_mask);
    3697                 :        7031 :   if (option_index == OPT_SPECIAL_unknown)
    3698                 :             :     {
    3699                 :           2 :       option_proposer op;
    3700                 :           2 :       const char *hint = op.suggest_option (new_option);
    3701                 :           2 :       if (hint)
    3702                 :           3 :         error_at (loc, "%<-W%serror=%s%>: no option %<-%s%>;"
    3703                 :             :                   " did you mean %<-%s%>?", value ? "" : "no-",
    3704                 :             :                   arg, new_option, hint);
    3705                 :             :       else
    3706                 :           0 :         error_at (loc, "%<-W%serror=%s%>: no option %<-%s%>",
    3707                 :             :                   value ? "" : "no-", arg, new_option);
    3708                 :           2 :     }
    3709                 :        7029 :   else if (!(cl_options[option_index].flags & CL_WARNING))
    3710                 :           4 :     error_at (loc, "%<-Werror=%s%>: %<-%s%> is not an option that "
    3711                 :             :               "controls warnings", arg, new_option);
    3712                 :             :   else
    3713                 :             :     {
    3714                 :        7025 :       const diagnostic_t kind = value ? DK_ERROR : DK_WARNING;
    3715                 :        7025 :       const char *arg = NULL;
    3716                 :             : 
    3717                 :        7025 :       if (cl_options[option_index].flags & CL_JOINED)
    3718                 :          17 :         arg = new_option + cl_options[option_index].opt_len;
    3719                 :        7025 :       control_warning_option (option_index, (int) kind, arg, value,
    3720                 :             :                               loc, lang_mask,
    3721                 :             :                               handlers, opts, opts_set, dc);
    3722                 :             :     }
    3723                 :        7031 :   free (new_option);
    3724                 :        7031 : }
    3725                 :             : 
    3726                 :             : /* Return malloced memory for the name of the option OPTION_INDEX
    3727                 :             :    which enabled a diagnostic, originally of type
    3728                 :             :    ORIG_DIAG_KIND but possibly converted to DIAG_KIND by options such
    3729                 :             :    as -Werror.  */
    3730                 :             : 
    3731                 :             : char *
    3732                 :     1507671 : compiler_diagnostic_option_manager::
    3733                 :             : make_option_name (diagnostic_option_id option_id,
    3734                 :             :                   diagnostic_t orig_diag_kind,
    3735                 :             :                   diagnostic_t diag_kind) const
    3736                 :             : {
    3737                 :     1507671 :   if (option_id.m_idx)
    3738                 :             :     {
    3739                 :             :       /* A warning classified as an error.  */
    3740                 :       86960 :       if ((orig_diag_kind == DK_WARNING || orig_diag_kind == DK_PEDWARN)
    3741                 :       73482 :           && diag_kind == DK_ERROR)
    3742                 :         222 :         return concat (cl_options[OPT_Werror_].opt_text,
    3743                 :             :                        /* Skip over "-W".  */
    3744                 :         222 :                        cl_options[option_id.m_idx].opt_text + 2,
    3745                 :         222 :                        NULL);
    3746                 :             :       /* A warning with option.  */
    3747                 :             :       else
    3748                 :       86738 :         return xstrdup (cl_options[option_id.m_idx].opt_text);
    3749                 :             :     }
    3750                 :             :   /* A warning without option classified as an error.  */
    3751                 :     1420711 :   else if ((orig_diag_kind == DK_WARNING || orig_diag_kind == DK_PEDWARN
    3752                 :     1391261 :             || diag_kind == DK_WARNING)
    3753                 :     1420711 :            && m_context.warning_as_error_requested_p ())
    3754                 :         102 :     return xstrdup (cl_options[OPT_Werror].opt_text);
    3755                 :             :   else
    3756                 :             :     return NULL;
    3757                 :             : }
    3758                 :             : 
    3759                 :             : /* Get the page within the documentation for this option.  */
    3760                 :             : 
    3761                 :             : static const char *
    3762                 :        6358 : get_option_html_page (int option_index)
    3763                 :             : {
    3764                 :        6358 :   const cl_option *cl_opt = &cl_options[option_index];
    3765                 :             : 
    3766                 :             : #ifdef CL_Fortran
    3767                 :        6358 :   if ((cl_opt->flags & CL_Fortran) != 0
    3768                 :             :       /* If it is option common to both C/C++ and Fortran, it is documented
    3769                 :             :          in gcc/ rather than gfortran/ docs.  */
    3770                 :          82 :       && (cl_opt->flags & CL_C) == 0
    3771                 :             : #ifdef CL_CXX
    3772                 :          79 :       && (cl_opt->flags & CL_CXX) == 0
    3773                 :             : #endif
    3774                 :             :      )
    3775                 :          79 :     return "gfortran/Error-and-Warning-Options.html";
    3776                 :             : #endif
    3777                 :             : 
    3778                 :             :   return nullptr;
    3779                 :             : }
    3780                 :             : 
    3781                 :             : /* Get the url within the documentation for this option, or NULL.  */
    3782                 :             : 
    3783                 :             : label_text
    3784                 :       20132 : get_option_url_suffix (int option_index, unsigned lang_mask)
    3785                 :             : {
    3786                 :       20132 :   if (const char *url = get_opt_url_suffix (option_index, lang_mask))
    3787                 :             : 
    3788                 :       13774 :     return label_text::borrow (url);
    3789                 :             : 
    3790                 :             :   /* Fallback code for some options that aren't handled byt opt_url_suffixes
    3791                 :             :      e.g. links below "gfortran/".  */
    3792                 :        6358 :   if (const char *html_page = get_option_html_page (option_index))
    3793                 :          79 :     return label_text::take
    3794                 :             :       (concat (html_page,
    3795                 :             :                /* Expect an anchor of the form "index-Wfoo" e.g.
    3796                 :             :                   <a name="index-Wformat"></a>, and thus an id within
    3797                 :             :                   the page of "#index-Wformat".  */
    3798                 :             :                "#index",
    3799                 :          79 :                cl_options[option_index].opt_text,
    3800                 :          79 :                NULL));
    3801                 :             : 
    3802                 :        6279 :   return label_text ();
    3803                 :             : }
    3804                 :             : 
    3805                 :             : /* Return malloced memory for a URL describing the option OPTION_INDEX
    3806                 :             :    which enabled a diagnostic.  */
    3807                 :             : 
    3808                 :             : char *
    3809                 :         181 : gcc_diagnostic_option_manager::
    3810                 :             : make_option_url (diagnostic_option_id option_id) const
    3811                 :             : {
    3812                 :         181 :   if (option_id.m_idx)
    3813                 :             :     {
    3814                 :         142 :       label_text url_suffix = get_option_url_suffix (option_id.m_idx,
    3815                 :         142 :                                                      m_lang_mask);
    3816                 :         142 :       if (url_suffix.get ())
    3817                 :         142 :         return concat (DOCUMENTATION_ROOT_URL, url_suffix.get (), nullptr);
    3818                 :         142 :     }
    3819                 :             : 
    3820                 :             :   return nullptr;
    3821                 :             : }
    3822                 :             : 
    3823                 :             : /* Return a heap allocated producer with command line options.  */
    3824                 :             : 
    3825                 :             : char *
    3826                 :       52701 : gen_command_line_string (cl_decoded_option *options,
    3827                 :             :                          unsigned int options_count)
    3828                 :             : {
    3829                 :       52701 :   auto_vec<const char *> switches;
    3830                 :       52701 :   char *options_string, *tail;
    3831                 :       52701 :   const char *p;
    3832                 :       52701 :   size_t len = 0;
    3833                 :             : 
    3834                 :     1788328 :   for (unsigned i = 0; i < options_count; i++)
    3835                 :     1735627 :     switch (options[i].opt_index)
    3836                 :             :       {
    3837                 :      759090 :       case OPT_o:
    3838                 :      759090 :       case OPT_d:
    3839                 :      759090 :       case OPT_dumpbase:
    3840                 :      759090 :       case OPT_dumpbase_ext:
    3841                 :      759090 :       case OPT_dumpdir:
    3842                 :      759090 :       case OPT_quiet:
    3843                 :      759090 :       case OPT_version:
    3844                 :      759090 :       case OPT_v:
    3845                 :      759090 :       case OPT_w:
    3846                 :      759090 :       case OPT_L:
    3847                 :      759090 :       case OPT_I:
    3848                 :      759090 :       case OPT_SPECIAL_unknown:
    3849                 :      759090 :       case OPT_SPECIAL_ignore:
    3850                 :      759090 :       case OPT_SPECIAL_warn_removed:
    3851                 :      759090 :       case OPT_SPECIAL_program_name:
    3852                 :      759090 :       case OPT_SPECIAL_input_file:
    3853                 :      759090 :       case OPT_grecord_gcc_switches:
    3854                 :      759090 :       case OPT_frecord_gcc_switches:
    3855                 :      759090 :       case OPT__output_pch:
    3856                 :      759090 :       case OPT_fdiagnostics_show_highlight_colors:
    3857                 :      759090 :       case OPT_fdiagnostics_show_location_:
    3858                 :      759090 :       case OPT_fdiagnostics_show_option:
    3859                 :      759090 :       case OPT_fdiagnostics_show_caret:
    3860                 :      759090 :       case OPT_fdiagnostics_show_event_links:
    3861                 :      759090 :       case OPT_fdiagnostics_show_labels:
    3862                 :      759090 :       case OPT_fdiagnostics_show_line_numbers:
    3863                 :      759090 :       case OPT_fdiagnostics_color_:
    3864                 :      759090 :       case OPT_fdiagnostics_format_:
    3865                 :      759090 :       case OPT_fverbose_asm:
    3866                 :      759090 :       case OPT____:
    3867                 :      759090 :       case OPT__sysroot_:
    3868                 :      759090 :       case OPT_nostdinc:
    3869                 :      759090 :       case OPT_nostdinc__:
    3870                 :      759090 :       case OPT_fpreprocessed:
    3871                 :      759090 :       case OPT_fltrans_output_list_:
    3872                 :      759090 :       case OPT_fresolution_:
    3873                 :      759090 :       case OPT_fdebug_prefix_map_:
    3874                 :      759090 :       case OPT_fmacro_prefix_map_:
    3875                 :      759090 :       case OPT_ffile_prefix_map_:
    3876                 :      759090 :       case OPT_fprofile_prefix_map_:
    3877                 :      759090 :       case OPT_fcanon_prefix_map:
    3878                 :      759090 :       case OPT_fcompare_debug:
    3879                 :      759090 :       case OPT_fchecking:
    3880                 :      759090 :       case OPT_fchecking_:
    3881                 :             :         /* Ignore these.  */
    3882                 :      759090 :         continue;
    3883                 :       67296 :       case OPT_D:
    3884                 :       67296 :       case OPT_U:
    3885                 :       67296 :         if (startswith (options[i].arg, "_FORTIFY_SOURCE")
    3886                 :       67296 :             && (options[i].arg[sizeof ("_FORTIFY_SOURCE") - 1] == '\0'
    3887                 :           0 :                 || (options[i].opt_index == OPT_D
    3888                 :           0 :                     && options[i].arg[sizeof ("_FORTIFY_SOURCE") - 1] == '=')))
    3889                 :             :           {
    3890                 :           0 :             switches.safe_push (options[i].orig_option_with_args_text);
    3891                 :           0 :             len += strlen (options[i].orig_option_with_args_text) + 1;
    3892                 :             :           }
    3893                 :             :         /* Otherwise ignore these. */
    3894                 :       67296 :         continue;
    3895                 :           0 :       case OPT_flto_:
    3896                 :           0 :         {
    3897                 :           0 :           const char *lto_canonical = "-flto";
    3898                 :           0 :           switches.safe_push (lto_canonical);
    3899                 :           0 :           len += strlen (lto_canonical) + 1;
    3900                 :           0 :           break;
    3901                 :             :         }
    3902                 :      909241 :       default:
    3903                 :      910011 :         if (cl_options[options[i].opt_index].flags
    3904                 :      909241 :             & CL_NO_DWARF_RECORD)
    3905                 :         770 :           continue;
    3906                 :      908471 :         gcc_checking_assert (options[i].canonical_option[0][0] == '-');
    3907                 :      908471 :         switch (options[i].canonical_option[0][1])
    3908                 :             :           {
    3909                 :      272687 :           case 'M':
    3910                 :      272687 :           case 'i':
    3911                 :      272687 :           case 'W':
    3912                 :      272687 :             continue;
    3913                 :      359065 :           case 'f':
    3914                 :      359065 :             if (strncmp (options[i].canonical_option[0] + 2,
    3915                 :             :                          "dump", 4) == 0)
    3916                 :        1750 :               continue;
    3917                 :             :             break;
    3918                 :             :           default:
    3919                 :             :             break;
    3920                 :             :           }
    3921                 :      634034 :         switches.safe_push (options[i].orig_option_with_args_text);
    3922                 :      634034 :         len += strlen (options[i].orig_option_with_args_text) + 1;
    3923                 :      634034 :         break;
    3924                 :      826386 :       }
    3925                 :             : 
    3926                 :       52701 :   options_string = XNEWVEC (char, len + 1);
    3927                 :       52701 :   tail = options_string;
    3928                 :             : 
    3929                 :       52701 :   unsigned i;
    3930                 :      739436 :   FOR_EACH_VEC_ELT (switches, i, p)
    3931                 :             :     {
    3932                 :      634034 :       len = strlen (p);
    3933                 :      634034 :       memcpy (tail, p, len);
    3934                 :      634034 :       tail += len;
    3935                 :      634034 :       if (i != switches.length () - 1)
    3936                 :             :         {
    3937                 :      581333 :           *tail = ' ';
    3938                 :      581333 :           ++tail;
    3939                 :             :         }
    3940                 :             :     }
    3941                 :             : 
    3942                 :       52701 :   *tail = '\0';
    3943                 :       52701 :   return options_string;
    3944                 :       52701 : }
    3945                 :             : 
    3946                 :             : /* Return a heap allocated producer string including command line options.  */
    3947                 :             : 
    3948                 :             : char *
    3949                 :       52690 : gen_producer_string (const char *language_string, cl_decoded_option *options,
    3950                 :             :                      unsigned int options_count)
    3951                 :             : {
    3952                 :       52690 :   char *cmdline = gen_command_line_string (options, options_count);
    3953                 :       52690 :   char *combined = concat (language_string, " ", version_string, " ",
    3954                 :             :                            cmdline, NULL);
    3955                 :       52690 :   free (cmdline);
    3956                 :       52690 :   return combined;
    3957                 :             : }
    3958                 :             : 
    3959                 :             : #if CHECKING_P
    3960                 :             : 
    3961                 :             : namespace selftest {
    3962                 :             : 
    3963                 :             : /* Verify that get_option_url_suffix works as expected.  */
    3964                 :             : 
    3965                 :             : static void
    3966                 :           4 : test_get_option_url_suffix ()
    3967                 :             : {
    3968                 :           4 :   ASSERT_STREQ (get_option_url_suffix (OPT_Wcpp, 0).get (),
    3969                 :             :                 "gcc/Warning-Options.html#index-Wcpp");
    3970                 :           4 :   ASSERT_STREQ (get_option_url_suffix (OPT_Wanalyzer_double_free, 0).get (),
    3971                 :             :                 "gcc/Static-Analyzer-Options.html#index-Wanalyzer-double-free");
    3972                 :             : 
    3973                 :             :   /* Test of a D-specific option.  */
    3974                 :             : #ifdef CL_D
    3975                 :           4 :   ASSERT_EQ (get_option_url_suffix (OPT_fbounds_check_, 0).get (), nullptr);
    3976                 :           4 :   ASSERT_STREQ (get_option_url_suffix (OPT_fbounds_check_, CL_D).get (),
    3977                 :             :                 "gdc/Runtime-Options.html#index-fbounds-check");
    3978                 :             : 
    3979                 :             :   /* Test of a D-specific override to an option URL.  */
    3980                 :             :   /* Generic URL.  */
    3981                 :           4 :   ASSERT_STREQ (get_option_url_suffix (OPT_fmax_errors_, 0).get (),
    3982                 :             :                 "gcc/Warning-Options.html#index-fmax-errors");
    3983                 :             :   /* D-specific URL.  */
    3984                 :           4 :   ASSERT_STREQ (get_option_url_suffix (OPT_fmax_errors_, CL_D).get (),
    3985                 :             :                 "gdc/Warnings.html#index-fmax-errors");
    3986                 :             : #endif
    3987                 :             : 
    3988                 :             : #ifdef CL_Fortran
    3989                 :           4 :   ASSERT_STREQ
    3990                 :             :     (get_option_url_suffix (OPT_Wline_truncation, CL_Fortran).get (),
    3991                 :             :      "gfortran/Error-and-Warning-Options.html#index-Wline-truncation");
    3992                 :             : #endif
    3993                 :           4 : }
    3994                 :             : 
    3995                 :             : /* Verify EnumSet and EnumBitSet requirements.  */
    3996                 :             : 
    3997                 :             : static void
    3998                 :           4 : test_enum_sets ()
    3999                 :             : {
    4000                 :        9756 :   for (unsigned i = 0; i < cl_options_count; ++i)
    4001                 :        9752 :     if (cl_options[i].var_type == CLVC_ENUM
    4002                 :         344 :         && cl_options[i].var_value != CLEV_NORMAL)
    4003                 :             :       {
    4004                 :          32 :         const struct cl_enum *e = &cl_enums[cl_options[i].var_enum];
    4005                 :          32 :         unsigned HOST_WIDE_INT used_sets = 0;
    4006                 :          32 :         unsigned HOST_WIDE_INT mask = 0;
    4007                 :          32 :         unsigned highest_set = 0;
    4008                 :         176 :         for (unsigned j = 0; e->values[j].arg; ++j)
    4009                 :             :           {
    4010                 :         144 :             unsigned set = e->values[j].flags >> CL_ENUM_SET_SHIFT;
    4011                 :         144 :             if (cl_options[i].var_value == CLEV_BITSET)
    4012                 :             :               {
    4013                 :             :                 /* For EnumBitSet Set shouldn't be used and Value should
    4014                 :             :                    be a power of two.  */
    4015                 :          24 :                 ASSERT_TRUE (set == 0);
    4016                 :          48 :                 ASSERT_TRUE (pow2p_hwi (e->values[j].value));
    4017                 :          24 :                 continue;
    4018                 :          24 :               }
    4019                 :             :             /* Test that enumerators referenced in EnumSet have all
    4020                 :             :                Set(n) on them within the valid range.  */
    4021                 :         120 :             ASSERT_TRUE (set >= 1 && set <= HOST_BITS_PER_WIDE_INT);
    4022                 :         120 :             highest_set = MAX (set, highest_set);
    4023                 :         120 :             used_sets |= HOST_WIDE_INT_1U << (set - 1);
    4024                 :             :           }
    4025                 :          32 :         if (cl_options[i].var_value == CLEV_BITSET)
    4026                 :           8 :           continue;
    4027                 :             :         /* If there is just one set, no point to using EnumSet.  */
    4028                 :          24 :         ASSERT_TRUE (highest_set >= 2);
    4029                 :             :         /* Test that there are no gaps in between the sets.  */
    4030                 :          24 :         if (highest_set == HOST_BITS_PER_WIDE_INT)
    4031                 :           0 :           ASSERT_TRUE (used_sets == HOST_WIDE_INT_M1U);
    4032                 :             :         else
    4033                 :          24 :           ASSERT_TRUE (used_sets == (HOST_WIDE_INT_1U << highest_set) - 1);
    4034                 :         112 :         for (unsigned int j = 1; j <= highest_set; ++j)
    4035                 :             :           {
    4036                 :             :             unsigned HOST_WIDE_INT this_mask = 0;
    4037                 :         616 :             for (unsigned k = 0; e->values[k].arg; ++k)
    4038                 :             :               {
    4039                 :         528 :                 unsigned set = e->values[j].flags >> CL_ENUM_SET_SHIFT;
    4040                 :         528 :                 if (set == j)
    4041                 :         128 :                   this_mask |= e->values[j].value;
    4042                 :             :               }
    4043                 :          88 :             ASSERT_TRUE ((mask & this_mask) == 0);
    4044                 :          88 :             mask |= this_mask;
    4045                 :             :           }
    4046                 :             :       }
    4047                 :           4 : }
    4048                 :             : 
    4049                 :             : /* Run all of the selftests within this file.  */
    4050                 :             : 
    4051                 :             : void
    4052                 :           4 : opts_cc_tests ()
    4053                 :             : {
    4054                 :           4 :   test_get_option_url_suffix ();
    4055                 :           4 :   test_enum_sets ();
    4056                 :           4 : }
    4057                 :             : 
    4058                 :             : } // namespace selftest
    4059                 :             : 
    4060                 :             : #endif /* #if CHECKING_P */
        

Generated by: LCOV version 2.1-beta

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto,rust,m2 --enable-host-shared. GCC test suite is run with the built compiler.