LCOV - code coverage report
Current view: top level - gcc - toplev.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 80.8 % 995 804
Test Date: 2026-02-28 14:20:25 Functions: 91.3 % 46 42
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* Top level of GCC compilers (cc1, cc1plus, etc.)
       2              :    Copyright (C) 1987-2026 Free Software Foundation, Inc.
       3              : 
       4              : This file is part of GCC.
       5              : 
       6              : GCC is free software; you can redistribute it and/or modify it under
       7              : the terms of the GNU General Public License as published by the Free
       8              : Software Foundation; either version 3, or (at your option) any later
       9              : version.
      10              : 
      11              : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      12              : WARRANTY; without even the implied warranty of MERCHANTABILITY or
      13              : FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      14              : for more details.
      15              : 
      16              : You should have received a copy of the GNU General Public License
      17              : along with GCC; see the file COPYING3.  If not see
      18              : <http://www.gnu.org/licenses/>.  */
      19              : 
      20              : /* This is the top level of cc1/c++.
      21              :    It parses command args, opens files, invokes the various passes
      22              :    in the proper order, and counts the time used by each.
      23              :    Error messages and low-level interface to malloc also handled here.  */
      24              : 
      25              : #define INCLUDE_VECTOR
      26              : #include "config.h"
      27              : #include "system.h"
      28              : #include "coretypes.h"
      29              : #include "backend.h"
      30              : #include "target.h"
      31              : #include "rtl.h"
      32              : #include "tree.h"
      33              : #include "gimple.h"
      34              : #include "alloc-pool.h"
      35              : #include "timevar.h"
      36              : #include "memmodel.h"
      37              : #include "tm_p.h"
      38              : #include "optabs-libfuncs.h"
      39              : #include "insn-config.h"
      40              : #include "ira.h"
      41              : #include "recog.h"
      42              : #include "cgraph.h"
      43              : #include "coverage.h"
      44              : #include "diagnostic.h"
      45              : #include "pretty-print-urlifier.h"
      46              : #include "varasm.h"
      47              : #include "tree-inline.h"
      48              : #include "realmpfr.h" /* For GMP/MPFR/MPC versions, in print_version.  */
      49              : #include "version.h"
      50              : #include "flags.h"
      51              : #include "insn-attr.h"
      52              : #include "output.h"
      53              : #include "toplev.h"
      54              : #include "expr.h"
      55              : #include "intl.h"
      56              : #include "tree-diagnostic.h"
      57              : #include "reload.h"
      58              : #include "lra.h"
      59              : #include "dwarf2asm.h"
      60              : #include "debug.h"
      61              : #include "common/common-target.h"
      62              : #include "langhooks.h"
      63              : #include "cfgloop.h" /* for init_set_costs */
      64              : #include "hosthooks.h"
      65              : #include "opts.h"
      66              : #include "opts-diagnostic.h"
      67              : #include "stringpool.h"
      68              : #include "attribs.h"
      69              : #include "asan.h"
      70              : #include "tsan.h"
      71              : #include "plugin.h"
      72              : #include "context.h"
      73              : #include "pass_manager.h"
      74              : #include "auto-profile.h"
      75              : #include "dwarf2out.h"
      76              : #include "ipa-reference.h"
      77              : #include "symbol-summary.h"
      78              : #include "tree-vrp.h"
      79              : #include "sreal.h"
      80              : #include "ipa-cp.h"
      81              : #include "ipa-prop.h"
      82              : #include "ipa-utils.h"
      83              : #include "gcse.h"
      84              : #include "omp-offload.h"
      85              : #include "diagnostics/changes.h"
      86              : #include "diagnostics/file-cache.h"
      87              : #include "diagnostics/sarif-sink.h"
      88              : #include "tree-pass.h"
      89              : #include "dumpfile.h"
      90              : #include "ipa-fnsummary.h"
      91              : #include "dump-context.h"
      92              : #include "print-tree.h"
      93              : #include "optinfo-emit-json.h"
      94              : #include "ipa-modref-tree.h"
      95              : #include "ipa-modref.h"
      96              : #include "ipa-param-manipulation.h"
      97              : #include "dbgcnt.h"
      98              : #include "gcc-urlifier.h"
      99              : #include "unique-argv.h"
     100              : 
     101              : #include "selftest.h"
     102              : 
     103              : #ifdef HAVE_isl
     104              : #include <isl/version.h>
     105              : #endif
     106              : 
     107              : static void general_init (const char *, bool, unique_argv original_argv);
     108              : static void backend_init (void);
     109              : static int lang_dependent_init (const char *);
     110              : static void init_asm_output (const char *);
     111              : static void finalize ();
     112              : 
     113              : static void crash_signal (int) ATTRIBUTE_NORETURN;
     114              : static void compile_file (void);
     115              : 
     116              : /* Decoded options, and number of such options.  */
     117              : struct cl_decoded_option *save_decoded_options;
     118              : unsigned int save_decoded_options_count;
     119              : 
     120              : /* Vector of saved Optimization decoded command line options.  */
     121              : vec<cl_decoded_option> *save_opt_decoded_options;
     122              : 
     123              : /* Debug hooks - dependent upon command line options.  */
     124              : 
     125              : const struct gcc_debug_hooks *debug_hooks;
     126              : 
     127              : /* The FUNCTION_DECL for the function currently being compiled,
     128              :    or 0 if between functions.  */
     129              : tree current_function_decl;
     130              : 
     131              : /* Set to the FUNC_BEGIN label of the current function, or NULL
     132              :    if none.  */
     133              : const char * current_function_func_begin_label;
     134              : 
     135              : /* A random sequence of characters, unless overridden by user.  */
     136              : static const char *flag_random_seed;
     137              : 
     138              : /* A local time stamp derived from the time of compilation. It will be
     139              :    zero if the system cannot provide a time.  It will be -1u, if the
     140              :    user has specified a particular random seed.  */
     141              : unsigned local_tick;
     142              : 
     143              : /* Random number for this compilation */
     144              : HOST_WIDE_INT random_seed;
     145              : 
     146              : /* -f flags.  */
     147              : 
     148              : /* When non-NULL, indicates that whenever space is allocated on the
     149              :    stack, the resulting stack pointer must not pass this
     150              :    address---that is, for stacks that grow downward, the stack pointer
     151              :    must always be greater than or equal to this address; for stacks
     152              :    that grow upward, the stack pointer must be less than this address.
     153              :    At present, the rtx may be either a REG or a SYMBOL_REF, although
     154              :    the support provided depends on the backend.  */
     155              : rtx stack_limit_rtx;
     156              : 
     157              : class target_flag_state default_target_flag_state;
     158              : #if SWITCHABLE_TARGET
     159              : class target_flag_state *this_target_flag_state = &default_target_flag_state;
     160              : #else
     161              : #define this_target_flag_state (&default_target_flag_state)
     162              : #endif
     163              : 
     164              : /* The user symbol prefix after having resolved same.  */
     165              : const char *user_label_prefix;
     166              : 
     167              : /* Output files for assembler code (real compiler output)
     168              :    and debugging dumps.  */
     169              : 
     170              : FILE *asm_out_file;
     171              : FILE *aux_info_file;
     172              : FILE *callgraph_info_file = NULL;
     173              : static bitmap callgraph_info_external_printed;
     174              : FILE *stack_usage_file = NULL;
     175              : static bool no_backend = false;
     176              : 
     177              : /* The current working directory of a translation.  It's generally the
     178              :    directory from which compilation was initiated, but a preprocessed
     179              :    file may specify the original directory in which it was
     180              :    created.  */
     181              : 
     182              : static const char *src_pwd;
     183              : 
     184              : /* Initialize src_pwd with the given string, and return true.  If it
     185              :    was already initialized, return false.  As a special case, it may
     186              :    be called with a NULL argument to test whether src_pwd has NOT been
     187              :    initialized yet.  */
     188              : 
     189              : bool
     190           55 : set_src_pwd (const char *pwd)
     191              : {
     192           55 :   if (src_pwd)
     193              :     {
     194            0 :       if (strcmp (src_pwd, pwd) == 0)
     195              :         return true;
     196              :       else
     197              :         return false;
     198              :     }
     199              : 
     200           55 :   src_pwd = xstrdup (pwd);
     201           55 :   return true;
     202              : }
     203              : 
     204              : /* Return the directory from which the translation unit was initiated,
     205              :    in case set_src_pwd() was not called before to assign it a
     206              :    different value.  */
     207              : 
     208              : const char *
     209        64389 : get_src_pwd (void)
     210              : {
     211        64389 :   if (! src_pwd)
     212              :     {
     213        59208 :       src_pwd = getpwd ();
     214        59208 :       if (!src_pwd)
     215            0 :         src_pwd = ".";
     216              :     }
     217              : 
     218        64389 :    return src_pwd;
     219              : }
     220              : 
     221              : /* Called when the start of a function definition is parsed,
     222              :    this function prints on stderr the name of the function.  */
     223              : void
     224    204104994 : announce_function (tree decl)
     225              : {
     226    204104994 :   if (!quiet_flag)
     227              :     {
     228            0 :       if (rtl_dump_and_exit)
     229            0 :         fprintf (stderr, "%s ",
     230            0 :                  identifier_to_locale (IDENTIFIER_POINTER (DECL_NAME (decl))));
     231              :       else
     232            0 :         fprintf (stderr, " %s",
     233            0 :                  identifier_to_locale (lang_hooks.decl_printable_name (decl, 2)));
     234            0 :       fflush (stderr);
     235            0 :       pp_needs_newline (global_dc->get_reference_printer ()) = true;
     236            0 :       diagnostic_set_last_function (global_dc,
     237              :                                     (diagnostics::diagnostic_info *) nullptr);
     238              :     }
     239    204104994 : }
     240              : 
     241              : /* Initialize local_tick with the time of day, or -1 if
     242              :    flag_random_seed is set.  */
     243              : 
     244              : static void
     245       285718 : init_local_tick (void)
     246              : {
     247       285718 :   if (!flag_random_seed)
     248              :     {
     249              : #ifdef HAVE_GETTIMEOFDAY
     250       283924 :       {
     251       283924 :         struct timeval tv;
     252              : 
     253       283924 :         gettimeofday (&tv, NULL);
     254       283924 :         local_tick = (unsigned) tv.tv_sec * 1000 + tv.tv_usec / 1000;
     255              :       }
     256              : #else
     257              :       {
     258              :         time_t now = time (NULL);
     259              : 
     260              :         if (now != (time_t)-1)
     261              :           local_tick = (unsigned) now;
     262              :       }
     263              : #endif
     264              :     }
     265              :   else
     266         1794 :     local_tick = -1;
     267       285718 : }
     268              : 
     269              : /* Obtain the random_seed.  Unless NOINIT, initialize it if
     270              :    it's not provided in the command line.  */
     271              : 
     272              : HOST_WIDE_INT
     273       400091 : get_random_seed (bool noinit)
     274              : {
     275       400091 :   if (!random_seed && !noinit)
     276              :     {
     277        22919 :       int fd = open ("/dev/urandom", O_RDONLY);
     278        22919 :       if (fd >= 0)
     279              :         {
     280        22919 :           if (read (fd, &random_seed, sizeof (random_seed))
     281              :               != sizeof (random_seed))
     282            0 :             random_seed = 0;
     283        22919 :           close (fd);
     284              :         }
     285        22919 :       if (!random_seed)
     286            0 :         random_seed = local_tick ^ getpid ();
     287              :     }
     288       400091 :   return random_seed;
     289              : }
     290              : 
     291              : /* Set flag_random_seed to VAL, and if non-null, reinitialize random_seed.  */
     292              : 
     293              : void
     294         1794 : set_random_seed (const char *val)
     295              : {
     296         1794 :   flag_random_seed = val;
     297         1794 :   if (flag_random_seed)
     298              :     {
     299         1794 :       char *endp;
     300              : 
     301              :       /* When the driver passed in a hex number don't crc it again */
     302         1794 :       random_seed = strtoul (flag_random_seed, &endp, 0);
     303         1794 :       if (!(endp > flag_random_seed && *endp == 0))
     304          560 :         random_seed = crc32_string (0, flag_random_seed);
     305              :     }
     306         1794 : }
     307              : 
     308              : /* Handler for fatal signals, such as SIGSEGV.  These are transformed
     309              :    into ICE messages, which is much more user friendly.  In case the
     310              :    error printer crashes, reset the signal to prevent infinite recursion.  */
     311              : 
     312              : static void
     313            3 : crash_signal (int signo)
     314              : {
     315            3 :   signal (signo, SIG_DFL);
     316              : 
     317              :   /* If we crashed while processing an ASM statement, then be a little more
     318              :      graceful.  It's most likely the user's fault.  */
     319            3 :   if (this_is_asm_operands)
     320              :     {
     321            0 :       output_operand_lossage ("unrecoverable error");
     322            0 :       exit (FATAL_EXIT_CODE);
     323              :     }
     324              : 
     325            3 :   internal_error ("%s", strsignal (signo));
     326              : }
     327              : 
     328              : /* A subroutine of wrapup_global_declarations.  We've come to the end of
     329              :    the compilation unit.  All deferred variables should be undeferred,
     330              :    and all incomplete decls should be finalized.  */
     331              : 
     332              : void
     333    659532450 : wrapup_global_declaration_1 (tree decl)
     334              : {
     335              :   /* We're not deferring this any longer.  Assignment is conditional to
     336              :      avoid needlessly dirtying PCH pages.  */
     337    659532450 :   if (HAS_DECL_ASSEMBLER_NAME_P (decl)
     338    659532450 :       && DECL_DEFER_OUTPUT (decl) != 0)
     339     23254587 :     DECL_DEFER_OUTPUT (decl) = 0;
     340              : 
     341    659532450 :   if (VAR_P (decl) && DECL_SIZE (decl) == 0)
     342       341587 :     lang_hooks.finish_incomplete_decl (decl);
     343    659532450 : }
     344              : 
     345              : /* A subroutine of wrapup_global_declarations.  Decide whether or not DECL
     346              :    needs to be output.  Return true if it is output.  */
     347              : 
     348              : bool
     349    830643659 : wrapup_global_declaration_2 (tree decl)
     350              : {
     351    828852691 :   if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl)
     352   1009752501 :       || (VAR_P (decl) && DECL_HAS_VALUE_EXPR_P (decl)))
     353              :     return false;
     354              : 
     355              :   /* Don't write out static consts, unless we still need them.
     356              : 
     357              :      We also keep static consts if not optimizing (for debugging),
     358              :      unless the user specified -fno-keep-static-consts.
     359              :      ??? They might be better written into the debug information.
     360              :      This is possible when using DWARF.
     361              : 
     362              :      A language processor that wants static constants to be always
     363              :      written out (even if it is not used) is responsible for
     364              :      calling rest_of_decl_compilation itself.  E.g. the C front-end
     365              :      calls rest_of_decl_compilation from finish_decl.
     366              :      One motivation for this is that is conventional in some
     367              :      environments to write things like:
     368              :      static const char rcsid[] = "... version string ...";
     369              :      intending to force the string to be in the executable.
     370              : 
     371              :      A language processor that would prefer to have unneeded
     372              :      static constants "optimized away" would just defer writing
     373              :      them out until here.  E.g. C++ does this, because static
     374              :      constants are often defined in header files.
     375              : 
     376              :      ??? A tempting alternative (for both C and C++) would be
     377              :      to force a constant to be written if and only if it is
     378              :      defined in a main file, as opposed to an include file.  */
     379              : 
     380    179107431 :   if (VAR_P (decl) && TREE_STATIC (decl))
     381              :     {
     382    153519673 :       varpool_node *node;
     383    153519673 :       bool needed = true;
     384    153519673 :       node = varpool_node::get (decl);
     385              : 
     386    153519673 :       if (!node && flag_ltrans)
     387              :         needed = false;
     388    153418029 :       else if (node && node->definition)
     389              :         needed = false;
     390     19800992 :       else if (node && node->alias)
     391              :         needed = false;
     392     19902404 :       else if (!symtab->global_info_ready
     393     19902404 :                && (TREE_USED (decl)
     394       762665 :                    || TREE_USED (DECL_ASSEMBLER_NAME (decl))))
     395              :         /* needed */;
     396       762654 :       else if (node && node->analyzed)
     397              :         /* needed */;
     398       762654 :       else if (DECL_COMDAT (decl))
     399              :         needed = false;
     400       724392 :       else if (TREE_READONLY (decl) && !TREE_PUBLIC (decl)
     401       724256 :                && (optimize || !flag_keep_static_consts
     402            6 :                    || DECL_ARTIFICIAL (decl)))
     403              :         needed = false;
     404              : 
     405              :       if (needed)
     406              :         {
     407     19864000 :           rest_of_decl_compilation (decl, 1, 1);
     408     19864000 :           return true;
     409              :         }
     410              :     }
     411              : 
     412              :   return false;
     413              : }
     414              : 
     415              : /* Do any final processing required for the declarations in VEC, of
     416              :    which there are LEN.  We write out inline functions and variables
     417              :    that have been deferred until this point, but which are required.
     418              :    Returns nonzero if anything was put out.  */
     419              : 
     420              : bool
     421       226327 : wrapup_global_declarations (tree *vec, int len)
     422              : {
     423       226327 :   bool reconsider, output_something = false;
     424       226327 :   int i;
     425              : 
     426    276471286 :   for (i = 0; i < len; i++)
     427    276244959 :     wrapup_global_declaration_1 (vec[i]);
     428              : 
     429              :   /* Now emit any global variables or functions that we have been
     430              :      putting off.  We need to loop in case one of the things emitted
     431              :      here references another one which comes earlier in the list.  */
     432       263918 :   do
     433              :     {
     434       263918 :       reconsider = false;
     435    334724983 :       for (i = 0; i < len; i++)
     436    334461065 :         reconsider |= wrapup_global_declaration_2 (vec[i]);
     437       263918 :       if (reconsider)
     438        37591 :         output_something = true;
     439              :     }
     440              :   while (reconsider);
     441              : 
     442       226327 :   return output_something;
     443              : }
     444              : 
     445              : /* Compile an entire translation unit.  Write a file of assembly
     446              :    output and various debugging dumps.  */
     447              : 
     448              : static void
     449       278638 : compile_file (void)
     450              : {
     451       278638 :   timevar_start (TV_PHASE_PARSING);
     452       278638 :   timevar_push (TV_PARSE_GLOBAL);
     453              : 
     454              :   /* Parse entire file and generate initial debug information.  */
     455       278638 :   lang_hooks.parse_file ();
     456              : 
     457       276784 :   timevar_pop (TV_PARSE_GLOBAL);
     458       276784 :   timevar_stop (TV_PHASE_PARSING);
     459              : 
     460       276784 :   if (flag_dump_locations)
     461            1 :     dump_location_info (stderr);
     462              : 
     463       276784 :   free_attr_data ();
     464              : 
     465              :   /* Compilation is now finished except for writing
     466              :      what's left of the symbol table output.  */
     467              : 
     468       276784 :   if (flag_syntax_only || flag_wpa)
     469              :     return;
     470              : 
     471              :   /* Reset maximum_field_alignment, it can be adjusted by #pragma pack
     472              :      and this shouldn't influence any types built by the middle-end
     473              :      from now on (like gcov_info_type).  */
     474       268272 :   maximum_field_alignment = initial_max_fld_align * BITS_PER_UNIT;
     475              : 
     476       268272 :   ggc_protect_identifiers = false;
     477              : 
     478              :   /* Run the actual compilation process.  */
     479       268272 :   if (!in_lto_p)
     480              :     {
     481       255697 :       timevar_start (TV_PHASE_OPT_GEN);
     482       255697 :       symtab->finalize_compilation_unit ();
     483       255675 :       timevar_stop (TV_PHASE_OPT_GEN);
     484              :     }
     485              : 
     486              :   /* Perform any post compilation-proper parser cleanups and
     487              :      processing.  This is currently only needed for the C++ parser,
     488              :      which can be hopefully cleaned up so this hook is no longer
     489              :      necessary.  */
     490       268250 :   if (lang_hooks.decls.post_compilation_parsing_cleanups)
     491        95543 :     lang_hooks.decls.post_compilation_parsing_cleanups ();
     492              : 
     493       268250 :   dump_context::get ().finish_any_json_writer ();
     494              : 
     495       268250 :   if (seen_error ())
     496              :     return;
     497              : 
     498       242078 :   timevar_start (TV_PHASE_LATE_ASM);
     499              : 
     500              :   /* Compilation unit is finalized.  When producing non-fat LTO object, we are
     501              :      basically finished.  */
     502       242078 :   if ((in_lto_p && flag_incremental_link != INCREMENTAL_LINK_LTO)
     503       229536 :       || !flag_lto || flag_fat_lto_objects)
     504              :     {
     505              :       /* File-scope initialization for AddressSanitizer.  */
     506       230133 :       if (flag_sanitize & SANITIZE_ADDRESS)
     507         2435 :         asan_finish_file ();
     508              : 
     509       230133 :       if (flag_sanitize & SANITIZE_THREAD)
     510          257 :         tsan_finish_file ();
     511              : 
     512       230133 :       if (gate_hwasan ())
     513          258 :         hwasan_finish_file ();
     514              : 
     515       230133 :       omp_finish_file ();
     516              : 
     517       230133 :       output_shared_constant_pool ();
     518       230133 :       output_object_blocks ();
     519       230133 :       finish_tm_clone_pairs ();
     520              : 
     521              :       /* Write out any pending weak symbol declarations.  */
     522       230133 :       weak_finish ();
     523              : 
     524              :       /* This must be at the end before unwind and debug info.
     525              :          Some target ports emit PIC setup thunks here.  */
     526       230133 :       insn_locations_init ();
     527       230133 :       targetm.asm_out.code_end ();
     528              : 
     529              :       /* Do dbx symbols.  */
     530       230133 :       timevar_push (TV_SYMOUT);
     531              : 
     532              : #if defined DWARF2_DEBUGGING_INFO || defined DWARF2_UNWIND_INFO
     533       230133 :       dwarf2out_frame_finish ();
     534              : #endif
     535              : 
     536       230133 :       debuginfo_start ();
     537       230133 :       (*debug_hooks->finish) (main_input_filename);
     538       230133 :       debuginfo_stop ();
     539       230133 :       timevar_pop (TV_SYMOUT);
     540              : 
     541              :       /* Output some stuff at end of file if nec.  */
     542              : 
     543       230133 :       dw2_output_indirect_constants ();
     544              : 
     545              :       /* Flush any pending external directives.  */
     546       230133 :       process_pending_assemble_externals ();
     547              :    }
     548              : 
     549              :   /* Let linker plugin know that this is a slim object and must be LTOed
     550              :      even when user did not ask for it.  */
     551       242078 :   if (flag_generate_lto && !flag_fat_lto_objects)
     552              :     {
     553              : #if defined ASM_OUTPUT_ALIGNED_DECL_COMMON
     554        11945 :       ASM_OUTPUT_ALIGNED_DECL_COMMON (asm_out_file, NULL_TREE, "__gnu_lto_slim",
     555        11945 :                                       HOST_WIDE_INT_1U, 8);
     556              : #elif defined ASM_OUTPUT_ALIGNED_COMMON
     557              :       ASM_OUTPUT_ALIGNED_COMMON (asm_out_file, "__gnu_lto_slim",
     558              :                                  HOST_WIDE_INT_1U, 8);
     559              : #else
     560              :       ASM_OUTPUT_COMMON (asm_out_file, "__gnu_lto_slim",
     561              :                          HOST_WIDE_INT_1U,
     562              :                          HOST_WIDE_INT_1U);
     563              : #endif
     564              :     }
     565              : 
     566              :   /* Attach a special .ident directive to the end of the file to identify
     567              :      the version of GCC which compiled this code.  The format of the .ident
     568              :      string is patterned after the ones produced by native SVR4 compilers.  */
     569       242078 :   if (!flag_no_ident)
     570              :     {
     571       234260 :       const char *pkg_version = "(GNU) ";
     572       234260 :       char *ident_str;
     573              : 
     574       234260 :       if (strcmp ("(GCC) ", pkgversion_string))
     575              :         pkg_version = pkgversion_string;
     576              : 
     577       234260 :       ident_str = ACONCAT (("GCC: ", pkg_version, version_string, NULL));
     578       234260 :       targetm.asm_out.output_ident (ident_str);
     579              :     }
     580              : 
     581              :   /* Auto profile finalization. */
     582       242078 :   if (flag_auto_profile)
     583            0 :     end_auto_profile ();
     584              : 
     585              :   /* Invoke registered plugin callbacks.  */
     586       242078 :   invoke_plugin_callbacks (PLUGIN_FINISH_UNIT, NULL);
     587              : 
     588              :   /* This must be at the end.  Some target ports emit end of file directives
     589              :      into the assembly file here, and hence we cannot output anything to the
     590              :      assembly file after this point.  */
     591       242078 :   targetm.asm_out.file_end ();
     592              : 
     593       242078 :   timevar_stop (TV_PHASE_LATE_ASM);
     594              : }
     595              : 
     596              : /* Print version information to FILE.
     597              :    Each line begins with INDENT (for the case where FILE is the
     598              :    assembler output file).
     599              : 
     600              :    If SHOW_GLOBAL_STATE is true (for cc1 etc), we are within the compiler
     601              :    proper and can print pertinent state (e.g. params and plugins).
     602              : 
     603              :    If SHOW_GLOBAL_STATE is false (for use by libgccjit), we are outside the
     604              :    compiler, and we don't hold the mutex on the compiler's global state:
     605              :    we can't print params and plugins, since they might not be initialized,
     606              :    or might be being manipulated by a compile running in another
     607              :    thread.  */
     608              : 
     609              : void
     610         2414 : print_version (FILE *file, const char *indent, bool show_global_state)
     611              : {
     612         2414 :   static const char fmt1[] =
     613              : #ifdef __GNUC__
     614              :     N_("%s%s%s %sversion %s (%s)\n%s\tcompiled by GNU C version %s, ")
     615              : #else
     616              :     N_("%s%s%s %sversion %s (%s) compiled by CC, ")
     617              : #endif
     618              :     ;
     619         2414 :   static const char fmt2[] =
     620              :     N_("GMP version %s, MPFR version %s, MPC version %s, isl version %s\n");
     621         2414 :   static const char fmt3[] =
     622              :     N_("%s%swarning: %s header version %s differs from library version %s.\n");
     623         2414 :   static const char fmt4[] =
     624              :     N_("%s%sGGC heuristics: --param ggc-min-expand=%d --param ggc-min-heapsize=%d\n");
     625              : #ifndef __VERSION__
     626              : #define __VERSION__ "[?]"
     627              : #endif
     628         2414 :   fprintf (file,
     629         2414 :            file == stderr ? _(fmt1) : fmt1,
     630         2414 :            indent, *indent != 0 ? " " : "",
     631              :            lang_hooks.name, pkgversion_string, version_string, TARGET_NAME,
     632              :            indent, __VERSION__);
     633              : 
     634              :   /* We need to stringify the GMP macro values.  Ugh, gmp_version has
     635              :      two string formats, "i.j.k" and "i.j" when k is zero.  As of
     636              :      gmp-4.3.0, GMP always uses the 3 number format.  */
     637              : #define GCC_GMP_STRINGIFY_VERSION3(X) #X
     638              : #define GCC_GMP_STRINGIFY_VERSION2(X) GCC_GMP_STRINGIFY_VERSION3 (X)
     639              : #define GCC_GMP_VERSION_NUM(X,Y,Z) (((X) << 16L) | ((Y) << 8) | (Z))
     640              : #define GCC_GMP_VERSION \
     641              :   GCC_GMP_VERSION_NUM(__GNU_MP_VERSION, __GNU_MP_VERSION_MINOR, __GNU_MP_VERSION_PATCHLEVEL)
     642              : #if GCC_GMP_VERSION < GCC_GMP_VERSION_NUM(4,3,0) && __GNU_MP_VERSION_PATCHLEVEL == 0
     643              : #define GCC_GMP_STRINGIFY_VERSION \
     644              :   GCC_GMP_STRINGIFY_VERSION2 (__GNU_MP_VERSION) "." \
     645              :   GCC_GMP_STRINGIFY_VERSION2 (__GNU_MP_VERSION_MINOR)
     646              : #else
     647              : #define GCC_GMP_STRINGIFY_VERSION \
     648              :   GCC_GMP_STRINGIFY_VERSION2 (__GNU_MP_VERSION) "." \
     649              :   GCC_GMP_STRINGIFY_VERSION2 (__GNU_MP_VERSION_MINOR) "." \
     650              :   GCC_GMP_STRINGIFY_VERSION2 (__GNU_MP_VERSION_PATCHLEVEL)
     651              : #endif
     652         4828 :   fprintf (file,
     653         2414 :            file == stderr ? _(fmt2) : fmt2,
     654              :            GCC_GMP_STRINGIFY_VERSION, MPFR_VERSION_STRING, MPC_VERSION_STRING,
     655              : #ifndef HAVE_isl
     656              :            "none"
     657              : #else
     658              :            isl_version ()
     659              : #endif
     660              :            );
     661         2414 :   if (strcmp (GCC_GMP_STRINGIFY_VERSION, gmp_version))
     662            0 :     fprintf (file,
     663            0 :              file == stderr ? _(fmt3) : fmt3,
     664            0 :              indent, *indent != 0 ? " " : "",
     665              :              "GMP", GCC_GMP_STRINGIFY_VERSION, gmp_version);
     666         2414 :   if (strcmp (MPFR_VERSION_STRING, mpfr_get_version ()))
     667            0 :     fprintf (file,
     668            0 :              file == stderr ? _(fmt3) : fmt3,
     669            0 :              indent, *indent != 0 ? " " : "",
     670              :              "MPFR", MPFR_VERSION_STRING, mpfr_get_version ());
     671         2414 :   if (strcmp (MPC_VERSION_STRING, mpc_get_version ()))
     672            0 :     fprintf (file,
     673            0 :              file == stderr ? _(fmt3) : fmt3,
     674            0 :              indent, *indent != 0 ? " " : "",
     675              :              "MPC", MPC_VERSION_STRING, mpc_get_version ());
     676              : 
     677         2414 :   if (show_global_state)
     678              :     {
     679          124 :       fprintf (file,
     680          124 :                file == stderr ? _(fmt4) : fmt4,
     681          124 :                indent, *indent != 0 ? " " : "",
     682              :                param_ggc_min_expand, param_ggc_min_heapsize);
     683              : 
     684          124 :       print_plugins_versions (file, indent);
     685              :     }
     686         2414 : }
     687              : 
     688              : 
     689              : 
     690              : /* Open assembly code output file.  Do this even if -fsyntax-only is
     691              :    on, because then the driver will have provided the name of a
     692              :    temporary file or bit bucket for us.  NAME is the file specified on
     693              :    the command line, possibly NULL.  */
     694              : static void
     695       270821 : init_asm_output (const char *name)
     696              : {
     697       270821 :   if (name == NULL && asm_file_name == 0)
     698            0 :     asm_out_file = stdout;
     699              :   else
     700              :     {
     701       270821 :       if (asm_file_name == 0)
     702              :         {
     703         1326 :           int len = strlen (dump_base_name);
     704         1326 :           char *dumpname = XNEWVEC (char, len + 6);
     705              : 
     706         1326 :           memcpy (dumpname, dump_base_name, len + 1);
     707         1326 :           strip_off_ending (dumpname, len);
     708         1326 :           strcat (dumpname, ".s");
     709         1326 :           asm_file_name = dumpname;
     710              :         }
     711       270821 :       if (!strcmp (asm_file_name, "-"))
     712          163 :         asm_out_file = stdout;
     713       270658 :       else if (!canonical_filename_eq (asm_file_name, name)
     714       270658 :                || !strcmp (asm_file_name, HOST_BIT_BUCKET))
     715       270658 :         asm_out_file = fopen (asm_file_name, "w");
     716              :       else
     717              :         /* Use UNKOWN_LOCATION to prevent gcc from printing the first
     718              :            line in the current file. */
     719            0 :         fatal_error (UNKNOWN_LOCATION,
     720              :                      "input file %qs is the same as output file",
     721              :                      asm_file_name);
     722       270821 :       if (asm_out_file == 0)
     723            0 :         fatal_error (UNKNOWN_LOCATION,
     724              :                      "cannot open %qs for writing: %m", asm_file_name);
     725              :     }
     726              : 
     727       270821 :   if (!flag_syntax_only && !(global_dc->get_lang_mask () & CL_LTODump))
     728              :     {
     729       270554 :       targetm.asm_out.file_start ();
     730              : 
     731       270554 :       if (flag_record_gcc_switches)
     732              :         {
     733            0 :           if (targetm.asm_out.record_gcc_switches)
     734              :             {
     735            0 :               const char *str
     736            0 :                 = gen_producer_string (lang_hooks.name,
     737              :                                        save_decoded_options,
     738              :                                        save_decoded_options_count);
     739            0 :               targetm.asm_out.record_gcc_switches (str);
     740              :             }
     741              :           else
     742            0 :             inform (UNKNOWN_LOCATION,
     743              :                     "%<-frecord-gcc-switches%> is not supported by "
     744              :                     "the current target");
     745              :         }
     746              : 
     747       270554 :       if (flag_verbose_asm)
     748              :         {
     749           11 :           print_version (asm_out_file, ASM_COMMENT_START, true);
     750           11 :           fputs (ASM_COMMENT_START, asm_out_file);
     751           11 :           fputs (" options passed: ", asm_out_file);
     752           11 :           char *cmdline = gen_command_line_string (save_decoded_options,
     753              :                                                    save_decoded_options_count);
     754           11 :           fputs (cmdline, asm_out_file);
     755           11 :           free (cmdline);
     756           11 :           fputc ('\n', asm_out_file);
     757              :         }
     758              :     }
     759       270821 : }
     760              : 
     761              : /* A helper function; used as the reallocator function for cpp's line
     762              :    table.  */
     763              : static void *
     764    647619002 : realloc_for_line_map (void *ptr, size_t len)
     765              : {
     766    647619002 :   return ggc_realloc (ptr, len);
     767              : }
     768              : 
     769              : /* A helper function: used as the allocator function for
     770              :    identifier_to_locale.  */
     771              : static void *
     772         1287 : alloc_for_identifier_to_locale (size_t len)
     773              : {
     774         1287 :   return ggc_alloc_atomic (len);
     775              : }
     776              : 
     777              : /* Output stack usage information.  */
     778              : static void
     779          355 : output_stack_usage_1 (FILE *cf)
     780              : {
     781          355 :   static bool warning_issued = false;
     782          355 :   enum stack_usage_kind_type { STATIC = 0, DYNAMIC, DYNAMIC_BOUNDED };
     783          355 :   const char *stack_usage_kind_str[] = {
     784              :     "static",
     785              :     "dynamic",
     786              :     "dynamic,bounded"
     787              :   };
     788          355 :   HOST_WIDE_INT stack_usage = current_function_static_stack_size;
     789          355 :   enum stack_usage_kind_type stack_usage_kind;
     790              : 
     791          355 :   if (stack_usage < 0)
     792              :     {
     793            0 :       if (!warning_issued)
     794              :         {
     795            0 :           warning (0, "stack usage computation not supported for this target");
     796            0 :           warning_issued = true;
     797              :         }
     798            0 :       return;
     799              :     }
     800              : 
     801          355 :   stack_usage_kind = STATIC;
     802              : 
     803              :   /* Add the maximum amount of space pushed onto the stack.  */
     804          355 :   if (maybe_ne (current_function_pushed_stack_size, 0))
     805              :     {
     806            0 :       HOST_WIDE_INT extra;
     807            0 :       if (current_function_pushed_stack_size.is_constant (&extra))
     808              :         {
     809            0 :           stack_usage += extra;
     810            0 :           stack_usage_kind = DYNAMIC_BOUNDED;
     811              :         }
     812              :       else
     813              :         {
     814              :           extra = constant_lower_bound (current_function_pushed_stack_size);
     815              :           stack_usage += extra;
     816              :           stack_usage_kind = DYNAMIC;
     817              :         }
     818              :     }
     819              : 
     820              :   /* Now on to the tricky part: dynamic stack allocation.  */
     821          355 :   if (current_function_allocates_dynamic_stack_space)
     822              :     {
     823            2 :       if (stack_usage_kind != DYNAMIC)
     824              :         {
     825            2 :           if (current_function_has_unbounded_dynamic_stack_size)
     826              :             stack_usage_kind = DYNAMIC;
     827              :           else
     828            1 :             stack_usage_kind = DYNAMIC_BOUNDED;
     829              :         }
     830              : 
     831              :       /* Add the size even in the unbounded case, this can't hurt.  */
     832            2 :       stack_usage += current_function_dynamic_stack_size;
     833              :     }
     834              : 
     835          355 :   if (cf && flag_callgraph_info & CALLGRAPH_INFO_STACK_USAGE)
     836            0 :     fprintf (cf, "\\n" HOST_WIDE_INT_PRINT_DEC " bytes (%s)",
     837              :              stack_usage,
     838            0 :              stack_usage_kind_str[stack_usage_kind]);
     839              : 
     840          355 :   if (stack_usage_file)
     841              :     {
     842          329 :       print_decl_identifier (stack_usage_file, current_function_decl,
     843              :                              PRINT_DECL_ORIGIN | PRINT_DECL_NAME
     844              :                              | PRINT_DECL_REMAP_DEBUG);
     845          329 :       fprintf (stack_usage_file, "\t" HOST_WIDE_INT_PRINT_DEC"\t%s\n",
     846          329 :                stack_usage, stack_usage_kind_str[stack_usage_kind]);
     847              :     }
     848              : 
     849          355 :   if (warn_stack_usage >= 0 && warn_stack_usage < HOST_WIDE_INT_MAX)
     850              :     {
     851           13 :       const location_t loc = DECL_SOURCE_LOCATION (current_function_decl);
     852              : 
     853           13 :       if (stack_usage_kind == DYNAMIC)
     854            1 :         warning_at (loc, OPT_Wstack_usage_, "stack usage might be unbounded");
     855           12 :       else if (stack_usage > warn_stack_usage)
     856              :         {
     857            2 :           if (stack_usage_kind == DYNAMIC_BOUNDED)
     858            1 :             warning_at (loc,
     859            1 :                         OPT_Wstack_usage_, "stack usage might be %wu bytes",
     860              :                         stack_usage);
     861              :           else
     862            1 :             warning_at (loc, OPT_Wstack_usage_, "stack usage is %wu bytes",
     863              :                         stack_usage);
     864              :         }
     865              :     }
     866              : }
     867              : 
     868              : /* Dump placeholder node for indirect calls in VCG format.  */
     869              : 
     870              : #define INDIRECT_CALL_NAME  "__indirect_call"
     871              : 
     872              : static void
     873            2 : dump_final_node_vcg_start (FILE *f, tree decl)
     874              : {
     875            2 :   fputs ("node: { title: \"", f);
     876            2 :   if (decl)
     877            2 :     print_decl_identifier (f, decl, PRINT_DECL_UNIQUE_NAME);
     878              :   else
     879            0 :     fputs (INDIRECT_CALL_NAME, f);
     880            2 :   fputs ("\" label: \"", f);
     881            2 :   if (decl)
     882              :     {
     883            2 :       print_decl_identifier (f, decl, PRINT_DECL_NAME);
     884            2 :       fputs ("\\n", f);
     885            2 :       print_decl_identifier (f, decl, PRINT_DECL_ORIGIN);
     886              :     }
     887              :   else
     888            0 :     fputs ("Indirect Call Placeholder", f);
     889            2 : }
     890              : 
     891              : /* Dump final cgraph edge in VCG format.  */
     892              : 
     893              : static void
     894            0 : dump_final_callee_vcg (FILE *f, location_t location, tree callee)
     895              : {
     896            0 :   if ((!callee || DECL_EXTERNAL (callee))
     897            0 :       && bitmap_set_bit (callgraph_info_external_printed,
     898            0 :                          callee ? DECL_UID (callee) + 1 : 0))
     899              :     {
     900            0 :       dump_final_node_vcg_start (f, callee);
     901            0 :       fputs ("\" shape : ellipse }\n", f);
     902              :     }
     903              : 
     904            0 :   fputs ("edge: { sourcename: \"", f);
     905            0 :   print_decl_identifier (f, current_function_decl, PRINT_DECL_UNIQUE_NAME);
     906            0 :   fputs ("\" targetname: \"", f);
     907            0 :   if (callee)
     908            0 :     print_decl_identifier (f, callee, PRINT_DECL_UNIQUE_NAME);
     909              :   else
     910            0 :     fputs (INDIRECT_CALL_NAME, f);
     911            0 :   if (LOCATION_LOCUS (location) != UNKNOWN_LOCATION)
     912              :     {
     913            0 :       expanded_location loc;
     914            0 :       fputs ("\" label: \"", f);
     915            0 :       loc = expand_location (location);
     916            0 :       fprintf (f, "%s:%d:%d", loc.file, loc.line, loc.column);
     917              :     }
     918            0 :   fputs ("\" }\n", f);
     919            0 : }
     920              : 
     921              : /* Callback for cgraph_node::call_for_symbol_thunks_and_aliases to dump to F_ a
     922              :    node and an edge from ALIAS->DECL to CURRENT_FUNCTION_DECL.  */
     923              : 
     924              : static bool
     925            2 : dump_final_alias_vcg (cgraph_node *alias, void *f_)
     926              : {
     927            2 :   FILE *f = (FILE *)f_;
     928              : 
     929            2 :   if (alias->decl == current_function_decl)
     930              :     return false;
     931              : 
     932            1 :   dump_final_node_vcg_start (f, alias->decl);
     933            1 :   fputs ("\" shape : triangle }\n", f);
     934              : 
     935            1 :   fputs ("edge: { sourcename: \"", f);
     936            1 :   print_decl_identifier (f, alias->decl, PRINT_DECL_UNIQUE_NAME);
     937            1 :   fputs ("\" targetname: \"", f);
     938            1 :   print_decl_identifier (f, current_function_decl, PRINT_DECL_UNIQUE_NAME);
     939            1 :   location_t location = DECL_SOURCE_LOCATION (alias->decl);
     940            1 :   if (LOCATION_LOCUS (location) != UNKNOWN_LOCATION)
     941              :     {
     942            1 :       expanded_location loc;
     943            1 :       fputs ("\" label: \"", f);
     944            1 :       loc = expand_location (location);
     945            1 :       fprintf (f, "%s:%d:%d", loc.file, loc.line, loc.column);
     946              :     }
     947            1 :   fputs ("\" }\n", f);
     948              : 
     949            1 :   return false;
     950              : }
     951              : 
     952              : /* Dump final cgraph node in VCG format.  */
     953              : 
     954              : static void
     955            1 : dump_final_node_vcg (FILE *f)
     956              : {
     957            1 :   dump_final_node_vcg_start (f, current_function_decl);
     958              : 
     959            1 :   if (flag_stack_usage_info
     960            1 :       || (flag_callgraph_info & CALLGRAPH_INFO_STACK_USAGE))
     961            0 :     output_stack_usage_1 (f);
     962              : 
     963            1 :   if (flag_callgraph_info & CALLGRAPH_INFO_DYNAMIC_ALLOC)
     964              :     {
     965            0 :       fprintf (f, "\\n%u dynamic objects", vec_safe_length (cfun->su->dallocs));
     966              : 
     967            0 :       unsigned i;
     968            0 :       callinfo_dalloc *cda;
     969            0 :       FOR_EACH_VEC_SAFE_ELT (cfun->su->dallocs, i, cda)
     970              :         {
     971            0 :           expanded_location loc = expand_location (cda->location);
     972            0 :           fprintf (f, "\\n %s", cda->name);
     973            0 :           fprintf (f, " %s:%d:%d", loc.file, loc.line, loc.column);
     974              :         }
     975              : 
     976            0 :       vec_free (cfun->su->dallocs);
     977            0 :       cfun->su->dallocs = NULL;
     978              :     }
     979              : 
     980            1 :   fputs ("\" }\n", f);
     981              : 
     982            1 :   unsigned i;
     983            1 :   callinfo_callee *c;
     984            2 :   FOR_EACH_VEC_SAFE_ELT (cfun->su->callees, i, c)
     985            0 :     dump_final_callee_vcg (f, c->location, c->decl);
     986            1 :   vec_free (cfun->su->callees);
     987            1 :   cfun->su->callees = NULL;
     988              : 
     989            1 :   cgraph_node *node = cgraph_node::get (current_function_decl);
     990            1 :   if (!node)
     991            1 :     return;
     992            1 :   node->call_for_symbol_thunks_and_aliases (dump_final_alias_vcg, f,
     993              :                                             true, false);
     994              : }
     995              : 
     996              : /* Output stack usage and callgraph info, as requested.  */
     997              : void
     998          356 : output_stack_usage (void)
     999              : {
    1000          356 :   if (flag_callgraph_info)
    1001            1 :     dump_final_node_vcg (callgraph_info_file);
    1002              :   else
    1003          355 :     output_stack_usage_1 (NULL);
    1004          356 : }
    1005              : 
    1006              : /* Open an auxiliary output file.  */
    1007              : static FILE *
    1008          312 : open_auxiliary_file (const char *ext)
    1009              : {
    1010          312 :   char *filename;
    1011          312 :   FILE *file;
    1012              : 
    1013          312 :   filename = concat (aux_base_name, ".", ext, NULL);
    1014          312 :   file = fopen (filename, "w");
    1015          312 :   if (!file)
    1016            0 :     fatal_error (input_location, "cannot open %s for writing: %m", filename);
    1017          312 :   free (filename);
    1018          312 :   return file;
    1019              : }
    1020              : 
    1021              : /* Alternative diagnostics callback for reentered ICE reporting.  */
    1022              : 
    1023              : static void
    1024            0 : internal_error_reentered (diagnostics::context *, const char *, va_list *)
    1025              : {
    1026              :   /* Flush the dump file if emergency_dump_function itself caused an ICE.  */
    1027            0 :   if (dump_file)
    1028            0 :     fflush (dump_file);
    1029            0 : }
    1030              : 
    1031              : /* Auxiliary callback for the diagnostics code.  */
    1032              : 
    1033              : static void
    1034           22 : internal_error_function (diagnostics::context *, const char *, va_list *)
    1035              : {
    1036           22 :   global_dc->set_internal_error_callback (internal_error_reentered);
    1037           22 :   warn_if_plugins ();
    1038           22 :   emergency_dump_function ();
    1039           22 : }
    1040              : 
    1041              : /* Initialization of the front end environment, before command line
    1042              :    options are parsed.  Signal handlers, internationalization etc.
    1043              :    ARGV0 is main's argv[0].  */
    1044              : static void
    1045       285722 : general_init (const char *argv0, bool init_signals, unique_argv original_argv)
    1046              : {
    1047       285722 :   const char *p;
    1048              : 
    1049       285722 :   p = argv0 + strlen (argv0);
    1050      1663174 :   while (p != argv0 && !IS_DIR_SEPARATOR (p[-1]))
    1051      1377452 :     --p;
    1052       285722 :   progname = p;
    1053              : 
    1054       285722 :   xmalloc_set_program_name (progname);
    1055              : 
    1056       285722 :   hex_init ();
    1057              : 
    1058              :   /* Unlock the stdio streams.  */
    1059       285722 :   unlock_std_streams ();
    1060              : 
    1061       285722 :   gcc_init_libintl ();
    1062              : 
    1063       285722 :   identifier_to_locale_alloc = alloc_for_identifier_to_locale;
    1064       285722 :   identifier_to_locale_free = ggc_free;
    1065              : 
    1066              :   /* Initialize the diagnostics reporting machinery, so option parsing
    1067              :      can give warnings and errors.  */
    1068       285722 :   diagnostic_initialize (global_dc, N_OPTS);
    1069              :   /* Set a default printer.  Language specific initializations will
    1070              :      override it later.  */
    1071       285722 :   tree_diagnostics_defaults (global_dc);
    1072              : 
    1073       285722 :   global_dc->set_original_argv (std::move (original_argv));
    1074              : 
    1075       285722 :   auto &source_printing_opts = global_dc->get_source_printing_options ();
    1076       285722 :   source_printing_opts.enabled
    1077       285722 :     = global_options_init.x_flag_diagnostics_show_caret;
    1078       285722 :   source_printing_opts.show_event_links_p
    1079       285722 :     = global_options_init.x_flag_diagnostics_show_event_links;
    1080       285722 :   source_printing_opts.show_labels_p
    1081       285722 :     = global_options_init.x_flag_diagnostics_show_labels;
    1082       285722 :   source_printing_opts.show_line_numbers_p
    1083       285722 :     = global_options_init.x_flag_diagnostics_show_line_numbers;
    1084       285722 :   global_dc->set_show_cwe (global_options_init.x_flag_diagnostics_show_cwe);
    1085       285722 :   global_dc->set_show_rules (global_options_init.x_flag_diagnostics_show_rules);
    1086       285722 :   global_dc->set_path_format
    1087       285722 :     ((enum diagnostic_path_format)
    1088       285722 :      global_options_init.x_flag_diagnostics_path_format);
    1089       285722 :   global_dc->set_show_path_depths
    1090       285722 :     (global_options_init.x_flag_diagnostics_show_path_depths);
    1091       285722 :   global_dc->set_show_option_requested
    1092       285722 :     (global_options_init.x_flag_diagnostics_show_option);
    1093       285722 :   source_printing_opts.min_margin_width
    1094       285722 :     = global_options_init.x_diagnostics_minimum_margin_width;
    1095       285722 :   global_dc->m_show_column
    1096       285722 :     = global_options_init.x_flag_show_column;
    1097       285722 :   global_dc->set_show_highlight_colors
    1098       285722 :     (global_options_init.x_flag_diagnostics_show_highlight_colors);
    1099       285722 :   global_dc->set_show_nesting
    1100       285722 :     (global_options_init.x_flag_diagnostics_show_nesting);
    1101       285722 :   global_dc->set_show_nesting_locations
    1102       285722 :     (global_options_init.x_flag_diagnostics_show_nesting_locations);
    1103       285722 :   global_dc->set_show_nesting_levels
    1104       285722 :     (global_options_init.x_flag_diagnostics_show_nesting_levels);
    1105       285722 :   global_dc->set_internal_error_callback (internal_error_function);
    1106       285722 :   const unsigned lang_mask = lang_hooks.option_lang_mask ();
    1107       285722 :   global_dc->set_option_id_manager
    1108       285722 :     (std::make_unique<compiler_diagnostic_option_id_manager> (*global_dc,
    1109              :                                                               lang_mask,
    1110       285722 :                                                               &global_options),
    1111              :      lang_mask);
    1112       285722 :   global_dc->push_owned_urlifier (make_gcc_urlifier (lang_mask));
    1113              : 
    1114       285722 :   if (init_signals)
    1115              :     {
    1116              :       /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages.  */
    1117              : #ifdef SIGSEGV
    1118       284391 :       signal (SIGSEGV, crash_signal);
    1119              : #endif
    1120              : #ifdef SIGILL
    1121       284391 :       signal (SIGILL, crash_signal);
    1122              : #endif
    1123              : #ifdef SIGBUS
    1124       284391 :       signal (SIGBUS, crash_signal);
    1125              : #endif
    1126              : #ifdef SIGABRT
    1127       284391 :       signal (SIGABRT, crash_signal);
    1128              : #endif
    1129              : #if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT)
    1130              :       signal (SIGIOT, crash_signal);
    1131              : #endif
    1132              : #ifdef SIGFPE
    1133       284391 :       signal (SIGFPE, crash_signal);
    1134              : #endif
    1135              : 
    1136              :       /* Other host-specific signal setup.  */
    1137       284391 :       (*host_hooks.extra_signals)();
    1138              :   }
    1139              : 
    1140              :   /* Initialize the garbage-collector, string pools and tree type hash
    1141              :      table.  */
    1142       285722 :   init_ggc ();
    1143       285722 :   init_stringpool ();
    1144       285722 :   input_location = UNKNOWN_LOCATION;
    1145       285722 :   line_table = ggc_alloc<line_maps> ();
    1146       285722 :   linemap_init (line_table, BUILTINS_LOCATION);
    1147       285722 :   line_table->m_reallocator = realloc_for_line_map;
    1148       285722 :   line_table->m_round_alloc_size = ggc_round_alloc_size;
    1149       285722 :   line_table->default_range_bits = line_map_suggested_range_bits;
    1150       285722 :   init_ttree ();
    1151              : 
    1152              :   /* Initialize register usage now so switches may override.  */
    1153       285722 :   init_reg_sets ();
    1154              : 
    1155              :   /* Create the singleton holder for global state.  This creates the
    1156              :      dump manager.  */
    1157       285722 :   g = new gcc::context ();
    1158              : 
    1159              :   /* Allow languages and middle-end to register their dumps before the
    1160              :      optimization passes.  */
    1161       285722 :   g->get_dumps ()->register_dumps ();
    1162              : 
    1163              :   /* Create the passes.  */
    1164       285722 :   g->set_passes (new gcc::pass_manager (g));
    1165              : 
    1166       285722 :   symtab = new (ggc_alloc <symbol_table> ()) symbol_table ();
    1167              : 
    1168       285722 :   statistics_early_init ();
    1169       285722 :   debuginfo_early_init ();
    1170       285722 : }
    1171              : 
    1172              : /* Return true if the current target supports -fsection-anchors.  */
    1173              : 
    1174              : static bool
    1175            0 : target_supports_section_anchors_p (void)
    1176              : {
    1177            0 :   if (targetm.min_anchor_offset == 0 && targetm.max_anchor_offset == 0)
    1178              :     return false;
    1179              : 
    1180            0 :   if (targetm.asm_out.output_anchor == NULL)
    1181            0 :     return false;
    1182              : 
    1183              :   return true;
    1184              : }
    1185              : 
    1186              : /* Parse "N[:M][:...]" into struct align_flags A.
    1187              :    VALUES contains parsed values (in reverse order), all processed
    1188              :    values are popped.  */
    1189              : 
    1190              : static void
    1191       598792 : read_log_maxskip (auto_vec<unsigned> &values, align_flags_tuple *a)
    1192              : {
    1193       598792 :   unsigned n = values.pop ();
    1194       598792 :   if (n != 0)
    1195       479035 :     a->log = floor_log2 (n * 2 - 1);
    1196              : 
    1197       598792 :   if (values.is_empty ())
    1198       359275 :     a->maxskip = n ? n - 1 : 0;
    1199              :   else
    1200              :     {
    1201       239517 :       unsigned m = values.pop ();
    1202              :       /* -falign-foo=N:M means M-1 max bytes of padding, not M.  */
    1203       239517 :       if (m > 0)
    1204       119760 :         m--;
    1205       239517 :       a->maxskip = m;
    1206              :     }
    1207              : 
    1208              :   /* Normalize the tuple.  */
    1209       598792 :   a->normalize ();
    1210       598792 : }
    1211              : 
    1212              : /* Parse "N[:M[:N2[:M2]]]" string FLAG into a pair of struct align_flags.  */
    1213              : 
    1214              : static void
    1215   3405512280 : parse_N_M (const char *flag, align_flags &a)
    1216              : {
    1217   3405512280 :   if (flag)
    1218              :     {
    1219   3123098824 :       static hash_map <nofree_string_hash, align_flags> cache;
    1220   3123098824 :       align_flags *entry = cache.get (flag);
    1221   3123098824 :       if (entry)
    1222              :         {
    1223   3122739546 :           a = *entry;
    1224   3122739546 :           return;
    1225              :         }
    1226              : 
    1227       359278 :       auto_vec<unsigned> result_values;
    1228       359278 :       bool r = parse_and_check_align_values (flag, NULL, result_values, false,
    1229              :                                              UNKNOWN_LOCATION);
    1230       359278 :       if (!r)
    1231            0 :         return;
    1232              : 
    1233              :       /* Reverse values for easier manipulation.  */
    1234       359278 :       result_values.reverse ();
    1235              : 
    1236       359278 :       read_log_maxskip (result_values, &a.levels[0]);
    1237       359278 :       if (!result_values.is_empty ())
    1238       239514 :         read_log_maxskip (result_values, &a.levels[1]);
    1239              : #ifdef SUBALIGN_LOG
    1240              :       else
    1241              :         {
    1242              :           /* N2[:M2] is not specified.  This arch has a default for N2.
    1243              :              Before -falign-foo=N:M:N2:M2 was introduced, x86 had a tweak.
    1244              :              -falign-functions=N with N > 8 was adding secondary alignment.
    1245              :              -falign-functions=10 was emitting this before every function:
    1246              :                         .p2align 4,,9
    1247              :                         .p2align 3
    1248              :              Now this behavior (and more) can be explicitly requested:
    1249              :              -falign-functions=16:10:8
    1250              :              Retain old behavior if N2 is missing: */
    1251              : 
    1252       119764 :           int align = 1 << a.levels[0].log;
    1253       119764 :           int subalign = 1 << SUBALIGN_LOG;
    1254              : 
    1255       119764 :           if (a.levels[0].log > SUBALIGN_LOG
    1256       119763 :               && a.levels[0].maxskip >= subalign - 1)
    1257              :             {
    1258              :               /* Set N2 unless subalign can never have any effect.  */
    1259       119763 :               if (align > a.levels[0].maxskip + 1)
    1260              :                 {
    1261           32 :                   a.levels[1].log = SUBALIGN_LOG;
    1262           32 :                   a.levels[1].normalize ();
    1263              :                 }
    1264              :             }
    1265              :         }
    1266              : #endif
    1267              : 
    1268              :       /* Cache seen value.  */
    1269       359278 :       cache.put (flag, a);
    1270       359278 :     }
    1271              : }
    1272              : 
    1273              : /* Process -falign-foo=N[:M[:N2[:M2]]] options.  */
    1274              : 
    1275              : void
    1276    851378070 : parse_alignment_opts (void)
    1277              : {
    1278    851378070 :   parse_N_M (str_align_loops, align_loops);
    1279    851378070 :   parse_N_M (str_align_jumps, align_jumps);
    1280    851378070 :   parse_N_M (str_align_labels, align_labels);
    1281    851378070 :   parse_N_M (str_align_functions, align_functions);
    1282    851378070 : }
    1283              : 
    1284              : /* Process the options that have been parsed.  */
    1285              : static void
    1286       285643 : process_options ()
    1287              : {
    1288       285643 :   const char *language_string = lang_hooks.name;
    1289              : 
    1290       285643 :   maximum_field_alignment = initial_max_fld_align * BITS_PER_UNIT;
    1291              : 
    1292              :   /* Some machines may reject certain combinations of options.  */
    1293       285643 :   location_t saved_location = input_location;
    1294       285643 :   input_location = UNKNOWN_LOCATION;
    1295       285643 :   targetm.target_option.override ();
    1296       285643 :   input_location = saved_location;
    1297              : 
    1298       285643 :   if (flag_diagnostics_generate_patch)
    1299           17 :     global_dc->initialize_fixits_change_set ();
    1300              : 
    1301              :   /* Avoid any informative notes in the second run of -fcompare-debug.  */
    1302       285643 :   if (flag_compare_debug)
    1303          616 :     global_dc->inhibit_notes ();
    1304              : 
    1305       285643 :   if (flag_section_anchors && !target_supports_section_anchors_p ())
    1306              :     {
    1307            0 :       warning_at (UNKNOWN_LOCATION, OPT_fsection_anchors,
    1308              :                   "this target does not support %qs",
    1309              :                   "-fsection-anchors");
    1310            0 :       flag_section_anchors = 0;
    1311              :     }
    1312              : 
    1313       285643 :   if (!OPTION_SET_P (flag_short_enums))
    1314       285515 :     flag_short_enums = targetm.default_short_enums ();
    1315              : 
    1316              :   /* Set aux_base_name if not already set.  */
    1317       285643 :   if (aux_base_name)
    1318              :     ;
    1319       285643 :   else if (dump_base_name)
    1320              :     {
    1321       282870 :       const char *name = dump_base_name;
    1322       282870 :       int nlen, len;
    1323              : 
    1324       262219 :       if (dump_base_ext && (len = strlen (dump_base_ext))
    1325       262219 :           && (nlen = strlen (name)) && nlen > len
    1326       545089 :           && strcmp (name + nlen - len, dump_base_ext) == 0)
    1327              :         {
    1328       262219 :           char *p = xstrndup (name, nlen - len);
    1329       262219 :           name = p;
    1330              :         }
    1331              : 
    1332       282870 :       aux_base_name = name;
    1333              :     }
    1334              :   else
    1335         2773 :     aux_base_name = "gccaux";
    1336              : 
    1337              : #ifndef HAVE_isl
    1338              :   if (flag_graphite
    1339              :       || flag_loop_nest_optimize
    1340              :       || flag_graphite_identity
    1341              :       || flag_loop_parallelize_all)
    1342              :     sorry ("Graphite loop optimizations cannot be used (isl is not available) "
    1343              :            "(%<-fgraphite%>, %<-fgraphite-identity%>, "
    1344              :            "%<-floop-nest-optimize%>, %<-floop-parallelize-all%>)");
    1345              : #endif
    1346              : 
    1347       285643 :   if (flag_cf_protection != CF_NONE
    1348        20110 :       && !(flag_cf_protection & CF_SET))
    1349              :     {
    1350            0 :       if (flag_cf_protection == CF_FULL)
    1351              :         {
    1352            0 :           error_at (UNKNOWN_LOCATION,
    1353              :                     "%<-fcf-protection=full%> is not supported for this "
    1354              :                     "target");
    1355            0 :           flag_cf_protection = CF_NONE;
    1356              :         }
    1357            0 :       if (flag_cf_protection == CF_BRANCH)
    1358              :         {
    1359            0 :           error_at (UNKNOWN_LOCATION,
    1360              :                     "%<-fcf-protection=branch%> is not supported for this "
    1361              :                     "target");
    1362            0 :           flag_cf_protection = CF_NONE;
    1363              :         }
    1364            0 :       if (flag_cf_protection == CF_RETURN)
    1365              :         {
    1366            0 :           error_at (UNKNOWN_LOCATION,
    1367              :                     "%<-fcf-protection=return%> is not supported for this "
    1368              :                     "target");
    1369            0 :           flag_cf_protection = CF_NONE;
    1370              :         }
    1371              :     }
    1372              : 
    1373              :   /* One region RA really helps to decrease the code size.  */
    1374       285643 :   if (!OPTION_SET_P (flag_ira_region))
    1375       285640 :     flag_ira_region
    1376       411091 :       = optimize_size || !optimize ? IRA_REGION_ONE : IRA_REGION_MIXED;
    1377              : 
    1378       285643 :   if (!abi_version_at_least (2))
    1379              :     {
    1380              :       /* -fabi-version=1 support was removed after GCC 4.9.  */
    1381            0 :       error_at (UNKNOWN_LOCATION,
    1382              :                 "%<-fabi-version=1%> is no longer supported");
    1383            0 :       flag_abi_version = 2;
    1384              :     }
    1385              : 
    1386       285643 :   if (flag_non_call_exceptions)
    1387         5517 :     flag_asynchronous_unwind_tables = 1;
    1388       285643 :   if (flag_asynchronous_unwind_tables)
    1389       285615 :     flag_unwind_tables = 1;
    1390              : 
    1391       285643 :   if (flag_value_profile_transformations)
    1392          155 :     flag_profile_values = 1;
    1393              : 
    1394              :   /* Warn about options that are not supported on this machine.  */
    1395              : #ifndef INSN_SCHEDULING
    1396              :   if (flag_schedule_insns || flag_schedule_insns_after_reload)
    1397              :     warning_at (UNKNOWN_LOCATION, 0,
    1398              :                 "instruction scheduling not supported on this target machine");
    1399              : #endif
    1400       285643 :   if (!DELAY_SLOTS && flag_delayed_branch)
    1401            0 :     warning_at (UNKNOWN_LOCATION, 0,
    1402              :                 "this target machine does not have delayed branches");
    1403              : 
    1404       285643 :   user_label_prefix = USER_LABEL_PREFIX;
    1405       285643 :   if (flag_leading_underscore != -1)
    1406              :     {
    1407              :       /* If the default prefix is more complicated than "" or "_",
    1408              :          issue a warning and ignore this option.  */
    1409            3 :       if (user_label_prefix[0] == 0 ||
    1410              :           (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
    1411              :         {
    1412            3 :           user_label_prefix = flag_leading_underscore ? "_" : "";
    1413              :         }
    1414              :       else
    1415              :         warning_at (UNKNOWN_LOCATION, 0,
    1416              :                     "%<-f%sleading-underscore%> not supported on this "
    1417              :                     "target machine", flag_leading_underscore ? "" : "no-");
    1418              :     }
    1419              : 
    1420              :   /* If we are in verbose mode, write out the version and maybe all the
    1421              :      option flags in use.  */
    1422       285643 :   if (version_flag)
    1423              :     {
    1424              :       /* We already printed the version header in main ().  */
    1425          110 :       if (!quiet_flag)
    1426              :         {
    1427            0 :           fputs ("options passed: ", stderr);
    1428            0 :           char *cmdline = gen_command_line_string (save_decoded_options,
    1429              :                                                    save_decoded_options_count);
    1430              : 
    1431            0 :           fputs (cmdline, stderr);
    1432            0 :           free (cmdline);
    1433            0 :           fputc ('\n', stderr);
    1434              :         }
    1435              :     }
    1436              : 
    1437              :   /* CTF is supported for only C at this time.  */
    1438       285643 :   if (!lang_GNU_C ()
    1439       174750 :       && ctf_debug_info_level > CTFINFO_LEVEL_NONE
    1440       285679 :       && warn_complain_wrong_lang)
    1441              :     {
    1442              :       /* Compiling with -flto results in frontend language of GNU GIMPLE.  It
    1443              :          is not useful to warn in that case.  */
    1444           36 :       if (!startswith (lang_hooks.name, "GNU GIMPLE"))
    1445           34 :         inform (UNKNOWN_LOCATION,
    1446              :                 "CTF debug info requested, but not supported for %qs frontend",
    1447              :                 language_string);
    1448           36 :       ctf_debug_info_level = CTFINFO_LEVEL_NONE;
    1449              :     }
    1450              : 
    1451       285643 :   if (flag_dump_final_insns && !flag_syntax_only && !no_backend)
    1452              :     {
    1453         1233 :       FILE *final_output = fopen (flag_dump_final_insns, "w");
    1454         1233 :       if (!final_output)
    1455              :         {
    1456            0 :           error_at (UNKNOWN_LOCATION,
    1457              :                     "could not open final insn dump file %qs: %m",
    1458              :                     flag_dump_final_insns);
    1459            0 :           flag_dump_final_insns = NULL;
    1460              :         }
    1461         1233 :       else if (fclose (final_output))
    1462              :         {
    1463            0 :           error_at (UNKNOWN_LOCATION,
    1464              :                     "could not close zeroed insn dump file %qs: %m",
    1465              :                     flag_dump_final_insns);
    1466            0 :           flag_dump_final_insns = NULL;
    1467              :         }
    1468              :     }
    1469              : 
    1470              :   /* A lot of code assumes write_symbols == NO_DEBUG if the debugging
    1471              :      level is 0.  */
    1472       285643 :   if (debug_info_level == DINFO_LEVEL_NONE
    1473       227444 :       && ctf_debug_info_level == CTFINFO_LEVEL_NONE)
    1474       227440 :     write_symbols = NO_DEBUG;
    1475              : 
    1476       285643 :   if (write_symbols == NO_DEBUG)
    1477              :     ;
    1478              : #ifdef DWARF2_DEBUGGING_INFO
    1479        58203 :   else if (dwarf_debuginfo_p ())
    1480        57892 :     debug_hooks = &dwarf2_debug_hooks;
    1481              : #endif
    1482              : #ifdef CTF_DEBUGGING_INFO
    1483          311 :   else if (ctf_debuginfo_p ())
    1484          233 :     debug_hooks = &dwarf2_debug_hooks;
    1485              : #endif
    1486              : #ifdef BTF_DEBUGGING_INFO
    1487           78 :   else if (btf_debuginfo_p ())
    1488           78 :     debug_hooks = &dwarf2_debug_hooks;
    1489              : #endif
    1490              : #ifdef VMS_DEBUGGING_INFO
    1491              :   else if (write_symbols == VMS_DEBUG || write_symbols == VMS_AND_DWARF2_DEBUG)
    1492              :     debug_hooks = &vmsdbg_debug_hooks;
    1493              : #endif
    1494              : #ifdef DWARF2_LINENO_DEBUGGING_INFO
    1495              :   else if (write_symbols == DWARF2_DEBUG)
    1496              :     debug_hooks = &dwarf2_lineno_debug_hooks;
    1497              : #endif
    1498              : #ifdef CODEVIEW_DEBUGGING_INFO
    1499              :   else if (codeview_debuginfo_p ())
    1500              :     debug_hooks = &dwarf2_debug_hooks;
    1501              : #endif
    1502              :   else
    1503              :     {
    1504            0 :       gcc_assert (debug_set_count (write_symbols) <= 1);
    1505            0 :       error_at (UNKNOWN_LOCATION,
    1506              :                 "target system does not support the %qs debug format",
    1507            0 :                 debug_type_names[debug_set_to_format (write_symbols)]);
    1508              :     }
    1509              : 
    1510              :   /* The debug hooks are used to implement -fdump-go-spec because it
    1511              :      gives a simple and stable API for all the information we need to
    1512              :      dump.  */
    1513       285643 :   if (flag_dump_go_spec != NULL)
    1514            4 :     debug_hooks = dump_go_spec_init (flag_dump_go_spec, debug_hooks);
    1515              : 
    1516       285643 :   if (!OPTION_SET_P (dwarf2out_as_loc_support))
    1517       285637 :     dwarf2out_as_loc_support = dwarf2out_default_as_loc_support ();
    1518       285643 :   if (!OPTION_SET_P (dwarf2out_as_locview_support))
    1519       285643 :     dwarf2out_as_locview_support = dwarf2out_default_as_locview_support ();
    1520       285643 :   if (dwarf2out_as_locview_support && !dwarf2out_as_loc_support)
    1521              :     {
    1522            6 :       if (OPTION_SET_P (dwarf2out_as_locview_support))
    1523            0 :         warning_at (UNKNOWN_LOCATION, 0,
    1524              :                     "%<-gas-locview-support%> is forced disabled "
    1525              :                     "without %<-gas-loc-support%>");
    1526            6 :       dwarf2out_as_locview_support = false;
    1527              :     }
    1528              : 
    1529       285643 :   if (!OPTION_SET_P (debug_variable_location_views))
    1530              :     {
    1531       285643 :       debug_variable_location_views
    1532       571286 :         = (flag_var_tracking
    1533        49837 :            && debug_info_level >= DINFO_LEVEL_NORMAL
    1534        49837 :            && dwarf_debuginfo_p ()
    1535       571287 :            && !dwarf_strict);
    1536              :     }
    1537            0 :   else if (debug_variable_location_views == -1 && dwarf_version != 5)
    1538              :     {
    1539            0 :       warning_at (UNKNOWN_LOCATION, 0,
    1540              :                   "without %<-gdwarf-5%>, "
    1541              :                   "%<-gvariable-location-views=incompat5%> "
    1542              :                   "is equivalent to %<-gvariable-location-views%>");
    1543            0 :       debug_variable_location_views = 1;
    1544              :     }
    1545              : 
    1546       285643 :   if (debug_internal_reset_location_views == 2)
    1547              :     {
    1548       285643 :       debug_internal_reset_location_views
    1549       571286 :         = (debug_variable_location_views
    1550       571286 :            && targetm.reset_location_view);
    1551              :     }
    1552            0 :   else if (debug_internal_reset_location_views
    1553            0 :            && !debug_variable_location_views)
    1554              :     {
    1555            0 :       warning_at (UNKNOWN_LOCATION, 0,
    1556              :                   "%<-ginternal-reset-location-views%> is forced disabled "
    1557              :                   "without %<-gvariable-location-views%>");
    1558            0 :       debug_internal_reset_location_views = 0;
    1559              :     }
    1560              : 
    1561       285643 :   if (!OPTION_SET_P (debug_inline_points))
    1562       285643 :     debug_inline_points = debug_variable_location_views;
    1563            0 :   else if (debug_inline_points && !debug_nonbind_markers_p)
    1564              :     {
    1565            0 :       warning_at (UNKNOWN_LOCATION, 0,
    1566              :                   "%<-ginline-points%> is forced disabled without "
    1567              :                   "%<-gstatement-frontiers%>");
    1568            0 :       debug_inline_points = 0;
    1569              :     }
    1570              : 
    1571       285643 :   if (!OPTION_SET_P (flag_tree_cselim))
    1572              :     {
    1573       285613 :       if (HAVE_conditional_move)
    1574       285613 :         flag_tree_cselim = 1;
    1575              :       else
    1576              :         flag_tree_cselim = 0;
    1577              :     }
    1578              : 
    1579              :   /* If auxiliary info generation is desired, open the output file.
    1580              :      This goes in the same directory as the source file--unlike
    1581              :      all the other output files.  */
    1582       285643 :   if (flag_gen_aux_info)
    1583              :     {
    1584            0 :       aux_info_file = fopen (aux_info_file_name, "w");
    1585            0 :       if (aux_info_file == 0)
    1586            0 :         fatal_error (UNKNOWN_LOCATION,
    1587              :                      "cannot open %s: %m", aux_info_file_name);
    1588              :     }
    1589              : 
    1590       285643 :   if (!targetm_common.have_named_sections)
    1591              :     {
    1592            0 :       if (flag_function_sections)
    1593              :         {
    1594            0 :           warning_at (UNKNOWN_LOCATION, 0,
    1595              :                       "%<-ffunction-sections%> not supported for this target");
    1596            0 :           flag_function_sections = 0;
    1597              :         }
    1598            0 :       if (flag_data_sections)
    1599              :         {
    1600            0 :           warning_at (UNKNOWN_LOCATION, 0,
    1601              :                       "%<-fdata-sections%> not supported for this target");
    1602            0 :           flag_data_sections = 0;
    1603              :         }
    1604              :     }
    1605              : 
    1606       285643 :   if (flag_prefetch_loop_arrays > 0 && !targetm.code_for_prefetch)
    1607              :     {
    1608            0 :       warning_at (UNKNOWN_LOCATION, 0,
    1609              :                   "%<-fprefetch-loop-arrays%> not supported for this target");
    1610            0 :       flag_prefetch_loop_arrays = 0;
    1611              :     }
    1612       285643 :   else if (flag_prefetch_loop_arrays > 0 && !targetm.have_prefetch ())
    1613              :     {
    1614            0 :       warning_at (UNKNOWN_LOCATION, 0,
    1615              :                   "%<-fprefetch-loop-arrays%> not supported for this target "
    1616              :                   "(try %<-march%> switches)");
    1617            0 :       flag_prefetch_loop_arrays = 0;
    1618              :     }
    1619              : 
    1620              :   /* This combination of options isn't handled for i386 targets and doesn't
    1621              :      make much sense anyway, so don't allow it.  */
    1622       285643 :   if (flag_prefetch_loop_arrays > 0 && optimize_size)
    1623              :     {
    1624            2 :       warning_at (UNKNOWN_LOCATION, 0,
    1625              :                   "%<-fprefetch-loop-arrays%> is not supported with %<-Os%>");
    1626            2 :       flag_prefetch_loop_arrays = 0;
    1627              :     }
    1628              : 
    1629              :   /* The presence of IEEE signaling NaNs, implies all math can trap.  */
    1630       285643 :   if (flag_signaling_nans)
    1631          597 :     flag_trapping_math = 1;
    1632              : 
    1633              :   /* We cannot reassociate if we want traps or signed zeros.  */
    1634       285643 :   if (flag_associative_math && (flag_trapping_math || flag_signed_zeros))
    1635              :     {
    1636           18 :       warning_at (UNKNOWN_LOCATION, 0,
    1637              :                   "%<-fassociative-math%> disabled; other options take "
    1638              :                   "precedence");
    1639           18 :       flag_associative_math = 0;
    1640              :     }
    1641              : 
    1642       285643 :   if (flag_hardened && !HAVE_FHARDENED_SUPPORT)
    1643              :     {
    1644              :       warning_at (UNKNOWN_LOCATION, 0,
    1645              :                   "%<-fhardened%> not supported for this target");
    1646              :       flag_hardened = 0;
    1647              :     }
    1648              : 
    1649              :   /* -fstack-clash-protection is not currently supported on targets
    1650              :      where the stack grows up.  */
    1651       285643 :   if (flag_stack_clash_protection && !STACK_GROWS_DOWNWARD)
    1652              :     {
    1653              :       warning_at (UNKNOWN_LOCATION, 0,
    1654              :                   "%<-fstack-clash-protection%> is not supported on targets "
    1655              :                   "where the stack grows from lower to higher addresses");
    1656              :       flag_stack_clash_protection = 0;
    1657              :     }
    1658       285643 :   else if (flag_hardened)
    1659              :     {
    1660           91 :       if (!flag_stack_clash_protection
    1661              :            /* Don't enable -fstack-clash-protection when -fstack-check=
    1662              :               is used: it would result in confusing errors.  */
    1663           91 :            && flag_stack_check == NO_STACK_CHECK)
    1664           87 :         flag_stack_clash_protection = 1;
    1665            4 :       else if (flag_stack_check != NO_STACK_CHECK)
    1666            4 :         warning_at (UNKNOWN_LOCATION, OPT_Whardened,
    1667              :                     "%<-fstack-clash-protection%> is not enabled by "
    1668              :                     "%<-fhardened%> because %<-fstack-check%> was "
    1669              :                     "specified on the command line");
    1670              :     }
    1671              : 
    1672              :   /* We cannot support -fstack-check= and -fstack-clash-protection at
    1673              :      the same time.  */
    1674       285643 :   if (flag_stack_check != NO_STACK_CHECK && flag_stack_clash_protection)
    1675              :     {
    1676            0 :       warning_at (UNKNOWN_LOCATION, 0,
    1677              :                   "%<-fstack-check=%> and %<-fstack-clash-protection%> are "
    1678              :                   "mutually exclusive; disabling %<-fstack-check=%>");
    1679            0 :       flag_stack_check = NO_STACK_CHECK;
    1680              :     }
    1681              : 
    1682              :   /* Targets must be able to place spill slots at lower addresses.  If the
    1683              :      target already uses a soft frame pointer, the transition is trivial.  */
    1684       285643 :   if (!FRAME_GROWS_DOWNWARD && flag_stack_protect)
    1685              :     {
    1686              :       if (!flag_stack_protector_set_by_fhardened_p)
    1687              :         warning_at (UNKNOWN_LOCATION, 0,
    1688              :                     "%<-fstack-protector%> not supported for this target");
    1689              :       flag_stack_protect = 0;
    1690              :     }
    1691       285643 :   if (!flag_stack_protect)
    1692       285358 :     warn_stack_protect = 0;
    1693              : 
    1694              :   /* Address Sanitizer needs porting to each target architecture.  */
    1695              : 
    1696       285643 :   if ((flag_sanitize & SANITIZE_ADDRESS)
    1697              :       && !FRAME_GROWS_DOWNWARD)
    1698              :     {
    1699              :       warning_at (UNKNOWN_LOCATION, 0,
    1700              :                   "%<-fsanitize=address%> and %<-fsanitize=kernel-address%> "
    1701              :                   "are not supported for this target");
    1702              :       flag_sanitize &= ~SANITIZE_ADDRESS;
    1703              :     }
    1704              : 
    1705       285643 :   if ((flag_sanitize & SANITIZE_USER_ADDRESS)
    1706       285643 :       && ((targetm.asan_shadow_offset == NULL)
    1707         2881 :           || ((targetm.asan_shadow_offset () == 0)
    1708            0 :               && !targetm.asan_dynamic_shadow_offset_p ())))
    1709              :     {
    1710            0 :       warning_at (UNKNOWN_LOCATION, 0,
    1711              :                   "%<-fsanitize=address%> not supported for this target");
    1712            0 :       flag_sanitize &= ~SANITIZE_ADDRESS;
    1713              :     }
    1714              : 
    1715       285643 :   if ((flag_sanitize & SANITIZE_KERNEL_ADDRESS)
    1716       285643 :       && (targetm.asan_shadow_offset == NULL
    1717            0 :           && !asan_shadow_offset_set_p ()))
    1718              :     {
    1719            0 :       warning_at (UNKNOWN_LOCATION, 0,
    1720              :                   "%<-fsanitize=kernel-address%> with stack protection "
    1721              :                   "is not supported without %<-fasan-shadow-offset=%> "
    1722              :                   "for this target");
    1723            0 :       flag_sanitize &= ~SANITIZE_ADDRESS;
    1724              :     }
    1725              : 
    1726              :   /* HWAsan requires top byte ignore feature in the backend.  */
    1727       285643 :   if (flag_sanitize & SANITIZE_HWADDRESS
    1728       285643 :       && ! targetm.memtag.can_tag_addresses ())
    1729              :     {
    1730            0 :       warning_at (UNKNOWN_LOCATION, 0, "%qs is not supported for this target",
    1731              :                   "-fsanitize=hwaddress");
    1732            0 :       flag_sanitize &= ~SANITIZE_HWADDRESS;
    1733              :     }
    1734              : 
    1735       285643 :   if (flag_sanitize & SANITIZE_SHADOW_CALL_STACK)
    1736              :     {
    1737            0 :       if (!targetm.have_shadow_call_stack)
    1738            0 :         sorry ("%<-fsanitize=shadow-call-stack%> not supported "
    1739              :                "in current platform");
    1740            0 :       else if (flag_exceptions)
    1741            0 :         error_at (UNKNOWN_LOCATION, "%<-fsanitize=shadow-call-stack%> "
    1742              :                   "requires %<-fno-exceptions%>");
    1743              :     }
    1744              : 
    1745       285643 :   HOST_WIDE_INT patch_area_size, patch_area_start;
    1746       285643 :   parse_and_check_patch_area (flag_patchable_function_entry, false,
    1747              :                               &patch_area_size, &patch_area_start);
    1748              : 
    1749              :  /* Do not use IPA optimizations for register allocation if profiler is active
    1750              :     or patchable function entries are inserted for run-time instrumentation
    1751              :     or port does not emit prologue and epilogue as RTL.  */
    1752       285347 :   if (profile_flag || patch_area_size
    1753       570957 :       || !targetm.have_prologue () || !targetm.have_epilogue ())
    1754          329 :     flag_ipa_ra = 0;
    1755              : 
    1756              :   /* Enable -Werror=coverage-mismatch when -Werror and -Wno-error
    1757              :      have not been set.  */
    1758       285643 :   if (!OPTION_SET_P (warnings_are_errors))
    1759              :     {
    1760       281314 :       if (warn_coverage_mismatch
    1761       281314 :           && option_unspecified_p (OPT_Wcoverage_mismatch))
    1762       281308 :         diagnostic_classify_diagnostic (global_dc, OPT_Wcoverage_mismatch,
    1763              :                                         diagnostics::kind::error,
    1764              :                                         UNKNOWN_LOCATION);
    1765       281314 :       if (warn_coverage_invalid_linenum
    1766       281314 :           && option_unspecified_p (OPT_Wcoverage_invalid_line_number))
    1767       281313 :         diagnostic_classify_diagnostic (global_dc, OPT_Wcoverage_invalid_line_number,
    1768              :                                         diagnostics::kind::error,
    1769              :                                         UNKNOWN_LOCATION);
    1770              :     }
    1771              : 
    1772              :   /* Save the current optimization options.  */
    1773       285643 :   optimization_default_node
    1774       285643 :     = build_optimization_node (&global_options, &global_options_set);
    1775       285643 :   optimization_current_node = optimization_default_node;
    1776              : 
    1777       285643 :   if (flag_checking >= 2)
    1778       285581 :     hash_table_sanitize_eq_limit
    1779       285581 :       = param_hash_table_verification_limit;
    1780              : 
    1781       285643 :   diagnose_options (&global_options, &global_options_set, UNKNOWN_LOCATION);
    1782              : 
    1783              :   /* Please don't change global_options after this point, those changes won't
    1784              :      be reflected in optimization_{default,current}_node.  */
    1785       285643 : }
    1786              : 
    1787              : /* This function can be called multiple times to reinitialize the compiler
    1788              :    back end when register classes or instruction sets have changed,
    1789              :    before each function.  */
    1790              : static void
    1791       213440 : backend_init_target (void)
    1792              : {
    1793              :   /* This depends on stack_pointer_rtx.  */
    1794       213440 :   init_fake_stack_mems ();
    1795              : 
    1796              :   /* Sets static_base_value[HARD_FRAME_POINTER_REGNUM], which is
    1797              :      mode-dependent.  */
    1798       213440 :   init_alias_target ();
    1799              : 
    1800              :   /* Depends on HARD_FRAME_POINTER_REGNUM.  */
    1801       213440 :   if (!ira_use_lra_p)
    1802            0 :     init_reload ();
    1803              : 
    1804              :   /* Depends on the enabled attribute.  */
    1805       213440 :   recog_init ();
    1806              : 
    1807              :   /* The following initialization functions need to generate rtl, so
    1808              :      provide a dummy function context for them.  */
    1809       213440 :   init_dummy_function_start ();
    1810              : 
    1811              :   /* rtx_cost is mode-dependent, so cached values need to be recomputed
    1812              :      on a mode change.  */
    1813       213440 :   init_expmed ();
    1814       213440 :   init_lower_subreg ();
    1815       213440 :   init_set_costs ();
    1816              : 
    1817       213440 :   init_expr_target ();
    1818       213440 :   ira_init ();
    1819              : 
    1820              :   /* We may need to recompute regno_save_code[] and regno_restore_code[]
    1821              :      after a mode change as well.  */
    1822       213440 :   caller_save_initialized_p = false;
    1823              : 
    1824       213440 :   expand_dummy_function_end ();
    1825       213440 : }
    1826              : 
    1827              : /* Initialize the compiler back end.  This function is called only once,
    1828              :    when starting the compiler.  */
    1829              : static void
    1830       278641 : backend_init (void)
    1831              : {
    1832              : #if CHECKING_P
    1833       278641 :   verify_reg_names_in_constraints ();
    1834              : #endif
    1835              : 
    1836       278641 :   init_emit_once ();
    1837              : 
    1838       278641 :   init_rtlanal ();
    1839       278641 :   init_inline_once ();
    1840       278641 :   init_varasm_once ();
    1841       278641 :   save_register_info ();
    1842              : 
    1843              :   /* Middle end needs this initialization for default mem attributes
    1844              :      used by early calls to make_decl_rtl.  */
    1845       278641 :   init_emit_regs ();
    1846              : 
    1847              :   /* Middle end needs this initialization for mode tables used to assign
    1848              :      modes to vector variables.  */
    1849       278641 :   init_regs ();
    1850       278641 : }
    1851              : 
    1852              : /* Initialize things that are both lang-dependent and target-dependent.
    1853              :    This function can be called more than once if target parameters change.  */
    1854              : static void
    1855       774345 : lang_dependent_init_target (void)
    1856              : {
    1857              :   /* This creates various _DECL nodes, so needs to be called after the
    1858              :      front end is initialized.  It also depends on the HAVE_xxx macros
    1859              :      generated from the target machine description.  */
    1860       774345 :   init_optabs ();
    1861              : 
    1862       774345 :   gcc_assert (!this_target_rtl->target_specific_initialized);
    1863       774345 : }
    1864              : 
    1865              : /* Perform initializations that are lang-dependent or target-dependent.
    1866              :    but matters only for late optimizations and RTL generation.  */
    1867              : 
    1868              : static int rtl_initialized;
    1869              : 
    1870              : void
    1871      1477767 : initialize_rtl (void)
    1872              : {
    1873      1477767 :   auto_timevar tv (g_timer, TV_INITIALIZE_RTL);
    1874              : 
    1875              :   /* Initialization done just once per compilation, but delayed
    1876              :      till code generation.  */
    1877      1477767 :   if (!rtl_initialized)
    1878       209218 :     ira_init_once ();
    1879      1477767 :   rtl_initialized = true;
    1880              : 
    1881              :   /* Target specific RTL backend initialization.  */
    1882      1477767 :   if (!this_target_rtl->target_specific_initialized)
    1883              :     {
    1884       213440 :       backend_init_target ();
    1885       213440 :       this_target_rtl->target_specific_initialized = true;
    1886              :     }
    1887      1477767 : }
    1888              : 
    1889              : /* Language-dependent initialization.  Returns nonzero on success.  */
    1890              : static int
    1891       285422 : lang_dependent_init (const char *name)
    1892              : {
    1893       285422 :   location_t save_loc = input_location;
    1894       285422 :   if (!dump_base_name)
    1895              :     {
    1896         2768 :       dump_base_name = name && name[0] ? name : "gccdump";
    1897              : 
    1898              :       /* We do not want to derive a non-empty dumpbase-ext from an
    1899              :          explicit -dumpbase argument, only from a defaulted
    1900              :          dumpbase.  */
    1901         2768 :       if (!dump_base_ext)
    1902              :         {
    1903         2768 :           const char *base = lbasename (dump_base_name);
    1904         2768 :           const char *ext = strrchr (base, '.');
    1905         2768 :           if (ext)
    1906         2768 :             dump_base_ext = ext;
    1907              :         }
    1908              :     }
    1909              : 
    1910              :   /* Other front-end initialization.  */
    1911       285422 :   input_location = BUILTINS_LOCATION;
    1912       285422 :   if (lang_hooks.init () == 0)
    1913              :     return 0;
    1914       278638 :   input_location = save_loc;
    1915              : 
    1916       278638 :   if (!flag_wpa)
    1917              :     {
    1918       270821 :       init_asm_output (name);
    1919              : 
    1920       270821 :       if (!flag_generate_lto && !flag_compare_debug)
    1921              :         {
    1922              :           /* If stack usage information is desired, open the output file.  */
    1923       246926 :           if (flag_stack_usage)
    1924          311 :             stack_usage_file = open_auxiliary_file ("su");
    1925              : 
    1926              :           /* If call graph information is desired, open the output file.  */
    1927       246926 :           if (flag_callgraph_info)
    1928              :             {
    1929            1 :               callgraph_info_file = open_auxiliary_file ("ci");
    1930              :               /* Write the file header.  */
    1931            1 :               fprintf (callgraph_info_file,
    1932              :                        "graph: { title: \"%s\"\n", main_input_filename);
    1933            1 :               bitmap_obstack_initialize (NULL);
    1934            1 :               callgraph_info_external_printed = BITMAP_ALLOC (NULL);
    1935              :             }
    1936              :         }
    1937              :       else
    1938        23895 :         flag_stack_usage = flag_callgraph_info = false;
    1939              :     }
    1940              : 
    1941              :   /* This creates various _DECL nodes, so needs to be called after the
    1942              :      front end is initialized.  */
    1943       278638 :   init_eh ();
    1944              : 
    1945              :   /* Do the target-specific parts of the initialization.  */
    1946       278638 :   lang_dependent_init_target ();
    1947              : 
    1948       278638 :   if (!flag_wpa)
    1949              :     {
    1950              :       /* If dbx symbol table desired, initialize writing it and output the
    1951              :          predefined types.  */
    1952       270821 :       timevar_push (TV_SYMOUT);
    1953              : 
    1954              :       /* Now we have the correct original filename, we can initialize
    1955              :          debug output.  */
    1956       270821 :       (*debug_hooks->init) (name);
    1957              : 
    1958       270821 :       timevar_pop (TV_SYMOUT);
    1959              :     }
    1960              : 
    1961              :   return 1;
    1962              : }
    1963              : 
    1964              : 
    1965              : /* Reinitialize everything when target parameters, such as register usage,
    1966              :    have changed.  */
    1967              : void
    1968       497940 : target_reinit (void)
    1969              : {
    1970       497940 :   if (no_backend)
    1971         2233 :     return;
    1972              : 
    1973       495707 :   struct rtl_data saved_x_rtl;
    1974       495707 :   rtx *saved_regno_reg_rtx;
    1975       495707 :   tree saved_optimization_current_node;
    1976       495707 :   struct target_optabs *saved_this_fn_optabs;
    1977              : 
    1978              :   /* Temporarily switch to the default optimization node, so that
    1979              :      *this_target_optabs is set to the default, not reflecting
    1980              :      whatever a previous function used for the optimize
    1981              :      attribute.  */
    1982       495707 :   saved_optimization_current_node = optimization_current_node;
    1983       495707 :   saved_this_fn_optabs = this_fn_optabs;
    1984       495707 :   if (saved_optimization_current_node != optimization_default_node)
    1985              :     {
    1986            0 :       optimization_current_node = optimization_default_node;
    1987            0 :       cl_optimization_restore
    1988            0 :         (&global_options, &global_options_set,
    1989            0 :          TREE_OPTIMIZATION (optimization_default_node));
    1990              :     }
    1991       495707 :   this_fn_optabs = this_target_optabs;
    1992              : 
    1993              :   /* Save *crtl and regno_reg_rtx around the reinitialization
    1994              :      to allow target_reinit being called even after prepare_function_start.  */
    1995       495707 :   saved_regno_reg_rtx = regno_reg_rtx;
    1996       495707 :   if (saved_regno_reg_rtx)
    1997              :     {
    1998            5 :       saved_x_rtl = *crtl;
    1999            5 :       memset (crtl, '\0', sizeof (*crtl));
    2000            5 :       regno_reg_rtx = NULL;
    2001              :     }
    2002              : 
    2003       495707 :   this_target_rtl->target_specific_initialized = false;
    2004              : 
    2005              :   /* This initializes hard_frame_pointer, and calls init_reg_modes_target()
    2006              :      to initialize reg_raw_mode[].  */
    2007       495707 :   init_emit_regs ();
    2008              : 
    2009              :   /* This invokes target hooks to set fixed_reg[] etc, which is
    2010              :      mode-dependent.  */
    2011       495707 :   init_regs ();
    2012              : 
    2013              :   /* Reinitialize lang-dependent parts.  */
    2014       495707 :   lang_dependent_init_target ();
    2015              : 
    2016              :   /* Restore the original optimization node.  */
    2017       495707 :   if (saved_optimization_current_node != optimization_default_node)
    2018              :     {
    2019            0 :       optimization_current_node = saved_optimization_current_node;
    2020            0 :       cl_optimization_restore (&global_options, &global_options_set,
    2021            0 :                                TREE_OPTIMIZATION (optimization_current_node));
    2022              :     }
    2023       495707 :   this_fn_optabs = saved_this_fn_optabs;
    2024              : 
    2025              :   /* Restore regno_reg_rtx at the end, as free_after_compilation from
    2026              :      expand_dummy_function_end clears it.  */
    2027       495707 :   if (saved_regno_reg_rtx)
    2028              :     {
    2029            5 :       *crtl = saved_x_rtl;
    2030            5 :       regno_reg_rtx = saved_regno_reg_rtx;
    2031            5 :       saved_regno_reg_rtx = NULL;
    2032              :     }
    2033              : }
    2034              : 
    2035              : void
    2036            0 : dump_memory_report (const char *header)
    2037              : {
    2038              :   /* Print significant header.  */
    2039            0 :   fputc ('\n', stderr);
    2040            0 :   for (unsigned i = 0; i < 80; i++)
    2041            0 :     fputc ('#', stderr);
    2042            0 :   fprintf (stderr, "\n# %-77s#\n", header);
    2043            0 :   for (unsigned i = 0; i < 80; i++)
    2044            0 :     fputc ('#', stderr);
    2045            0 :   fputs ("\n\n", stderr);
    2046              : 
    2047            0 :   dump_line_table_statistics ();
    2048            0 :   ggc_print_statistics ();
    2049            0 :   stringpool_statistics ();
    2050            0 :   dump_tree_statistics ();
    2051            0 :   dump_gimple_statistics ();
    2052            0 :   dump_rtx_statistics ();
    2053            0 :   dump_alloc_pool_statistics ();
    2054            0 :   dump_bitmap_statistics ();
    2055            0 :   dump_hash_table_loc_statistics ();
    2056            0 :   dump_vec_loc_statistics ();
    2057            0 :   dump_ggc_loc_statistics ();
    2058            0 :   dump_alias_stats (stderr);
    2059            0 :   dump_pta_stats (stderr);
    2060            0 : }
    2061              : 
    2062              : /* Clean up: close opened files, etc.  */
    2063              : 
    2064              : static void
    2065       283366 : finalize ()
    2066              : {
    2067              :   /* Close the dump files.  */
    2068       283366 :   if (flag_gen_aux_info)
    2069              :     {
    2070            0 :       fclose (aux_info_file);
    2071            0 :       aux_info_file = NULL;
    2072            0 :       if (seen_error ())
    2073            0 :         unlink (aux_info_file_name);
    2074              :     }
    2075              : 
    2076              :   /* Close non-debugging input and output files.  Take special care to note
    2077              :      whether fclose returns an error, since the pages might still be on the
    2078              :      buffer chain while the file is open.  */
    2079              : 
    2080       283366 :   if (asm_out_file)
    2081              :     {
    2082       268945 :       if (ferror (asm_out_file) != 0)
    2083            0 :         fatal_error (input_location, "error writing to %s: %m", asm_file_name);
    2084       268945 :       if (fclose (asm_out_file) != 0)
    2085            0 :         fatal_error (input_location, "error closing %s: %m", asm_file_name);
    2086       268945 :       asm_out_file = NULL;
    2087              :     }
    2088              : 
    2089       283366 :   if (stack_usage_file)
    2090              :     {
    2091          311 :       fclose (stack_usage_file);
    2092          311 :       stack_usage_file = NULL;
    2093              :     }
    2094              : 
    2095       283366 :   if (callgraph_info_file)
    2096              :     {
    2097            1 :       fputs ("}\n", callgraph_info_file);
    2098            1 :       fclose (callgraph_info_file);
    2099            1 :       callgraph_info_file = NULL;
    2100            1 :       BITMAP_FREE (callgraph_info_external_printed);
    2101            1 :       bitmap_obstack_release (NULL);
    2102              :     }
    2103              : 
    2104       283366 :   if (seen_error ())
    2105        26735 :     coverage_remove_note_file ();
    2106              : 
    2107       283366 :   if (!no_backend)
    2108              :     {
    2109       276762 :       statistics_fini ();
    2110       276762 :       debuginfo_fini ();
    2111              : 
    2112       276762 :       g->get_passes ()->finish_optimization_passes ();
    2113              : 
    2114       276762 :       lra_finish_once ();
    2115              :     }
    2116              : 
    2117       283366 :   if (mem_report)
    2118            0 :     dump_memory_report ("Final");
    2119              : 
    2120       283366 :   if (profile_report)
    2121            0 :     dump_profile_report ();
    2122              : 
    2123       283366 :   if (flag_dbg_cnt_list)
    2124            0 :     dbg_cnt_list_all_counters ();
    2125              : 
    2126              :   /* Language-specific end of compilation actions.  */
    2127       283366 :   lang_hooks.finish ();
    2128       283366 : }
    2129              : 
    2130              : static bool
    2131       278262 : standard_type_bitsize (int bitsize)
    2132              : {
    2133              :   /* As a special exception, we always want __int128 enabled if possible.  */
    2134       278262 :   if (bitsize == 128)
    2135              :     return false;
    2136              :   if (bitsize == CHAR_TYPE_SIZE
    2137              :       || bitsize == SHORT_TYPE_SIZE
    2138              :       || bitsize == INT_TYPE_SIZE
    2139            0 :       || bitsize == LONG_TYPE_SIZE
    2140            0 :       || bitsize == LONG_LONG_TYPE_SIZE)
    2141            0 :     return true;
    2142              :   return false;
    2143              : }
    2144              : 
    2145              : /* Initialize the compiler, and compile the input file.  */
    2146              : static void
    2147       285643 : do_compile ()
    2148              : {
    2149              :   /* Don't do any more if an error has already occurred.  */
    2150       285643 :   if (!seen_error ())
    2151              :     {
    2152       285422 :       int i;
    2153              : 
    2154       285422 :       timevar_start (TV_PHASE_SETUP);
    2155              : 
    2156       285422 :       if (flag_save_optimization_record)
    2157              :         {
    2158           41 :           dump_context::get ().set_json_writer (new optrecord_json_writer ());
    2159              :         }
    2160              : 
    2161              :       /* This must be run always, because it is needed to compute the FP
    2162              :          predefined macros, such as __LDBL_MAX__, for targets using non
    2163              :          default FP formats.  */
    2164       285422 :       init_adjust_machine_modes ();
    2165       285422 :       init_derived_machine_modes ();
    2166              : 
    2167              :       /* This must happen after the backend has a chance to process
    2168              :          command line options, but before the parsers are
    2169              :          initialized.  */
    2170       856266 :       for (i = 0; i < NUM_INT_N_ENTS; i ++)
    2171       285422 :         if (targetm.scalar_mode_supported_p (int_n_data[i].m)
    2172       285422 :             && ! standard_type_bitsize (int_n_data[i].bitsize))
    2173       278262 :           int_n_enabled_p[i] = true;
    2174              :         else
    2175         7160 :           int_n_enabled_p[i] = false;
    2176              : 
    2177              :       /* Initialize mpfrs exponent range.  This is important to get
    2178              :          underflow/overflow in a reasonable timeframe.  */
    2179       285422 :       machine_mode mode;
    2180       285422 :       int min_exp = -1;
    2181       285422 :       int max_exp = 1;
    2182      1997954 :       FOR_EACH_MODE_IN_CLASS (mode, MODE_FLOAT)
    2183      1712532 :         if (SCALAR_FLOAT_MODE_P (mode))
    2184              :           {
    2185      1712532 :             const real_format *fmt = REAL_MODE_FORMAT (mode);
    2186      1712532 :             if (fmt)
    2187              :               {
    2188              :                 /* fmt->emin - fmt->p + 1 should be enough but the
    2189              :                    back-and-forth dance in real_to_decimal_for_mode we
    2190              :                    do for checking fails due to rounding effects then.  */
    2191      1712532 :                 if ((fmt->emin - fmt->p) < min_exp)
    2192              :                   min_exp = fmt->emin - fmt->p;
    2193      1712532 :                 if (fmt->emax > max_exp)
    2194              :                   max_exp = fmt->emax;
    2195              :               }
    2196              :           }
    2197              :       /* E.g. mpc_norm assumes it can square a number without bothering with
    2198              :          with range scaling, so until that is fixed, double the minimum
    2199              :          and maximum exponents, plus add some buffer for arithmetics
    2200              :          on the squared numbers.  */
    2201       285422 :       if (mpfr_set_emin (2 * (min_exp - 1))
    2202       285422 :           || mpfr_set_emax (2 * (max_exp + 1)))
    2203            0 :         sorry ("mpfr not configured to handle all floating modes");
    2204              : 
    2205              :       /* Set up the back-end if requested.  */
    2206       285422 :       if (!no_backend)
    2207       278641 :         backend_init ();
    2208              : 
    2209              :       /* Language-dependent initialization.  Returns true on success.  */
    2210       285422 :       if (lang_dependent_init (main_input_filename))
    2211              :         {
    2212              :           /* Initialize yet another pass.  */
    2213              : 
    2214       278638 :           ggc_protect_identifiers = true;
    2215              : 
    2216       278638 :           symtab->initialize ();
    2217       278638 :           init_final (main_input_filename);
    2218       278638 :           coverage_init (aux_base_name);
    2219       278638 :           statistics_init ();
    2220       278638 :           debuginfo_init ();
    2221       278638 :           invoke_plugin_callbacks (PLUGIN_START_UNIT, NULL);
    2222              : 
    2223       278638 :           timevar_stop (TV_PHASE_SETUP);
    2224              : 
    2225       278638 :           compile_file ();
    2226              :         }
    2227              :       else
    2228              :         {
    2229         6604 :           timevar_stop (TV_PHASE_SETUP);
    2230              :         }
    2231              : 
    2232       283366 :       timevar_start (TV_PHASE_FINALIZE);
    2233              : 
    2234       283366 :       finalize ();
    2235              : 
    2236       283366 :       timevar_stop (TV_PHASE_FINALIZE);
    2237              :     }
    2238       283587 : }
    2239              : 
    2240       285722 : toplev::toplev (timer *external_timer,
    2241       285722 :                 bool init_signals)
    2242       285722 :   : m_use_TV_TOTAL (external_timer == NULL),
    2243       285722 :     m_init_signals (init_signals)
    2244              : {
    2245       285722 :   if (external_timer)
    2246          400 :     g_timer = external_timer;
    2247       285722 : }
    2248              : 
    2249       283661 : toplev::~toplev ()
    2250              : {
    2251       283661 :   if (g_timer && m_use_TV_TOTAL)
    2252              :     {
    2253           12 :       g_timer->stop (TV_TOTAL);
    2254           12 :       g_timer->print (stderr);
    2255           12 :       delete g_timer;
    2256           12 :       g_timer = NULL;
    2257              :     }
    2258       283661 : }
    2259              : 
    2260              : /* Potentially call timevar_init (which will create g_timevars if it
    2261              :    doesn't already exist).  */
    2262              : 
    2263              : void
    2264       285243 : toplev::start_timevars ()
    2265              : {
    2266       285243 :   if (time_report || !quiet_flag  || flag_detailed_statistics)
    2267           20 :     timevar_init ();
    2268              : 
    2269       285243 :   timevar_start (TV_TOTAL);
    2270       285243 : }
    2271              : 
    2272              : /* Handle -fself-test.   */
    2273              : 
    2274              : void
    2275            4 : toplev::run_self_tests ()
    2276              : {
    2277              : #if CHECKING_P
    2278              :   /* Reset some state.  */
    2279            4 :   input_location = UNKNOWN_LOCATION;
    2280            4 :   bitmap_obstack_initialize (NULL);
    2281              : 
    2282              :   /* Run the tests; any failures will lead to an abort of the process.
    2283              :      Use "make selftests-gdb" to run under the debugger.  */
    2284            4 :   ::selftest::run_tests ();
    2285              : 
    2286              :   /* Cleanup.  */
    2287            4 :   bitmap_obstack_release (NULL);
    2288              : #else
    2289              :   inform (UNKNOWN_LOCATION, "self-tests are not enabled in this build");
    2290              : #endif /* #if CHECKING_P */
    2291            4 : }
    2292              : 
    2293              : /* Entry point of cc1, cc1plus, jc1, f771, etc.
    2294              :    Exit code is FATAL_EXIT_CODE if can't open files or if there were
    2295              :    any errors, or SUCCESS_EXIT_CODE if compilation succeeded.
    2296              : 
    2297              :    It is not safe to call this function more than once.  */
    2298              : 
    2299              : int
    2300       285722 : toplev::main (int argc, char **argv)
    2301              : {
    2302              :   /* Parsing and gimplification sometimes need quite large stack.
    2303              :      Increase stack size limits if possible.  */
    2304       285722 :   stack_limit_increase (64 * 1024 * 1024);
    2305              : 
    2306              :   /* Stash a copy of the original argv before expansion
    2307              :      for use by SARIF output.  */
    2308       285722 :   unique_argv original_argv (dupargv (argv));
    2309              : 
    2310       285722 :   expandargv (&argc, &argv);
    2311              : 
    2312              :   /* Initialization of GCC's environment, and diagnostics.  */
    2313       285722 :   general_init (argv[0], m_init_signals, std::move (original_argv));
    2314              : 
    2315              :   /* One-off initialization of options that does not need to be
    2316              :      repeated when options are added for particular functions.  */
    2317       285722 :   init_options_once ();
    2318       285722 :   init_opts_obstack ();
    2319              : 
    2320              :   /* Initialize global options structures; this must be repeated for
    2321              :      each structure used for parsing options.  */
    2322       285722 :   init_options_struct (&global_options, &global_options_set);
    2323       285722 :   lang_hooks.init_options_struct (&global_options);
    2324              : 
    2325              :   /* Init GGC heuristics must be caller after we initialize
    2326              :      options.  */
    2327       285722 :   init_ggc_heuristics ();
    2328              : 
    2329              :   /* Convert the options to an array.  */
    2330       285722 :   decode_cmdline_options_to_array_default_mask (argc,
    2331              :                                                 const_cast<const char **> (argv),
    2332              :                                                 &save_decoded_options,
    2333              :                                                 &save_decoded_options_count);
    2334              : 
    2335              :   /* Save Optimization decoded options.  */
    2336       285722 :   save_opt_decoded_options = new vec<cl_decoded_option> ();
    2337      8304084 :   for (unsigned i = 1; i < save_decoded_options_count; ++i)
    2338      8018362 :     if (save_decoded_options[i].opt_index < cl_options_count
    2339      7721750 :         && cl_options[save_decoded_options[i].opt_index].flags & CL_OPTIMIZATION)
    2340       321478 :       save_opt_decoded_options->safe_push (save_decoded_options[i]);
    2341              : 
    2342              :   /* Perform language-specific options initialization.  */
    2343       285722 :   lang_hooks.init_options (save_decoded_options_count, save_decoded_options);
    2344              : 
    2345              :   /* Parse the options and do minimal processing; basically just
    2346              :      enough to default flags appropriately.  */
    2347       285722 :   decode_options (&global_options, &global_options_set,
    2348              :                   save_decoded_options, save_decoded_options_count,
    2349              :                   UNKNOWN_LOCATION, global_dc,
    2350              :                   targetm.target_option.override);
    2351              : 
    2352       285722 :   global_dc->get_file_cache ().tune (param_file_cache_files,
    2353       285722 :                                      param_file_cache_lines);
    2354              : 
    2355       285722 :   handle_common_deferred_options ();
    2356              : 
    2357       285718 :   diagnostics::maybe_open_sarif_sink_for_socket (*global_dc);
    2358              : 
    2359       285718 :   init_local_tick ();
    2360              : 
    2361       285718 :   initialize_plugins ();
    2362              : 
    2363              :   /* Handle the dump options now that plugins have had a chance to install new
    2364              :      passes.  */
    2365       285718 :   handle_deferred_dump_options ();
    2366              : 
    2367       285718 :   if (version_flag)
    2368          113 :     print_version (stderr, "", true);
    2369              : 
    2370       285718 :   if (help_flag)
    2371            3 :     print_plugins_help (stderr, "");
    2372              : 
    2373              :   /* Exit early if we can (e.g. -help).  */
    2374       285718 :   if (!exit_after_options)
    2375              :     {
    2376              :       /* Just in case lang_hooks.post_options ends up calling a debug_hook.
    2377              :          This can happen with incorrect pre-processed input. */
    2378       285644 :       debug_hooks = &do_nothing_debug_hooks;
    2379              :       /* Allow the front end to perform consistency checks and do further
    2380              :          initialization based on the command line options.  This hook also
    2381              :          sets the original filename if appropriate (e.g. foo.i -> foo.c)
    2382              :          so we can correctly initialize debug output.  */
    2383       285644 :       no_backend = lang_hooks.post_options (&main_input_filename);
    2384              : 
    2385       285643 :       process_options ();
    2386              : 
    2387       285643 :       if (m_use_TV_TOTAL)
    2388       285243 :         start_timevars ();
    2389       285643 :       do_compile ();
    2390              : 
    2391       283587 :       if (flag_self_test && !seen_error ())
    2392              :         {
    2393            5 :           if (no_backend)
    2394            1 :             error_at (UNKNOWN_LOCATION, "self-tests incompatible with %<-E%>");
    2395              :           else
    2396            4 :             run_self_tests ();
    2397              :         }
    2398              :     }
    2399              : 
    2400       283661 :   if (warningcount || errorcount || werrorcount)
    2401        39899 :     print_ignored_options ();
    2402              : 
    2403              :   /* Invoke registered plugin callbacks if any.  Some plugins could
    2404              :      emit some diagnostics here.  */
    2405       283661 :   invoke_plugin_callbacks (PLUGIN_FINISH, NULL);
    2406              : 
    2407       283661 :   if (auto change_set_ptr = global_dc->get_fixits_change_set ())
    2408              :     {
    2409           17 :       pretty_printer pp;
    2410           17 :       pp_show_color (&pp) = pp_show_color (global_dc->get_reference_printer ());
    2411           17 :       change_set_ptr->print_diff (&pp, true);
    2412           17 :       pp_flush (&pp);
    2413           17 :     }
    2414              : 
    2415       283661 :   diagnostic_finish (global_dc);
    2416              : 
    2417       283661 :   finalize_plugins ();
    2418              : 
    2419       283661 :   after_memory_report = true;
    2420              : 
    2421       283661 :   if (global_dc->execution_failed_p ())
    2422        27222 :     return (FATAL_EXIT_CODE);
    2423              : 
    2424              :   return (SUCCESS_EXIT_CODE);
    2425       283661 : }
    2426              : 
    2427              : /* For those that want to, this function aims to clean up enough state that
    2428              :    you can call toplev::main again. */
    2429              : void
    2430       256621 : toplev::finalize (void)
    2431              : {
    2432       256621 :   no_backend = false;
    2433       256621 :   rtl_initialized = false;
    2434       256621 :   this_target_rtl->target_specific_initialized = false;
    2435              : 
    2436              :   /* Needs to be called before cgraph_cc_finalize since it uses symtab.  */
    2437       256621 :   ipa_reference_cc_finalize ();
    2438       256621 :   ipa_fnsummary_cc_finalize ();
    2439       256621 :   ipa_modref_cc_finalize ();
    2440       256621 :   ipa_edge_modifications_finalize ();
    2441       256621 :   ipa_icf_cc_finalize ();
    2442              : 
    2443       256621 :   ipa_prop_cc_finalize ();
    2444       256621 :   ipa_profile_cc_finalize ();
    2445       256621 :   ipa_sra_cc_finalize ();
    2446       256621 :   cgraph_cc_finalize ();
    2447       256621 :   cgraphunit_cc_finalize ();
    2448       256621 :   symtab_thunks_cc_finalize ();
    2449       256621 :   dwarf2cfi_cc_finalize ();
    2450       256621 :   dwarf2out_cc_finalize ();
    2451       256621 :   gcse_cc_finalize ();
    2452       256621 :   ipa_cp_cc_finalize ();
    2453       256621 :   ira_costs_cc_finalize ();
    2454       256621 :   tree_cc_finalize ();
    2455       256621 :   reginfo_cc_finalize ();
    2456       256621 :   varasm_cc_finalize ();
    2457              : 
    2458              :   /* save_decoded_options uses opts_obstack, so these must
    2459              :      be cleaned up together.  */
    2460       256621 :   obstack_free (&opts_obstack, NULL);
    2461       256621 :   XDELETEVEC (save_decoded_options);
    2462       256621 :   save_decoded_options = NULL;
    2463       256621 :   save_decoded_options_count = 0;
    2464              : 
    2465       256621 :   ggc_common_finalize ();
    2466              : 
    2467              :   /* Clean up the context (and pass_manager etc). */
    2468       256621 :   delete g;
    2469       256621 :   g = NULL;
    2470              : 
    2471       256621 : }
        

Generated by: LCOV version 2.4-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.