LCOV - code coverage report
Current view: top level - gcc - varasm.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 81.7 % 3784 3093
Test Date: 2026-02-28 14:20:25 Functions: 84.5 % 226 191
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* Output variables, constants and external declarations, for GNU compiler.
       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              : 
      21              : /* This file handles generation of all the assembler code
      22              :    *except* the instructions of a function.
      23              :    This includes declarations of variables and their initial values.
      24              : 
      25              :    We also output the assembler code for constants stored in memory
      26              :    and are responsible for combining constants with the same value.  */
      27              : 
      28              : #include "config.h"
      29              : #include "system.h"
      30              : #include "coretypes.h"
      31              : #include "backend.h"
      32              : #include "target.h"
      33              : #include "rtl.h"
      34              : #include "tree.h"
      35              : #include "predict.h"
      36              : #include "memmodel.h"
      37              : #include "tm_p.h"
      38              : #include "stringpool.h"
      39              : #include "regs.h"
      40              : #include "emit-rtl.h"
      41              : #include "cgraph.h"
      42              : #include "diagnostic-core.h"
      43              : #include "fold-const.h"
      44              : #include "stor-layout.h"
      45              : #include "varasm.h"
      46              : #include "version.h"
      47              : #include "flags.h"
      48              : #include "stmt.h"
      49              : #include "expr.h"
      50              : #include "expmed.h"
      51              : #include "optabs.h"
      52              : #include "output.h"
      53              : #include "langhooks.h"
      54              : #include "debug.h"
      55              : #include "common/common-target.h"
      56              : #include "stringpool.h"
      57              : #include "attribs.h"
      58              : #include "asan.h"
      59              : #include "rtl-iter.h"
      60              : #include "file-prefix-map.h" /* remap_debug_filename()  */
      61              : #include "alloc-pool.h"
      62              : #include "toplev.h"
      63              : #include "opts.h"
      64              : #include "asan.h"
      65              : #include "recog.h"
      66              : #include "gimple-expr.h"
      67              : 
      68              : /* The (assembler) name of the first globally-visible object output.  */
      69              : extern GTY(()) const char *first_global_object_name;
      70              : extern GTY(()) const char *weak_global_object_name;
      71              : 
      72              : const char *first_global_object_name;
      73              : const char *weak_global_object_name;
      74              : 
      75              : class addr_const;
      76              : class constant_descriptor_rtx;
      77              : struct rtx_constant_pool;
      78              : 
      79              : #define n_deferred_constants (crtl->varasm.deferred_constants)
      80              : 
      81              : /* Number for making the label on the next
      82              :    constant that is stored in memory.  */
      83              : 
      84              : static GTY(()) int const_labelno;
      85              : 
      86              : /* Carry information from ASM_DECLARE_OBJECT_NAME
      87              :    to ASM_FINISH_DECLARE_OBJECT.  */
      88              : 
      89              : int size_directive_output;
      90              : 
      91              : /* The last decl for which assemble_variable was called,
      92              :    if it did ASM_DECLARE_OBJECT_NAME.
      93              :    If the last call to assemble_variable didn't do that,
      94              :    this holds 0.  */
      95              : 
      96              : tree last_assemble_variable_decl;
      97              : 
      98              : /* The following global variable indicates if the first basic block
      99              :    in a function belongs to the cold partition or not.  */
     100              : 
     101              : bool first_function_block_is_cold;
     102              : 
     103              : /* Whether we saw any functions with no_split_stack.  */
     104              : 
     105              : static bool saw_no_split_stack;
     106              : 
     107              : static const char *strip_reg_name (const char *);
     108              : static bool contains_pointers_p (tree);
     109              : #ifdef ASM_OUTPUT_EXTERNAL
     110              : static bool incorporeal_function_p (tree);
     111              : #endif
     112              : static void decode_addr_const (tree, class addr_const *);
     113              : static hashval_t const_hash_1 (const tree);
     114              : static bool compare_constant (const tree, const tree);
     115              : static void output_constant_def_contents (rtx);
     116              : static void output_addressed_constants (tree, int);
     117              : static unsigned HOST_WIDE_INT output_constant (tree, unsigned HOST_WIDE_INT,
     118              :                                                unsigned int, bool, bool);
     119              : static void globalize_decl (tree);
     120              : static bool decl_readonly_section_1 (enum section_category);
     121              : #ifdef BSS_SECTION_ASM_OP
     122              : #ifdef ASM_OUTPUT_ALIGNED_BSS
     123              : static void asm_output_aligned_bss (FILE *, tree, const char *,
     124              :                                     unsigned HOST_WIDE_INT, int)
     125              :      ATTRIBUTE_UNUSED;
     126              : #endif
     127              : #endif /* BSS_SECTION_ASM_OP */
     128              : static void mark_weak (tree);
     129              : static void output_constant_pool (const char *, tree);
     130              : static void handle_vtv_comdat_section (section *, const_tree);
     131              : 
     132              : /* Well-known sections, each one associated with some sort of *_ASM_OP.  */
     133              : section *text_section;
     134              : section *data_section;
     135              : section *readonly_data_section;
     136              : section *sdata_section;
     137              : section *ctors_section;
     138              : section *dtors_section;
     139              : section *bss_section;
     140              : section *sbss_section;
     141              : 
     142              : /* Various forms of common section.  All are guaranteed to be nonnull.  */
     143              : section *tls_comm_section;
     144              : section *comm_section;
     145              : section *lcomm_section;
     146              : 
     147              : /* A SECTION_NOSWITCH section used for declaring global BSS variables.
     148              :    May be null.  */
     149              : section *bss_noswitch_section;
     150              : 
     151              : /* The section that holds the main exception table, when known.  The section
     152              :    is set either by the target's init_sections hook or by the first call to
     153              :    switch_to_exception_section.  */
     154              : section *exception_section;
     155              : 
     156              : /* The section that holds the DWARF2 frame unwind information, when known.
     157              :    The section is set either by the target's init_sections hook or by the
     158              :    first call to switch_to_eh_frame_section.  */
     159              : section *eh_frame_section;
     160              : 
     161              : /* asm_out_file's current section.  This is NULL if no section has yet
     162              :    been selected or if we lose track of what the current section is.  */
     163              : section *in_section;
     164              : 
     165              : /* True if code for the current function is currently being directed
     166              :    at the cold section.  */
     167              : bool in_cold_section_p;
     168              : 
     169              : /* The following global holds the "function name" for the code in the
     170              :    cold section of a function, if hot/cold function splitting is enabled
     171              :    and there was actually code that went into the cold section.  A
     172              :    pseudo function name is needed for the cold section of code for some
     173              :    debugging tools that perform symbolization. */
     174              : tree cold_function_name = NULL_TREE;
     175              : 
     176              : /* A linked list of all the unnamed sections.  */
     177              : static GTY(()) section *unnamed_sections;
     178              : 
     179              : /* Return a nonzero value if DECL has a section attribute.  */
     180              : #define IN_NAMED_SECTION(DECL) \
     181              :   (VAR_OR_FUNCTION_DECL_P (DECL) && DECL_SECTION_NAME (DECL) != NULL)
     182              : 
     183              : struct section_hasher : ggc_ptr_hash<section>
     184              : {
     185              :   typedef const char *compare_type;
     186              : 
     187              :   static hashval_t hash (section *);
     188              :   static bool equal (section *, const char *);
     189              : };
     190              : 
     191              : /* Hash table of named sections.  */
     192              : static GTY(()) hash_table<section_hasher> *section_htab;
     193              : 
     194              : struct object_block_hasher : ggc_ptr_hash<object_block>
     195              : {
     196              :   typedef const section *compare_type;
     197              : 
     198              :   static hashval_t hash (object_block *);
     199              :   static bool equal (object_block *, const section *);
     200              : };
     201              : 
     202              : /* A table of object_blocks, indexed by section.  */
     203              : static GTY(()) hash_table<object_block_hasher> *object_block_htab;
     204              : 
     205              : /* The next number to use for internal anchor labels.  */
     206              : static GTY(()) int anchor_labelno;
     207              : 
     208              : /* A pool of constants that can be shared between functions.  */
     209              : static GTY(()) struct rtx_constant_pool *shared_constant_pool;
     210              : 
     211              : /* Helper routines for maintaining section_htab.  */
     212              : 
     213              : bool
     214    446287684 : section_hasher::equal (section *old, const char *new_name)
     215              : {
     216    446287684 :   return strcmp (old->named.name, new_name) == 0;
     217              : }
     218              : 
     219              : hashval_t
     220    324075878 : section_hasher::hash (section *old)
     221              : {
     222    324075878 :   return htab_hash_string (old->named.name);
     223              : }
     224              : 
     225              : /* Return a hash value for section SECT.  */
     226              : 
     227              : static hashval_t
     228            0 : hash_section (section *sect)
     229              : {
     230            0 :   if (sect->common.flags & SECTION_NAMED)
     231            0 :     return htab_hash_string (sect->named.name);
     232            0 :   return sect->common.flags & ~SECTION_DECLARED;
     233              : }
     234              : 
     235              : /* Helper routines for maintaining object_block_htab.  */
     236              : 
     237              : inline bool
     238            0 : object_block_hasher::equal (object_block *old, const section *new_section)
     239              : {
     240            0 :   return old->sect == new_section;
     241              : }
     242              : 
     243              : hashval_t
     244            0 : object_block_hasher::hash (object_block *old)
     245              : {
     246            0 :   return hash_section (old->sect);
     247              : }
     248              : 
     249              : /* Return a new unnamed section with the given fields.  */
     250              : 
     251              : section *
     252      1114564 : get_unnamed_section (unsigned int flags, void (*callback) (const char *),
     253              :                      const char *data)
     254              : {
     255      1114564 :   section *sect;
     256              : 
     257      1114564 :   sect = ggc_alloc<section> ();
     258      1114564 :   sect->unnamed.common.flags = flags | SECTION_UNNAMED;
     259      1114564 :   sect->unnamed.callback = callback;
     260      1114564 :   sect->unnamed.data = data;
     261      1114564 :   sect->unnamed.next = unnamed_sections;
     262              : 
     263      1114564 :   unnamed_sections = sect;
     264      1114564 :   return sect;
     265              : }
     266              : 
     267              : /* Return a SECTION_NOSWITCH section with the given fields.  */
     268              : 
     269              : static section *
     270      1114564 : get_noswitch_section (unsigned int flags, noswitch_section_callback callback)
     271              : {
     272      1114564 :   section *sect;
     273              : 
     274            0 :   sect = ggc_alloc<section> ();
     275      1114564 :   sect->noswitch.common.flags = flags | SECTION_NOSWITCH;
     276      1114564 :   sect->noswitch.callback = callback;
     277              : 
     278      1114564 :   return sect;
     279              : }
     280              : 
     281              : /* Return the named section structure associated with NAME.  Create
     282              :    a new section with the given fields if no such structure exists.
     283              :    When NOT_EXISTING, then fail if the section already exists.  Return
     284              :    the existing section if the SECTION_RETAIN bit doesn't match.  Set
     285              :    the SECTION_WRITE | SECTION_RELRO bits on the existing section
     286              :    if one of the section flags is SECTION_WRITE | SECTION_RELRO and the
     287              :    other has none of these flags in named sections and either the section
     288              :    hasn't been declared yet or has been declared as writable.  */
     289              : 
     290              : section *
     291     68811163 : get_section (const char *name, unsigned int flags, tree decl,
     292              :              bool not_existing)
     293              : {
     294     68811163 :   section *sect, **slot;
     295              : 
     296     68811163 :   slot = section_htab->find_slot_with_hash (name, htab_hash_string (name),
     297              :                                             INSERT);
     298     68811163 :   flags |= SECTION_NAMED;
     299     68811163 :   if (decl != nullptr
     300     66844489 :       && DECL_P (decl)
     301    135655652 :       && lookup_attribute ("retain", DECL_ATTRIBUTES (decl)))
     302          454 :     flags |= SECTION_RETAIN;
     303     68811163 :   if (*slot == NULL)
     304              :     {
     305      3425982 :       sect = ggc_alloc<section> ();
     306      3425982 :       sect->named.common.flags = flags;
     307      3425982 :       sect->named.name = ggc_strdup (name);
     308      3425982 :       sect->named.decl = decl;
     309      3425982 :       *slot = sect;
     310              :     }
     311              :   else
     312              :     {
     313     65385181 :       if (not_existing)
     314            0 :         internal_error ("section already exists: %qs", name);
     315              : 
     316     65385181 :       sect = *slot;
     317              :       /* It is fine if one of the sections has SECTION_NOTYPE as long as
     318              :          the other has none of the contrary flags (see the logic at the end
     319              :          of default_section_type_flags, below).  */
     320     65385181 :       if (((sect->common.flags ^ flags) & SECTION_NOTYPE)
     321            5 :           && !((sect->common.flags | flags)
     322            5 :                & (SECTION_CODE | SECTION_BSS | SECTION_TLS | SECTION_ENTSIZE
     323              :                   | (HAVE_COMDAT_GROUP ? SECTION_LINKONCE : 0))))
     324              :         {
     325            3 :           sect->common.flags |= SECTION_NOTYPE;
     326            3 :           flags |= SECTION_NOTYPE;
     327              :         }
     328     65385181 :       if ((sect->common.flags & ~SECTION_DECLARED) != flags
     329           54 :           && ((sect->common.flags | flags) & SECTION_OVERRIDE) == 0)
     330              :         {
     331              :           /* It is fine if one of the section flags is
     332              :              SECTION_WRITE | SECTION_RELRO and the other has none of these
     333              :              flags (i.e. read-only) in named sections and either the
     334              :              section hasn't been declared yet or has been declared as writable.
     335              :              In that case just make sure the resulting flags are
     336              :              SECTION_WRITE | SECTION_RELRO, ie. writable only because of
     337              :              relocations.  */
     338           50 :           if (((sect->common.flags ^ flags) & (SECTION_WRITE | SECTION_RELRO))
     339              :               == (SECTION_WRITE | SECTION_RELRO)
     340            8 :               && (sect->common.flags
     341            8 :                   & ~(SECTION_DECLARED | SECTION_WRITE | SECTION_RELRO))
     342            8 :                  == (flags & ~(SECTION_WRITE | SECTION_RELRO))
     343            8 :               && ((sect->common.flags & SECTION_DECLARED) == 0
     344            2 :                   || (sect->common.flags & SECTION_WRITE)))
     345              :             {
     346            8 :               sect->common.flags |= (SECTION_WRITE | SECTION_RELRO);
     347            8 :               return sect;
     348              :             }
     349              :           /* If the SECTION_RETAIN bit doesn't match, return and switch
     350              :              to a new section later.  */
     351           42 :           if ((sect->common.flags & SECTION_RETAIN)
     352           42 :               != (flags & SECTION_RETAIN))
     353              :             return sect;
     354              :           /* Sanity check user variables for flag changes.  */
     355            2 :           if (sect->named.decl != NULL
     356            2 :               && DECL_P (sect->named.decl)
     357            2 :               && decl != sect->named.decl)
     358              :             {
     359            2 :               if (decl != NULL && DECL_P (decl))
     360            2 :                 error ("%+qD causes a section type conflict with %qD"
     361              :                        " in section %qs",
     362              :                        decl, sect->named.decl, name);
     363              :               else
     364            0 :                 error ("section type conflict with %qD in section %qs",
     365              :                        sect->named.decl, name);
     366            2 :               inform (DECL_SOURCE_LOCATION (sect->named.decl),
     367              :                       "%qD was declared here", sect->named.decl);
     368              :             }
     369            0 :           else if (decl != NULL && DECL_P (decl))
     370            0 :             error ("%+qD causes a section type conflict for section %qs",
     371              :                    decl, name);
     372              :           else
     373            0 :             error ("section type conflict for section %qs", name);
     374              :           /* Make sure we don't error about one section multiple times.  */
     375            2 :           sect->common.flags |= SECTION_OVERRIDE;
     376              :         }
     377              :     }
     378              :   return sect;
     379              : }
     380              : 
     381              : /* Return true if the current compilation mode benefits from having
     382              :    objects grouped into blocks.  */
     383              : 
     384              : static bool
     385     10147650 : use_object_blocks_p (void)
     386              : {
     387     10147650 :   return flag_section_anchors;
     388              : }
     389              : 
     390              : /* Return the object_block structure for section SECT.  Create a new
     391              :    structure if we haven't created one already.  Return null if SECT
     392              :    itself is null.  Return also null for mergeable sections since
     393              :    section anchors can't be used in mergeable sections anyway,
     394              :    because the linker might move objects around, and using the
     395              :    object blocks infrastructure in that case is both a waste and a
     396              :    maintenance burden.  */
     397              : 
     398              : static struct object_block *
     399            0 : get_block_for_section (section *sect)
     400              : {
     401            0 :   struct object_block *block;
     402              : 
     403            0 :   if (sect == NULL)
     404              :     return NULL;
     405              : 
     406            0 :   if (sect->common.flags & SECTION_MERGE)
     407              :     return NULL;
     408              : 
     409            0 :   object_block **slot
     410            0 :     = object_block_htab->find_slot_with_hash (sect, hash_section (sect),
     411              :                                               INSERT);
     412            0 :   block = *slot;
     413            0 :   if (block == NULL)
     414              :     {
     415            0 :       block = ggc_cleared_alloc<object_block> ();
     416            0 :       block->sect = sect;
     417            0 :       *slot = block;
     418              :     }
     419              :   return block;
     420              : }
     421              : 
     422              : /* Create a symbol with label LABEL and place it at byte offset
     423              :    OFFSET in BLOCK.  OFFSET can be negative if the symbol's offset
     424              :    is not yet known.  LABEL must be a garbage-collected string.  */
     425              : 
     426              : static rtx
     427            0 : create_block_symbol (const char *label, struct object_block *block,
     428              :                      HOST_WIDE_INT offset)
     429              : {
     430            0 :   rtx symbol;
     431            0 :   unsigned int size;
     432              : 
     433              :   /* Create the extended SYMBOL_REF.  */
     434            0 :   size = RTX_HDR_SIZE + sizeof (struct block_symbol);
     435            0 :   symbol = (rtx) ggc_internal_alloc (size);
     436              : 
     437              :   /* Initialize the normal SYMBOL_REF fields.  */
     438            0 :   memset (symbol, 0, size);
     439            0 :   PUT_CODE (symbol, SYMBOL_REF);
     440            0 :   PUT_MODE (symbol, Pmode);
     441            0 :   XSTR (symbol, 0) = label;
     442            0 :   SYMBOL_REF_FLAGS (symbol) = SYMBOL_FLAG_HAS_BLOCK_INFO;
     443              : 
     444              :   /* Initialize the block_symbol stuff.  */
     445            0 :   SYMBOL_REF_BLOCK (symbol) = block;
     446            0 :   SYMBOL_REF_BLOCK_OFFSET (symbol) = offset;
     447              : 
     448            0 :   return symbol;
     449              : }
     450              : 
     451              : /* Return a section with a particular name and with whatever SECTION_*
     452              :    flags section_type_flags deems appropriate.  The name of the section
     453              :    is taken from NAME if nonnull, otherwise it is taken from DECL's
     454              :    DECL_SECTION_NAME.  DECL is the decl associated with the section
     455              :    (see the section comment for details) and RELOC is as for
     456              :    section_type_flags.  */
     457              : 
     458              : section *
     459     66667127 : get_named_section (tree decl, const char *name, int reloc)
     460              : {
     461     66667127 :   unsigned int flags;
     462              : 
     463     66667127 :   if (name == NULL)
     464              :     {
     465     58985315 :       gcc_assert (decl && DECL_P (decl) && DECL_SECTION_NAME (decl));
     466     58985315 :       name = DECL_SECTION_NAME (decl);
     467              :     }
     468              : 
     469     66667127 :   flags = targetm.section_type_flags (decl, name, reloc);
     470     66667127 :   return get_section (name, flags, decl);
     471              : }
     472              : 
     473              : /* Worker for resolve_unique_section.  */
     474              : 
     475              : static bool
     476      1835179 : set_implicit_section (struct symtab_node *n, void *data ATTRIBUTE_UNUSED)
     477              : {
     478      1835179 :   n->implicit_section = true;
     479      1835179 :   return false;
     480              : }
     481              : 
     482              : /* If required, set DECL_SECTION_NAME to a unique name.  */
     483              : 
     484              : void
     485      7454083 : resolve_unique_section (tree decl, int reloc ATTRIBUTE_UNUSED,
     486              :                         int flag_function_or_data_sections)
     487              : {
     488      7454083 :   if (DECL_SECTION_NAME (decl) == NULL
     489      4581431 :       && targetm_common.have_named_sections
     490     12035514 :       && (flag_function_or_data_sections
     491      2902275 :           || lookup_attribute ("retain", DECL_ATTRIBUTES (decl))
     492      2902157 :           || DECL_COMDAT_GROUP (decl)))
     493              :     {
     494      1794298 :       targetm.asm_out.unique_section (decl, reloc);
     495      1794298 :       if (DECL_SECTION_NAME (decl))
     496      1794298 :         symtab_node::get (decl)->call_for_symbol_and_aliases
     497      1794298 :           (set_implicit_section, NULL, true);
     498              :     }
     499      7454083 : }
     500              : 
     501              : #ifdef BSS_SECTION_ASM_OP
     502              : 
     503              : #ifdef ASM_OUTPUT_ALIGNED_BSS
     504              : 
     505              : /* Utility function for targets to use in implementing
     506              :    ASM_OUTPUT_ALIGNED_BSS.
     507              :    ??? It is believed that this function will work in most cases so such
     508              :    support is localized here.  */
     509              : 
     510              : static void
     511            0 : asm_output_aligned_bss (FILE *file, tree decl ATTRIBUTE_UNUSED,
     512              :                         const char *name, unsigned HOST_WIDE_INT size,
     513              :                         int align)
     514              : {
     515            0 :   switch_to_section (bss_section);
     516            0 :   ASM_OUTPUT_ALIGN (file, floor_log2 (align / BITS_PER_UNIT));
     517              : #ifdef ASM_DECLARE_OBJECT_NAME
     518            0 :   last_assemble_variable_decl = decl;
     519            0 :   ASM_DECLARE_OBJECT_NAME (file, name, decl);
     520              : #else
     521              :   /* Standard thing is just output label for the object.  */
     522              :   ASM_OUTPUT_LABEL (file, name);
     523              : #endif /* ASM_DECLARE_OBJECT_NAME */
     524            0 :   ASM_OUTPUT_SKIP (file, size ? size : 1);
     525            0 : }
     526              : 
     527              : #endif
     528              : 
     529              : #endif /* BSS_SECTION_ASM_OP */
     530              : 
     531              : #ifndef USE_SELECT_SECTION_FOR_FUNCTIONS
     532              : /* Return the hot section for function DECL.  Return text_section for
     533              :    null DECLs.  */
     534              : 
     535              : static section *
     536     80745260 : hot_function_section (tree decl)
     537              : {
     538     80745260 :   if (decl != NULL_TREE
     539     80745260 :       && DECL_SECTION_NAME (decl) != NULL
     540    136771660 :       && targetm_common.have_named_sections)
     541     56026400 :     return get_named_section (decl, NULL, 0);
     542              :   else
     543     24718860 :     return text_section;
     544              : }
     545              : #endif
     546              : 
     547              : /* Return section for TEXT_SECTION_NAME if DECL or DECL_SECTION_NAME (DECL)
     548              :    is NULL.
     549              : 
     550              :    When DECL_SECTION_NAME is non-NULL and it is implicit section and
     551              :    NAMED_SECTION_SUFFIX is non-NULL, then produce section called
     552              :    concatenate the name with NAMED_SECTION_SUFFIX.
     553              :    Otherwise produce "TEXT_SECTION_NAME.IMPLICIT_NAME".  */
     554              : 
     555              : section *
     556      7676494 : get_named_text_section (tree decl,
     557              :                         const char *text_section_name,
     558              :                         const char *named_section_suffix)
     559              : {
     560      7676494 :   if (decl && DECL_SECTION_NAME (decl))
     561              :     {
     562      6749014 :       if (named_section_suffix)
     563              :         {
     564            0 :           const char *dsn = DECL_SECTION_NAME (decl);
     565            0 :           const char *stripped_name;
     566            0 :           char *name, *buffer;
     567              : 
     568            0 :           name = (char *) alloca (strlen (dsn) + 1);
     569            0 :           memcpy (name, dsn,
     570            0 :                   strlen (dsn) + 1);
     571              : 
     572            0 :           stripped_name = targetm.strip_name_encoding (name);
     573              : 
     574            0 :           buffer = ACONCAT ((stripped_name, named_section_suffix, NULL));
     575            0 :           return get_named_section (decl, buffer, 0);
     576              :         }
     577      6749014 :       else if (symtab_node::get (decl)->implicit_section)
     578              :         {
     579      6748993 :           const char *name;
     580              : 
     581              :           /* Do not try to split gnu_linkonce functions.  This gets somewhat
     582              :              slipperly.  */
     583      6748993 :           if (DECL_COMDAT_GROUP (decl) && !HAVE_COMDAT_GROUP)
     584              :             return NULL;
     585      6748993 :           name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
     586      6748993 :           name = targetm.strip_name_encoding (name);
     587      6748993 :           return get_named_section (decl, ACONCAT ((text_section_name, ".",
     588      6748993 :                                                    name, NULL)), 0);
     589              :         }
     590              :       else
     591              :         return NULL;
     592              :     }
     593       927480 :   return get_named_section (decl, text_section_name, 0);
     594              : }
     595              : 
     596              : /* Choose named function section based on its frequency.  */
     597              : 
     598              : section *
     599     88421733 : default_function_section (tree decl, enum node_frequency freq,
     600              :                           bool startup, bool exit)
     601              : {
     602              : #if defined HAVE_LD_EH_GC_SECTIONS && defined HAVE_LD_EH_GC_SECTIONS_BUG
     603              :   /* Old GNU linkers have buggy --gc-section support, which sometimes
     604              :      results in .gcc_except_table* sections being garbage collected.  */
     605              :   if (decl
     606              :       && symtab_node::get (decl)->implicit_section)
     607              :     return NULL;
     608              : #endif
     609              : 
     610     88421733 :   if (!flag_reorder_functions
     611     86075590 :       || !targetm_common.have_named_sections)
     612              :     return NULL;
     613              :   /* Startup code should go to startup subsection unless it is
     614              :      unlikely executed (this happens especially with function splitting
     615              :      where we can split away unnecessary parts of static constructors.  */
     616     86075590 :   if (startup && freq != NODE_FREQUENCY_UNLIKELY_EXECUTED)
     617              :   {
     618              :     /* During LTO the tp_first_run profiling will naturally place all
     619              :        initialization code first.  Using separate section is counter-productive
     620              :        because startup only code may call functions which are no longer
     621              :        startup only.  */
     622      1724938 :     if (!in_lto_p
     623        37732 :         || !cgraph_node::get (decl)->tp_first_run
     624      1724946 :         || !opt_for_fn (decl, flag_profile_reorder_functions))
     625      1724930 :       return get_named_text_section (decl, ".text.startup", NULL);
     626              :     else
     627              :       return NULL;
     628              :   }
     629              : 
     630              :   /* Similarly for exit.  */
     631     84350652 :   if (exit && freq != NODE_FREQUENCY_UNLIKELY_EXECUTED)
     632         3980 :     return get_named_text_section (decl, ".text.exit", NULL);
     633              : 
     634              :   /* Group cold functions together, similarly for hot code.  */
     635     84346672 :   switch (freq)
     636              :     {
     637      5946927 :       case NODE_FREQUENCY_UNLIKELY_EXECUTED:
     638      5946927 :         return get_named_text_section (decl, ".text.unlikely", NULL);
     639          657 :       case NODE_FREQUENCY_HOT:
     640          657 :         return get_named_text_section (decl, ".text.hot", NULL);
     641              :         /* FALLTHRU */
     642              :       default:
     643              :         return NULL;
     644              :     }
     645              : }
     646              : 
     647              : /* Return the section for function DECL.
     648              : 
     649              :    If DECL is NULL_TREE, return the text section.  We can be passed
     650              :    NULL_TREE under some circumstances by dbxout.cc at least.
     651              : 
     652              :    If FORCE_COLD is true, return cold function section ignoring
     653              :    the frequency info of cgraph_node.  */
     654              : 
     655              : static section *
     656     88421733 : function_section_1 (tree decl, bool force_cold)
     657              : {
     658     88421733 :   section *section = NULL;
     659     88421733 :   enum node_frequency freq = NODE_FREQUENCY_NORMAL;
     660     88421733 :   bool startup = false, exit = false;
     661              : 
     662     88421733 :   if (decl)
     663              :     {
     664     88421733 :       struct cgraph_node *node = cgraph_node::get (decl);
     665              : 
     666     88421733 :       if (node)
     667              :         {
     668     88421733 :           freq = node->frequency;
     669     88421733 :           startup = node->only_called_at_startup;
     670     88421733 :           exit = node->only_called_at_exit;
     671              :         }
     672              :     }
     673     88421733 :   if (force_cold)
     674      5795949 :     freq = NODE_FREQUENCY_UNLIKELY_EXECUTED;
     675              : 
     676              : #ifdef USE_SELECT_SECTION_FOR_FUNCTIONS
     677              :   if (decl != NULL_TREE
     678              :       && DECL_SECTION_NAME (decl) != NULL)
     679              :     {
     680              :       if (targetm.asm_out.function_section)
     681              :         section = targetm.asm_out.function_section (decl, freq,
     682              :                                                     startup, exit);
     683              :       if (section)
     684              :         return section;
     685              :       return get_named_section (decl, NULL, 0);
     686              :     }
     687              :   else
     688              :     return targetm.asm_out.select_section
     689              :             (decl, freq == NODE_FREQUENCY_UNLIKELY_EXECUTED,
     690              :              symtab_node::get (decl)->definition_alignment ());
     691              : #else
     692     88421733 :   if (targetm.asm_out.function_section)
     693     88421733 :     section = targetm.asm_out.function_section (decl, freq, startup, exit);
     694     88421733 :   if (section)
     695              :     return section;
     696     80745260 :   return hot_function_section (decl);
     697              : #endif
     698              : }
     699              : 
     700              : /* Return the section for function DECL.
     701              : 
     702              :    If DECL is NULL_TREE, return the text section.  We can be passed
     703              :    NULL_TREE under some circumstances by dbxout.cc at least.  */
     704              : 
     705              : section *
     706      3639295 : function_section (tree decl)
     707              : {
     708              :   /* Handle cases where function splitting code decides
     709              :      to put function entry point into unlikely executed section
     710              :      despite the fact that the function itself is not cold
     711              :      (i.e. it is called rarely but contains a hot loop that is
     712              :      better to live in hot subsection for the code locality).  */
     713      3639295 :   return function_section_1 (decl,
     714      3639295 :                              first_function_block_is_cold);
     715              : }
     716              : 
     717              : /* Return the section for the current function, take IN_COLD_SECTION_P
     718              :    into account.  */
     719              : 
     720              : section *
     721     84644962 : current_function_section (void)
     722              : {
     723     84644962 :   return function_section_1 (current_function_decl, in_cold_section_p);
     724              : }
     725              : 
     726              : /* Tell assembler to switch to unlikely-to-be-executed text section.  */
     727              : 
     728              : section *
     729       137476 : unlikely_text_section (void)
     730              : {
     731       137476 :   return function_section_1 (current_function_decl, true);
     732              : }
     733              : 
     734              : /* When called within a function context, return true if the function
     735              :    has been assigned a cold text section and if SECT is that section.
     736              :    When called outside a function context, return true if SECT is the
     737              :    default cold section.  */
     738              : 
     739              : bool
     740            0 : unlikely_text_section_p (section *sect)
     741              : {
     742            0 :   return sect == function_section_1 (current_function_decl, true);
     743              : }
     744              : 
     745              : /* Switch to the other function partition (if inside of hot section
     746              :    into cold section, otherwise into the hot section).  */
     747              : 
     748              : void
     749            0 : switch_to_other_text_partition (void)
     750              : {
     751            0 :   in_cold_section_p = !in_cold_section_p;
     752            0 :   switch_to_section (current_function_section ());
     753            0 : }
     754              : 
     755              : /* Return the read-only or relocated read-only data section
     756              :    associated with function DECL.  */
     757              : 
     758              : section *
     759       628376 : default_function_rodata_section (tree decl, bool relocatable)
     760              : {
     761       628376 :   const char* sname;
     762       628376 :   unsigned int flags;
     763              : 
     764       628376 :   flags = 0;
     765              : 
     766       628376 :   if (relocatable)
     767              :     {
     768              :       sname = ".data.rel.ro.local";
     769              :       flags = (SECTION_WRITE | SECTION_RELRO);
     770              :     }
     771              :   else
     772       628376 :     sname = ".rodata";
     773              : 
     774       628376 :   if (decl && DECL_SECTION_NAME (decl))
     775              :     {
     776       125305 :       const char *name = DECL_SECTION_NAME (decl);
     777              : 
     778       125305 :       if (DECL_COMDAT_GROUP (decl) && HAVE_COMDAT_GROUP)
     779              :         {
     780        38029 :           const char *dot;
     781        38029 :           size_t len;
     782        38029 :           char* rname;
     783              : 
     784        38029 :           dot = strchr (name + 1, '.');
     785        38029 :           if (!dot)
     786            0 :             dot = name;
     787        38029 :           len = strlen (dot) + strlen (sname) + 1;
     788        38029 :           rname = (char *) alloca (len);
     789              : 
     790        38029 :           strcpy (rname, sname);
     791        38029 :           strcat (rname, dot);
     792        38029 :           return get_section (rname, (SECTION_LINKONCE | flags), decl);
     793              :         }
     794              :       /* For .gnu.linkonce.t.foo we want to use .gnu.linkonce.r.foo or
     795              :          .gnu.linkonce.d.rel.ro.local.foo if the jump table is relocatable.  */
     796        87276 :       else if (DECL_COMDAT_GROUP (decl)
     797        87276 :                && startswith (name, ".gnu.linkonce.t."))
     798              :         {
     799            0 :           size_t len;
     800            0 :           char *rname;
     801              : 
     802            0 :           if (relocatable)
     803              :             {
     804            0 :               len = strlen (name) + strlen (".rel.ro.local") + 1;
     805            0 :               rname = (char *) alloca (len);
     806              : 
     807            0 :               strcpy (rname, ".gnu.linkonce.d.rel.ro.local");
     808            0 :               strcat (rname, name + 15);
     809              :             }
     810              :           else
     811              :             {
     812            0 :               len = strlen (name) + 1;
     813            0 :               rname = (char *) alloca (len);
     814              : 
     815            0 :               memcpy (rname, name, len);
     816            0 :               rname[14] = 'r';
     817              :             }
     818            0 :           return get_section (rname, (SECTION_LINKONCE | flags), decl);
     819              :         }
     820              :       /* For .text.foo we want to use .rodata.foo.  */
     821        87272 :       else if (flag_function_sections && flag_data_sections
     822       174548 :                && startswith (name, ".text."))
     823              :         {
     824        87272 :           size_t len = strlen (name) + 1;
     825        87272 :           char *rname = (char *) alloca (len + strlen (sname) - 5);
     826              : 
     827        87272 :           memcpy (rname, sname, strlen (sname));
     828        87272 :           memcpy (rname + strlen (sname), name + 5, len - 5);
     829        87272 :           return get_section (rname, flags, decl);
     830              :         }
     831              :     }
     832              : 
     833       503075 :   if (relocatable)
     834            0 :     return get_section (sname, flags, decl);
     835              :   else
     836       503075 :     return readonly_data_section;
     837              : }
     838              : 
     839              : /* Return the read-only data section associated with function DECL
     840              :    for targets where that section should be always the single
     841              :    readonly data section.  */
     842              : 
     843              : section *
     844            0 : default_no_function_rodata_section (tree, bool)
     845              : {
     846            0 :   return readonly_data_section;
     847              : }
     848              : 
     849              : /* A subroutine of mergeable_string_section and mergeable_constant_section.  */
     850              : 
     851              : static const char *
     852       612334 : function_mergeable_rodata_prefix (void)
     853              : {
     854       612334 :   section *s = targetm.asm_out.function_rodata_section (current_function_decl,
     855              :                                                         false);
     856       612334 :   if (SECTION_STYLE (s) == SECTION_NAMED)
     857       115211 :     return s->named.name;
     858              :   else
     859       497123 :     return targetm.asm_out.mergeable_rodata_prefix;
     860              : }
     861              : 
     862              : /* Return the section to use for string merging.  */
     863              : 
     864              : static section *
     865      1231867 : mergeable_string_section (tree decl ATTRIBUTE_UNUSED,
     866              :                           unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED,
     867              :                           unsigned int flags ATTRIBUTE_UNUSED)
     868              : {
     869      1231867 :   HOST_WIDE_INT len;
     870              : 
     871      1231867 :   if (HAVE_GAS_SHF_MERGE && flag_merge_constants
     872      1051916 :       && TREE_CODE (decl) == STRING_CST
     873      1051916 :       && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE
     874      1051916 :       && align <= MAX_MERGEABLE_BITSIZE
     875      1051916 :       && (len = int_size_in_bytes (TREE_TYPE (decl))) > 0
     876      2283652 :       && TREE_STRING_LENGTH (decl) == len)
     877              :     {
     878       406767 :       scalar_int_mode mode;
     879       406767 :       unsigned int modesize;
     880       406767 :       const char *str;
     881       406767 :       HOST_WIDE_INT i;
     882       406767 :       int j, unit;
     883       406767 :       const char *prefix = function_mergeable_rodata_prefix ();
     884       406767 :       char *name = (char *) alloca (strlen (prefix) + 30);
     885              : 
     886       406767 :       mode = SCALAR_INT_TYPE_MODE (TREE_TYPE (TREE_TYPE (decl)));
     887       406767 :       modesize = GET_MODE_BITSIZE (mode);
     888       406767 :       if (modesize >= 8 && modesize <= MAX_MERGEABLE_BITSIZE
     889       406767 :           && (modesize & (modesize - 1)) == 0)
     890              :         {
     891       406767 :           if (align < modesize)
     892              :             align = modesize;
     893              : 
     894       406767 :           str = TREE_STRING_POINTER (decl);
     895       406767 :           unit = GET_MODE_SIZE (mode);
     896              : 
     897              :           /* Check for embedded NUL characters.  */
     898    115728156 :           for (i = 0; i < len; i += unit)
     899              :             {
     900    116076671 :               for (j = 0; j < unit; j++)
     901    115705748 :                 if (str[i + j] != '\0')
     902              :                   break;
     903    115692312 :               if (j == unit)
     904              :                 break;
     905              :             }
     906       406767 :           if (i == len - unit || (unit == 1 && i == len))
     907              :             {
     908       403004 :               sprintf (name, "%s.str%d.%d", prefix,
     909       403004 :                        modesize / BITS_PER_UNIT, (int) (align / BITS_PER_UNIT));
     910       403004 :               flags |= (modesize / BITS_PER_UNIT) | SECTION_MERGE | SECTION_STRINGS;
     911       403004 :               return get_section (name, flags, NULL);
     912              :             }
     913              :         }
     914              :     }
     915              : 
     916       828863 :   return readonly_data_section;
     917              : }
     918              : 
     919              : /* Return the section to use for constant merging.  */
     920              : 
     921              : section *
     922       248713 : mergeable_constant_section (unsigned HOST_WIDE_INT size_bits,
     923              :                             unsigned HOST_WIDE_INT align,
     924              :                             unsigned int flags)
     925              : {
     926       248713 :   unsigned HOST_WIDE_INT newsize;
     927       248713 :   newsize = HOST_WIDE_INT_1U << ceil_log2 (size_bits);
     928       248713 :   if (HAVE_GAS_SHF_MERGE && flag_merge_constants
     929       209977 :       && newsize <= MAX_MERGEABLE_BITSIZE
     930       209977 :       && align >= 8
     931       205568 :       && align <= newsize
     932       205567 :       && (align & (align - 1)) == 0)
     933              :     {
     934       205567 :       const char *prefix = function_mergeable_rodata_prefix ();
     935       205567 :       char *name = (char *) alloca (strlen (prefix) + 30);
     936              : 
     937       205567 :       sprintf (name, "%s.cst%d", prefix, (int) (newsize / BITS_PER_UNIT));
     938       205567 :       flags |= (newsize / BITS_PER_UNIT) | SECTION_MERGE;
     939       205567 :       return get_section (name, flags, NULL);
     940              :     }
     941        43146 :   return readonly_data_section;
     942              : }
     943              : 
     944              : 
     945              : /* Return the section to use for constant merging. Like the above
     946              :    but the size stored as a tree.  */
     947              : static section *
     948          476 : mergeable_constant_section (tree size_bits,
     949              :                             unsigned HOST_WIDE_INT align,
     950              :                             unsigned int flags)
     951              : {
     952          476 :   if (!size_bits || !tree_fits_uhwi_p (size_bits))
     953            0 :     return readonly_data_section;
     954          476 :   return mergeable_constant_section (tree_to_uhwi (size_bits), align, flags);
     955              : }
     956              : 
     957              : 
     958              : /* Return the section to use for constant merging. Like the above
     959              :    but given a mode rather than the size.  */
     960              : 
     961              : section *
     962       248237 : mergeable_constant_section (machine_mode mode,
     963              :                             unsigned HOST_WIDE_INT align,
     964              :                             unsigned int flags)
     965              : {
     966              :   /* If the mode is unknown (BLK or VOID), then return a non mergable section.  */
     967       248237 :   if (mode == BLKmode || mode == VOIDmode)
     968            0 :     return readonly_data_section;
     969       248237 :   unsigned HOST_WIDE_INT size;
     970       496474 :   if (!GET_MODE_BITSIZE (mode).is_constant (&size))
     971              :     return readonly_data_section;
     972       248237 :   return mergeable_constant_section (size, align, flags);
     973              : }
     974              : 
     975              : 
     976              : /* Given NAME, a putative register name, discard any customary prefixes.  */
     977              : 
     978              : static const char *
     979     15166679 : strip_reg_name (const char *name)
     980              : {
     981              : #ifdef REGISTER_PREFIX
     982              :   if (!strncmp (name, REGISTER_PREFIX, strlen (REGISTER_PREFIX)))
     983              :     name += strlen (REGISTER_PREFIX);
     984              : #endif
     985     15166058 :   if (name[0] == '%' || name[0] == '#')
     986          621 :     name++;
     987     15166679 :   return name;
     988              : }
     989              : 
     990              : /* The user has asked for a DECL to have a particular name.  Set (or
     991              :    change) it in such a way that we don't prefix an underscore to
     992              :    it.  */
     993              : void
     994      2849002 : set_user_assembler_name (tree decl, const char *name)
     995              : {
     996      2849002 :   char *starred = (char *) alloca (strlen (name) + 2);
     997      2849002 :   starred[0] = '*';
     998      2849002 :   strcpy (starred + 1, name);
     999      2849002 :   symtab->change_decl_assembler_name (decl, get_identifier (starred));
    1000      2849002 :   SET_DECL_RTL (decl, NULL_RTX);
    1001      2849002 : }
    1002              : 
    1003              : /* Decode an `asm' spec for a declaration as a register name.
    1004              :    Return the register number, or -1 if nothing specified,
    1005              :    or -2 if the ASMSPEC is not `cc' or `memory' or `redzone' and is not
    1006              :    recognized,
    1007              :    or -3 if ASMSPEC is `cc' and is not recognized,
    1008              :    or -4 if ASMSPEC is `memory' and is not recognized,
    1009              :    or -5 if ASMSPEC is `redzone' and is not recognized.
    1010              :    Accept an exact spelling or a decimal number.
    1011              :    Prefixes such as % are optional.  */
    1012              : 
    1013              : int
    1014       197392 : decode_reg_name_and_count (const char *asmspec, int *pnregs)
    1015              : {
    1016              :   /* Presume just one register is clobbered.  */
    1017       197392 :   *pnregs = 1;
    1018              : 
    1019       197392 :   if (asmspec != 0)
    1020              :     {
    1021       197392 :       int i;
    1022              : 
    1023              :       /* Get rid of confusing prefixes.  */
    1024       197392 :       asmspec = strip_reg_name (asmspec);
    1025              : 
    1026              :       /* Allow a decimal number as a "register name".  */
    1027       197392 :       if (ISDIGIT (asmspec[0]))
    1028              :         {
    1029           60 :           char *pend;
    1030           60 :           errno = 0;
    1031           60 :           unsigned long j = strtoul (asmspec, &pend, 10);
    1032           60 :           if (*pend == '\0')
    1033              :             {
    1034           54 :               static_assert (FIRST_PSEUDO_REGISTER <= INT_MAX, "");
    1035           54 :               if (errno != ERANGE
    1036           51 :                   && j < FIRST_PSEUDO_REGISTER
    1037           36 :                   && reg_names[j][0])
    1038           54 :                 return j;
    1039              :               else
    1040              :                 return -2;
    1041              :             }
    1042              :         }
    1043              : 
    1044     15102150 :       for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
    1045     14969287 :         if (reg_names[i][0]
    1046     29938574 :             && ! strcmp (asmspec, strip_reg_name (reg_names[i])))
    1047              :           return i;
    1048              : 
    1049              : #ifdef OVERLAPPING_REGISTER_NAMES
    1050              :       {
    1051              :         static const struct
    1052              :         {
    1053              :           const char *const name;
    1054              :           const int number;
    1055              :           const int nregs;
    1056              :         } table[] = OVERLAPPING_REGISTER_NAMES;
    1057              : 
    1058              :         for (i = 0; i < (int) ARRAY_SIZE (table); i++)
    1059              :           if (table[i].name[0]
    1060              :               && ! strcmp (asmspec, table[i].name))
    1061              :             {
    1062              :               *pnregs = table[i].nregs;
    1063              :               return table[i].number;
    1064              :             }
    1065              :       }
    1066              : #endif /* OVERLAPPING_REGISTER_NAMES */
    1067              : 
    1068              : #ifdef ADDITIONAL_REGISTER_NAMES
    1069              :       {
    1070              :         static const struct { const char *const name; const int number; } table[]
    1071              :           = ADDITIONAL_REGISTER_NAMES;
    1072              : 
    1073     10487625 :         for (i = 0; i < (int) ARRAY_SIZE (table); i++)
    1074     10377922 :           if (table[i].name[0]
    1075     10377922 :               && ! strcmp (asmspec, table[i].name)
    1076        23160 :               && reg_names[table[i].number][0])
    1077              :             return table[i].number;
    1078              :       }
    1079              : #endif /* ADDITIONAL_REGISTER_NAMES */
    1080              : 
    1081       109703 :       if (!strcmp (asmspec, "redzone"))
    1082              :         return -5;
    1083              : 
    1084       109699 :       if (!strcmp (asmspec, "memory"))
    1085              :         return -4;
    1086              : 
    1087        31659 :       if (!strcmp (asmspec, "cc"))
    1088              :         return -3;
    1089              : 
    1090           51 :       return -2;
    1091              :     }
    1092              : 
    1093              :   return -1;
    1094              : }
    1095              : 
    1096              : int
    1097       100234 : decode_reg_name (const char *name)
    1098              : {
    1099       100234 :   int count;
    1100       100234 :   return decode_reg_name_and_count (name, &count);
    1101              : }
    1102              : 
    1103              : 
    1104              : /* Return true if DECL's initializer is suitable for a BSS section.  */
    1105              : 
    1106              : bool
    1107      6448551 : bss_initializer_p (const_tree decl, bool named)
    1108              : {
    1109              :   /* Do not put non-common constants into the .bss section, they belong in
    1110              :      a readonly section, except when NAMED is true.  */
    1111     11095332 :   return ((!TREE_READONLY (decl) || DECL_COMMON (decl) || named)
    1112      6472185 :           && (DECL_INITIAL (decl) == NULL
    1113              :               /* In LTO we have no errors in program; error_mark_node is used
    1114              :                  to mark offlined constructors.  */
    1115       664476 :               || (DECL_INITIAL (decl) == error_mark_node
    1116            4 :                   && !in_lto_p)
    1117       664472 :               || (flag_zero_initialized_in_bss
    1118       664414 :                   && initializer_zerop (DECL_INITIAL (decl))
    1119              :                   /* A decl with the "persistent" attribute applied and
    1120              :                      explicitly initialized to 0 should not be treated as a BSS
    1121              :                      variable.  */
    1122        39710 :                   && !DECL_PERSISTENT_P (decl))));
    1123              : }
    1124              : 
    1125              : /* Compute the alignment of variable specified by DECL.
    1126              :    DONT_OUTPUT_DATA is from assemble_variable.  */
    1127              : 
    1128              : void
    1129      5916351 : align_variable (tree decl, bool dont_output_data)
    1130              : {
    1131      5916351 :   unsigned int align = DECL_ALIGN (decl);
    1132              : 
    1133              :   /* In the case for initialing an array whose length isn't specified,
    1134              :      where we have not yet been able to do the layout,
    1135              :      figure out the proper alignment now.  */
    1136          863 :   if (dont_output_data && DECL_SIZE (decl) == 0
    1137      5916351 :       && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
    1138            0 :     align = MAX (align, TYPE_ALIGN (TREE_TYPE (TREE_TYPE (decl))));
    1139              : 
    1140              :   /* Some object file formats have a maximum alignment which they support.
    1141              :      In particular, a.out format supports a maximum alignment of 4.  */
    1142            0 :   if (align > MAX_OFILE_ALIGNMENT)
    1143              :     {
    1144              :       error ("alignment of %q+D is greater than maximum object "
    1145              :              "file alignment %d", decl,
    1146              :              MAX_OFILE_ALIGNMENT/BITS_PER_UNIT);
    1147              :       align = MAX_OFILE_ALIGNMENT;
    1148              :     }
    1149              : 
    1150      5916351 :   if (! DECL_USER_ALIGN (decl))
    1151              :     {
    1152              : #ifdef DATA_ABI_ALIGNMENT
    1153      5790203 :       unsigned int data_abi_align
    1154      5790203 :         = DATA_ABI_ALIGNMENT (TREE_TYPE (decl), align);
    1155              :       /* For backwards compatibility, don't assume the ABI alignment for
    1156              :          TLS variables.  */
    1157      5790295 :       if (! DECL_THREAD_LOCAL_P (decl) || data_abi_align <= BITS_PER_WORD)
    1158              :         align = data_abi_align;
    1159              : #endif
    1160              : 
    1161              :       /* On some machines, it is good to increase alignment sometimes.
    1162              :          But as DECL_ALIGN is used both for actually emitting the variable
    1163              :          and for code accessing the variable as guaranteed alignment, we
    1164              :          can only increase the alignment if it is a performance optimization
    1165              :          if the references to it must bind to the current definition.  */
    1166      5790203 :       if (decl_binds_to_current_def_p (decl)
    1167      5790203 :           && !DECL_VIRTUAL_P (decl))
    1168              :         {
    1169              : #ifdef DATA_ALIGNMENT
    1170      5177433 :           unsigned int data_align = DATA_ALIGNMENT (TREE_TYPE (decl), align);
    1171              :           /* Don't increase alignment too much for TLS variables - TLS space
    1172              :              is too precious.  */
    1173      5177501 :           if (! DECL_THREAD_LOCAL_P (decl) || data_align <= BITS_PER_WORD)
    1174              :             align = data_align;
    1175              : #endif
    1176      5177433 :           if (DECL_INITIAL (decl) != 0
    1177              :               /* In LTO we have no errors in program; error_mark_node is used
    1178              :                  to mark offlined constructors.  */
    1179      5177433 :               && (in_lto_p || DECL_INITIAL (decl) != error_mark_node))
    1180              :             {
    1181      3235683 :               unsigned int const_align
    1182      3235683 :                 = targetm.constant_alignment (DECL_INITIAL (decl), align);
    1183              :               /* Don't increase alignment too much for TLS variables - TLS
    1184              :                  space is too precious.  */
    1185      3235689 :               if (! DECL_THREAD_LOCAL_P (decl) || const_align <= BITS_PER_WORD)
    1186              :                 align = const_align;
    1187              :             }
    1188              :         }
    1189              :     }
    1190              : 
    1191              :   /* Reset the alignment in case we have made it tighter, so we can benefit
    1192              :      from it in get_pointer_alignment.  */
    1193      5916351 :   SET_DECL_ALIGN (decl, align);
    1194      5916351 : }
    1195              : 
    1196              : /* Return DECL_ALIGN (decl), possibly increased for optimization purposes
    1197              :    beyond what align_variable returned.  */
    1198              : 
    1199              : static unsigned int
    1200      5782530 : get_variable_align (tree decl)
    1201              : {
    1202      5782530 :   unsigned int align = DECL_ALIGN (decl);
    1203              : 
    1204              :   /* For user aligned vars or static vars align_variable already did
    1205              :      everything.  */
    1206      5782530 :   if (DECL_USER_ALIGN (decl) || !TREE_PUBLIC (decl))
    1207              :     return align;
    1208              : 
    1209              : #ifdef DATA_ABI_ALIGNMENT
    1210      2871347 :   if (DECL_THREAD_LOCAL_P (decl))
    1211         6172 :     align = DATA_ABI_ALIGNMENT (TREE_TYPE (decl), align);
    1212              : #endif
    1213              : 
    1214              :   /* For decls that bind to the current definition, align_variable
    1215              :      did also everything, except for not assuming ABI required alignment
    1216              :      of TLS variables.  For other vars, increase the alignment here
    1217              :      as an optimization.  */
    1218      2871347 :   if (!decl_binds_to_current_def_p (decl))
    1219              :     {
    1220              :       /* On some machines, it is good to increase alignment sometimes.  */
    1221              : #ifdef DATA_ALIGNMENT
    1222       593773 :       unsigned int data_align = DATA_ALIGNMENT (TREE_TYPE (decl), align);
    1223              :       /* Don't increase alignment too much for TLS variables - TLS space
    1224              :          is too precious.  */
    1225       593794 :       if (! DECL_THREAD_LOCAL_P (decl) || data_align <= BITS_PER_WORD)
    1226              :         align = data_align;
    1227              : #endif
    1228       593773 :       if (DECL_INITIAL (decl) != 0
    1229              :           /* In LTO we have no errors in program; error_mark_node is used
    1230              :              to mark offlined constructors.  */
    1231       593773 :           && (in_lto_p || DECL_INITIAL (decl) != error_mark_node))
    1232              :         {
    1233       579088 :           unsigned int const_align
    1234       579088 :             = targetm.constant_alignment (DECL_INITIAL (decl), align);
    1235              :           /* Don't increase alignment too much for TLS variables - TLS space
    1236              :              is too precious.  */
    1237       579093 :           if (! DECL_THREAD_LOCAL_P (decl) || const_align <= BITS_PER_WORD)
    1238              :             align = const_align;
    1239              :         }
    1240              :     }
    1241              : 
    1242              :   return align;
    1243              : }
    1244              : 
    1245              : /* Compute reloc for get_variable_section.  The return value
    1246              :    is a mask for which bit 1 indicates a global relocation, and bit 0
    1247              :    indicates a local relocation.  */
    1248              : 
    1249              : int
    1250      4489136 : compute_reloc_for_var (tree decl)
    1251              : {
    1252      4489136 :   int reloc;
    1253              : 
    1254      4489136 :   if (DECL_INITIAL (decl) == error_mark_node)
    1255      1139326 :     reloc = contains_pointers_p (TREE_TYPE (decl)) ? 3 : 0;
    1256      4489134 :   else if (DECL_INITIAL (decl))
    1257      3349810 :     reloc = compute_reloc_for_constant (DECL_INITIAL (decl));
    1258              :   else
    1259              :     reloc = 0;
    1260              : 
    1261      4489136 :   return reloc;
    1262              : }
    1263              : 
    1264              : /* Return the section into which the given VAR_DECL or CONST_DECL
    1265              :    should be placed.  PREFER_NOSWITCH_P is true if a noswitch
    1266              :    section should be used wherever possible.  */
    1267              : 
    1268              : section *
    1269      4490538 : get_variable_section (tree decl, bool prefer_noswitch_p)
    1270              : {
    1271      4490538 :   addr_space_t as = ADDR_SPACE_GENERIC;
    1272      4490538 :   int reloc;
    1273      4490538 :   varpool_node *vnode = varpool_node::get (decl);
    1274      4490538 :   if (vnode)
    1275              :     {
    1276      4490523 :       vnode = vnode->ultimate_alias_target ();
    1277      4490523 :       decl = vnode->decl;
    1278              :     }
    1279              : 
    1280      4490538 :   if (TREE_TYPE (decl) != error_mark_node)
    1281      4490538 :     as = TYPE_ADDR_SPACE (TREE_TYPE (decl));
    1282              : 
    1283              :   /* We need the constructor to figure out reloc flag.  */
    1284      4490538 :   if (vnode)
    1285      4490523 :     vnode->get_constructor ();
    1286              : 
    1287      4490538 :   if (DECL_COMMON (decl)
    1288      4490538 :       && !lookup_attribute ("retain", DECL_ATTRIBUTES (decl)))
    1289              :     {
    1290              :       /* If the decl has been given an explicit section name, or it resides
    1291              :          in a non-generic address space, then it isn't common, and shouldn't
    1292              :          be handled as such.  */
    1293         1402 :       gcc_assert (DECL_SECTION_NAME (decl) == NULL
    1294              :                   && ADDR_SPACE_GENERIC_P (as));
    1295         1402 :       if (DECL_THREAD_LOCAL_P (decl))
    1296           55 :         return tls_comm_section;
    1297         1347 :       else if (TREE_PUBLIC (decl) && bss_initializer_p (decl))
    1298         1347 :         return comm_section;
    1299              :     }
    1300              : 
    1301      4489136 :   reloc = compute_reloc_for_var (decl);
    1302              : 
    1303      4489136 :   resolve_unique_section (decl, reloc, flag_data_sections);
    1304      4489136 :   if (IN_NAMED_SECTION (decl))
    1305              :     {
    1306      2955328 :       section *sect = get_named_section (decl, NULL, reloc);
    1307              : 
    1308      2955328 :       if ((sect->common.flags & SECTION_BSS)
    1309      2955328 :           && !bss_initializer_p (decl, true))
    1310              :         {
    1311            2 :           if (flag_zero_initialized_in_bss)
    1312            2 :             error_at (DECL_SOURCE_LOCATION (decl),
    1313              :                       "only zero initializers are allowed in section %qs",
    1314              :                       sect->named.name);
    1315              :           else
    1316            0 :             error_at (DECL_SOURCE_LOCATION (decl),
    1317              :                       "no initializers are allowed in section %qs",
    1318              :                       sect->named.name);
    1319            2 :           DECL_INITIAL (decl) = error_mark_node;
    1320              :         }
    1321      2955328 :       return sect;
    1322              :     }
    1323              : 
    1324      1533808 :   if (ADDR_SPACE_GENERIC_P (as)
    1325      1533802 :       && !DECL_THREAD_LOCAL_P (decl)
    1326      1530171 :       && !DECL_NOINIT_P (decl)
    1327      1530171 :       && !(prefer_noswitch_p && targetm.have_switchable_bss_sections)
    1328      3063979 :       && bss_initializer_p (decl))
    1329              :     {
    1330      1147281 :       if (!TREE_PUBLIC (decl)
    1331      1147464 :           && !((flag_sanitize & SANITIZE_ADDRESS)
    1332          183 :                && asan_protect_global (decl)))
    1333       156834 :         return lcomm_section;
    1334       990447 :       if (bss_noswitch_section)
    1335              :         return bss_noswitch_section;
    1336              :     }
    1337              : 
    1338       386527 :   return targetm.asm_out.select_section (decl, reloc,
    1339       773054 :                                          get_variable_align (decl));
    1340              : }
    1341              : 
    1342              : /* Return the block into which object_block DECL should be placed.  */
    1343              : 
    1344              : static struct object_block *
    1345            0 : get_block_for_decl (tree decl)
    1346              : {
    1347            0 :   section *sect;
    1348              : 
    1349            0 :   if (VAR_P (decl))
    1350              :     {
    1351              :       /* The object must be defined in this translation unit.  */
    1352            0 :       if (DECL_EXTERNAL (decl))
    1353              :         return NULL;
    1354              : 
    1355              :       /* There's no point using object blocks for something that is
    1356              :          isolated by definition.  */
    1357            0 :       if (DECL_COMDAT_GROUP (decl))
    1358              :         return NULL;
    1359              :     }
    1360              : 
    1361              :   /* We can only calculate block offsets if the decl has a known
    1362              :      constant size.  */
    1363            0 :   if (DECL_SIZE_UNIT (decl) == NULL)
    1364              :     return NULL;
    1365            0 :   if (!tree_fits_uhwi_p (DECL_SIZE_UNIT (decl)))
    1366              :     return NULL;
    1367              : 
    1368              :   /* Find out which section should contain DECL.  We cannot put it into
    1369              :      an object block if it requires a standalone definition.  */
    1370            0 :   if (VAR_P (decl))
    1371            0 :       align_variable (decl, 0);
    1372            0 :   sect = get_variable_section (decl, true);
    1373            0 :   if (SECTION_STYLE (sect) == SECTION_NOSWITCH)
    1374              :     return NULL;
    1375              : 
    1376            0 :   if (bool (lookup_attribute ("retain", DECL_ATTRIBUTES (decl)))
    1377            0 :       != bool (sect->common.flags & SECTION_RETAIN))
    1378              :     return NULL;
    1379              : 
    1380            0 :   return get_block_for_section (sect);
    1381              : }
    1382              : 
    1383              : /* Make sure block symbol SYMBOL is in block BLOCK.  */
    1384              : 
    1385              : static void
    1386            0 : change_symbol_block (rtx symbol, struct object_block *block)
    1387              : {
    1388            0 :   if (block != SYMBOL_REF_BLOCK (symbol))
    1389              :     {
    1390            0 :       gcc_assert (SYMBOL_REF_BLOCK_OFFSET (symbol) < 0);
    1391            0 :       SYMBOL_REF_BLOCK (symbol) = block;
    1392              :     }
    1393            0 : }
    1394              : 
    1395              : /* Return true if it is possible to put DECL in an object_block.  */
    1396              : 
    1397              : static bool
    1398            0 : use_blocks_for_decl_p (tree decl)
    1399              : {
    1400            0 :   struct symtab_node *snode;
    1401              : 
    1402              :   /* Don't create object blocks if each DECL is placed into a separate
    1403              :      section because that will uselessly create a section anchor for
    1404              :      each DECL.  */
    1405            0 :   if (flag_data_sections)
    1406              :     return false;
    1407              : 
    1408              :   /* Only data DECLs can be placed into object blocks.  */
    1409            0 :   if (!VAR_P (decl) && TREE_CODE (decl) != CONST_DECL)
    1410              :     return false;
    1411              : 
    1412              :   /* DECL_INITIAL (decl) set to decl is a hack used for some decls that
    1413              :      are never used from code directly and we never want object block handling
    1414              :      for those.  */
    1415            0 :   if (DECL_INITIAL (decl) == decl)
    1416              :     return false;
    1417              : 
    1418              :   /* If this decl is an alias, then we don't want to emit a
    1419              :      definition.  */
    1420            0 :   if (VAR_P (decl)
    1421            0 :       && (snode = symtab_node::get (decl)) != NULL
    1422            0 :       && snode->alias)
    1423              :     return false;
    1424              : 
    1425            0 :   return targetm.use_blocks_for_decl_p (decl);
    1426              : }
    1427              : 
    1428              : /* Follow the IDENTIFIER_TRANSPARENT_ALIAS chain starting at *ALIAS
    1429              :    until we find an identifier that is not itself a transparent alias.
    1430              :    Modify the alias passed to it by reference (and all aliases on the
    1431              :    way to the ultimate target), such that they do not have to be
    1432              :    followed again, and return the ultimate target of the alias
    1433              :    chain.  */
    1434              : 
    1435              : static inline tree
    1436     36804157 : ultimate_transparent_alias_target (tree *alias)
    1437              : {
    1438     36804157 :   tree target = *alias;
    1439              : 
    1440     36804157 :   if (IDENTIFIER_TRANSPARENT_ALIAS (target))
    1441              :     {
    1442            0 :       gcc_assert (TREE_CHAIN (target));
    1443            0 :       target = ultimate_transparent_alias_target (&TREE_CHAIN (target));
    1444            0 :       gcc_assert (! IDENTIFIER_TRANSPARENT_ALIAS (target)
    1445              :                   && ! TREE_CHAIN (target));
    1446            0 :       *alias = target;
    1447              :     }
    1448              : 
    1449     36804157 :   return target;
    1450              : }
    1451              : 
    1452              : /* Return true if REGNUM is mentioned in ELIMINABLE_REGS as a from
    1453              :    register number.  */
    1454              : 
    1455              : static bool
    1456            0 : eliminable_regno_p (int regnum)
    1457              : {
    1458            0 :   static const struct
    1459              :   {
    1460              :     const int from;
    1461              :     const int to;
    1462              :   } eliminables[] = ELIMINABLE_REGS;
    1463           13 :   for (size_t i = 0; i < ARRAY_SIZE (eliminables); i++)
    1464           13 :     if (regnum == eliminables[i].from)
    1465              :       return true;
    1466              :   return false;
    1467              : }
    1468              : 
    1469              : /* Create the DECL_RTL for a VAR_DECL or FUNCTION_DECL.  DECL should
    1470              :    have static storage duration.  In other words, it should not be an
    1471              :    automatic variable, including PARM_DECLs.
    1472              : 
    1473              :    There is, however, one exception: this function handles variables
    1474              :    explicitly placed in a particular register by the user.
    1475              : 
    1476              :    This is never called for PARM_DECL nodes.  */
    1477              : 
    1478              : void
    1479      8536802 : make_decl_rtl (tree decl)
    1480              : {
    1481      8536802 :   const char *name = 0;
    1482      8536802 :   int reg_number;
    1483      8536802 :   tree id;
    1484      8536802 :   rtx x;
    1485              : 
    1486              :   /* Check that we are not being given an automatic variable.  */
    1487      8536802 :   gcc_assert (TREE_CODE (decl) != PARM_DECL
    1488              :               && TREE_CODE (decl) != RESULT_DECL);
    1489              : 
    1490              :   /* A weak alias has TREE_PUBLIC set but not the other bits.  */
    1491      8536802 :   gcc_assert (!VAR_P (decl)
    1492              :               || TREE_STATIC (decl)
    1493              :               || TREE_PUBLIC (decl)
    1494              :               || DECL_EXTERNAL (decl)
    1495              :               || DECL_REGISTER (decl));
    1496              : 
    1497              :   /* And that we were not given a type or a label.  */
    1498      8536802 :   gcc_assert (TREE_CODE (decl) != TYPE_DECL
    1499              :               && TREE_CODE (decl) != LABEL_DECL);
    1500              : 
    1501              :   /* For a duplicate declaration, we can be called twice on the
    1502              :      same DECL node.  Don't discard the RTL already made.  */
    1503      8536802 :   if (DECL_RTL_SET_P (decl))
    1504              :     {
    1505              :       /* If the old RTL had the wrong mode, fix the mode.  */
    1506        12249 :       x = DECL_RTL (decl);
    1507        12249 :       if (GET_MODE (x) != DECL_MODE (decl))
    1508            0 :         SET_DECL_RTL (decl, adjust_address_nv (x, DECL_MODE (decl), 0));
    1509              : 
    1510        12249 :       if (TREE_CODE (decl) != FUNCTION_DECL && DECL_REGISTER (decl))
    1511              :         return;
    1512              : 
    1513              :       /* ??? Another way to do this would be to maintain a hashed
    1514              :          table of such critters.  Instead of adding stuff to a DECL
    1515              :          to give certain attributes to it, we could use an external
    1516              :          hash map from DECL to set of attributes.  */
    1517              : 
    1518              :       /* Let the target reassign the RTL if it wants.
    1519              :          This is necessary, for example, when one machine specific
    1520              :          decl attribute overrides another.  */
    1521        12181 :       targetm.encode_section_info (decl, DECL_RTL (decl), false);
    1522              : 
    1523              :       /* If the symbol has a SYMBOL_REF_BLOCK field, update it based
    1524              :          on the new decl information.  */
    1525        12181 :       if (MEM_P (x)
    1526        12181 :           && GET_CODE (XEXP (x, 0)) == SYMBOL_REF
    1527        24362 :           && SYMBOL_REF_HAS_BLOCK_INFO_P (XEXP (x, 0)))
    1528            0 :         change_symbol_block (XEXP (x, 0), get_block_for_decl (decl));
    1529              : 
    1530        12181 :       return;
    1531              :     }
    1532              : 
    1533              :   /* If this variable belongs to the global constant pool, retrieve the
    1534              :      pre-computed RTL or recompute it in LTO mode.  */
    1535      8524553 :   if (VAR_P (decl) && DECL_IN_CONSTANT_POOL (decl))
    1536              :     {
    1537         5445 :       SET_DECL_RTL (decl, output_constant_def (DECL_INITIAL (decl), 1));
    1538         5445 :       return;
    1539              :     }
    1540              : 
    1541      8519108 :   id = DECL_ASSEMBLER_NAME (decl);
    1542      8519108 :   name = IDENTIFIER_POINTER (id);
    1543              : 
    1544      8460926 :   if (name[0] != '*' && TREE_CODE (decl) != FUNCTION_DECL
    1545     11649881 :       && DECL_REGISTER (decl))
    1546              :     {
    1547           13 :       error ("register name not specified for %q+D", decl);
    1548              :     }
    1549      8519095 :   else if (TREE_CODE (decl) != FUNCTION_DECL && DECL_REGISTER (decl))
    1550              :     {
    1551         1201 :       const char *asmspec = name+1;
    1552         1201 :       machine_mode mode = DECL_MODE (decl);
    1553         1201 :       reg_number = decode_reg_name (asmspec);
    1554              :       /* First detect errors in declaring global registers.  */
    1555         1201 :       if (reg_number == -1)
    1556            0 :         error ("register name not specified for %q+D", decl);
    1557         1201 :       else if (reg_number < 0)
    1558           28 :         error ("invalid register name for %q+D", decl);
    1559         1173 :       else if (mode == BLKmode)
    1560            5 :         error ("data type of %q+D isn%'t suitable for a register",
    1561              :                decl);
    1562         1168 :       else if (!in_hard_reg_set_p (accessible_reg_set, mode, reg_number))
    1563            2 :         error ("the register specified for %q+D cannot be accessed"
    1564              :                " by the current target", decl);
    1565         1166 :       else if (!in_hard_reg_set_p (operand_reg_set, mode, reg_number))
    1566            0 :         error ("the register specified for %q+D is not general enough"
    1567              :                " to be used as a register variable", decl);
    1568         1166 :       else if (!targetm.hard_regno_mode_ok (reg_number, mode))
    1569            2 :         error ("register specified for %q+D isn%'t suitable for data type",
    1570              :                decl);
    1571         1164 :       else if (reg_number != HARD_FRAME_POINTER_REGNUM
    1572         1158 :                && (reg_number == FRAME_POINTER_REGNUM
    1573              : #ifdef RETURN_ADDRESS_POINTER_REGNUM
    1574              :                    || reg_number == RETURN_ADDRESS_POINTER_REGNUM
    1575              : #endif
    1576         1158 :                    || reg_number == ARG_POINTER_REGNUM)
    1577         1169 :                && eliminable_regno_p (reg_number))
    1578            5 :         error ("register specified for %q+D is an internal GCC "
    1579              :                "implementation detail", decl);
    1580              :       /* Now handle properly declared static register variables.  */
    1581              :       else
    1582              :         {
    1583         1159 :           int nregs;
    1584              : 
    1585         1159 :           if (DECL_INITIAL (decl) != 0 && TREE_STATIC (decl))
    1586              :             {
    1587            0 :               DECL_INITIAL (decl) = 0;
    1588            0 :               error ("global register variable has initial value");
    1589              :             }
    1590         1159 :           if (TREE_THIS_VOLATILE (decl))
    1591           11 :             warning (OPT_Wvolatile_register_var,
    1592              :                      "optimization may eliminate reads and/or "
    1593              :                      "writes to register variables");
    1594              : 
    1595              :           /* If the user specified one of the eliminables registers here,
    1596              :              e.g., FRAME_POINTER_REGNUM, we don't want to get this variable
    1597              :              confused with that register and be eliminated.  This usage is
    1598              :              somewhat suspect...  */
    1599              : 
    1600         1159 :           SET_DECL_RTL (decl, gen_raw_REG (mode, reg_number));
    1601         1159 :           ORIGINAL_REGNO (DECL_RTL (decl)) = reg_number;
    1602         1159 :           REG_USERVAR_P (DECL_RTL (decl)) = 1;
    1603              : 
    1604         1159 :           if (TREE_STATIC (decl))
    1605              :             {
    1606              :               /* Make this register global, so not usable for anything
    1607              :                  else.  */
    1608              : #ifdef ASM_DECLARE_REGISTER_GLOBAL
    1609              :               name = IDENTIFIER_POINTER (DECL_NAME (decl));
    1610              :               ASM_DECLARE_REGISTER_GLOBAL (asm_out_file, decl, reg_number, name);
    1611              : #endif
    1612          109 :               nregs = hard_regno_nregs (reg_number, mode);
    1613          218 :               while (nregs > 0)
    1614          109 :                 globalize_reg (decl, reg_number + --nregs);
    1615              :             }
    1616              : 
    1617              :           /* As a register variable, it has no section.  */
    1618         1159 :           return;
    1619              :         }
    1620              :       /* Avoid internal errors from invalid register
    1621              :          specifications.  */
    1622           42 :       SET_DECL_ASSEMBLER_NAME (decl, NULL_TREE);
    1623           42 :       DECL_HARD_REGISTER (decl) = 0;
    1624              :       /* Also avoid SSA inconsistencies by pretending this is an external
    1625              :          decl now.  */
    1626           42 :       DECL_EXTERNAL (decl) = 1;
    1627           42 :       return;
    1628              :     }
    1629              :   /* Now handle ordinary static variables and functions (in memory).
    1630              :      Also handle vars declared register invalidly.  */
    1631              :   else if (name[0] == '*')
    1632              :   {
    1633              : #ifdef REGISTER_PREFIX
    1634              :     if (strlen (REGISTER_PREFIX) != 0)
    1635              :       {
    1636              :         reg_number = decode_reg_name (name);
    1637              :         if (reg_number >= 0 || reg_number == -3)
    1638              :           error ("register name given for non-register variable %q+D", decl);
    1639              :       }
    1640              : #endif
    1641              :   }
    1642              : 
    1643              :   /* Specifying a section attribute on a variable forces it into a
    1644              :      non-.bss section, and thus it cannot be common.  */
    1645              :   /* FIXME: In general this code should not be necessary because
    1646              :      visibility pass is doing the same work.  But notice_global_symbol
    1647              :      is called early and it needs to make DECL_RTL to get the name.
    1648              :      we take care of recomputing the DECL_RTL after visibility is changed.  */
    1649      8517907 :   if (VAR_P (decl)
    1650      3169215 :       && (TREE_STATIC (decl) || DECL_EXTERNAL (decl))
    1651      3169215 :       && DECL_SECTION_NAME (decl) != NULL
    1652      1432705 :       && DECL_INITIAL (decl) == NULL_TREE
    1653      8518024 :       && DECL_COMMON (decl))
    1654            0 :     DECL_COMMON (decl) = 0;
    1655              : 
    1656              :   /* Variables can't be both common and weak.  */
    1657      8517907 :   if (VAR_P (decl) && DECL_WEAK (decl))
    1658       326215 :     DECL_COMMON (decl) = 0;
    1659              : 
    1660      8517907 :   if (use_object_blocks_p () && use_blocks_for_decl_p (decl))
    1661            0 :     x = create_block_symbol (name, get_block_for_decl (decl), -1);
    1662              :   else
    1663              :     {
    1664      8517907 :       machine_mode address_mode = Pmode;
    1665      8517907 :       if (TREE_TYPE (decl) != error_mark_node)
    1666              :         {
    1667      8517907 :           addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (decl));
    1668      8517907 :           address_mode = targetm.addr_space.address_mode (as);
    1669              :         }
    1670      8517907 :       x = gen_rtx_SYMBOL_REF (address_mode, name);
    1671              :     }
    1672      8517907 :   SYMBOL_REF_WEAK (x) = DECL_WEAK (decl);
    1673      8517907 :   SET_SYMBOL_REF_DECL (x, decl);
    1674              : 
    1675      8517907 :   x = gen_rtx_MEM (DECL_MODE (decl), x);
    1676      8517907 :   if (TREE_CODE (decl) != FUNCTION_DECL)
    1677      3169215 :     set_mem_attributes (x, decl, 1);
    1678      8517907 :   SET_DECL_RTL (decl, x);
    1679              : 
    1680              :   /* Optionally set flags or add text to the name to record information
    1681              :      such as that it is a function name.
    1682              :      If the name is changed, the macro ASM_OUTPUT_LABELREF
    1683              :      will have to know how to strip this information.  */
    1684      8517907 :   targetm.encode_section_info (decl, DECL_RTL (decl), true);
    1685              : }
    1686              : 
    1687              : /* Like make_decl_rtl, but inhibit creation of new alias sets when
    1688              :    calling make_decl_rtl.  Also, reset DECL_RTL before returning the
    1689              :    rtl.  */
    1690              : 
    1691              : rtx
    1692        27977 : make_decl_rtl_for_debug (tree decl)
    1693              : {
    1694        27977 :   unsigned int save_aliasing_flag;
    1695        27977 :   rtx rtl;
    1696              : 
    1697        27977 :   if (DECL_RTL_SET_P (decl))
    1698            0 :     return DECL_RTL (decl);
    1699              : 
    1700              :   /* Kludge alert!  Somewhere down the call chain, make_decl_rtl will
    1701              :      call new_alias_set.  If running with -fcompare-debug, sometimes
    1702              :      we do not want to create alias sets that will throw the alias
    1703              :      numbers off in the comparison dumps.  So... clearing
    1704              :      flag_strict_aliasing will keep new_alias_set() from creating a
    1705              :      new set.  */
    1706        27977 :   save_aliasing_flag = flag_strict_aliasing;
    1707        27977 :   flag_strict_aliasing = 0;
    1708              : 
    1709        27977 :   rtl = DECL_RTL (decl);
    1710              :   /* Reset DECL_RTL back, as various parts of the compiler expects
    1711              :      DECL_RTL set meaning it is actually going to be output.  */
    1712        27977 :   SET_DECL_RTL (decl, NULL);
    1713              : 
    1714        27977 :   flag_strict_aliasing = save_aliasing_flag;
    1715        27977 :   return rtl;
    1716              : }
    1717              : 
    1718              : /* Output a string of literal assembler code
    1719              :    for an `asm' keyword used between functions.  */
    1720              : 
    1721              : void
    1722        12306 : assemble_asm (tree asm_str)
    1723              : {
    1724        12306 :   const char *p;
    1725              : 
    1726        12306 :   if (TREE_CODE (asm_str) != ASM_EXPR)
    1727              :     {
    1728        12241 :       app_enable ();
    1729        12241 :       if (TREE_CODE (asm_str) == ADDR_EXPR)
    1730            0 :         asm_str = TREE_OPERAND (asm_str, 0);
    1731              : 
    1732        12241 :       p = TREE_STRING_POINTER (asm_str);
    1733        24447 :       fprintf (asm_out_file, "%s%s\n", p[0] == '\t' ? "" : "\t", p);
    1734              :     }
    1735              :   else
    1736              :     {
    1737           65 :       location_t save_loc = input_location;
    1738           65 :       int save_reload_completed = reload_completed;
    1739           65 :       int save_cse_not_expected = cse_not_expected;
    1740           65 :       input_location = EXPR_LOCATION (asm_str);
    1741           65 :       int noutputs = list_length (ASM_OUTPUTS (asm_str));
    1742           65 :       int ninputs = list_length (ASM_INPUTS (asm_str));
    1743           65 :       const char **constraints = NULL;
    1744           65 :       int i;
    1745           65 :       tree tail;
    1746           65 :       bool allows_mem, allows_reg, is_inout;
    1747           65 :       rtx *ops = NULL;
    1748           65 :       if (noutputs + ninputs > MAX_RECOG_OPERANDS)
    1749              :         {
    1750            0 :           error ("more than %d operands in %<asm%>", MAX_RECOG_OPERANDS);
    1751            0 :           goto done;
    1752              :         }
    1753           65 :       constraints = XALLOCAVEC (const char *, noutputs + ninputs);
    1754           65 :       ops = XALLOCAVEC (rtx, noutputs + ninputs);
    1755           65 :       memset (&recog_data, 0, sizeof (recog_data));
    1756           65 :       recog_data.n_operands = ninputs + noutputs;
    1757           65 :       recog_data.is_asm = true;
    1758           65 :       reload_completed = 0;
    1759           65 :       cse_not_expected = 1;
    1760           69 :       for (i = 0, tail = ASM_OUTPUTS (asm_str); tail;
    1761            4 :            ++i, tail = TREE_CHAIN (tail))
    1762              :         {
    1763           16 :           tree output = TREE_VALUE (tail);
    1764           16 :           if (output == error_mark_node)
    1765            0 :             goto done;
    1766           32 :           constraints[i]
    1767           16 :             = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (tail)));
    1768           16 :           if (!parse_output_constraint (&constraints[i], i, ninputs, noutputs,
    1769              :                                         &allows_mem, &allows_reg, &is_inout,
    1770              :                                         nullptr))
    1771            0 :             goto done;
    1772           16 :           if (is_inout)
    1773              :             {
    1774            4 :               error ("%qc in output operand outside of a function", '+');
    1775            4 :               goto done;
    1776              :             }
    1777           12 :           if (strchr (constraints[i], '&'))
    1778              :             {
    1779            4 :               error ("%qc in output operand outside of a function", '&');
    1780            4 :               goto done;
    1781              :             }
    1782            8 :           if (strchr (constraints[i], '%'))
    1783              :             {
    1784            4 :               error ("%qc in output operand outside of a function", '%');
    1785            4 :               goto done;
    1786              :             }
    1787            4 :           output_addressed_constants (output, 0);
    1788            4 :           if (!is_gimple_addressable (output))
    1789              :             {
    1790            0 :               error ("output number %d not directly addressable", i);
    1791            0 :               goto done;
    1792              :             }
    1793            4 :           ops[i] = expand_expr (build_fold_addr_expr (output), NULL_RTX,
    1794              :                                 VOIDmode, EXPAND_INITIALIZER);
    1795            4 :           ops[i] = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (output)), ops[i]);
    1796              : 
    1797            4 :           recog_data.operand[i] = ops[i];
    1798            4 :           recog_data.operand_loc[i] = &ops[i];
    1799            4 :           recog_data.constraints[i] = constraints[i];
    1800            4 :           recog_data.operand_mode[i] = TYPE_MODE (TREE_TYPE (output));
    1801              :         }
    1802          186 :       for (i = 0, tail = ASM_INPUTS (asm_str); tail;
    1803          133 :            ++i, tail = TREE_CHAIN (tail))
    1804              :         {
    1805          137 :           tree input = TREE_VALUE (tail);
    1806          137 :           if (input == error_mark_node)
    1807            0 :             goto done;
    1808          274 :           constraints[i + noutputs]
    1809          137 :             = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (tail)));
    1810          137 :           if (!parse_input_constraint (&constraints[i + noutputs], i,
    1811              :                                        ninputs, noutputs, 0, constraints,
    1812              :                                        &allows_mem, &allows_reg, nullptr))
    1813            0 :             goto done;
    1814          137 :           if (strchr (constraints[i], '%'))
    1815              :             {
    1816            4 :               error ("%qc in input operand outside of a function", '%');
    1817            4 :               goto done;
    1818              :             }
    1819          133 :           const char *constraint = constraints[i + noutputs];
    1820          133 :           size_t c_len = strlen (constraint);
    1821          298 :           for (size_t j = 0; j < c_len;
    1822          165 :                j += CONSTRAINT_LEN (constraint[j], constraint + j))
    1823          165 :             if (constraint[j] >= '0' && constraint[j] <= '9')
    1824              :               {
    1825            0 :                 error ("matching constraint outside of a function");
    1826            0 :                 goto done;
    1827              :               }
    1828          133 :           output_addressed_constants (input, 0);
    1829          133 :           if (allows_mem && is_gimple_addressable (input))
    1830              :             {
    1831            8 :               ops[i + noutputs]
    1832            8 :                 = expand_expr (build_fold_addr_expr (input), NULL_RTX,
    1833              :                                VOIDmode, EXPAND_INITIALIZER);
    1834            8 :               ops[i + noutputs] = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (input)),
    1835              :                                                ops[i + noutputs]);
    1836              :             }
    1837              :           else
    1838          125 :             ops[i + noutputs] = expand_expr (input, NULL_RTX, VOIDmode,
    1839              :                                              EXPAND_INITIALIZER);
    1840          133 :           if (asm_operand_ok (ops[i + noutputs], constraint, NULL) <= 0)
    1841              :             {
    1842            0 :               if (!allows_mem)
    1843            0 :                 warning (0, "%<asm%> operand %d probably does not "
    1844              :                             "match constraints", i + noutputs);
    1845              :             }
    1846          133 :           recog_data.operand[i + noutputs] = ops[i + noutputs];
    1847          133 :           recog_data.operand_loc[i + noutputs] = &ops[i + noutputs];
    1848          133 :           recog_data.constraints[i + noutputs] = constraints[i + noutputs];
    1849          133 :           recog_data.operand_mode[i + noutputs]
    1850          133 :             = TYPE_MODE (TREE_TYPE (input));
    1851              :         }
    1852           49 :       if (recog_data.n_operands > 0)
    1853              :         {
    1854           49 :           const char *p = recog_data.constraints[0];
    1855           49 :           recog_data.n_alternatives = 1;
    1856          102 :           while (*p)
    1857           53 :             recog_data.n_alternatives += (*p++ == ',');
    1858              :         }
    1859          186 :       for (i = 0; i < recog_data.n_operands; i++)
    1860          137 :         recog_data.operand_type[i]
    1861          270 :           = recog_data.constraints[i][0] == '=' ? OP_OUT : OP_IN;
    1862           49 :       reload_completed = 1;
    1863           49 :       constrain_operands (1, ALL_ALTERNATIVES);
    1864           49 :       if (which_alternative < 0)
    1865              :         {
    1866            0 :           error ("impossible constraint in %<asm%>");
    1867            0 :           goto done;
    1868              :         }
    1869           49 :       this_is_asm_operands = make_insn_raw (gen_nop ());
    1870           49 :       insn_noperands = recog_data.n_operands;
    1871           49 :       if (TREE_STRING_POINTER (ASM_STRING (asm_str))[0])
    1872              :         {
    1873           49 :           app_enable ();
    1874           49 :           output_asm_insn (TREE_STRING_POINTER (ASM_STRING (asm_str)), ops);
    1875              :         }
    1876           49 :       insn_noperands = 0;
    1877           49 :       this_is_asm_operands = NULL;
    1878              : 
    1879           65 :     done:
    1880           65 :       input_location = save_loc;
    1881           65 :       reload_completed = save_reload_completed;
    1882           65 :       cse_not_expected = save_cse_not_expected;
    1883              :     }
    1884        12306 : }
    1885              : 
    1886              : /* Write the address of the entity given by SYMBOL to SEC.  */
    1887              : void
    1888        23526 : assemble_addr_to_section (rtx symbol, section *sec)
    1889              : {
    1890        23526 :   switch_to_section (sec);
    1891        23931 :   assemble_align (POINTER_SIZE);
    1892        24336 :   assemble_integer (symbol, POINTER_SIZE_UNITS, POINTER_SIZE, 1);
    1893        23526 : }
    1894              : 
    1895              : /* Return the numbered .ctors.N (if CONSTRUCTOR_P) or .dtors.N (if
    1896              :    not) section for PRIORITY.  */
    1897              : section *
    1898            0 : get_cdtor_priority_section (int priority, bool constructor_p)
    1899              : {
    1900              :   /* Buffer conservatively large enough for the full range of a 32-bit
    1901              :      int plus the text below.  */
    1902            0 :   char buf[18];
    1903              : 
    1904              :   /* ??? This only works reliably with the GNU linker.  */
    1905            0 :   sprintf (buf, "%s.%.5u",
    1906              :            constructor_p ? ".ctors" : ".dtors",
    1907              :            /* Invert the numbering so the linker puts us in the proper
    1908              :               order; constructors are run from right to left, and the
    1909              :               linker sorts in increasing order.  */
    1910              :            MAX_INIT_PRIORITY - priority);
    1911            0 :   return get_section (buf, SECTION_WRITE, NULL);
    1912              : }
    1913              : 
    1914              : void
    1915            0 : default_named_section_asm_out_destructor (rtx symbol, int priority)
    1916              : {
    1917            0 :   section *sec;
    1918              : 
    1919            0 :   if (priority != DEFAULT_INIT_PRIORITY)
    1920            0 :     sec = get_cdtor_priority_section (priority,
    1921              :                                       /*constructor_p=*/false);
    1922              :   else
    1923            0 :     sec = get_section (".dtors", SECTION_WRITE, NULL);
    1924              : 
    1925            0 :   assemble_addr_to_section (symbol, sec);
    1926            0 : }
    1927              : 
    1928              : #ifdef DTORS_SECTION_ASM_OP
    1929              : void
    1930              : default_dtor_section_asm_out_destructor (rtx symbol,
    1931              :                                          int priority ATTRIBUTE_UNUSED)
    1932              : {
    1933              :   assemble_addr_to_section (symbol, dtors_section);
    1934              : }
    1935              : #endif
    1936              : 
    1937              : void
    1938            0 : default_named_section_asm_out_constructor (rtx symbol, int priority)
    1939              : {
    1940            0 :   section *sec;
    1941              : 
    1942            0 :   if (priority != DEFAULT_INIT_PRIORITY)
    1943            0 :     sec = get_cdtor_priority_section (priority,
    1944              :                                       /*constructor_p=*/true);
    1945              :   else
    1946            0 :     sec = get_section (".ctors", SECTION_WRITE, NULL);
    1947              : 
    1948            0 :   assemble_addr_to_section (symbol, sec);
    1949            0 : }
    1950              : 
    1951              : #ifdef CTORS_SECTION_ASM_OP
    1952              : void
    1953              : default_ctor_section_asm_out_constructor (rtx symbol,
    1954              :                                           int priority ATTRIBUTE_UNUSED)
    1955              : {
    1956              :   assemble_addr_to_section (symbol, ctors_section);
    1957              : }
    1958              : #endif
    1959              : 
    1960              : /* CONSTANT_POOL_BEFORE_FUNCTION may be defined as an expression with
    1961              :    a nonzero value if the constant pool should be output before the
    1962              :    start of the function, or a zero value if the pool should output
    1963              :    after the end of the function.  The default is to put it before the
    1964              :    start.  */
    1965              : 
    1966              : #ifndef CONSTANT_POOL_BEFORE_FUNCTION
    1967              : #define CONSTANT_POOL_BEFORE_FUNCTION 1
    1968              : #endif
    1969              : 
    1970              : /* DECL is an object (either VAR_DECL or FUNCTION_DECL) which is going
    1971              :    to be output to assembler.
    1972              :    Set first_global_object_name and weak_global_object_name as appropriate.  */
    1973              : 
    1974              : void
    1975    133897866 : notice_global_symbol (tree decl)
    1976              : {
    1977    133897866 :   const char **t = &first_global_object_name;
    1978              : 
    1979    133897866 :   if (first_global_object_name
    1980     83502059 :       || !TREE_PUBLIC (decl)
    1981     82624371 :       || DECL_EXTERNAL (decl)
    1982     23320508 :       || !DECL_NAME (decl)
    1983     23320434 :       || (VAR_P (decl) && DECL_HARD_REGISTER (decl))
    1984    157218260 :       || (TREE_CODE (decl) != FUNCTION_DECL
    1985     15566907 :           && (!VAR_P (decl)
    1986     15566907 :               || (DECL_COMMON (decl)
    1987         9039 :                   && (DECL_INITIAL (decl) == 0
    1988         8773 :                       || DECL_INITIAL (decl) == error_mark_node)))))
    1989              :     return;
    1990              : 
    1991              :   /* We win when global object is found, but it is useful to know about weak
    1992              :      symbol as well so we can produce nicer unique names.  */
    1993     23320128 :   if (DECL_WEAK (decl) || DECL_ONE_ONLY (decl) || flag_shlib)
    1994              :     t = &weak_global_object_name;
    1995              : 
    1996     23320128 :   if (!*t)
    1997              :     {
    1998       272016 :       tree id = DECL_ASSEMBLER_NAME (decl);
    1999       272016 :       ultimate_transparent_alias_target (&id);
    2000       272016 :       *t = ggc_strdup (targetm.strip_name_encoding (IDENTIFIER_POINTER (id)));
    2001              :     }
    2002              : }
    2003              : 
    2004              : /* If not using flag_reorder_blocks_and_partition, decide early whether the
    2005              :    current function goes into the cold section, so that targets can use
    2006              :    current_function_section during RTL expansion.  DECL describes the
    2007              :    function.  */
    2008              : 
    2009              : void
    2010      1477667 : decide_function_section (tree decl)
    2011              : {
    2012      1477667 :   first_function_block_is_cold = false;
    2013              : 
    2014      1477667 :  if (DECL_SECTION_NAME (decl))
    2015              :     {
    2016         8561 :       struct cgraph_node *node = cgraph_node::get (current_function_decl);
    2017              :       /* Calls to function_section rely on first_function_block_is_cold
    2018              :          being accurate.  */
    2019         8561 :       first_function_block_is_cold = (node
    2020         8561 :                                       && node->frequency
    2021         8561 :                                       == NODE_FREQUENCY_UNLIKELY_EXECUTED);
    2022              :     }
    2023              : 
    2024      1477667 :   in_cold_section_p = first_function_block_is_cold;
    2025      1477667 : }
    2026              : 
    2027              : /* Get the function's name, as described by its RTL.  This may be
    2028              :    different from the DECL_NAME name used in the source file.  */
    2029              : const char *
    2030      1547348 : get_fnname_from_decl (tree decl)
    2031              : {
    2032      1547348 :   rtx x = DECL_RTL (decl);
    2033      1547348 :   gcc_assert (MEM_P (x));
    2034      1547348 :   x = XEXP (x, 0);
    2035      1547348 :   gcc_assert (GET_CODE (x) == SYMBOL_REF);
    2036      1547348 :   return XSTR (x, 0);
    2037              : }
    2038              : 
    2039              : /* Output function label, possibly with accompanying metadata.  No additional
    2040              :    code or data is output after the label.  */
    2041              : 
    2042              : void
    2043      1541054 : assemble_function_label_raw (FILE *file, const char *name)
    2044              : {
    2045      1541054 :   ASM_OUTPUT_LABEL (file, name);
    2046      1541054 :   assemble_function_label_final ();
    2047      1541054 : }
    2048              : 
    2049              : /* Finish outputting function label.  Needs to be called when outputting
    2050              :    function label without using assemble_function_label_raw ().  */
    2051              : 
    2052              : void
    2053      1541054 : assemble_function_label_final (void)
    2054              : {
    2055      1541054 :   if ((flag_sanitize & SANITIZE_ADDRESS)
    2056              :       /* Notify ASAN only about the first function label.  */
    2057         6281 :       && (in_cold_section_p == first_function_block_is_cold)
    2058              :       /* Do not notify ASAN when called from, e.g., code_end ().  */
    2059         6116 :       && cfun)
    2060         6116 :     asan_function_start ();
    2061      1541054 : }
    2062              : 
    2063              : /* Output assembler code for the constant pool of a function and associated
    2064              :    with defining the name of the function.  DECL describes the function.
    2065              :    NAME is the function's name.  For the constant pool, we use the current
    2066              :    constant pool data.  */
    2067              : 
    2068              : void
    2069      1473125 : assemble_start_function (tree decl, const char *fnname)
    2070              : {
    2071      1473125 :   int align;
    2072      1473125 :   char tmp_label[100];
    2073      1473125 :   bool hot_label_written = false;
    2074              : 
    2075      1473125 :   if (crtl->has_bb_partition)
    2076              :     {
    2077        64342 :       ASM_GENERATE_INTERNAL_LABEL (tmp_label, "LHOTB", const_labelno);
    2078        64342 :       crtl->subsections.hot_section_label = ggc_strdup (tmp_label);
    2079        64342 :       ASM_GENERATE_INTERNAL_LABEL (tmp_label, "LCOLDB", const_labelno);
    2080        64342 :       crtl->subsections.cold_section_label = ggc_strdup (tmp_label);
    2081        64342 :       ASM_GENERATE_INTERNAL_LABEL (tmp_label, "LHOTE", const_labelno);
    2082        64342 :       crtl->subsections.hot_section_end_label = ggc_strdup (tmp_label);
    2083        64342 :       ASM_GENERATE_INTERNAL_LABEL (tmp_label, "LCOLDE", const_labelno);
    2084        64342 :       crtl->subsections.cold_section_end_label = ggc_strdup (tmp_label);
    2085        64342 :       const_labelno++;
    2086        64342 :       cold_function_name = NULL_TREE;
    2087              :     }
    2088              :   else
    2089              :     {
    2090      1408783 :       crtl->subsections.hot_section_label = NULL;
    2091      1408783 :       crtl->subsections.cold_section_label = NULL;
    2092      1408783 :       crtl->subsections.hot_section_end_label = NULL;
    2093      1408783 :       crtl->subsections.cold_section_end_label = NULL;
    2094              :     }
    2095              : 
    2096              :   /* The following code does not need preprocessing in the assembler.  */
    2097              : 
    2098      1473125 :   app_disable ();
    2099              : 
    2100      1473125 :   if (CONSTANT_POOL_BEFORE_FUNCTION)
    2101      1473125 :     output_constant_pool (fnname, decl);
    2102              : 
    2103      1473125 :   align = symtab_node::get (decl)->definition_alignment ();
    2104              : 
    2105              :   /* Make sure the not and cold text (code) sections are properly
    2106              :      aligned.  This is necessary here in the case where the function
    2107              :      has both hot and cold sections, because we don't want to re-set
    2108              :      the alignment when the section switch happens mid-function.  */
    2109              : 
    2110      1473125 :   if (crtl->has_bb_partition)
    2111              :     {
    2112        64342 :       first_function_block_is_cold = false;
    2113              : 
    2114        64342 :       switch_to_section (unlikely_text_section ());
    2115        64342 :       assemble_align (align);
    2116        64342 :       ASM_OUTPUT_LABEL (asm_out_file, crtl->subsections.cold_section_label);
    2117              : 
    2118              :       /* When the function starts with a cold section, we need to explicitly
    2119              :          align the hot section and write out the hot section label.
    2120              :          But if the current function is a thunk, we do not have a CFG.  */
    2121        64342 :       if (!cfun->is_thunk
    2122        64342 :           && BB_PARTITION (ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb) == BB_COLD_PARTITION)
    2123              :         {
    2124            0 :           switch_to_section (text_section);
    2125            0 :           assemble_align (align);
    2126            0 :           ASM_OUTPUT_LABEL (asm_out_file, crtl->subsections.hot_section_label);
    2127            0 :           hot_label_written = true;
    2128            0 :           first_function_block_is_cold = true;
    2129              :         }
    2130        64342 :       in_cold_section_p = first_function_block_is_cold;
    2131              :     }
    2132              : 
    2133              : 
    2134              :   /* Switch to the correct text section for the start of the function.  */
    2135              : 
    2136      1473125 :   switch_to_section (function_section (decl), decl);
    2137      1473125 :   if (crtl->has_bb_partition && !hot_label_written)
    2138        64342 :     ASM_OUTPUT_LABEL (asm_out_file, crtl->subsections.hot_section_label);
    2139              : 
    2140              :   /* Tell assembler to move to target machine's alignment for functions.  */
    2141      1473125 :   align = floor_log2 (align / BITS_PER_UNIT);
    2142              :   /* Handle forced alignment.  This really ought to apply to all functions,
    2143              :      since it is used by patchable entries.  */
    2144      1473125 :   if (flag_min_function_alignment)
    2145            0 :     align = MAX (align, floor_log2 (flag_min_function_alignment));
    2146              : 
    2147      1473125 :   if (align > 0)
    2148              :     {
    2149       170968 :       ASM_OUTPUT_ALIGN (asm_out_file, align);
    2150              :     }
    2151              : 
    2152              :   /* Handle a user-specified function alignment.
    2153              :      Note that we still need to align to DECL_ALIGN, as above,
    2154              :      because ASM_OUTPUT_MAX_SKIP_ALIGN might not do any alignment at all.  */
    2155      1473125 :   if (! DECL_USER_ALIGN (decl)
    2156      1473091 :       && align_functions.levels[0].log > align
    2157      2391833 :       && optimize_function_for_speed_p (cfun))
    2158              :     {
    2159              : #ifdef ASM_OUTPUT_MAX_SKIP_ALIGN
    2160       900302 :       int align_log = align_functions.levels[0].log;
    2161              : #endif
    2162       900302 :       int max_skip = align_functions.levels[0].maxskip;
    2163       900302 :       if (flag_limit_function_alignment && crtl->max_insn_address > 0
    2164            1 :           && max_skip >= crtl->max_insn_address)
    2165            1 :         max_skip = crtl->max_insn_address - 1;
    2166              : 
    2167              : #ifdef ASM_OUTPUT_MAX_SKIP_ALIGN
    2168       900302 :       ASM_OUTPUT_MAX_SKIP_ALIGN (asm_out_file, align_log, max_skip);
    2169       900302 :       if (max_skip == align_functions.levels[0].maxskip)
    2170       900301 :         ASM_OUTPUT_MAX_SKIP_ALIGN (asm_out_file,
    2171              :                                    align_functions.levels[1].log,
    2172              :                                    align_functions.levels[1].maxskip);
    2173              : #else
    2174              :       ASM_OUTPUT_ALIGN (asm_out_file, align_functions.levels[0].log);
    2175              : #endif
    2176              :     }
    2177              : 
    2178              : #ifdef ASM_OUTPUT_FUNCTION_PREFIX
    2179              :   ASM_OUTPUT_FUNCTION_PREFIX (asm_out_file, fnname);
    2180              : #endif
    2181              : 
    2182      1473125 :   if (!DECL_IGNORED_P (decl))
    2183      1448520 :     (*debug_hooks->begin_function) (decl);
    2184              : 
    2185              :   /* Make function name accessible from other files, if appropriate.  */
    2186              : 
    2187      1473125 :   if (TREE_PUBLIC (decl))
    2188              :     {
    2189      1204013 :       notice_global_symbol (decl);
    2190              : 
    2191      1204013 :       globalize_decl (decl);
    2192              : 
    2193      1204013 :       maybe_assemble_visibility (decl);
    2194              :     }
    2195              : 
    2196      1473125 :   if (DECL_PRESERVE_P (decl))
    2197         4274 :     targetm.asm_out.mark_decl_preserved (fnname);
    2198              : 
    2199      1473125 :   unsigned short patch_area_size = crtl->patch_area_size;
    2200      1473125 :   unsigned short patch_area_entry = crtl->patch_area_entry;
    2201              : 
    2202              :   /* Emit the patching area before the entry label, if any.  */
    2203      1473125 :   if (patch_area_entry > 0)
    2204            8 :     targetm.asm_out.print_patchable_function_entry (asm_out_file,
    2205              :                                                     patch_area_entry, true);
    2206              : 
    2207              :   /* Do any machine/system dependent processing of the function name.  */
    2208              : #ifdef ASM_DECLARE_FUNCTION_NAME
    2209      1473125 :   ASM_DECLARE_FUNCTION_NAME (asm_out_file, fnname, current_function_decl);
    2210              : #else
    2211              :   /* Standard thing is just output label for the function.  */
    2212              :   ASM_OUTPUT_FUNCTION_LABEL (asm_out_file, fnname, current_function_decl);
    2213              : #endif /* ASM_DECLARE_FUNCTION_NAME */
    2214              : 
    2215              :   /* And the area after the label.  Record it if we haven't done so yet.  */
    2216      1473125 :   if (patch_area_size > patch_area_entry)
    2217           51 :     targetm.asm_out.print_patchable_function_entry (asm_out_file,
    2218           51 :                                                     patch_area_size
    2219           51 :                                                     - patch_area_entry,
    2220              :                                                     patch_area_entry == 0);
    2221              : 
    2222      1473125 :   if (lookup_attribute ("no_split_stack", DECL_ATTRIBUTES (decl)))
    2223         2458 :     saw_no_split_stack = true;
    2224      1473125 : }
    2225              : 
    2226              : /* Output assembler code associated with defining the size of the
    2227              :    function.  DECL describes the function.  NAME is the function's name.  */
    2228              : 
    2229              : void
    2230      1473125 : assemble_end_function (tree decl, const char *fnname ATTRIBUTE_UNUSED)
    2231              : {
    2232              : #ifdef ASM_DECLARE_FUNCTION_SIZE
    2233              :   /* We could have switched section in the middle of the function.  */
    2234      1473125 :   if (crtl->has_bb_partition)
    2235        64342 :     switch_to_section (function_section (decl));
    2236      1473125 :   ASM_DECLARE_FUNCTION_SIZE (asm_out_file, fnname, decl);
    2237              : #endif
    2238      1473125 :   if (! CONSTANT_POOL_BEFORE_FUNCTION)
    2239              :     {
    2240              :       output_constant_pool (fnname, decl);
    2241              :       switch_to_section (function_section (decl)); /* need to switch back */
    2242              :     }
    2243              :   /* Output labels for end of hot/cold text sections (to be used by
    2244              :      debug info.)  */
    2245      1473125 :   if (crtl->has_bb_partition)
    2246              :     {
    2247        64342 :       section *save_text_section;
    2248              : 
    2249        64342 :       save_text_section = in_section;
    2250        64342 :       switch_to_section (unlikely_text_section ());
    2251              : #ifdef ASM_DECLARE_COLD_FUNCTION_SIZE
    2252        64342 :       if (cold_function_name != NULL_TREE)
    2253        64342 :         ASM_DECLARE_COLD_FUNCTION_SIZE (asm_out_file,
    2254              :                                         IDENTIFIER_POINTER (cold_function_name),
    2255              :                                         decl);
    2256              : #endif
    2257        64342 :       ASM_OUTPUT_LABEL (asm_out_file, crtl->subsections.cold_section_end_label);
    2258        64342 :       if (first_function_block_is_cold)
    2259            0 :         switch_to_section (text_section);
    2260              :       else
    2261        64342 :         switch_to_section (function_section (decl));
    2262        64342 :       ASM_OUTPUT_LABEL (asm_out_file, crtl->subsections.hot_section_end_label);
    2263        64342 :       switch_to_section (save_text_section);
    2264              :     }
    2265      1473125 : }
    2266              : 
    2267              : /* Assemble code to leave SIZE bytes of zeros.  */
    2268              : 
    2269              : void
    2270      1047252 : assemble_zeros (unsigned HOST_WIDE_INT size)
    2271              : {
    2272              :   /* Do no output if -fsyntax-only.  */
    2273      1047252 :   if (flag_syntax_only)
    2274              :     return;
    2275              : 
    2276              : #ifdef ASM_NO_SKIP_IN_TEXT
    2277              :   /* The `space' pseudo in the text section outputs nop insns rather than 0s,
    2278              :      so we must output 0s explicitly in the text section.  */
    2279      1047252 :   if (ASM_NO_SKIP_IN_TEXT && (in_section->common.flags & SECTION_CODE) != 0)
    2280              :     {
    2281              :       unsigned HOST_WIDE_INT i;
    2282            0 :       for (i = 0; i < size; i++)
    2283            0 :         assemble_integer (const0_rtx, 1, BITS_PER_UNIT, 1);
    2284              :     }
    2285              :   else
    2286              : #endif
    2287      1047252 :     if (size > 0)
    2288       975793 :       ASM_OUTPUT_SKIP (asm_out_file, size);
    2289              : }
    2290              : 
    2291              : /* Assemble an alignment pseudo op for an ALIGN-bit boundary.  */
    2292              : 
    2293              : void
    2294       384350 : assemble_align (unsigned int align)
    2295              : {
    2296       384350 :   if (align > BITS_PER_UNIT)
    2297              :     {
    2298       325420 :       ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
    2299              :     }
    2300       384350 : }
    2301              : 
    2302              : /* Assemble a string constant with the specified C string as contents.  */
    2303              : 
    2304              : void
    2305     32850738 : assemble_string (const char *p, int size)
    2306              : {
    2307     32850738 :   int pos = 0;
    2308              : #if defined(BASE64_ASM_OP) \
    2309              :     && BITS_PER_UNIT == 8 \
    2310              :     && CHAR_BIT == 8 \
    2311              :     && 'A' == 65 \
    2312              :     && 'a' == 97 \
    2313              :     && '0' == 48 \
    2314              :     && '+' == 43 \
    2315              :     && '/' == 47 \
    2316              :     && '=' == 61
    2317     32850738 :   int maximum = 16384;
    2318              : #else
    2319              :   int maximum = 2000;
    2320              : #endif
    2321              : 
    2322              :   /* If the string is very long, split it up.  */
    2323              : 
    2324     65698489 :   while (pos < size)
    2325              :     {
    2326     32847751 :       int thissize = size - pos;
    2327     32847751 :       if (thissize > maximum)
    2328              :         thissize = maximum;
    2329              : 
    2330     32847751 :       ASM_OUTPUT_ASCII (asm_out_file, p, thissize);
    2331              : 
    2332     32847751 :       pos += thissize;
    2333     32847751 :       p += thissize;
    2334              :     }
    2335     32850738 : }
    2336              : 
    2337              : 
    2338              : /* A noswitch_section_callback for lcomm_section.  */
    2339              : 
    2340              : static bool
    2341       156830 : emit_local (tree decl ATTRIBUTE_UNUSED,
    2342              :             const char *name ATTRIBUTE_UNUSED,
    2343              :             unsigned HOST_WIDE_INT size ATTRIBUTE_UNUSED,
    2344              :             unsigned HOST_WIDE_INT rounded ATTRIBUTE_UNUSED)
    2345              : {
    2346              : #if defined ASM_OUTPUT_ALIGNED_DECL_LOCAL
    2347       156830 :   unsigned int align = symtab_node::get (decl)->definition_alignment ();
    2348       156830 :   ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file, decl, name,
    2349              :                                  size, align);
    2350       156830 :   return true;
    2351              : #elif defined ASM_OUTPUT_ALIGNED_LOCAL
    2352              :   unsigned int align = symtab_node::get (decl)->definition_alignment ();
    2353              :   ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size, align);
    2354              :   return true;
    2355              : #else
    2356              :   ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
    2357              :   return false;
    2358              : #endif
    2359              : }
    2360              : 
    2361              : /* A noswitch_section_callback for bss_noswitch_section.  */
    2362              : 
    2363              : #if defined ASM_OUTPUT_ALIGNED_BSS
    2364              : static bool
    2365       766928 : emit_bss (tree decl ATTRIBUTE_UNUSED,
    2366              :           const char *name ATTRIBUTE_UNUSED,
    2367              :           unsigned HOST_WIDE_INT size ATTRIBUTE_UNUSED,
    2368              :           unsigned HOST_WIDE_INT rounded ATTRIBUTE_UNUSED)
    2369              : {
    2370       766928 :   ASM_OUTPUT_ALIGNED_BSS (asm_out_file, decl, name, size,
    2371              :                           get_variable_align (decl));
    2372       766928 :   return true;
    2373              : }
    2374              : #endif
    2375              : 
    2376              : /* A noswitch_section_callback for comm_section.  */
    2377              : 
    2378              : static bool
    2379         1285 : emit_common (tree decl ATTRIBUTE_UNUSED,
    2380              :              const char *name ATTRIBUTE_UNUSED,
    2381              :              unsigned HOST_WIDE_INT size ATTRIBUTE_UNUSED,
    2382              :              unsigned HOST_WIDE_INT rounded ATTRIBUTE_UNUSED)
    2383              : {
    2384              : #if defined ASM_OUTPUT_ALIGNED_DECL_COMMON
    2385         1285 :   ASM_OUTPUT_ALIGNED_DECL_COMMON (asm_out_file, decl, name,
    2386         1285 :                                   size, get_variable_align (decl));
    2387         1285 :   return true;
    2388              : #elif defined ASM_OUTPUT_ALIGNED_COMMON
    2389              :   ASM_OUTPUT_ALIGNED_COMMON (asm_out_file, name, size,
    2390              :                              get_variable_align (decl));
    2391              :   return true;
    2392              : #else
    2393              :   ASM_OUTPUT_COMMON (asm_out_file, name, size, rounded);
    2394              :   return false;
    2395              : #endif
    2396              : }
    2397              : 
    2398              : /* A noswitch_section_callback for tls_comm_section.  */
    2399              : 
    2400              : static bool
    2401           55 : emit_tls_common (tree decl ATTRIBUTE_UNUSED,
    2402              :                  const char *name ATTRIBUTE_UNUSED,
    2403              :                  unsigned HOST_WIDE_INT size ATTRIBUTE_UNUSED,
    2404              :                  unsigned HOST_WIDE_INT rounded ATTRIBUTE_UNUSED)
    2405              : {
    2406              : #ifdef ASM_OUTPUT_TLS_COMMON
    2407           55 :   ASM_OUTPUT_TLS_COMMON (asm_out_file, decl, name, size);
    2408           55 :   return true;
    2409              : #else
    2410              :   sorry ("thread-local COMMON data not implemented");
    2411              :   return true;
    2412              : #endif
    2413              : }
    2414              : 
    2415              : /* Assemble DECL given that it belongs in SECTION_NOSWITCH section SECT.
    2416              :    NAME is the name of DECL's SYMBOL_REF.  */
    2417              : 
    2418              : static void
    2419       925098 : assemble_noswitch_variable (tree decl, const char *name, section *sect,
    2420              :                             unsigned int align)
    2421              : {
    2422       925098 :   unsigned HOST_WIDE_INT size, rounded;
    2423              : 
    2424       925098 :   size = tree_to_uhwi (DECL_SIZE_UNIT (decl));
    2425       925098 :   rounded = size;
    2426              : 
    2427       925098 :   if ((flag_sanitize & SANITIZE_ADDRESS) && asan_protect_global (decl))
    2428         1902 :     size += asan_red_zone_size (size);
    2429              : 
    2430              :   /* Don't allocate zero bytes of common,
    2431              :      since that means "undefined external" in the linker.  */
    2432       925098 :   if (size == 0)
    2433         1582 :     rounded = 1;
    2434              : 
    2435              :   /* Round size up to multiple of BIGGEST_ALIGNMENT bits
    2436              :      so that each uninitialized object starts on such a boundary.  */
    2437       925098 :   rounded += (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1;
    2438       925098 :   rounded = (rounded / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
    2439       925098 :              * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
    2440              : 
    2441       925098 :   if (!sect->noswitch.callback (decl, name, size, rounded)
    2442       925098 :       && (unsigned HOST_WIDE_INT) (align / BITS_PER_UNIT) > rounded)
    2443            0 :     error ("requested alignment for %q+D is greater than "
    2444              :            "implemented alignment of %wu", decl, rounded);
    2445       925098 : }
    2446              : 
    2447              : /* A subroutine of assemble_variable.  Output the label and contents of
    2448              :    DECL, whose address is a SYMBOL_REF with name NAME.  DONT_OUTPUT_DATA
    2449              :    is as for assemble_variable.  */
    2450              : 
    2451              : static void
    2452      1899182 : assemble_variable_contents (tree decl, const char *name,
    2453              :                             bool dont_output_data, bool merge_strings)
    2454              : {
    2455              :   /* Do any machine/system dependent processing of the object.  */
    2456              : #ifdef ASM_DECLARE_OBJECT_NAME
    2457      1899182 :   last_assemble_variable_decl = decl;
    2458      1899182 :   ASM_DECLARE_OBJECT_NAME (asm_out_file, name, decl);
    2459              : #else
    2460              :   /* Standard thing is just output label for the object.  */
    2461              :   ASM_OUTPUT_LABEL (asm_out_file, name);
    2462              : #endif /* ASM_DECLARE_OBJECT_NAME */
    2463              : 
    2464      1899182 :   if (!dont_output_data)
    2465              :     {
    2466              :       /* Caller is supposed to use varpool_get_constructor when it wants
    2467              :          to output the body.  */
    2468      1898319 :       gcc_assert (!in_lto_p || DECL_INITIAL (decl) != error_mark_node);
    2469      1898319 :       if (DECL_INITIAL (decl)
    2470      1885935 :           && DECL_INITIAL (decl) != error_mark_node
    2471      3784252 :           && !initializer_zerop (DECL_INITIAL (decl)))
    2472              :         /* Output the actual data.  */
    2473      3607020 :         output_constant (DECL_INITIAL (decl),
    2474      1803510 :                          tree_to_uhwi (DECL_SIZE_UNIT (decl)),
    2475              :                          get_variable_align (decl),
    2476              :                          false, merge_strings);
    2477              :       else
    2478              :         /* Leave space for it.  */
    2479        94809 :         assemble_zeros (tree_to_uhwi (DECL_SIZE_UNIT (decl)));
    2480              :       /* For mergeable section, make sure the section is zero filled up to
    2481              :          the entity size of the section.  */
    2482      1898319 :       if (in_section
    2483      1898319 :           && (in_section->common.flags & SECTION_MERGE)
    2484          105 :           && tree_fits_uhwi_p (DECL_SIZE_UNIT (decl))
    2485      1898319 :           && ((in_section->common.flags & SECTION_ENTSIZE)
    2486          105 :               > tree_to_uhwi (DECL_SIZE_UNIT (decl))))
    2487              :         {
    2488           70 :           unsigned HOST_WIDE_INT entsize, declsize;
    2489           70 :           entsize = (in_section->common.flags & SECTION_ENTSIZE);
    2490           70 :           declsize = tree_to_uhwi (DECL_SIZE_UNIT (decl));
    2491           70 :           assemble_zeros (entsize - declsize);
    2492              :         }
    2493      1898319 :       targetm.asm_out.decl_end ();
    2494              :     }
    2495      1899182 : }
    2496              : 
    2497              : /* Write out assembly for the variable DECL, which is not defined in
    2498              :    the current translation unit.  */
    2499              : void
    2500       293849 : assemble_undefined_decl (tree decl)
    2501              : {
    2502       293849 :   const char *name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
    2503       293849 :   targetm.asm_out.assemble_undefined_decl (asm_out_file, name, decl);
    2504       293849 : }
    2505              : 
    2506              : /* Assemble everything that is needed for a variable or function declaration.
    2507              :    Not used for automatic variables, and not used for function definitions.
    2508              :    Should not be called for variables of incomplete structure type.
    2509              : 
    2510              :    TOP_LEVEL is nonzero if this variable has file scope.
    2511              :    AT_END is nonzero if this is the special handling, at end of compilation,
    2512              :    to define things that have had only tentative definitions.
    2513              :    DONT_OUTPUT_DATA if nonzero means don't actually output the
    2514              :    initial value (that will be done by the caller).  */
    2515              : 
    2516              : void
    2517      2828522 : assemble_variable (tree decl, int top_level ATTRIBUTE_UNUSED,
    2518              :                    int at_end ATTRIBUTE_UNUSED, int dont_output_data)
    2519              : {
    2520      2828522 :   const char *name;
    2521      2828522 :   rtx decl_rtl, symbol;
    2522      2828522 :   section *sect;
    2523      2828522 :   unsigned int align;
    2524      2828522 :   bool asan_protected = false;
    2525              : 
    2526              :   /* This function is supposed to handle VARIABLES.  Ensure we have one.  */
    2527      2828522 :   gcc_assert (VAR_P (decl));
    2528              : 
    2529              :   /* Emulated TLS had better not get this far.  */
    2530      2828522 :   gcc_checking_assert (targetm.have_tls || !DECL_THREAD_LOCAL_P (decl));
    2531              : 
    2532      2828522 :   last_assemble_variable_decl = 0;
    2533              : 
    2534              :   /* Normally no need to say anything here for external references,
    2535              :      since assemble_external is called by the language-specific code
    2536              :      when a declaration is first seen.  */
    2537              : 
    2538      2828522 :   if (DECL_EXTERNAL (decl))
    2539              :     return;
    2540              : 
    2541              :   /* Do nothing for global register variables.  */
    2542      2826164 :   if (DECL_RTL_SET_P (decl) && REG_P (DECL_RTL (decl)))
    2543              :     {
    2544            0 :       TREE_ASM_WRITTEN (decl) = 1;
    2545            0 :       return;
    2546              :     }
    2547              : 
    2548              :   /* If type was incomplete when the variable was declared,
    2549              :      see if it is complete now.  */
    2550              : 
    2551      2826164 :   if (DECL_SIZE (decl) == 0)
    2552            1 :     layout_decl (decl, 0);
    2553              : 
    2554              :   /* Still incomplete => don't allocate it; treat the tentative defn
    2555              :      (which is what it must have been) as an `extern' reference.  */
    2556              : 
    2557      2826164 :   if (!dont_output_data && DECL_SIZE (decl) == 0)
    2558              :     {
    2559            1 :       error ("storage size of %q+D isn%'t known", decl);
    2560            1 :       TREE_ASM_WRITTEN (decl) = 1;
    2561            1 :       return;
    2562              :     }
    2563              : 
    2564              :   /* The first declaration of a variable that comes through this function
    2565              :      decides whether it is global (in C, has external linkage)
    2566              :      or local (in C, has internal linkage).  So do nothing more
    2567              :      if this function has already run.  */
    2568              : 
    2569      2826163 :   if (TREE_ASM_WRITTEN (decl))
    2570              :     return;
    2571              : 
    2572              :   /* Make sure targetm.encode_section_info is invoked before we set
    2573              :      ASM_WRITTEN.  */
    2574      2826163 :   decl_rtl = DECL_RTL (decl);
    2575              : 
    2576      2826163 :   TREE_ASM_WRITTEN (decl) = 1;
    2577              : 
    2578              :   /* Do no output if -fsyntax-only.  */
    2579      2826163 :   if (flag_syntax_only)
    2580              :     return;
    2581              : 
    2582      2826163 :   if (! dont_output_data
    2583      2826163 :       && ! valid_constant_size_p (DECL_SIZE_UNIT (decl)))
    2584              :     {
    2585            2 :       error ("size of variable %q+D is too large", decl);
    2586            2 :       return;
    2587              :     }
    2588              : 
    2589      2826161 :   gcc_assert (MEM_P (decl_rtl));
    2590      2826161 :   gcc_assert (GET_CODE (XEXP (decl_rtl, 0)) == SYMBOL_REF);
    2591      2826161 :   symbol = XEXP (decl_rtl, 0);
    2592              : 
    2593              :   /* If this symbol belongs to the tree constant pool, output the constant
    2594              :      if it hasn't already been written.  */
    2595      2826161 :   if (TREE_CONSTANT_POOL_ADDRESS_P (symbol))
    2596              :     {
    2597         1881 :       tree decl = SYMBOL_REF_DECL (symbol);
    2598         1881 :       if (!TREE_ASM_WRITTEN (DECL_INITIAL (decl)))
    2599         1199 :         output_constant_def_contents (symbol);
    2600         1881 :       return;
    2601              :     }
    2602              : 
    2603      2824280 :   app_disable ();
    2604              : 
    2605      2824280 :   name = XSTR (symbol, 0);
    2606      2824280 :   if (TREE_PUBLIC (decl) && DECL_NAME (decl))
    2607      1407703 :     notice_global_symbol (decl);
    2608              : 
    2609              :   /* Compute the alignment of this data.  */
    2610              : 
    2611      2824280 :   align_variable (decl, dont_output_data);
    2612              : 
    2613      2824280 :   if ((flag_sanitize & SANITIZE_ADDRESS)
    2614      2824280 :       && asan_protect_global (decl))
    2615              :     {
    2616         2284 :       asan_protected = true;
    2617         2284 :       SET_DECL_ALIGN (decl, MAX (DECL_ALIGN (decl),
    2618              :                                  ASAN_RED_ZONE_SIZE * BITS_PER_UNIT));
    2619              :     }
    2620              : 
    2621      2824280 :   set_mem_align (decl_rtl, DECL_ALIGN (decl));
    2622              : 
    2623      2824280 :   align = get_variable_align (decl);
    2624              : 
    2625      2824280 :   if (TREE_PUBLIC (decl))
    2626      1408146 :     maybe_assemble_visibility (decl);
    2627              : 
    2628      2824280 :   if (DECL_PRESERVE_P (decl))
    2629          968 :     targetm.asm_out.mark_decl_preserved (name);
    2630              : 
    2631              :   /* First make the assembler name(s) global if appropriate.  */
    2632      2824280 :   sect = get_variable_section (decl, false);
    2633      2824280 :   if (TREE_PUBLIC (decl)
    2634      1408146 :       && (sect->common.flags & SECTION_COMMON) == 0)
    2635      1406806 :     globalize_decl (decl);
    2636              : 
    2637              :   /* Output any data that we will need to use the address of.  */
    2638      2824280 :   if (DECL_INITIAL (decl) && DECL_INITIAL (decl) != error_mark_node)
    2639      1907471 :     output_addressed_constants (DECL_INITIAL (decl), 0);
    2640              : 
    2641              :   /* dbxout.cc needs to know this.  */
    2642      2824280 :   if (sect && (sect->common.flags & SECTION_CODE) != 0)
    2643            0 :     DECL_IN_TEXT_SECTION (decl) = 1;
    2644              : 
    2645              :   /* If the decl is part of an object_block, make sure that the decl
    2646              :      has been positioned within its block, but do not write out its
    2647              :      definition yet.  output_object_blocks will do that later.  */
    2648      2824280 :   if (SYMBOL_REF_HAS_BLOCK_INFO_P (symbol) && SYMBOL_REF_BLOCK (symbol))
    2649              :     {
    2650            0 :       gcc_assert (!dont_output_data);
    2651            0 :       place_block_symbol (symbol);
    2652              :     }
    2653      2824280 :   else if (SECTION_STYLE (sect) == SECTION_NOSWITCH)
    2654       925098 :     assemble_noswitch_variable (decl, name, sect, align);
    2655              :   else
    2656              :     {
    2657              :       /* Special-case handling of vtv comdat sections.  */
    2658      1899182 :       if (SECTION_STYLE (sect) == SECTION_NAMED
    2659      1523608 :           && (strcmp (sect->named.name, ".vtable_map_vars") == 0))
    2660            3 :         handle_vtv_comdat_section (sect, decl);
    2661              :       else
    2662      1899179 :         switch_to_section (sect, decl);
    2663      1899182 :       if (align > BITS_PER_UNIT)
    2664      1814319 :         ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
    2665      1899182 :       assemble_variable_contents (decl, name, dont_output_data,
    2666      1899182 :                                   (sect->common.flags & SECTION_MERGE)
    2667      1899182 :                                   && (sect->common.flags & SECTION_STRINGS));
    2668      1899182 :       if (asan_protected)
    2669              :         {
    2670         1282 :           unsigned HOST_WIDE_INT int size
    2671         1282 :             = tree_to_uhwi (DECL_SIZE_UNIT (decl));
    2672         2428 :           assemble_zeros (asan_red_zone_size (size));
    2673              :         }
    2674              :     }
    2675              : }
    2676              : 
    2677              : /* Return true if type TYPE contains any pointers.  */
    2678              : 
    2679              : static bool
    2680            2 : contains_pointers_p (tree type)
    2681              : {
    2682            2 :   switch (TREE_CODE (type))
    2683              :     {
    2684              :     case POINTER_TYPE:
    2685              :     case REFERENCE_TYPE:
    2686              :       /* I'm not sure whether OFFSET_TYPE needs this treatment,
    2687              :          so I'll play safe and return 1.  */
    2688              :     case OFFSET_TYPE:
    2689              :       return true;
    2690              : 
    2691            0 :     case RECORD_TYPE:
    2692            0 :     case UNION_TYPE:
    2693            0 :     case QUAL_UNION_TYPE:
    2694            0 :       {
    2695            0 :         tree fields;
    2696              :         /* For a type that has fields, see if the fields have pointers.  */
    2697            0 :         for (fields = TYPE_FIELDS (type); fields; fields = DECL_CHAIN (fields))
    2698            0 :           if (TREE_CODE (fields) == FIELD_DECL
    2699            0 :               && contains_pointers_p (TREE_TYPE (fields)))
    2700              :             return true;
    2701              :         return false;
    2702              :       }
    2703              : 
    2704            0 :     case ARRAY_TYPE:
    2705              :       /* An array type contains pointers if its element type does.  */
    2706            0 :       return contains_pointers_p (TREE_TYPE (type));
    2707              : 
    2708              :     default:
    2709              :       return false;
    2710              :     }
    2711              : }
    2712              : 
    2713              : /* We delay assemble_external processing until
    2714              :    the compilation unit is finalized.  This is the best we can do for
    2715              :    right now (i.e. stage 3 of GCC 4.0) - the right thing is to delay
    2716              :    it all the way to final.  See PR 17982 for further discussion.  */
    2717              : static GTY(()) tree pending_assemble_externals;
    2718              : 
    2719              : /* A similar list of pending libcall symbols.  We only want to declare
    2720              :    symbols that are actually used in the final assembly.  */
    2721              : static GTY(()) rtx pending_libcall_symbols;
    2722              : 
    2723              : #ifdef ASM_OUTPUT_EXTERNAL
    2724              : /* Some targets delay some output to final using TARGET_ASM_FILE_END.
    2725              :    As a result, assemble_external can be called after the list of externals
    2726              :    is processed and the pointer set destroyed.  */
    2727              : static bool pending_assemble_externals_processed;
    2728              : 
    2729              : /* Avoid O(external_decls**2) lookups in the pending_assemble_externals
    2730              :    TREE_LIST in assemble_external.  */
    2731              : static hash_set<tree> *pending_assemble_externals_set;
    2732              : 
    2733              : /* True if DECL is a function decl for which no out-of-line copy exists.
    2734              :    It is assumed that DECL's assembler name has been set.  */
    2735              : 
    2736              : static bool
    2737      1800691 : incorporeal_function_p (tree decl)
    2738              : {
    2739      1800691 :   if (TREE_CODE (decl) == FUNCTION_DECL && fndecl_built_in_p (decl))
    2740              :     {
    2741       197863 :       const char *name;
    2742              : 
    2743       197863 :       if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL
    2744       197863 :           && ALLOCA_FUNCTION_CODE_P (DECL_FUNCTION_CODE (decl)))
    2745              :         return true;
    2746              : 
    2747       197858 :       name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
    2748              :       /* Atomic or sync builtins which have survived this far will be
    2749              :          resolved externally and therefore are not incorporeal.  */
    2750       197858 :       if (startswith (name, "__builtin_"))
    2751              :         return true;
    2752              :     }
    2753              :   return false;
    2754              : }
    2755              : 
    2756              : /* Actually do the tests to determine if this is necessary, and invoke
    2757              :    ASM_OUTPUT_EXTERNAL.  */
    2758              : static void
    2759      1812129 : assemble_external_real (tree decl)
    2760              : {
    2761      1812129 :   rtx rtl = DECL_RTL (decl);
    2762              : 
    2763      1812129 :   if (MEM_P (rtl) && GET_CODE (XEXP (rtl, 0)) == SYMBOL_REF
    2764      1812129 :       && !SYMBOL_REF_USED (XEXP (rtl, 0))
    2765      3612820 :       && !incorporeal_function_p (decl))
    2766              :     {
    2767              :       /* Some systems do require some output.  */
    2768      1800686 :       SYMBOL_REF_USED (XEXP (rtl, 0)) = 1;
    2769      1800686 :       ASM_OUTPUT_EXTERNAL (asm_out_file, decl, XSTR (XEXP (rtl, 0), 0));
    2770              :     }
    2771      1812129 : }
    2772              : #endif
    2773              : 
    2774              : void
    2775       230133 : process_pending_assemble_externals (void)
    2776              : {
    2777              : #ifdef ASM_OUTPUT_EXTERNAL
    2778       230133 :   tree list;
    2779      2042262 :   for (list = pending_assemble_externals; list; list = TREE_CHAIN (list))
    2780      1812129 :     assemble_external_real (TREE_VALUE (list));
    2781              : 
    2782       256805 :   for (rtx list = pending_libcall_symbols; list; list = XEXP (list, 1))
    2783              :     {
    2784        26672 :       rtx symbol = XEXP (list, 0);
    2785        26672 :       const char *name = targetm.strip_name_encoding (XSTR (symbol, 0));
    2786        26672 :       tree id = get_identifier (name);
    2787        26672 :       if (TREE_SYMBOL_REFERENCED (id))
    2788        26605 :         targetm.asm_out.external_libcall (symbol);
    2789              :     }
    2790              : 
    2791       230133 :   pending_assemble_externals = 0;
    2792       230133 :   pending_assemble_externals_processed = true;
    2793       230133 :   pending_libcall_symbols = NULL_RTX;
    2794       460266 :   delete pending_assemble_externals_set;
    2795       230133 :   pending_assemble_externals_set = nullptr;
    2796              : #endif
    2797       230133 : }
    2798              : 
    2799              : /* This TREE_LIST contains any weak symbol declarations waiting
    2800              :    to be emitted.  */
    2801              : static GTY(()) tree weak_decls;
    2802              : 
    2803              : /* Output something to declare an external symbol to the assembler,
    2804              :    and qualifiers such as weakness.  (Most assemblers don't need
    2805              :    extern declaration, so we normally output nothing.)  Do nothing if
    2806              :    DECL is not external.  */
    2807              : 
    2808              : void
    2809     40775480 : assemble_external (tree decl ATTRIBUTE_UNUSED)
    2810              : {
    2811              :   /*  Make sure that the ASM_OUT_FILE is open.
    2812              :       If it's not, we should not be calling this function.  */
    2813     40775480 :   gcc_assert (asm_out_file);
    2814              : 
    2815              :   /* In a perfect world, the following condition would be true.
    2816              :      Sadly, the Go front end emit assembly *from the front end*,
    2817              :      bypassing the call graph.  See PR52739.  Fix before GCC 4.8.  */
    2818              : #if 0
    2819              :   /* This function should only be called if we are expanding, or have
    2820              :      expanded, to RTL.
    2821              :      Ideally, only final.cc would be calling this function, but it is
    2822              :      not clear whether that would break things somehow.  See PR 17982
    2823              :      for further discussion.  */
    2824              :   gcc_assert (state == EXPANSION
    2825              :               || state == FINISHED);
    2826              : #endif
    2827              : 
    2828     40775480 :   if (!DECL_P (decl) || !DECL_EXTERNAL (decl) || !TREE_PUBLIC (decl))
    2829              :     return;
    2830              : 
    2831              :   /* We want to output annotation for weak and external symbols at
    2832              :      very last to check if they are references or not.  */
    2833              : 
    2834     17589571 :   if (TARGET_SUPPORTS_WEAK
    2835     17589571 :       && DECL_WEAK (decl)
    2836              :       /* TREE_STATIC is a weird and abused creature which is not
    2837              :          generally the right test for whether an entity has been
    2838              :          locally emitted, inlined or otherwise not-really-extern, but
    2839              :          for declarations that can be weak, it happens to be
    2840              :          match.  */
    2841        11591 :       && !TREE_STATIC (decl)
    2842         5642 :       && lookup_attribute ("weak", DECL_ATTRIBUTES (decl))
    2843     17594750 :       && value_member (decl, weak_decls) == NULL_TREE)
    2844         1005 :     weak_decls = tree_cons (NULL, decl, weak_decls);
    2845              : 
    2846              : #ifdef ASM_OUTPUT_EXTERNAL
    2847     17589571 :   if (pending_assemble_externals_processed)
    2848              :     {
    2849            0 :       assemble_external_real (decl);
    2850            0 :       return;
    2851              :     }
    2852              : 
    2853     17589571 :   if (! pending_assemble_externals_set->add (decl))
    2854      1812175 :     pending_assemble_externals = tree_cons (NULL, decl,
    2855              :                                             pending_assemble_externals);
    2856              : #endif
    2857              : }
    2858              : 
    2859              : /* Similar, for calling a library function FUN.  */
    2860              : 
    2861              : void
    2862       193390 : assemble_external_libcall (rtx fun)
    2863              : {
    2864              :   /* Declare library function name external when first used, if nec.  */
    2865       193390 :   if (! SYMBOL_REF_USED (fun))
    2866              :     {
    2867              : #ifdef ASM_OUTPUT_EXTERNAL
    2868        26685 :       gcc_assert (!pending_assemble_externals_processed);
    2869              : #endif
    2870        26685 :       SYMBOL_REF_USED (fun) = 1;
    2871              :       /* Make sure the libcall symbol is in the symtab so any
    2872              :          reference to it will mark its tree node as referenced, via
    2873              :          assemble_name_resolve.  These are eventually emitted, if
    2874              :          used, in process_pending_assemble_externals. */
    2875        26685 :       const char *name = targetm.strip_name_encoding (XSTR (fun, 0));
    2876        26685 :       get_identifier (name);
    2877        26685 :       pending_libcall_symbols = gen_rtx_EXPR_LIST (VOIDmode, fun,
    2878              :                                                    pending_libcall_symbols);
    2879              :     }
    2880       193390 : }
    2881              : 
    2882              : /* Assemble a label named NAME.  */
    2883              : 
    2884              : void
    2885      1263576 : assemble_label (FILE *file, const char *name)
    2886              : {
    2887      1263576 :   ASM_OUTPUT_LABEL (file, name);
    2888      1263576 : }
    2889              : 
    2890              : /* Set the symbol_referenced flag for ID.  */
    2891              : void
    2892     34573119 : mark_referenced (tree id)
    2893              : {
    2894     34573119 :   TREE_SYMBOL_REFERENCED (id) = 1;
    2895     34573119 : }
    2896              : 
    2897              : /* Set the symbol_referenced flag for DECL and notify callgraph.  */
    2898              : void
    2899         5870 : mark_decl_referenced (tree decl)
    2900              : {
    2901         5870 :   if (TREE_CODE (decl) == FUNCTION_DECL)
    2902              :     {
    2903              :       /* Extern inline functions don't become needed when referenced.
    2904              :          If we know a method will be emitted in other TU and no new
    2905              :          functions can be marked reachable, just use the external
    2906              :          definition.  */
    2907         5868 :       struct cgraph_node *node = cgraph_node::get_create (decl);
    2908         5868 :       if (!DECL_EXTERNAL (decl)
    2909         5868 :           && !node->definition)
    2910           12 :         node->mark_force_output ();
    2911              :     }
    2912            2 :   else if (VAR_P (decl))
    2913              :     {
    2914            2 :       varpool_node *node = varpool_node::get_create (decl);
    2915              :       /* C++ frontend use mark_decl_references to force COMDAT variables
    2916              :          to be output that might appear dead otherwise.  */
    2917            2 :       node->force_output = true;
    2918              :     }
    2919              :   /* else do nothing - we can get various sorts of CST nodes here,
    2920              :      which do not need to be marked.  */
    2921         5870 : }
    2922              : 
    2923              : 
    2924              : /* Output to FILE (an assembly file) a reference to NAME.  If NAME
    2925              :    starts with a *, the rest of NAME is output verbatim.  Otherwise
    2926              :    NAME is transformed in a target-specific way (usually by the
    2927              :    addition of an underscore).  */
    2928              : 
    2929              : void
    2930    466304568 : assemble_name_raw (FILE *file, const char *name)
    2931              : {
    2932    466304568 :   if (name[0] == '*')
    2933    431390093 :     fputs (&name[1], file);
    2934              :   else
    2935     34914475 :     ASM_OUTPUT_LABELREF (file, name);
    2936    466304568 : }
    2937              : 
    2938              : /* Return NAME that should actually be emitted, looking through
    2939              :    transparent aliases.  If NAME refers to an entity that is also
    2940              :    represented as a tree (like a function or variable), mark the entity
    2941              :    as referenced.  */
    2942              : const char *
    2943    393028091 : assemble_name_resolve (const char *name)
    2944              : {
    2945    393028091 :   const char *real_name = targetm.strip_name_encoding (name);
    2946    393028091 :   tree id = maybe_get_identifier (real_name);
    2947              : 
    2948    393028091 :   if (id)
    2949              :     {
    2950     34573119 :       tree id_orig = id;
    2951              : 
    2952     34573119 :       mark_referenced (id);
    2953     34573119 :       ultimate_transparent_alias_target (&id);
    2954     34573119 :       if (id != id_orig)
    2955            0 :         name = IDENTIFIER_POINTER (id);
    2956     34573119 :       gcc_assert (!IDENTIFIER_TRANSPARENT_ALIAS (id));
    2957              :     }
    2958              : 
    2959    393028091 :   return name;
    2960              : }
    2961              : 
    2962              : /* Like assemble_name_raw, but should be used when NAME might refer to
    2963              :    an entity that is also represented as a tree (like a function or
    2964              :    variable).  If NAME does refer to such an entity, that entity will
    2965              :    be marked as referenced.  */
    2966              : 
    2967              : void
    2968    270883014 : assemble_name (FILE *file, const char *name)
    2969              : {
    2970    270883014 :   assemble_name_raw (file, assemble_name_resolve (name));
    2971    270883014 : }
    2972              : 
    2973              : /* Allocate SIZE bytes writable static space with a gensym name
    2974              :    and return an RTX to refer to its address.  */
    2975              : 
    2976              : rtx
    2977            0 : assemble_static_space (unsigned HOST_WIDE_INT size)
    2978              : {
    2979            0 :   char name[17];
    2980            0 :   const char *namestring;
    2981            0 :   rtx x;
    2982              : 
    2983            0 :   ASM_GENERATE_INTERNAL_LABEL (name, "LF", const_labelno);
    2984            0 :   ++const_labelno;
    2985            0 :   namestring = ggc_strdup (name);
    2986              : 
    2987            0 :   x = gen_rtx_SYMBOL_REF (Pmode, namestring);
    2988            0 :   SYMBOL_REF_FLAGS (x) = SYMBOL_FLAG_LOCAL;
    2989              : 
    2990              : #ifdef ASM_OUTPUT_ALIGNED_DECL_LOCAL
    2991            0 :   ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file, NULL_TREE, name, size,
    2992              :                                  BIGGEST_ALIGNMENT);
    2993              : #else
    2994              : #ifdef ASM_OUTPUT_ALIGNED_LOCAL
    2995              :   ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size, BIGGEST_ALIGNMENT);
    2996              : #else
    2997              :   {
    2998              :     /* Round size up to multiple of BIGGEST_ALIGNMENT bits
    2999              :        so that each uninitialized object starts on such a boundary.  */
    3000              :     /* Variable `rounded' might or might not be used in ASM_OUTPUT_LOCAL.  */
    3001              :     unsigned HOST_WIDE_INT rounded ATTRIBUTE_UNUSED
    3002              :       = ((size + (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1)
    3003              :          / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
    3004              :          * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
    3005              :     ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
    3006              :   }
    3007              : #endif
    3008              : #endif
    3009            0 :   return x;
    3010              : }
    3011              : 
    3012              : /* Assemble the static constant template for function entry trampolines.
    3013              :    This is done at most once per compilation.
    3014              :    Returns an RTX for the address of the template.  */
    3015              : 
    3016              : static GTY(()) rtx initial_trampoline;
    3017              : 
    3018              : rtx
    3019            0 : assemble_trampoline_template (void)
    3020              : {
    3021            0 :   char label[256];
    3022            0 :   const char *name;
    3023            0 :   int align;
    3024            0 :   rtx symbol;
    3025              : 
    3026            0 :   gcc_assert (targetm.asm_out.trampoline_template != NULL);
    3027              : 
    3028            0 :   if (initial_trampoline)
    3029              :     return initial_trampoline;
    3030              : 
    3031              :   /* By default, put trampoline templates in read-only data section.  */
    3032              : 
    3033              : #ifdef TRAMPOLINE_SECTION
    3034              :   switch_to_section (TRAMPOLINE_SECTION);
    3035              : #else
    3036            0 :   switch_to_section (readonly_data_section);
    3037              : #endif
    3038              : 
    3039              :   /* Write the assembler code to define one.  */
    3040            0 :   align = floor_log2 (TRAMPOLINE_ALIGNMENT / BITS_PER_UNIT);
    3041            0 :   if (align > 0)
    3042            0 :     ASM_OUTPUT_ALIGN (asm_out_file, align);
    3043              : 
    3044            0 :   targetm.asm_out.internal_label (asm_out_file, "LTRAMP", 0);
    3045            0 :   targetm.asm_out.trampoline_template (asm_out_file);
    3046              : 
    3047              :   /* Record the rtl to refer to it.  */
    3048            0 :   ASM_GENERATE_INTERNAL_LABEL (label, "LTRAMP", 0);
    3049            0 :   name = ggc_strdup (label);
    3050            0 :   symbol = gen_rtx_SYMBOL_REF (Pmode, name);
    3051            0 :   SYMBOL_REF_FLAGS (symbol) = SYMBOL_FLAG_LOCAL;
    3052              : 
    3053            0 :   initial_trampoline = gen_const_mem (BLKmode, symbol);
    3054            0 :   set_mem_align (initial_trampoline, TRAMPOLINE_ALIGNMENT);
    3055            0 :   set_mem_size (initial_trampoline, TRAMPOLINE_SIZE);
    3056              : 
    3057            0 :   return initial_trampoline;
    3058              : }
    3059              : 
    3060              : /* A and B are either alignments or offsets.  Return the minimum alignment
    3061              :    that may be assumed after adding the two together.  */
    3062              : 
    3063              : static inline unsigned
    3064     15132789 : min_align (unsigned int a, unsigned int b)
    3065              : {
    3066     15132789 :   return least_bit_hwi (a | b);
    3067              : }
    3068              : 
    3069              : /* Return the assembler directive for creating a given kind of integer
    3070              :    object.  SIZE is the number of bytes in the object and ALIGNED_P
    3071              :    indicates whether it is known to be aligned.  Return NULL if the
    3072              :    assembly dialect has no such directive.
    3073              : 
    3074              :    The returned string should be printed at the start of a new line and
    3075              :    be followed immediately by the object's initial value.  */
    3076              : 
    3077              : const char *
    3078    445434875 : integer_asm_op (int size, int aligned_p)
    3079              : {
    3080    445434875 :   struct asm_int_op *ops;
    3081              : 
    3082    445434875 :   if (aligned_p)
    3083              :     ops = &targetm.asm_out.aligned_op;
    3084              :   else
    3085    431100608 :     ops = &targetm.asm_out.unaligned_op;
    3086              : 
    3087    445434875 :   switch (size)
    3088              :     {
    3089    228071827 :     case 1:
    3090    228071827 :       return targetm.asm_out.byte_op;
    3091     22503304 :     case 2:
    3092     22503304 :       return ops->hi;
    3093            0 :     case 3:
    3094            0 :       return ops->psi;
    3095    157310236 :     case 4:
    3096    157310236 :       return ops->si;
    3097            0 :     case 5:
    3098            0 :     case 6:
    3099            0 :     case 7:
    3100            0 :       return ops->pdi;
    3101     37522497 :     case 8:
    3102     37522497 :       return ops->di;
    3103            0 :     case 9:
    3104            0 :     case 10:
    3105            0 :     case 11:
    3106            0 :     case 12:
    3107            0 :     case 13:
    3108            0 :     case 14:
    3109            0 :     case 15:
    3110            0 :       return ops->pti;
    3111        26372 :     case 16:
    3112        26372 :       return ops->ti;
    3113              :     default:
    3114              :       return NULL;
    3115              :     }
    3116              : }
    3117              : 
    3118              : /* Use directive OP to assemble an integer object X.  Print OP at the
    3119              :    start of the line, followed immediately by the value of X.  */
    3120              : 
    3121              : void
    3122     14063332 : assemble_integer_with_op (const char *op, rtx x)
    3123              : {
    3124     14063332 :   fputs (op, asm_out_file);
    3125     14063332 :   output_addr_const (asm_out_file, x);
    3126     14063332 :   fputc ('\n', asm_out_file);
    3127     14063332 : }
    3128              : 
    3129              : /* The default implementation of the asm_out.integer target hook.  */
    3130              : 
    3131              : bool
    3132     14362098 : default_assemble_integer (rtx x ATTRIBUTE_UNUSED,
    3133              :                           unsigned int size ATTRIBUTE_UNUSED,
    3134              :                           int aligned_p ATTRIBUTE_UNUSED)
    3135              : {
    3136     14362098 :   const char *op = integer_asm_op (size, aligned_p);
    3137              :   /* Avoid GAS bugs for large values.  Specifically negative values whose
    3138              :      absolute value fits in a bfd_vma, but not in a bfd_signed_vma.  */
    3139     19334567 :   if (size > UNITS_PER_WORD && size > POINTER_SIZE_UNITS)
    3140              :     return false;
    3141     14063332 :   return op && (assemble_integer_with_op (op, x), true);
    3142              : }
    3143              : 
    3144              : /* Assemble the integer constant X into an object of SIZE bytes.  ALIGN is
    3145              :    the alignment of the integer in bits.  Return 1 if we were able to output
    3146              :    the constant, otherwise 0.  We must be able to output the constant,
    3147              :    if FORCE is nonzero.  */
    3148              : 
    3149              : bool
    3150     14362098 : assemble_integer (rtx x, unsigned int size, unsigned int align, int force)
    3151              : {
    3152     14362098 :   int aligned_p;
    3153              : 
    3154     14362098 :   aligned_p = (align >= MIN (size * BITS_PER_UNIT, BIGGEST_ALIGNMENT));
    3155              : 
    3156              :   /* See if the target hook can handle this kind of object.  */
    3157     14362098 :   if (targetm.asm_out.integer (x, size, aligned_p))
    3158              :     return true;
    3159              : 
    3160              :   /* If the object is a multi-byte one, try splitting it up.  Split
    3161              :      it into words it if is multi-word, otherwise split it into bytes.  */
    3162       298766 :   if (size > 1)
    3163              :     {
    3164       298766 :       machine_mode omode, imode;
    3165       298766 :       unsigned int subalign;
    3166       298766 :       unsigned int subsize, i;
    3167       298766 :       enum mode_class mclass;
    3168              : 
    3169       573739 :       subsize = size > UNITS_PER_WORD? UNITS_PER_WORD : 1;
    3170       298766 :       subalign = MIN (align, subsize * BITS_PER_UNIT);
    3171       298766 :       if (GET_CODE (x) == CONST_FIXED)
    3172            0 :         mclass = GET_MODE_CLASS (GET_MODE (x));
    3173              :       else
    3174              :         mclass = MODE_INT;
    3175              : 
    3176       298766 :       omode = mode_for_size (subsize * BITS_PER_UNIT, mclass, 0).require ();
    3177       298766 :       imode = mode_for_size (size * BITS_PER_UNIT, mclass, 0).require ();
    3178              : 
    3179       900036 :       for (i = 0; i < size; i += subsize)
    3180              :         {
    3181       601270 :           rtx partial = simplify_subreg (omode, x, imode, i);
    3182       601270 :           if (!partial || !assemble_integer (partial, subsize, subalign, 0))
    3183              :             break;
    3184              :         }
    3185       298766 :       if (i == size)
    3186     14362098 :         return true;
    3187              : 
    3188              :       /* If we've printed some of it, but not all of it, there's no going
    3189              :          back now.  */
    3190            0 :       gcc_assert (!i);
    3191              :     }
    3192              : 
    3193            0 :   gcc_assert (!force);
    3194              : 
    3195              :   return false;
    3196              : }
    3197              : 
    3198              : /* Assemble the floating-point constant D into an object of size MODE.  ALIGN
    3199              :    is the alignment of the constant in bits.  If REVERSE is true, D is output
    3200              :    in reverse storage order.  */
    3201              : 
    3202              : void
    3203       799810 : assemble_real (REAL_VALUE_TYPE d, scalar_float_mode mode, unsigned int align,
    3204              :                bool reverse)
    3205              : {
    3206       799810 :   long data[4] = {0, 0, 0, 0};
    3207       799810 :   int bitsize, nelts, nunits, units_per;
    3208       799810 :   rtx elt;
    3209              : 
    3210              :   /* This is hairy.  We have a quantity of known size.  real_to_target
    3211              :      will put it into an array of *host* longs, 32 bits per element
    3212              :      (even if long is more than 32 bits).  We need to determine the
    3213              :      number of array elements that are occupied (nelts) and the number
    3214              :      of *target* min-addressable units that will be occupied in the
    3215              :      object file (nunits).  We cannot assume that 32 divides the
    3216              :      mode's bitsize (size * BITS_PER_UNIT) evenly.
    3217              : 
    3218              :      size * BITS_PER_UNIT is used here to make sure that padding bits
    3219              :      (which might appear at either end of the value; real_to_target
    3220              :      will include the padding bits in its output array) are included.  */
    3221              : 
    3222       799810 :   nunits = GET_MODE_SIZE (mode);
    3223       799810 :   bitsize = nunits * BITS_PER_UNIT;
    3224       799810 :   nelts = CEIL (bitsize, 32);
    3225       799810 :   units_per = 32 / BITS_PER_UNIT;
    3226              : 
    3227       799810 :   real_to_target (data, &d, mode);
    3228              : 
    3229              :   /* Put out the first word with the specified alignment.  */
    3230       799810 :   unsigned int chunk_nunits = MIN (nunits, units_per);
    3231       799810 :   if (reverse)
    3232           72 :     elt = flip_storage_order (SImode, gen_int_mode (data[nelts - 1], SImode));
    3233              :   else
    3234       799738 :     elt = GEN_INT (sext_hwi (data[0], chunk_nunits * BITS_PER_UNIT));
    3235       799810 :   assemble_integer (elt, chunk_nunits, align, 1);
    3236       799810 :   nunits -= chunk_nunits;
    3237              : 
    3238              :   /* Subsequent words need only 32-bit alignment.  */
    3239       799810 :   align = min_align (align, 32);
    3240              : 
    3241      1207915 :   for (int i = 1; i < nelts; i++)
    3242              :     {
    3243       408105 :       chunk_nunits = MIN (nunits, units_per);
    3244       408105 :       if (reverse)
    3245           18 :         elt = flip_storage_order (SImode,
    3246           18 :                                   gen_int_mode (data[nelts - 1 - i], SImode));
    3247              :       else
    3248       408087 :         elt = GEN_INT (sext_hwi (data[i], chunk_nunits * BITS_PER_UNIT));
    3249       408105 :       assemble_integer (elt, chunk_nunits, align, 1);
    3250       408105 :       nunits -= chunk_nunits;
    3251              :     }
    3252       799810 : }
    3253              : 
    3254              : /* Given an expression EXP with a constant value,
    3255              :    reduce it to the sum of an assembler symbol and an integer.
    3256              :    Store them both in the structure *VALUE.
    3257              :    EXP must be reducible.  */
    3258              : 
    3259              : class addr_const {
    3260              : public:
    3261              :   rtx base;
    3262              :   poly_int64 offset;
    3263              : };
    3264              : 
    3265              : static void
    3266        28006 : decode_addr_const (tree exp, class addr_const *value)
    3267              : {
    3268        28006 :   tree target = TREE_OPERAND (exp, 0);
    3269        28006 :   poly_int64 offset = 0;
    3270        28458 :   rtx x;
    3271              : 
    3272        28910 :   while (1)
    3273              :     {
    3274        28458 :       poly_int64 bytepos;
    3275        28458 :       if (TREE_CODE (target) == COMPONENT_REF
    3276        28458 :           && poly_int_tree_p (byte_position (TREE_OPERAND (target, 1)),
    3277              :                               &bytepos))
    3278              :         {
    3279          438 :           offset += bytepos;
    3280          438 :           target = TREE_OPERAND (target, 0);
    3281              :         }
    3282        28020 :       else if (TREE_CODE (target) == ARRAY_REF
    3283        28020 :                || TREE_CODE (target) == ARRAY_RANGE_REF)
    3284              :         {
    3285              :           /* Truncate big offset.  */
    3286           14 :           offset
    3287           14 :             += (TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (target)))
    3288           28 :                 * wi::to_poly_widest (TREE_OPERAND (target, 1)).force_shwi ());
    3289           14 :           target = TREE_OPERAND (target, 0);
    3290              :         }
    3291        28006 :       else if (TREE_CODE (target) == MEM_REF
    3292        28006 :                && TREE_CODE (TREE_OPERAND (target, 0)) == ADDR_EXPR)
    3293              :         {
    3294            0 :           offset += mem_ref_offset (target).force_shwi ();
    3295            0 :           target = TREE_OPERAND (TREE_OPERAND (target, 0), 0);
    3296              :         }
    3297        28006 :       else if (INDIRECT_REF_P (target)
    3298            0 :                && TREE_CODE (TREE_OPERAND (target, 0)) == NOP_EXPR
    3299        28006 :                && TREE_CODE (TREE_OPERAND (TREE_OPERAND (target, 0), 0))
    3300              :                   == ADDR_EXPR)
    3301            0 :         target = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (target, 0), 0), 0);
    3302              :       else
    3303              :         break;
    3304          452 :     }
    3305              : 
    3306        28006 :   switch (TREE_CODE (target))
    3307              :     {
    3308        27904 :     case VAR_DECL:
    3309        27904 :     case FUNCTION_DECL:
    3310        27904 :       x = DECL_RTL (target);
    3311              :       break;
    3312              : 
    3313            0 :     case LABEL_DECL:
    3314            0 :       x = gen_rtx_MEM (FUNCTION_MODE,
    3315            0 :                        gen_rtx_LABEL_REF (Pmode, force_label_rtx (target)));
    3316            0 :       break;
    3317              : 
    3318            0 :     case REAL_CST:
    3319            0 :     case FIXED_CST:
    3320            0 :     case STRING_CST:
    3321            0 :     case COMPLEX_CST:
    3322            0 :     case CONSTRUCTOR:
    3323            0 :     case INTEGER_CST:
    3324            0 :       x = lookup_constant_def (target);
    3325              :       /* Should have been added by output_addressed_constants.  */
    3326            0 :       gcc_assert (x);
    3327              :       break;
    3328              : 
    3329            0 :     case INDIRECT_REF:
    3330              :       /* This deals with absolute addresses.  */
    3331            0 :       offset += tree_to_shwi (TREE_OPERAND (target, 0));
    3332            0 :       x = gen_rtx_MEM (QImode,
    3333            0 :                        gen_rtx_SYMBOL_REF (Pmode, "origin of addresses"));
    3334            0 :       break;
    3335              : 
    3336          102 :     case COMPOUND_LITERAL_EXPR:
    3337          102 :       gcc_assert (COMPOUND_LITERAL_EXPR_DECL (target));
    3338          102 :       x = DECL_RTL (COMPOUND_LITERAL_EXPR_DECL (target));
    3339              :       break;
    3340              : 
    3341            0 :     default:
    3342            0 :       gcc_unreachable ();
    3343              :     }
    3344              : 
    3345        28006 :   gcc_assert (MEM_P (x));
    3346        28006 :   x = XEXP (x, 0);
    3347              : 
    3348        28006 :   value->base = x;
    3349        28006 :   value->offset = offset;
    3350        28006 : }
    3351              : 
    3352              : static GTY(()) hash_table<tree_descriptor_hasher> *const_desc_htab;
    3353              : 
    3354              : static void maybe_output_constant_def_contents (struct constant_descriptor_tree *, int);
    3355              : 
    3356              : /* Constant pool accessor function.  */
    3357              : 
    3358              : hash_table<tree_descriptor_hasher> *
    3359         2435 : constant_pool_htab (void)
    3360              : {
    3361         2435 :   return const_desc_htab;
    3362              : }
    3363              : 
    3364              : /* Compute a hash code for a constant expression.  */
    3365              : 
    3366              : hashval_t
    3367      9248560 : tree_descriptor_hasher::hash (constant_descriptor_tree *ptr)
    3368              : {
    3369      9248560 :   return ptr->hash;
    3370              : }
    3371              : 
    3372              : static hashval_t
    3373      5490768 : const_hash_1 (const tree exp)
    3374              : {
    3375      5765166 :   const char *p;
    3376      5765166 :   hashval_t hi;
    3377      5765166 :   int len, i;
    3378      5765166 :   enum tree_code code = TREE_CODE (exp);
    3379              : 
    3380              :   /* Either set P and LEN to the address and len of something to hash and
    3381              :      exit the switch or return a value.  */
    3382              : 
    3383      5765166 :   switch (code)
    3384              :     {
    3385       680803 :     case INTEGER_CST:
    3386       680803 :       p = (char *) &TREE_INT_CST_ELT (exp, 0);
    3387       680803 :       len = TREE_INT_CST_NUNITS (exp) * sizeof (HOST_WIDE_INT);
    3388       680803 :       break;
    3389              : 
    3390        44940 :     case REAL_CST:
    3391        44940 :       return real_hash (TREE_REAL_CST_PTR (exp));
    3392              : 
    3393            0 :     case FIXED_CST:
    3394            0 :       return fixed_hash (TREE_FIXED_CST_PTR (exp));
    3395              : 
    3396      4508652 :     case STRING_CST:
    3397      4508652 :       p = TREE_STRING_POINTER (exp);
    3398      4508652 :       len = TREE_STRING_LENGTH (exp);
    3399      4508652 :       break;
    3400              : 
    3401        19517 :     case COMPLEX_CST:
    3402        19517 :       return (const_hash_1 (TREE_REALPART (exp)) * 5
    3403        19517 :               + const_hash_1 (TREE_IMAGPART (exp)));
    3404              : 
    3405            0 :     case VECTOR_CST:
    3406            0 :       {
    3407            0 :         hi = 7 + VECTOR_CST_NPATTERNS (exp);
    3408            0 :         hi = hi * 563 + VECTOR_CST_NELTS_PER_PATTERN (exp);
    3409            0 :         unsigned int count = vector_cst_encoded_nelts (exp);
    3410            0 :         for (unsigned int i = 0; i < count; ++i)
    3411            0 :           hi = hi * 563 + const_hash_1 (VECTOR_CST_ENCODED_ELT (exp, i));
    3412              :         return hi;
    3413              :       }
    3414              : 
    3415          151 :     case RAW_DATA_CST:
    3416          151 :       p = RAW_DATA_POINTER (exp);
    3417          151 :       len = RAW_DATA_LENGTH (exp);
    3418          151 :       break;
    3419              : 
    3420       228221 :     case CONSTRUCTOR:
    3421       228221 :       {
    3422       228221 :         unsigned HOST_WIDE_INT idx;
    3423       228221 :         tree value;
    3424              : 
    3425       228221 :         hi = 5 + int_size_in_bytes (TREE_TYPE (exp));
    3426              : 
    3427      1199872 :         FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (exp), idx, value)
    3428       971651 :           if (value)
    3429       971651 :             hi = hi * 603 + const_hash_1 (value);
    3430              : 
    3431              :         return hi;
    3432              :       }
    3433              : 
    3434       123058 :     case ADDR_EXPR:
    3435       123058 :       if (CONSTANT_CLASS_P (TREE_OPERAND (exp, 0)))
    3436        95058 :        return const_hash_1 (TREE_OPERAND (exp, 0));
    3437              : 
    3438              :       /* Fallthru.  */
    3439        28000 :     case FDESC_EXPR:
    3440        28000 :       {
    3441        28000 :         class addr_const value;
    3442              : 
    3443        28000 :         decode_addr_const (exp, &value);
    3444        28000 :         switch (GET_CODE (value.base))
    3445              :           {
    3446        28000 :           case SYMBOL_REF:
    3447              :             /* Don't hash the address of the SYMBOL_REF;
    3448              :                only use the offset and the symbol name.  */
    3449        28000 :             hi = value.offset.coeffs[0];
    3450        28000 :             p = XSTR (value.base, 0);
    3451       958134 :             for (i = 0; p[i] != 0; i++)
    3452       930134 :               hi = ((hi * 613) + (unsigned) (p[i]));
    3453              :             break;
    3454              : 
    3455            0 :           case LABEL_REF:
    3456            0 :             hi = (value.offset.coeffs[0]
    3457            0 :                   + CODE_LABEL_NUMBER (label_ref_label (value.base)) * 13);
    3458            0 :             break;
    3459              : 
    3460            0 :           default:
    3461            0 :             gcc_unreachable ();
    3462              :           }
    3463              :       }
    3464        28000 :       return hi;
    3465              : 
    3466           24 :     case PLUS_EXPR:
    3467           24 :     case POINTER_PLUS_EXPR:
    3468           24 :     case MINUS_EXPR:
    3469           24 :       return (const_hash_1 (TREE_OPERAND (exp, 0)) * 9
    3470           24 :               + const_hash_1 (TREE_OPERAND (exp, 1)));
    3471              : 
    3472       159799 :     CASE_CONVERT:
    3473       159799 :       return const_hash_1 (TREE_OPERAND (exp, 0)) * 7 + 2;
    3474              : 
    3475              :     default:
    3476              :       /* A language specific constant. Just hash the code.  */
    3477              :       return code;
    3478              :     }
    3479              : 
    3480              :   /* Compute hashing function.  */
    3481      5189606 :   hi = len;
    3482    320840512 :   for (i = 0; i < len; i++)
    3483    315650906 :     hi = ((hi * 613) + (unsigned) (p[i]));
    3484              : 
    3485              :   return hi;
    3486              : }
    3487              : 
    3488              : /* Wrapper of compare_constant, for the htab interface.  */
    3489              : bool
    3490     12920933 : tree_descriptor_hasher::equal (constant_descriptor_tree *c1,
    3491              :                                constant_descriptor_tree *c2)
    3492              : {
    3493     12920933 :   if (c1->hash != c2->hash)
    3494              :     return false;
    3495      2982834 :   return compare_constant (c1->value, c2->value);
    3496              : }
    3497              : 
    3498              : /* Compare t1 and t2, and return true only if they are known to result in
    3499              :    the same bit pattern on output.  */
    3500              : 
    3501              : static bool
    3502      3438410 : compare_constant (const tree t1, const tree t2)
    3503              : {
    3504      3441610 :   enum tree_code typecode;
    3505              : 
    3506      3441610 :   if (t1 == NULL_TREE)
    3507        20994 :     return t2 == NULL_TREE;
    3508      3420616 :   if (t2 == NULL_TREE)
    3509              :     return false;
    3510              : 
    3511      3420616 :   if (TREE_CODE (t1) != TREE_CODE (t2))
    3512              :     return false;
    3513              : 
    3514      3420588 :   switch (TREE_CODE (t1))
    3515              :     {
    3516       417474 :     case INTEGER_CST:
    3517              :       /* Integer constants are the same only if the same width of type.  */
    3518       417474 :       if (TYPE_PRECISION (TREE_TYPE (t1)) != TYPE_PRECISION (TREE_TYPE (t2)))
    3519              :         return false;
    3520       408865 :       if (TYPE_MODE (TREE_TYPE (t1)) != TYPE_MODE (TREE_TYPE (t2)))
    3521              :         return false;
    3522       408793 :       return tree_int_cst_equal (t1, t2);
    3523              : 
    3524        40357 :     case REAL_CST:
    3525              :       /* Real constants are the same only if the same width of type.  In
    3526              :          addition to the same width, we need to check whether the modes are the
    3527              :          same.  There might be two floating point modes that are the same size
    3528              :          but have different representations, such as the PowerPC that has 2
    3529              :          different 128-bit floating point types (IBM extended double and IEEE
    3530              :          128-bit floating point).  */
    3531        40357 :       if (TYPE_PRECISION (TREE_TYPE (t1)) != TYPE_PRECISION (TREE_TYPE (t2)))
    3532              :         return false;
    3533        27553 :       if (TYPE_MODE (TREE_TYPE (t1)) != TYPE_MODE (TREE_TYPE (t2)))
    3534              :         return false;
    3535        27553 :       return real_identical (&TREE_REAL_CST (t1), &TREE_REAL_CST (t2));
    3536              : 
    3537            0 :     case FIXED_CST:
    3538              :       /* Fixed constants are the same only if the same width of type.  */
    3539            0 :       if (TYPE_PRECISION (TREE_TYPE (t1)) != TYPE_PRECISION (TREE_TYPE (t2)))
    3540              :         return false;
    3541              : 
    3542            0 :       return FIXED_VALUES_IDENTICAL (TREE_FIXED_CST (t1), TREE_FIXED_CST (t2));
    3543              : 
    3544      2903883 :     case STRING_CST:
    3545      2903883 :       if (TYPE_MODE (TREE_TYPE (t1)) != TYPE_MODE (TREE_TYPE (t2))
    3546      5807766 :           || int_size_in_bytes (TREE_TYPE (t1))
    3547      2903883 :              != int_size_in_bytes (TREE_TYPE (t2)))
    3548            4 :         return false;
    3549              : 
    3550      2903879 :       return (TREE_STRING_LENGTH (t1) == TREE_STRING_LENGTH (t2)
    3551      2903879 :               && ! memcmp (TREE_STRING_POINTER (t1), TREE_STRING_POINTER (t2),
    3552      2903879 :                            TREE_STRING_LENGTH (t1)));
    3553              : 
    3554        25486 :     case COMPLEX_CST:
    3555        25486 :       return (compare_constant (TREE_REALPART (t1), TREE_REALPART (t2))
    3556        40183 :               && compare_constant (TREE_IMAGPART (t1), TREE_IMAGPART (t2)));
    3557              : 
    3558            0 :     case VECTOR_CST:
    3559            0 :       {
    3560            0 :         if (VECTOR_CST_NPATTERNS (t1)
    3561            0 :             != VECTOR_CST_NPATTERNS (t2))
    3562              :           return false;
    3563              : 
    3564            0 :         if (VECTOR_CST_NELTS_PER_PATTERN (t1)
    3565            0 :             != VECTOR_CST_NELTS_PER_PATTERN (t2))
    3566              :           return false;
    3567              : 
    3568            0 :         unsigned int count = vector_cst_encoded_nelts (t1);
    3569            0 :         for (unsigned int i = 0; i < count; ++i)
    3570            0 :           if (!compare_constant (VECTOR_CST_ENCODED_ELT (t1, i),
    3571            0 :                                  VECTOR_CST_ENCODED_ELT (t2, i)))
    3572              :             return false;
    3573              : 
    3574              :         return true;
    3575              :       }
    3576              : 
    3577           69 :     case RAW_DATA_CST:
    3578           69 :       return (RAW_DATA_LENGTH (t1) == RAW_DATA_LENGTH (t2)
    3579           69 :               && ! memcmp (RAW_DATA_POINTER (t1), RAW_DATA_POINTER (t2),
    3580           69 :                            RAW_DATA_LENGTH (t1)));
    3581              : 
    3582        30116 :     case CONSTRUCTOR:
    3583        30116 :       {
    3584        30116 :         vec<constructor_elt, va_gc> *v1, *v2;
    3585        30116 :         unsigned HOST_WIDE_INT idx;
    3586              : 
    3587        30116 :         typecode = TREE_CODE (TREE_TYPE (t1));
    3588        30116 :         if (typecode != TREE_CODE (TREE_TYPE (t2)))
    3589              :           return false;
    3590              : 
    3591        30116 :         if (typecode == ARRAY_TYPE)
    3592              :           {
    3593          842 :             HOST_WIDE_INT size_1 = int_size_in_bytes (TREE_TYPE (t1));
    3594              :             /* For arrays, check that mode, size and storage order match.  */
    3595          842 :             if (TYPE_MODE (TREE_TYPE (t1)) != TYPE_MODE (TREE_TYPE (t2))
    3596          842 :                 || size_1 == -1
    3597          842 :                 || size_1 != int_size_in_bytes (TREE_TYPE (t2))
    3598         1684 :                 || TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (t1))
    3599          842 :                    != TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (t2)))
    3600            0 :               return false;
    3601              :           }
    3602              :         else
    3603              :           {
    3604              :             /* For record and union constructors, require exact type
    3605              :                equality.  */
    3606        29274 :             if (TREE_TYPE (t1) != TREE_TYPE (t2))
    3607              :               return false;
    3608              :           }
    3609              : 
    3610        30108 :         v1 = CONSTRUCTOR_ELTS (t1);
    3611        30108 :         v2 = CONSTRUCTOR_ELTS (t2);
    3612        90324 :         if (vec_safe_length (v1) != vec_safe_length (v2))
    3613              :           return false;
    3614              : 
    3615       283555 :         for (idx = 0; idx < vec_safe_length (v1); ++idx)
    3616              :           {
    3617       253456 :             constructor_elt *c1 = &(*v1)[idx];
    3618       253456 :             constructor_elt *c2 = &(*v2)[idx];
    3619              : 
    3620              :             /* Check that each value is the same...  */
    3621       253456 :             if (!compare_constant (c1->value, c2->value))
    3622              :               return false;
    3623              :             /* ... and that they apply to the same fields!  */
    3624       253447 :             if (typecode == ARRAY_TYPE)
    3625              :               {
    3626       161937 :                 if (!compare_constant (c1->index, c2->index))
    3627              :                   return false;
    3628              :               }
    3629              :             else
    3630              :               {
    3631        91510 :                 if (c1->index != c2->index)
    3632              :                   return false;
    3633              :               }
    3634              :           }
    3635              : 
    3636              :         return true;
    3637              :       }
    3638              : 
    3639            3 :     case ADDR_EXPR:
    3640            3 :     case FDESC_EXPR:
    3641            3 :       {
    3642            3 :         class addr_const value1, value2;
    3643            3 :         enum rtx_code code;
    3644            3 :         bool ret;
    3645              : 
    3646            3 :         decode_addr_const (t1, &value1);
    3647            3 :         decode_addr_const (t2, &value2);
    3648              : 
    3649            3 :         if (maybe_ne (value1.offset, value2.offset))
    3650              :           return false;
    3651              : 
    3652            3 :         code = GET_CODE (value1.base);
    3653            3 :         if (code != GET_CODE (value2.base))
    3654              :           return false;
    3655              : 
    3656            3 :         switch (code)
    3657              :           {
    3658            3 :           case SYMBOL_REF:
    3659            3 :             ret = (strcmp (XSTR (value1.base, 0), XSTR (value2.base, 0)) == 0);
    3660            3 :             break;
    3661              : 
    3662            0 :           case LABEL_REF:
    3663            0 :             ret = (CODE_LABEL_NUMBER (label_ref_label (value1.base))
    3664            0 :                    == CODE_LABEL_NUMBER (label_ref_label (value2.base)));
    3665            0 :             break;
    3666              : 
    3667            0 :           default:
    3668            0 :             gcc_unreachable ();
    3669              :           }
    3670              :         return ret;
    3671              :       }
    3672              : 
    3673            0 :     case PLUS_EXPR:
    3674            0 :     case POINTER_PLUS_EXPR:
    3675            0 :     case MINUS_EXPR:
    3676            0 :     case RANGE_EXPR:
    3677            0 :       return (compare_constant (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0))
    3678            0 :               && compare_constant (TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1)));
    3679              : 
    3680         3200 :     CASE_CONVERT:
    3681         3200 :     case VIEW_CONVERT_EXPR:
    3682         3200 :       return compare_constant (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
    3683              : 
    3684              :     default:
    3685              :       return false;
    3686              :     }
    3687              : }
    3688              : 
    3689              : /* Return the section into which constant EXP should be placed.  */
    3690              : 
    3691              : static section *
    3692      1263576 : get_constant_section (tree exp, unsigned int align)
    3693              : {
    3694      1263576 :   return targetm.asm_out.select_section (exp,
    3695              :                                          compute_reloc_for_constant (exp),
    3696      1263576 :                                          align);
    3697              : }
    3698              : 
    3699              : /* Return the size of constant EXP in bytes.  */
    3700              : 
    3701              : static HOST_WIDE_INT
    3702      1265200 : get_constant_size (tree exp)
    3703              : {
    3704      1265200 :   HOST_WIDE_INT size;
    3705              : 
    3706      1265200 :   size = int_size_in_bytes (TREE_TYPE (exp));
    3707      1265200 :   gcc_checking_assert (size >= 0);
    3708      1265200 :   gcc_checking_assert (TREE_CODE (exp) != STRING_CST
    3709              :                        || size >= TREE_STRING_LENGTH (exp));
    3710      1265200 :   return size;
    3711              : }
    3712              : 
    3713              : /* Subroutine of output_constant_def:
    3714              :    No constant equal to EXP is known to have been output.
    3715              :    Make a constant descriptor to enter EXP in the hash table.
    3716              :    Assign the label number and construct RTL to refer to the
    3717              :    constant's location in memory.
    3718              :    Caller is responsible for updating the hash table.  */
    3719              : 
    3720              : static struct constant_descriptor_tree *
    3721      1275168 : build_constant_desc (tree exp)
    3722              : {
    3723      1275168 :   struct constant_descriptor_tree *desc;
    3724      1275168 :   rtx symbol, rtl;
    3725      1275168 :   char label[256];
    3726      1275168 :   int labelno;
    3727      1275168 :   tree decl;
    3728              : 
    3729      1275168 :   desc = ggc_alloc<constant_descriptor_tree> ();
    3730      1275168 :   desc->value = exp;
    3731              : 
    3732              :   /* Create a string containing the label name, in LABEL.  */
    3733      1275168 :   labelno = const_labelno++;
    3734      1275168 :   ASM_GENERATE_INTERNAL_LABEL (label, "LC", labelno);
    3735              : 
    3736              :   /* Construct the VAR_DECL associated with the constant.  */
    3737      1275168 :   decl = build_decl (UNKNOWN_LOCATION, VAR_DECL, get_identifier (label),
    3738      1275168 :                      TREE_TYPE (exp));
    3739      1275168 :   DECL_ARTIFICIAL (decl) = 1;
    3740      1275168 :   DECL_IGNORED_P (decl) = 1;
    3741      1275168 :   TREE_READONLY (decl) = 1;
    3742      1275168 :   TREE_STATIC (decl) = 1;
    3743      1275168 :   TREE_ADDRESSABLE (decl) = 1;
    3744              :   /* We don't set the RTL yet as this would cause varpool to assume that the
    3745              :      variable is referenced.  Moreover, it would just be dropped in LTO mode.
    3746              :      Instead we set the flag that will be recognized in make_decl_rtl.  */
    3747      1275168 :   DECL_IN_CONSTANT_POOL (decl) = 1;
    3748      1275168 :   DECL_INITIAL (decl) = desc->value;
    3749              :   /* ??? targetm.constant_alignment hasn't been updated for vector types on
    3750              :      most architectures so use DATA_ALIGNMENT as well, except for strings.  */
    3751      1275168 :   if (TREE_CODE (exp) == STRING_CST)
    3752      1243869 :     SET_DECL_ALIGN (decl, targetm.constant_alignment (exp, DECL_ALIGN (decl)));
    3753              :   else
    3754              :     {
    3755        31299 :       align_variable (decl, 0);
    3756        31299 :       if (DECL_ALIGN (decl) < GET_MODE_ALIGNMENT (DECL_MODE (decl))
    3757        31299 :           && ((optab_handler (movmisalign_optab, DECL_MODE (decl))
    3758              :                != CODE_FOR_nothing)
    3759            0 :               || targetm.slow_unaligned_access (DECL_MODE (decl),
    3760            0 :                                                 DECL_ALIGN (decl))))
    3761            0 :         SET_DECL_ALIGN (decl, GET_MODE_ALIGNMENT (DECL_MODE (decl)));
    3762              :     }
    3763              : 
    3764              :   /* Now construct the SYMBOL_REF and the MEM.  */
    3765      1275168 :   if (use_object_blocks_p ())
    3766              :     {
    3767            0 :       int align = (TREE_CODE (decl) == CONST_DECL
    3768            0 :                    || (VAR_P (decl) && DECL_IN_CONSTANT_POOL (decl))
    3769            0 :                    ? DECL_ALIGN (decl)
    3770            0 :                    : symtab_node::get (decl)->definition_alignment ());
    3771            0 :       section *sect = get_constant_section (exp, align);
    3772            0 :       symbol = create_block_symbol (ggc_strdup (label),
    3773              :                                     get_block_for_section (sect), -1);
    3774              :     }
    3775              :   else
    3776      1571258 :     symbol = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (label));
    3777      1275168 :   SYMBOL_REF_FLAGS (symbol) |= SYMBOL_FLAG_LOCAL;
    3778      1275168 :   SET_SYMBOL_REF_DECL (symbol, decl);
    3779      1275168 :   TREE_CONSTANT_POOL_ADDRESS_P (symbol) = 1;
    3780              : 
    3781      1275168 :   rtl = gen_const_mem (TYPE_MODE (TREE_TYPE (exp)), symbol);
    3782      1275168 :   set_mem_alias_set (rtl, 0);
    3783              : 
    3784              :   /* Putting EXP into the literal pool might have imposed a different
    3785              :      alignment which should be visible in the RTX as well.  */
    3786      1275168 :   set_mem_align (rtl, DECL_ALIGN (decl));
    3787              : 
    3788              :   /* We cannot share RTX'es in pool entries.
    3789              :      Mark this piece of RTL as required for unsharing.  */
    3790      1275168 :   RTX_FLAG (rtl, used) = 1;
    3791              : 
    3792              :   /* Set flags or add text to the name to record information, such as
    3793              :      that it is a local symbol.  If the name is changed, the macro
    3794              :      ASM_OUTPUT_LABELREF will have to know how to strip this
    3795              :      information.  This call might invalidate our local variable
    3796              :      SYMBOL; we can't use it afterward.  */
    3797      1275168 :   targetm.encode_section_info (exp, rtl, true);
    3798              : 
    3799      1275168 :   desc->rtl = rtl;
    3800              : 
    3801      1275168 :   return desc;
    3802              : }
    3803              : 
    3804              : /* Subroutine of output_constant_def and tree_output_constant_def:
    3805              :    Add a constant to the hash table that tracks which constants
    3806              :    already have labels.  */
    3807              : 
    3808              : static constant_descriptor_tree *
    3809      3942849 : add_constant_to_table (tree exp, int defer)
    3810              : {
    3811              :   /* The hash table methods may call output_constant_def for addressed
    3812              :      constants, so handle them first.  */
    3813      3942849 :   output_addressed_constants (exp, defer);
    3814              : 
    3815              :   /* Sanity check to catch recursive insertion.  */
    3816      3942849 :   static bool inserting;
    3817      3942849 :   gcc_assert (!inserting);
    3818      3942849 :   inserting = true;
    3819              : 
    3820              :   /* Look up EXP in the table of constant descriptors.  If we didn't
    3821              :      find it, create a new one.  */
    3822      3942849 :   struct constant_descriptor_tree key;
    3823      3942849 :   key.value = exp;
    3824      3942849 :   key.hash = const_hash_1 (exp);
    3825      3942849 :   constant_descriptor_tree **loc
    3826      3942849 :     = const_desc_htab->find_slot_with_hash (&key, key.hash, INSERT);
    3827              : 
    3828      3942849 :   inserting = false;
    3829              : 
    3830      3942849 :   struct constant_descriptor_tree *desc = *loc;
    3831      3942849 :   if (!desc)
    3832              :     {
    3833      1275168 :       desc = build_constant_desc (exp);
    3834      1275168 :       desc->hash = key.hash;
    3835      1275168 :       *loc = desc;
    3836              :     }
    3837              : 
    3838      3942849 :   return desc;
    3839              : }
    3840              : 
    3841              : /* Return an rtx representing a reference to constant data in memory
    3842              :    for the constant expression EXP.
    3843              : 
    3844              :    If assembler code for such a constant has already been output,
    3845              :    return an rtx to refer to it.
    3846              :    Otherwise, output such a constant in memory
    3847              :    and generate an rtx for it.
    3848              : 
    3849              :    If DEFER is nonzero, this constant can be deferred and output only
    3850              :    if referenced in the function after all optimizations.
    3851              : 
    3852              :    `const_desc_table' records which constants already have label strings.  */
    3853              : 
    3854              : rtx
    3855      3933219 : output_constant_def (tree exp, int defer)
    3856              : {
    3857      3933219 :   struct constant_descriptor_tree *desc = add_constant_to_table (exp, defer);
    3858      3933219 :   maybe_output_constant_def_contents (desc, defer);
    3859      3933219 :   return desc->rtl;
    3860              : }
    3861              : 
    3862              : /* Subroutine of output_constant_def: Decide whether or not we need to
    3863              :    output the constant DESC now, and if so, do it.  */
    3864              : static void
    3865      3933219 : maybe_output_constant_def_contents (struct constant_descriptor_tree *desc,
    3866              :                                     int defer)
    3867              : {
    3868      3933219 :   rtx symbol = XEXP (desc->rtl, 0);
    3869      3933219 :   tree exp = desc->value;
    3870              : 
    3871      3933219 :   if (flag_syntax_only)
    3872              :     return;
    3873              : 
    3874      3933219 :   if (TREE_ASM_WRITTEN (exp))
    3875              :     /* Already output; don't do it again.  */
    3876              :     return;
    3877              : 
    3878              :   /* We can always defer constants as long as the context allows
    3879              :      doing so.  */
    3880      1447713 :   if (defer)
    3881              :     {
    3882              :       /* Increment n_deferred_constants if it exists.  It needs to be at
    3883              :          least as large as the number of constants actually referred to
    3884              :          by the function.  If it's too small we'll stop looking too early
    3885              :          and fail to emit constants; if it's too large we'll only look
    3886              :          through the entire function when we could have stopped earlier.  */
    3887       192401 :       if (cfun)
    3888       107796 :         n_deferred_constants++;
    3889       192401 :       return;
    3890              :     }
    3891              : 
    3892      1255312 :   output_constant_def_contents (symbol);
    3893              : }
    3894              : 
    3895              : /* Subroutine of output_constant_def_contents.  Output the definition
    3896              :    of constant EXP, which is pointed to by label LABEL.  ALIGN is the
    3897              :    constant's alignment in bits.  */
    3898              : 
    3899              : static void
    3900      1263576 : assemble_constant_contents (tree exp, const char *label, unsigned int align,
    3901              :                             bool merge_strings)
    3902              : {
    3903      1263576 :   HOST_WIDE_INT size;
    3904              : 
    3905      1263576 :   size = get_constant_size (exp);
    3906              : 
    3907              :   /* Do any machine/system dependent processing of the constant.  */
    3908      1263576 :   targetm.asm_out.declare_constant_name (asm_out_file, label, exp, size);
    3909              : 
    3910              :   /* Output the value of EXP.  */
    3911      1263576 :   output_constant (exp, size, align, false, merge_strings);
    3912              : 
    3913      1263576 :   targetm.asm_out.decl_end ();
    3914      1263576 : }
    3915              : 
    3916              : /* We must output the constant data referred to by SYMBOL; do so.  */
    3917              : 
    3918              : static void
    3919      1263576 : output_constant_def_contents (rtx symbol)
    3920              : {
    3921      1263576 :   tree decl = SYMBOL_REF_DECL (symbol);
    3922      1263576 :   tree exp = DECL_INITIAL (decl);
    3923      1263576 :   bool asan_protected = false;
    3924              : 
    3925              :   /* Make sure any other constants whose addresses appear in EXP
    3926              :      are assigned label numbers.  */
    3927      1263576 :   output_addressed_constants (exp, 0);
    3928              : 
    3929              :   /* We are no longer deferring this constant.  */
    3930      1263576 :   TREE_ASM_WRITTEN (decl) = TREE_ASM_WRITTEN (exp) = 1;
    3931              : 
    3932      1263576 :   if ((flag_sanitize & SANITIZE_ADDRESS)
    3933         3221 :       && TREE_CODE (exp) == STRING_CST
    3934      1266775 :       && asan_protect_global (exp))
    3935              :     {
    3936         1624 :       asan_protected = true;
    3937         1624 :       SET_DECL_ALIGN (decl, MAX (DECL_ALIGN (decl),
    3938              :                                  ASAN_RED_ZONE_SIZE * BITS_PER_UNIT));
    3939              :     }
    3940              : 
    3941              :   /* If the constant is part of an object block, make sure that the
    3942              :      decl has been positioned within its block, but do not write out
    3943              :      its definition yet.  output_object_blocks will do that later.  */
    3944      1263576 :   if (SYMBOL_REF_HAS_BLOCK_INFO_P (symbol) && SYMBOL_REF_BLOCK (symbol))
    3945            0 :     place_block_symbol (symbol);
    3946              :   else
    3947              :     {
    3948      1263576 :       int align = (TREE_CODE (decl) == CONST_DECL
    3949      1263576 :                    || (VAR_P (decl) && DECL_IN_CONSTANT_POOL (decl))
    3950      2527152 :                    ? DECL_ALIGN (decl)
    3951      1263576 :                    : symtab_node::get (decl)->definition_alignment ());
    3952      1263576 :       section *sect = get_constant_section (exp, align);
    3953      1263576 :       switch_to_section (sect);
    3954      1263576 :       if (align > BITS_PER_UNIT)
    3955       395800 :         ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
    3956      1263576 :       assemble_constant_contents (exp, XSTR (symbol, 0), align,
    3957      1263576 :                                   (sect->common.flags & SECTION_MERGE)
    3958      1263576 :                                   && (sect->common.flags & SECTION_STRINGS));
    3959      1263576 :       if (asan_protected)
    3960              :         {
    3961         1624 :           HOST_WIDE_INT size = get_constant_size (exp);
    3962         3213 :           assemble_zeros (asan_red_zone_size (size));
    3963              :         }
    3964              :     }
    3965      1263576 : }
    3966              : 
    3967              : /* Look up EXP in the table of constant descriptors.  Return the rtl
    3968              :    if it has been emitted, else null.  */
    3969              : 
    3970              : rtx
    3971       556727 : lookup_constant_def (tree exp)
    3972              : {
    3973       556727 :   struct constant_descriptor_tree key;
    3974              : 
    3975       556727 :   key.value = exp;
    3976       556727 :   key.hash = const_hash_1 (exp);
    3977       556727 :   constant_descriptor_tree *desc
    3978       556727 :     = const_desc_htab->find_with_hash (&key, key.hash);
    3979              : 
    3980       556727 :   return (desc ? desc->rtl : NULL_RTX);
    3981              : }
    3982              : 
    3983              : /* Return a tree representing a reference to constant data in memory
    3984              :    for the constant expression EXP.
    3985              : 
    3986              :    This is the counterpart of output_constant_def at the Tree level.  */
    3987              : 
    3988              : tree
    3989         9630 : tree_output_constant_def (tree exp)
    3990              : {
    3991         9630 :   struct constant_descriptor_tree *desc = add_constant_to_table (exp, 1);
    3992         9630 :   tree decl = SYMBOL_REF_DECL (XEXP (desc->rtl, 0));
    3993         9630 :   varpool_node::finalize_decl (decl);
    3994         9630 :   return decl;
    3995              : }
    3996              : 
    3997      4195426 : class GTY((chain_next ("%h.next"), for_user)) constant_descriptor_rtx {
    3998              : public:
    3999              :   class constant_descriptor_rtx *next;
    4000              :   rtx mem;
    4001              :   rtx sym;
    4002              :   rtx constant;
    4003              :   HOST_WIDE_INT offset;
    4004              :   hashval_t hash;
    4005              :   fixed_size_mode mode;
    4006              :   unsigned int align;
    4007              :   int labelno;
    4008              :   int mark;
    4009              : };
    4010              : 
    4011              : struct const_rtx_desc_hasher : ggc_ptr_hash<constant_descriptor_rtx>
    4012              : {
    4013              :   static hashval_t hash (constant_descriptor_rtx *);
    4014              :   static bool equal (constant_descriptor_rtx *, constant_descriptor_rtx *);
    4015              : };
    4016              : 
    4017              : /* Used in the hash tables to avoid outputting the same constant
    4018              :    twice.  Unlike 'struct constant_descriptor_tree', RTX constants
    4019              :    are output once per function, not once per file.  */
    4020              : /* ??? Only a few targets need per-function constant pools.  Most
    4021              :    can use one per-file pool.  Should add a targetm bit to tell the
    4022              :    difference.  */
    4023              : 
    4024              : struct GTY(()) rtx_constant_pool {
    4025              :   /* Pointers to first and last constant in pool, as ordered by offset.  */
    4026              :   class constant_descriptor_rtx *first;
    4027              :   class constant_descriptor_rtx *last;
    4028              : 
    4029              :   /* Hash facility for making memory-constants from constant rtl-expressions.
    4030              :      It is used on RISC machines where immediate integer arguments and
    4031              :      constant addresses are restricted so that such constants must be stored
    4032              :      in memory.  */
    4033              :   hash_table<const_rtx_desc_hasher> *const_rtx_htab;
    4034              : 
    4035              :   /* Current offset in constant pool (does not include any
    4036              :      machine-specific header).  */
    4037              :   HOST_WIDE_INT offset;
    4038              : };
    4039              : 
    4040              : /* Hash and compare functions for const_rtx_htab.  */
    4041              : 
    4042              : hashval_t
    4043     16493933 : const_rtx_desc_hasher::hash (constant_descriptor_rtx *desc)
    4044              : {
    4045     16493933 :   return desc->hash;
    4046              : }
    4047              : 
    4048              : bool
    4049     20613475 : const_rtx_desc_hasher::equal (constant_descriptor_rtx *x,
    4050              :                               constant_descriptor_rtx *y)
    4051              : {
    4052     20613475 :   if (x->mode != y->mode)
    4053              :     return false;
    4054     11120142 :   return rtx_equal_p (x->constant, y->constant);
    4055              : }
    4056              : 
    4057              : /* Hash one component of a constant.  */
    4058              : 
    4059              : static hashval_t
    4060     15606596 : const_rtx_hash_1 (const_rtx x)
    4061              : {
    4062     15606596 :   unsigned HOST_WIDE_INT hwi;
    4063     15606596 :   machine_mode mode;
    4064     15606596 :   enum rtx_code code;
    4065     15606596 :   hashval_t h;
    4066     15606596 :   int i;
    4067              : 
    4068     15606596 :   code = GET_CODE (x);
    4069     15606596 :   mode = GET_MODE (x);
    4070     15606596 :   h = (hashval_t) code * 1048573 + mode;
    4071              : 
    4072     15606596 :   switch (code)
    4073              :     {
    4074     10257894 :     case CONST_INT:
    4075     10257894 :       hwi = INTVAL (x);
    4076              : 
    4077     10385459 :     fold_hwi:
    4078     10385459 :       {
    4079     10385459 :         int shift = sizeof (hashval_t) * CHAR_BIT;
    4080     10385459 :         const int n = sizeof (HOST_WIDE_INT) / sizeof (hashval_t);
    4081              : 
    4082     10385459 :         h ^= (hashval_t) hwi;
    4083     20770918 :         for (i = 1; i < n; ++i)
    4084              :           {
    4085     10385459 :             hwi >>= shift;
    4086     10385459 :             h ^= (hashval_t) hwi;
    4087              :           }
    4088              :       }
    4089              :       break;
    4090              : 
    4091              :     case CONST_WIDE_INT:
    4092              :       hwi = 0;
    4093              :       {
    4094       393335 :         for (i = 0; i < CONST_WIDE_INT_NUNITS (x); i++)
    4095       265770 :           hwi ^= CONST_WIDE_INT_ELT (x, i);
    4096       127565 :         goto fold_hwi;
    4097              :       }
    4098              : 
    4099      2845952 :     case CONST_DOUBLE:
    4100      2845952 :       if (TARGET_SUPPORTS_WIDE_INT == 0 && mode == VOIDmode)
    4101              :         {
    4102              :           hwi = CONST_DOUBLE_LOW (x) ^ CONST_DOUBLE_HIGH (x);
    4103              :           goto fold_hwi;
    4104              :         }
    4105              :       else
    4106      2845952 :         h ^= real_hash (CONST_DOUBLE_REAL_VALUE (x));
    4107      2845952 :       break;
    4108              : 
    4109            0 :     case CONST_FIXED:
    4110            0 :       h ^= fixed_hash (CONST_FIXED_VALUE (x));
    4111            0 :       break;
    4112              : 
    4113        97264 :     case SYMBOL_REF:
    4114        97264 :       h ^= htab_hash_string (XSTR (x, 0));
    4115        97264 :       break;
    4116              : 
    4117           29 :     case LABEL_REF:
    4118           29 :       h = h * 251 + CODE_LABEL_NUMBER (label_ref_label (x));
    4119           29 :       break;
    4120              : 
    4121            0 :     case UNSPEC:
    4122            0 :     case UNSPEC_VOLATILE:
    4123            0 :       h = h * 251 + XINT (x, 1);
    4124            0 :       break;
    4125              : 
    4126              :     default:
    4127              :       break;
    4128              :     }
    4129              : 
    4130     15606596 :   return h;
    4131              : }
    4132              : 
    4133              : /* Compute a hash value for X, which should be a constant.  */
    4134              : 
    4135              : static hashval_t
    4136      4174219 : const_rtx_hash (rtx x)
    4137              : {
    4138      4174219 :   hashval_t h = 0;
    4139      4174219 :   subrtx_iterator::array_type array;
    4140     19780815 :   FOR_EACH_SUBRTX (iter, array, x, ALL)
    4141     15606596 :     h = h * 509 + const_rtx_hash_1 (*iter);
    4142      4174219 :   return h;
    4143      4174219 : }
    4144              : 
    4145              : 
    4146              : /* Create and return a new rtx constant pool.  */
    4147              : 
    4148              : static struct rtx_constant_pool *
    4149      1969848 : create_constant_pool (void)
    4150              : {
    4151      1969848 :   struct rtx_constant_pool *pool;
    4152              : 
    4153      1969848 :   pool = ggc_alloc<rtx_constant_pool> ();
    4154      1969848 :   pool->const_rtx_htab = hash_table<const_rtx_desc_hasher>::create_ggc (31);
    4155      1969848 :   pool->first = NULL;
    4156      1969848 :   pool->last = NULL;
    4157      1969848 :   pool->offset = 0;
    4158      1969848 :   return pool;
    4159              : }
    4160              : 
    4161              : /* Initialize constant pool hashing for a new function.  */
    4162              : 
    4163              : void
    4164      1691207 : init_varasm_status (void)
    4165              : {
    4166      1691207 :   crtl->varasm.pool = create_constant_pool ();
    4167      1691207 :   crtl->varasm.deferred_constants = 0;
    4168      1691207 : }
    4169              : 
    4170              : /* Given a MINUS expression, simplify it if both sides
    4171              :    include the same symbol.  */
    4172              : 
    4173              : rtx
    4174      4759099 : simplify_subtraction (rtx x)
    4175              : {
    4176      4759099 :   rtx r = simplify_rtx (x);
    4177      4759099 :   return r ? r : x;
    4178              : }
    4179              : 
    4180              : /* Given a constant rtx X, make (or find) a memory constant for its value
    4181              :    and return a MEM rtx to refer to it in memory.  IN_MODE is the mode
    4182              :    of X.  */
    4183              : 
    4184              : rtx
    4185      4195426 : force_const_mem (machine_mode in_mode, rtx x)
    4186              : {
    4187      4195426 :   class constant_descriptor_rtx *desc, tmp;
    4188      4195426 :   struct rtx_constant_pool *pool;
    4189      4195426 :   char label[256];
    4190      4195426 :   rtx def, symbol;
    4191      4195426 :   hashval_t hash;
    4192      4195426 :   unsigned int align;
    4193      4195426 :   constant_descriptor_rtx **slot;
    4194      4195426 :   fixed_size_mode mode;
    4195              : 
    4196              :   /* We can't force variable-sized objects to memory.  */
    4197      4195426 :   if (!is_a <fixed_size_mode> (in_mode, &mode))
    4198              :     return NULL_RTX;
    4199              : 
    4200              :   /* If we're not allowed to drop X into the constant pool, don't.  */
    4201      4195426 :   if (targetm.cannot_force_const_mem (mode, x))
    4202              :     return NULL_RTX;
    4203              : 
    4204              :   /* Record that this function has used a constant pool entry.  */
    4205      4174219 :   crtl->uses_const_pool = 1;
    4206              : 
    4207              :   /* Decide which pool to use.  */
    4208      8348438 :   pool = (targetm.use_blocks_for_constant_p (mode, x)
    4209      4174219 :           ? shared_constant_pool
    4210              :           : crtl->varasm.pool);
    4211              : 
    4212              :   /* Lookup the value in the hashtable.  */
    4213      4174219 :   tmp.constant = x;
    4214      4174219 :   tmp.mode = mode;
    4215      4174219 :   hash = const_rtx_hash (x);
    4216      4174219 :   slot = pool->const_rtx_htab->find_slot_with_hash (&tmp, hash, INSERT);
    4217      4174219 :   desc = *slot;
    4218              : 
    4219              :   /* If the constant was already present, return its memory.  */
    4220      4174219 :   if (desc)
    4221      3819735 :     return copy_rtx (desc->mem);
    4222              : 
    4223              :   /* Otherwise, create a new descriptor.  */
    4224       354484 :   desc = ggc_alloc<constant_descriptor_rtx> ();
    4225       354484 :   *slot = desc;
    4226              : 
    4227              :   /* Align the location counter as required by EXP's data type.  */
    4228       354484 :   machine_mode align_mode = (mode == VOIDmode ? word_mode : mode);
    4229       354484 :   align = targetm.static_rtx_alignment (align_mode);
    4230              : 
    4231       354484 :   pool->offset += (align / BITS_PER_UNIT) - 1;
    4232       354484 :   pool->offset &= ~ ((align / BITS_PER_UNIT) - 1);
    4233              : 
    4234       354484 :   desc->next = NULL;
    4235       354484 :   desc->constant = copy_rtx (tmp.constant);
    4236       354484 :   desc->offset = pool->offset;
    4237       354484 :   desc->hash = hash;
    4238       354484 :   desc->mode = mode;
    4239       354484 :   desc->align = align;
    4240       354484 :   desc->labelno = const_labelno;
    4241       354484 :   desc->mark = 0;
    4242              : 
    4243       354484 :   pool->offset += GET_MODE_SIZE (mode);
    4244       354484 :   if (pool->last)
    4245       309727 :     pool->last->next = desc;
    4246              :   else
    4247        44757 :     pool->first = pool->last = desc;
    4248       354484 :   pool->last = desc;
    4249              : 
    4250              :   /* Create a string containing the label name, in LABEL.  */
    4251       354484 :   ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno);
    4252       354484 :   ++const_labelno;
    4253              : 
    4254              :   /* Construct the SYMBOL_REF.  Make sure to mark it as belonging to
    4255              :      the constants pool.  */
    4256       354484 :   if (use_object_blocks_p () && targetm.use_blocks_for_constant_p (mode, x))
    4257              :     {
    4258            0 :       section *sect = targetm.asm_out.select_rtx_section (mode, x, align);
    4259            0 :       symbol = create_block_symbol (ggc_strdup (label),
    4260              :                                     get_block_for_section (sect), -1);
    4261              :     }
    4262              :   else
    4263       387905 :     symbol = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (label));
    4264       354484 :   desc->sym = symbol;
    4265       354484 :   SYMBOL_REF_FLAGS (symbol) |= SYMBOL_FLAG_LOCAL;
    4266       354484 :   CONSTANT_POOL_ADDRESS_P (symbol) = 1;
    4267       354484 :   SET_SYMBOL_REF_CONSTANT (symbol, desc);
    4268              : 
    4269              :   /* Construct the MEM.  */
    4270       354484 :   desc->mem = def = gen_const_mem (mode, symbol);
    4271       354484 :   set_mem_align (def, align);
    4272              : 
    4273              :   /* If we're dropping a label to the constant pool, make sure we
    4274              :      don't delete it.  */
    4275       354484 :   if (GET_CODE (x) == LABEL_REF)
    4276           29 :     LABEL_PRESERVE_P (XEXP (x, 0)) = 1;
    4277              : 
    4278       354484 :   return copy_rtx (def);
    4279              : }
    4280              : 
    4281              : /* Given a constant pool SYMBOL_REF, return the corresponding constant.  */
    4282              : 
    4283              : rtx
    4284     11879093 : get_pool_constant (const_rtx addr)
    4285              : {
    4286     11879093 :   return SYMBOL_REF_CONSTANT (addr)->constant;
    4287              : }
    4288              : 
    4289              : /* Given a constant pool SYMBOL_REF, return the corresponding constant
    4290              :    and whether it has been output or not.  */
    4291              : 
    4292              : rtx
    4293            0 : get_pool_constant_mark (rtx addr, bool *pmarked)
    4294              : {
    4295            0 :   class constant_descriptor_rtx *desc;
    4296              : 
    4297            0 :   desc = SYMBOL_REF_CONSTANT (addr);
    4298            0 :   *pmarked = (desc->mark != 0);
    4299            0 :   return desc->constant;
    4300              : }
    4301              : 
    4302              : /* Similar, return the mode.  */
    4303              : 
    4304              : fixed_size_mode
    4305      5332505 : get_pool_mode (const_rtx addr)
    4306              : {
    4307      5332505 :   return SYMBOL_REF_CONSTANT (addr)->mode;
    4308              : }
    4309              : 
    4310              : /* Return TRUE if and only if the constant pool has no entries.  Note
    4311              :    that even entries we might end up choosing not to emit are counted
    4312              :    here, so there is the potential for missed optimizations.  */
    4313              : 
    4314              : bool
    4315            0 : constant_pool_empty_p (void)
    4316              : {
    4317            0 :   return crtl->varasm.pool->first == NULL;
    4318              : }
    4319              : 
    4320              : /* Worker function for output_constant_pool_1.  Emit assembly for X
    4321              :    in MODE with known alignment ALIGN.  */
    4322              : 
    4323              : static void
    4324       657314 : output_constant_pool_2 (fixed_size_mode mode, rtx x, unsigned int align)
    4325              : {
    4326       657314 :   switch (GET_MODE_CLASS (mode))
    4327              :     {
    4328       198837 :     case MODE_FLOAT:
    4329       198837 :     case MODE_DECIMAL_FLOAT:
    4330       198837 :       {
    4331       198837 :         gcc_assert (CONST_DOUBLE_AS_FLOAT_P (x));
    4332       198837 :         assemble_real (*CONST_DOUBLE_REAL_VALUE (x),
    4333              :                        as_a <scalar_float_mode> (mode), align, false);
    4334       198837 :         break;
    4335              :       }
    4336              : 
    4337       368751 :     case MODE_INT:
    4338       368751 :     case MODE_PARTIAL_INT:
    4339       368751 :     case MODE_FRACT:
    4340       368751 :     case MODE_UFRACT:
    4341       368751 :     case MODE_ACCUM:
    4342       368751 :     case MODE_UACCUM:
    4343       368751 :       assemble_integer (x, GET_MODE_SIZE (mode), align, 1);
    4344       368751 :       break;
    4345              : 
    4346            0 :     case MODE_VECTOR_BOOL:
    4347            0 :       {
    4348            0 :         gcc_assert (GET_CODE (x) == CONST_VECTOR);
    4349              : 
    4350            0 :         auto_vec<target_unit, 128> buffer;
    4351            0 :         buffer.reserve (GET_MODE_SIZE (mode));
    4352              : 
    4353            0 :         bool ok = native_encode_rtx (mode, x, buffer, 0, GET_MODE_SIZE (mode));
    4354            0 :         gcc_assert (ok);
    4355              : 
    4356            0 :         for (unsigned i = 0; i < GET_MODE_SIZE (mode); i++)
    4357              :           {
    4358            0 :             unsigned HOST_WIDE_INT value = buffer[i];
    4359            0 :             output_constant_pool_2 (byte_mode, gen_int_mode (value, byte_mode),
    4360              :                                     i == 0 ? align : 1);
    4361              :           }
    4362            0 :         break;
    4363            0 :       }
    4364        89726 :     case MODE_VECTOR_FLOAT:
    4365        89726 :     case MODE_VECTOR_INT:
    4366        89726 :     case MODE_VECTOR_FRACT:
    4367        89726 :     case MODE_VECTOR_UFRACT:
    4368        89726 :     case MODE_VECTOR_ACCUM:
    4369        89726 :     case MODE_VECTOR_UACCUM:
    4370        89726 :       {
    4371        89726 :         int i, units;
    4372        89726 :         scalar_mode submode = GET_MODE_INNER (mode);
    4373       269178 :         unsigned int subalign = MIN (align, GET_MODE_BITSIZE (submode));
    4374              : 
    4375        89726 :         gcc_assert (GET_CODE (x) == CONST_VECTOR);
    4376        89726 :         units = GET_MODE_NUNITS (mode);
    4377              : 
    4378       498537 :         for (i = 0; i < units; i++)
    4379              :           {
    4380       408811 :             rtx elt = CONST_VECTOR_ELT (x, i);
    4381       498537 :             output_constant_pool_2 (submode, elt, i ? subalign : align);
    4382              :           }
    4383              :       }
    4384              :       break;
    4385              : 
    4386            0 :     default:
    4387            0 :       gcc_unreachable ();
    4388              :     }
    4389       657314 : }
    4390              : 
    4391              : /* Worker function for output_constant_pool.  Emit constant DESC,
    4392              :    giving it ALIGN bits of alignment.  */
    4393              : 
    4394              : static void
    4395       248503 : output_constant_pool_1 (class constant_descriptor_rtx *desc,
    4396              :                         unsigned int align)
    4397              : {
    4398       248503 :   rtx x, tmp;
    4399              : 
    4400       248503 :   x = desc->constant;
    4401              : 
    4402              :   /* See if X is a LABEL_REF (or a CONST referring to a LABEL_REF)
    4403              :      whose CODE_LABEL has been deleted.  This can occur if a jump table
    4404              :      is eliminated by optimization.  If so, write a constant of zero
    4405              :      instead.  Note that this can also happen by turning the
    4406              :      CODE_LABEL into a NOTE.  */
    4407              :   /* ??? This seems completely and utterly wrong.  Certainly it's
    4408              :      not true for NOTE_INSN_DELETED_LABEL, but I disbelieve proper
    4409              :      functioning even with rtx_insn::deleted and friends.  */
    4410              : 
    4411       248503 :   tmp = x;
    4412       248503 :   switch (GET_CODE (tmp))
    4413              :     {
    4414         3821 :     case CONST:
    4415         3821 :       if (GET_CODE (XEXP (tmp, 0)) != PLUS
    4416         3821 :           || GET_CODE (XEXP (XEXP (tmp, 0), 0)) != LABEL_REF)
    4417              :         break;
    4418              :       tmp = XEXP (XEXP (tmp, 0), 0);
    4419              :       /* FALLTHRU  */
    4420              : 
    4421           29 :     case LABEL_REF:
    4422           29 :       {
    4423           29 :         rtx_insn *insn = label_ref_label (tmp);
    4424           29 :         gcc_assert (!insn->deleted ());
    4425           29 :         gcc_assert (!NOTE_P (insn)
    4426              :                     || NOTE_KIND (insn) != NOTE_INSN_DELETED);
    4427              :         break;
    4428              :       }
    4429              : 
    4430              :     default:
    4431              :       break;
    4432              :     }
    4433              : 
    4434              : #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
    4435              :   ASM_OUTPUT_SPECIAL_POOL_ENTRY (asm_out_file, x, desc->mode,
    4436              :                                  align, desc->labelno, done);
    4437              : #endif
    4438              : 
    4439       248503 :   assemble_align (align);
    4440              : 
    4441              :   /* Output the label.  */
    4442       248503 :   targetm.asm_out.internal_label (asm_out_file, "LC", desc->labelno);
    4443              : 
    4444              :   /* Output the data.
    4445              :      Pass actual alignment value while emitting string constant to asm code
    4446              :      as function 'output_constant_pool_1' explicitly passes the alignment as 1
    4447              :      assuming that the data is already aligned which prevents the generation
    4448              :      of fix-up table entries.  */
    4449       248503 :   output_constant_pool_2 (desc->mode, x, desc->align);
    4450              : 
    4451              :   /* Make sure all constants in SECTION_MERGE and not SECTION_STRINGS
    4452              :      sections have proper size.  */
    4453       248503 :   if (in_section
    4454       248503 :       && (in_section->common.flags & SECTION_MERGE)
    4455       248503 :       && ((in_section->common.flags & SECTION_ENTSIZE)
    4456       410922 :            > GET_MODE_SIZE (desc->mode)))
    4457              :     {
    4458           95 :       unsigned HOST_WIDE_INT entsize, constsize;
    4459           95 :       entsize = (in_section->common.flags & SECTION_ENTSIZE);
    4460           95 :       constsize = GET_MODE_SIZE (desc->mode);
    4461           95 :       assemble_zeros (entsize - constsize);
    4462              :     }
    4463              : 
    4464              : #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
    4465              :  done:
    4466              : #endif
    4467       248503 :   return;
    4468              : }
    4469              : 
    4470              : /* Recompute the offsets of entries in POOL, and the overall size of
    4471              :    POOL.  Do this after calling mark_constant_pool to ensure that we
    4472              :    are computing the offset values for the pool which we will actually
    4473              :    emit.  */
    4474              : 
    4475              : static void
    4476      1473125 : recompute_pool_offsets (struct rtx_constant_pool *pool)
    4477              : {
    4478      1473125 :   class constant_descriptor_rtx *desc;
    4479      1473125 :   pool->offset = 0;
    4480              : 
    4481      1473125 :   for (desc = pool->first; desc ; desc = desc->next)
    4482            0 :     if (desc->mark)
    4483              :       {
    4484              :           /* Recalculate offset.  */
    4485            0 :         unsigned int align = desc->align;
    4486            0 :         pool->offset += (align / BITS_PER_UNIT) - 1;
    4487            0 :         pool->offset &= ~ ((align / BITS_PER_UNIT) - 1);
    4488            0 :         desc->offset = pool->offset;
    4489            0 :         pool->offset += GET_MODE_SIZE (desc->mode);
    4490              :       }
    4491      1473125 : }
    4492              : 
    4493              : /* Mark all constants that are referenced by SYMBOL_REFs in X.
    4494              :    Emit referenced deferred strings.  */
    4495              : 
    4496              : static void
    4497     38719357 : mark_constants_in_pattern (rtx insn)
    4498              : {
    4499     38719357 :   subrtx_iterator::array_type array;
    4500    259423187 :   FOR_EACH_SUBRTX (iter, array, PATTERN (insn), ALL)
    4501              :     {
    4502    220703830 :       const_rtx x = *iter;
    4503    220703830 :       if (GET_CODE (x) == SYMBOL_REF)
    4504              :         {
    4505      7658284 :           if (CONSTANT_POOL_ADDRESS_P (x))
    4506              :             {
    4507       774787 :               class constant_descriptor_rtx *desc = SYMBOL_REF_CONSTANT (x);
    4508       774787 :               if (desc->mark == 0)
    4509              :                 {
    4510       256665 :                   desc->mark = 1;
    4511       256665 :                   iter.substitute (desc->constant);
    4512              :                 }
    4513              :             }
    4514      6883497 :           else if (TREE_CONSTANT_POOL_ADDRESS_P (x))
    4515              :             {
    4516       719885 :               tree decl = SYMBOL_REF_DECL (x);
    4517       719885 :               if (!TREE_ASM_WRITTEN (DECL_INITIAL (decl)))
    4518              :                 {
    4519         7065 :                   n_deferred_constants--;
    4520         7065 :                   output_constant_def_contents (const_cast<rtx> (x));
    4521              :                 }
    4522              :             }
    4523              :         }
    4524              :     }
    4525     38719357 : }
    4526              : 
    4527              : /* Look through appropriate parts of INSN, marking all entries in the
    4528              :    constant pool which are actually being used.  Entries that are only
    4529              :    referenced by other constants are also marked as used.  Emit
    4530              :    deferred strings that are used.  */
    4531              : 
    4532              : static void
    4533     85780612 : mark_constants (rtx_insn *insn)
    4534              : {
    4535     85780612 :   if (!INSN_P (insn))
    4536              :     return;
    4537              : 
    4538              :   /* Insns may appear inside a SEQUENCE.  Only check the patterns of
    4539              :      insns, not any notes that may be attached.  We don't want to mark
    4540              :      a constant just because it happens to appear in a REG_EQUIV note.  */
    4541     38719357 :   if (rtx_sequence *seq = dyn_cast <rtx_sequence *> (PATTERN (insn)))
    4542              :     {
    4543            0 :       int i, n = seq->len ();
    4544            0 :       for (i = 0; i < n; ++i)
    4545              :         {
    4546            0 :           rtx subinsn = seq->element (i);
    4547            0 :           if (INSN_P (subinsn))
    4548            0 :             mark_constants_in_pattern (subinsn);
    4549              :         }
    4550              :     }
    4551              :   else
    4552     38719357 :     mark_constants_in_pattern (insn);
    4553              : }
    4554              : 
    4555              : /* Look through the instructions for this function, and mark all the
    4556              :    entries in POOL which are actually being used.  Emit deferred constants
    4557              :    which have indeed been used.  */
    4558              : 
    4559              : static void
    4560      1473125 : mark_constant_pool (void)
    4561              : {
    4562      1473125 :   rtx_insn *insn;
    4563              : 
    4564      1473125 :   if (!crtl->uses_const_pool && n_deferred_constants == 0)
    4565              :     return;
    4566              : 
    4567     85958876 :   for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
    4568     85780612 :     mark_constants (insn);
    4569              : }
    4570              : 
    4571              : /* Write all the constants in POOL.  */
    4572              : 
    4573              : static void
    4574      1703258 : output_constant_pool_contents (struct rtx_constant_pool *pool)
    4575              : {
    4576      1703258 :   class constant_descriptor_rtx *desc;
    4577              : 
    4578      2057708 :   for (desc = pool->first; desc ; desc = desc->next)
    4579       354450 :     if (desc->mark < 0)
    4580              :       {
    4581              : #ifdef ASM_OUTPUT_DEF
    4582         8162 :         gcc_checking_assert (TARGET_SUPPORTS_ALIASES);
    4583              : 
    4584         8162 :         const char *name = XSTR (desc->sym, 0);
    4585         8162 :         char label[256];
    4586         8162 :         char buffer[256 + 32];
    4587         8162 :         const char *p;
    4588              : 
    4589         8162 :         ASM_GENERATE_INTERNAL_LABEL (label, "LC", ~desc->mark);
    4590         8162 :         p = label;
    4591         8162 :         if (desc->offset)
    4592              :           {
    4593         2797 :             sprintf (buffer, "%s+" HOST_WIDE_INT_PRINT_DEC, p, desc->offset);
    4594         2797 :             p = buffer;
    4595              :           }
    4596         8162 :         ASM_OUTPUT_DEF (asm_out_file, name, p);
    4597              : #else
    4598              :         gcc_unreachable ();
    4599              : #endif
    4600              :       }
    4601       346288 :     else if (desc->mark)
    4602              :       {
    4603              :         /* If the constant is part of an object_block, make sure that
    4604              :            the constant has been positioned within its block, but do not
    4605              :            write out its definition yet.  output_object_blocks will do
    4606              :            that later.  */
    4607       248503 :         if (SYMBOL_REF_HAS_BLOCK_INFO_P (desc->sym)
    4608       248503 :             && SYMBOL_REF_BLOCK (desc->sym))
    4609            0 :           place_block_symbol (desc->sym);
    4610              :         else
    4611              :           {
    4612       248503 :             switch_to_section (targetm.asm_out.select_rtx_section
    4613       248503 :                                (desc->mode, desc->constant, desc->align));
    4614       248503 :             output_constant_pool_1 (desc, desc->align);
    4615              :           }
    4616              :       }
    4617      1703258 : }
    4618              : 
    4619              : struct constant_descriptor_rtx_data {
    4620              :   constant_descriptor_rtx *desc;
    4621              :   target_unit *bytes;
    4622              :   unsigned short size;
    4623              :   unsigned short offset;
    4624              :   unsigned int hash;
    4625              : };
    4626              : 
    4627              : /* qsort callback to sort constant_descriptor_rtx_data * vector by
    4628              :    decreasing size.  */
    4629              : 
    4630              : static int
    4631      3785720 : constant_descriptor_rtx_data_cmp (const void *p1, const void *p2)
    4632              : {
    4633      3785720 :   constant_descriptor_rtx_data *const data1
    4634              :     = *(constant_descriptor_rtx_data * const *) p1;
    4635      3785720 :   constant_descriptor_rtx_data *const data2
    4636              :     = *(constant_descriptor_rtx_data * const *) p2;
    4637      3785720 :   if (data1->size > data2->size)
    4638              :     return -1;
    4639      3491971 :   if (data1->size < data2->size)
    4640              :     return 1;
    4641      3270828 :   if (data1->hash < data2->hash)
    4642              :     return -1;
    4643      1694613 :   gcc_assert (data1->hash > data2->hash);
    4644              :   return 1;
    4645              : }
    4646              : 
    4647              : struct const_rtx_data_hasher : nofree_ptr_hash<constant_descriptor_rtx_data>
    4648              : {
    4649              :   static hashval_t hash (constant_descriptor_rtx_data *);
    4650              :   static bool equal (constant_descriptor_rtx_data *,
    4651              :                      constant_descriptor_rtx_data *);
    4652              : };
    4653              : 
    4654              : /* Hash and compare functions for const_rtx_data_htab.  */
    4655              : 
    4656              : hashval_t
    4657      2175472 : const_rtx_data_hasher::hash (constant_descriptor_rtx_data *data)
    4658              : {
    4659      2175472 :   return data->hash;
    4660              : }
    4661              : 
    4662              : bool
    4663      2362078 : const_rtx_data_hasher::equal (constant_descriptor_rtx_data *x,
    4664              :                               constant_descriptor_rtx_data *y)
    4665              : {
    4666      2362078 :   if (x->hash != y->hash || x->size != y->size)
    4667              :     return false;
    4668       149141 :   unsigned int align1 = x->desc->align;
    4669       149141 :   unsigned int align2 = y->desc->align;
    4670       149141 :   unsigned int offset1 = (x->offset * BITS_PER_UNIT) & (align1 - 1);
    4671       149141 :   unsigned int offset2 = (y->offset * BITS_PER_UNIT) & (align2 - 1);
    4672       149141 :   if (offset1)
    4673        76259 :     align1 = least_bit_hwi (offset1);
    4674       149141 :   if (offset2)
    4675       103950 :     align2 = least_bit_hwi (offset2);
    4676       149141 :   if (align2 > align1)
    4677              :     return false;
    4678       126338 :   if (memcmp (x->bytes, y->bytes, x->size * sizeof (target_unit)) != 0)
    4679            0 :     return false;
    4680              :   return true;
    4681              : }
    4682              : 
    4683              : /* Attempt to optimize constant pool POOL.  If it contains both CONST_VECTOR
    4684              :    constants and scalar constants with the values of CONST_VECTOR elements,
    4685              :    try to alias the scalar constants with the CONST_VECTOR elements.  */
    4686              : 
    4687              : static void
    4688       149834 : optimize_constant_pool (struct rtx_constant_pool *pool)
    4689              : {
    4690       149834 :   auto_vec<target_unit, 128> buffer;
    4691       149834 :   auto_vec<constant_descriptor_rtx_data *, 128> vec;
    4692       149834 :   object_allocator<constant_descriptor_rtx_data>
    4693       149834 :     data_pool ("constant_descriptor_rtx_data_pool");
    4694       149834 :   int idx = 0;
    4695       149834 :   size_t size = 0;
    4696       462169 :   for (constant_descriptor_rtx *desc = pool->first; desc; desc = desc->next)
    4697       312335 :     if (desc->mark > 0
    4698       312335 :         && ! (SYMBOL_REF_HAS_BLOCK_INFO_P (desc->sym)
    4699            0 :               && SYMBOL_REF_BLOCK (desc->sym)))
    4700              :       {
    4701       218143 :         buffer.truncate (0);
    4702       436286 :         buffer.reserve (GET_MODE_SIZE (desc->mode));
    4703       218143 :         if (native_encode_rtx (desc->mode, desc->constant, buffer, 0,
    4704       436286 :                                GET_MODE_SIZE (desc->mode)))
    4705              :           {
    4706       187210 :             constant_descriptor_rtx_data *data = data_pool.allocate ();
    4707       187210 :             data->desc = desc;
    4708       187210 :             data->bytes = NULL;
    4709       187210 :             data->size = GET_MODE_SIZE (desc->mode);
    4710       187210 :             data->offset = 0;
    4711       187210 :             data->hash = idx++;
    4712       187210 :             size += data->size;
    4713       187210 :             vec.safe_push (data);
    4714              :           }
    4715              :       }
    4716       149834 :   if (idx)
    4717              :     {
    4718        28404 :       vec.qsort (constant_descriptor_rtx_data_cmp);
    4719        28404 :       unsigned min_size = vec.last ()->size;
    4720        28404 :       target_unit *bytes = XNEWVEC (target_unit, size);
    4721        28404 :       unsigned int i;
    4722        28404 :       constant_descriptor_rtx_data *data;
    4723        28404 :       hash_table<const_rtx_data_hasher> * htab
    4724        28404 :         = new hash_table<const_rtx_data_hasher> (31);
    4725        28404 :       size = 0;
    4726       215614 :       FOR_EACH_VEC_ELT (vec, i, data)
    4727              :         {
    4728       187210 :           buffer.truncate (0);
    4729       187210 :           native_encode_rtx (data->desc->mode, data->desc->constant,
    4730       187210 :                              buffer, 0, data->size);
    4731       187210 :           memcpy (bytes + size, buffer.address (), data->size);
    4732       187210 :           data->bytes = bytes + size;
    4733       374420 :           data->hash = iterative_hash (data->bytes,
    4734       187210 :                                        data->size * sizeof (target_unit), 0);
    4735       187210 :           size += data->size;
    4736       187210 :           constant_descriptor_rtx_data **slot
    4737       187210 :             = htab->find_slot_with_hash (data, data->hash, INSERT);
    4738       187210 :           if (*slot)
    4739              :             {
    4740         8162 :               data->desc->mark = ~(*slot)->desc->labelno;
    4741         8162 :               data->desc->offset = (*slot)->offset;
    4742              :             }
    4743              :           else
    4744              :             {
    4745       179048 :               unsigned int sz = 1 << floor_log2 (data->size);
    4746              : 
    4747       179048 :               *slot = data;
    4748       264029 :               for (sz >>= 1; sz >= min_size; sz >>= 1)
    4749       371426 :                 for (unsigned off = 0; off + sz <= data->size; off += sz)
    4750              :                   {
    4751       286445 :                     constant_descriptor_rtx_data tmp;
    4752       286445 :                     tmp.desc = data->desc;
    4753       286445 :                     tmp.bytes = data->bytes + off;
    4754       286445 :                     tmp.size = sz;
    4755       286445 :                     tmp.offset = off;
    4756       286445 :                     tmp.hash = iterative_hash (tmp.bytes,
    4757              :                                                sz * sizeof (target_unit), 0);
    4758       286445 :                     slot = htab->find_slot_with_hash (&tmp, tmp.hash, INSERT);
    4759       286445 :                     if (*slot == NULL)
    4760              :                       {
    4761       168269 :                         *slot = data_pool.allocate ();
    4762       168269 :                         **slot = tmp;
    4763              :                       }
    4764              :                   }
    4765              :             }
    4766              :         }
    4767        28404 :       delete htab;
    4768        28404 :       XDELETE (bytes);
    4769              :     }
    4770       149834 :   data_pool.release ();
    4771       149834 : }
    4772              : 
    4773              : /* Mark all constants that are used in the current function, then write
    4774              :    out the function's private constant pool.  */
    4775              : 
    4776              : static void
    4777      1473125 : output_constant_pool (const char *fnname ATTRIBUTE_UNUSED,
    4778              :                       tree fndecl ATTRIBUTE_UNUSED)
    4779              : {
    4780      1473125 :   struct rtx_constant_pool *pool = crtl->varasm.pool;
    4781              : 
    4782              :   /* It is possible for gcc to call force_const_mem and then to later
    4783              :      discard the instructions which refer to the constant.  In such a
    4784              :      case we do not need to output the constant.  */
    4785      1473125 :   mark_constant_pool ();
    4786              : 
    4787              :   /* Having marked the constant pool entries we'll actually emit, we
    4788              :      now need to rebuild the offset information, which may have become
    4789              :      stale.  */
    4790      1473125 :   recompute_pool_offsets (pool);
    4791              : 
    4792              : #ifdef ASM_OUTPUT_POOL_PROLOGUE
    4793              :   ASM_OUTPUT_POOL_PROLOGUE (asm_out_file, fnname, fndecl, pool->offset);
    4794              : #endif
    4795              : 
    4796      1473125 :   output_constant_pool_contents (pool);
    4797              : 
    4798              : #ifdef ASM_OUTPUT_POOL_EPILOGUE
    4799              :   ASM_OUTPUT_POOL_EPILOGUE (asm_out_file, fnname, fndecl, pool->offset);
    4800              : #endif
    4801      1473125 : }
    4802              : 
    4803              : /* Write the contents of the shared constant pool.  */
    4804              : 
    4805              : void
    4806       230133 : output_shared_constant_pool (void)
    4807              : {
    4808       230133 :   if (optimize
    4809              :       && TARGET_SUPPORTS_ALIASES)
    4810       149834 :     optimize_constant_pool (shared_constant_pool);
    4811              : 
    4812       230133 :   output_constant_pool_contents (shared_constant_pool);
    4813       230133 : }
    4814              : 
    4815              : /* Determine what kind of relocations EXP may need.  */
    4816              : 
    4817              : int
    4818     35384667 : compute_reloc_for_constant (tree exp)
    4819              : {
    4820     37861348 :   int reloc = 0, reloc2;
    4821     37861348 :   tree tem;
    4822              : 
    4823     37861348 :   switch (TREE_CODE (exp))
    4824              :     {
    4825     10058037 :     case ADDR_EXPR:
    4826     10058037 :     case FDESC_EXPR:
    4827              :       /* Go inside any operations that get_inner_reference can handle and see
    4828              :          if what's inside is a constant: no need to do anything here for
    4829              :          addresses of variables or functions.  */
    4830     10111756 :       for (tem = TREE_OPERAND (exp, 0); handled_component_p (tem);
    4831        53719 :            tem = TREE_OPERAND (tem, 0))
    4832              :         ;
    4833              : 
    4834     10058037 :       if (TREE_CODE (tem) == MEM_REF
    4835     10058037 :           && TREE_CODE (TREE_OPERAND (tem, 0)) == ADDR_EXPR)
    4836              :         {
    4837        57237 :           reloc = compute_reloc_for_constant (TREE_OPERAND (tem, 0));
    4838        57237 :           break;
    4839              :         }
    4840              : 
    4841     10000800 :       if (!targetm.binds_local_p (tem))
    4842              :         reloc |= 2;
    4843              :       else
    4844      7674525 :         reloc |= 1;
    4845              :       break;
    4846              : 
    4847        19380 :     case PLUS_EXPR:
    4848        19380 :     case POINTER_PLUS_EXPR:
    4849        19380 :       reloc = compute_reloc_for_constant (TREE_OPERAND (exp, 0));
    4850        19380 :       reloc |= compute_reloc_for_constant (TREE_OPERAND (exp, 1));
    4851        19380 :       break;
    4852              : 
    4853           26 :     case MINUS_EXPR:
    4854           26 :       reloc = compute_reloc_for_constant (TREE_OPERAND (exp, 0));
    4855           26 :       reloc2 = compute_reloc_for_constant (TREE_OPERAND (exp, 1));
    4856              :       /* The difference of two local labels is computable at link time.  */
    4857           26 :       if (reloc == 1 && reloc2 == 1)
    4858              :         reloc = 0;
    4859              :       else
    4860            0 :         reloc |= reloc2;
    4861              :       break;
    4862              : 
    4863      2419444 :     CASE_CONVERT:
    4864      2419444 :     case VIEW_CONVERT_EXPR:
    4865      2419444 :       reloc = compute_reloc_for_constant (TREE_OPERAND (exp, 0));
    4866      2419444 :       break;
    4867              : 
    4868              :     case CONSTRUCTOR:
    4869              :       {
    4870              :         unsigned HOST_WIDE_INT idx;
    4871     37520855 :         FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (exp), idx, tem)
    4872     29603468 :           if (tem != 0)
    4873     29603468 :             reloc |= compute_reloc_for_constant (tem);
    4874              :       }
    4875              :       break;
    4876              : 
    4877              :     default:
    4878              :       break;
    4879              :     }
    4880     35384667 :   return reloc;
    4881              : }
    4882              : 
    4883              : /* Find all the constants whose addresses are referenced inside of EXP,
    4884              :    and make sure assembler code with a label has been output for each one.
    4885              :    Indicate whether an ADDR_EXPR has been encountered.  */
    4886              : 
    4887              : static void
    4888     22449092 : output_addressed_constants (tree exp, int defer)
    4889              : {
    4890     22940778 :   tree tem;
    4891              : 
    4892     22940778 :   switch (TREE_CODE (exp))
    4893              :     {
    4894      4543631 :     case ADDR_EXPR:
    4895      4543631 :     case FDESC_EXPR:
    4896              :       /* Go inside any operations that get_inner_reference can handle and see
    4897              :          if what's inside is a constant: no need to do anything here for
    4898              :          addresses of variables or functions.  */
    4899      4597565 :       for (tem = TREE_OPERAND (exp, 0); handled_component_p (tem);
    4900        53934 :            tem = TREE_OPERAND (tem, 0))
    4901              :         ;
    4902              : 
    4903              :       /* If we have an initialized CONST_DECL, retrieve the initializer.  */
    4904      4543631 :       if (TREE_CODE (tem) == CONST_DECL && DECL_INITIAL (tem))
    4905            0 :         tem = DECL_INITIAL (tem);
    4906              : 
    4907      4543631 :       if (CONSTANT_CLASS_P (tem) || TREE_CODE (tem) == CONSTRUCTOR)
    4908       970465 :         output_constant_def (tem, defer);
    4909              : 
    4910      4543631 :       if (TREE_CODE (tem) == MEM_REF)
    4911        52732 :         output_addressed_constants (TREE_OPERAND (tem, 0), defer);
    4912              :       break;
    4913              : 
    4914        16931 :     case PLUS_EXPR:
    4915        16931 :     case POINTER_PLUS_EXPR:
    4916        16931 :     case MINUS_EXPR:
    4917        16931 :       output_addressed_constants (TREE_OPERAND (exp, 1), defer);
    4918       438954 :       gcc_fallthrough ();
    4919              : 
    4920       438954 :     CASE_CONVERT:
    4921       438954 :     case VIEW_CONVERT_EXPR:
    4922       438954 :       output_addressed_constants (TREE_OPERAND (exp, 0), defer);
    4923       438954 :       break;
    4924              : 
    4925              :     case CONSTRUCTOR:
    4926              :       {
    4927              :         unsigned HOST_WIDE_INT idx;
    4928     19391635 :         FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (exp), idx, tem)
    4929     15318128 :           if (tem != 0)
    4930     15318128 :             output_addressed_constants (tem, defer);
    4931              :       }
    4932              :       break;
    4933              : 
    4934              :     default:
    4935              :       break;
    4936              :     }
    4937     22449092 : }
    4938              : 
    4939              : /* Whether a constructor CTOR is a valid static constant initializer if all
    4940              :    its elements are.  This used to be internal to initializer_constant_valid_p
    4941              :    and has been exposed to let other functions like categorize_ctor_elements
    4942              :    evaluate the property while walking a constructor for other purposes.  */
    4943              : 
    4944              : bool
    4945     13174655 : constructor_static_from_elts_p (const_tree ctor)
    4946              : {
    4947     13174655 :   return (TREE_CONSTANT (ctor)
    4948     13174655 :           && (TREE_CODE (TREE_TYPE (ctor)) == UNION_TYPE
    4949     12554844 :               || TREE_CODE (TREE_TYPE (ctor)) == RECORD_TYPE
    4950      1490957 :               || TREE_CODE (TREE_TYPE (ctor)) == ARRAY_TYPE));
    4951              : }
    4952              : 
    4953              : static tree initializer_constant_valid_p_1 (tree value, tree endtype,
    4954              :                                             tree *cache);
    4955              : 
    4956              : /* A subroutine of initializer_constant_valid_p.  VALUE is a MINUS_EXPR,
    4957              :    PLUS_EXPR or POINTER_PLUS_EXPR.  This looks for cases of VALUE
    4958              :    which are valid when ENDTYPE is an integer of any size; in
    4959              :    particular, this does not accept a pointer minus a constant.  This
    4960              :    returns null_pointer_node if the VALUE is an absolute constant
    4961              :    which can be used to initialize a static variable.  Otherwise it
    4962              :    returns NULL.  */
    4963              : 
    4964              : static tree
    4965      1437277 : narrowing_initializer_constant_valid_p (tree value, tree endtype, tree *cache)
    4966              : {
    4967      1437277 :   tree op0, op1;
    4968              : 
    4969      1437277 :   if (!INTEGRAL_TYPE_P (endtype))
    4970              :     return NULL_TREE;
    4971              : 
    4972      1340431 :   op0 = TREE_OPERAND (value, 0);
    4973      1340431 :   op1 = TREE_OPERAND (value, 1);
    4974              : 
    4975              :   /* Like STRIP_NOPS except allow the operand mode to widen.  This
    4976              :      works around a feature of fold that simplifies (int)(p1 - p2) to
    4977              :      ((int)p1 - (int)p2) under the theory that the narrower operation
    4978              :      is cheaper.  */
    4979              : 
    4980      2653263 :   while (CONVERT_EXPR_P (op0)
    4981      3095403 :          || TREE_CODE (op0) == NON_LVALUE_EXPR)
    4982              :     {
    4983       488184 :       tree inner = TREE_OPERAND (op0, 0);
    4984       976368 :       if (inner == error_mark_node
    4985       488184 :           || ! INTEGRAL_TYPE_P (TREE_TYPE (op0))
    4986       488082 :           || ! SCALAR_INT_MODE_P (TYPE_MODE (TREE_TYPE (op0)))
    4987       488082 :           || ! INTEGRAL_TYPE_P (TREE_TYPE (inner))
    4988       487926 :           || ! SCALAR_INT_MODE_P (TYPE_MODE (TREE_TYPE (inner)))
    4989       976110 :           || (GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (op0)))
    4990      1012675 :               > GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (inner)))))
    4991              :         break;
    4992              :       op0 = inner;
    4993              :     }
    4994              : 
    4995      1294009 :   while (CONVERT_EXPR_P (op1)
    4996      2847729 :          || TREE_CODE (op1) == NON_LVALUE_EXPR)
    4997              :     {
    4998       296673 :       tree inner = TREE_OPERAND (op1, 0);
    4999       593346 :       if (inner == error_mark_node
    5000       296673 :           || ! INTEGRAL_TYPE_P (TREE_TYPE (op1))
    5001       278244 :           || ! SCALAR_INT_MODE_P (TYPE_MODE (TREE_TYPE (op1)))
    5002       278244 :           || ! INTEGRAL_TYPE_P (TREE_TYPE (inner))
    5003       278158 :           || ! SCALAR_INT_MODE_P (TYPE_MODE (TREE_TYPE (inner)))
    5004       574831 :           || (GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (op1)))
    5005       621489 :               > GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (inner)))))
    5006              :         break;
    5007              :       op1 = inner;
    5008              :     }
    5009              : 
    5010      1340431 :   op0 = initializer_constant_valid_p_1 (op0, endtype, cache);
    5011      1340431 :   if (!op0)
    5012              :     return NULL_TREE;
    5013              : 
    5014          865 :   op1 = initializer_constant_valid_p_1 (op1, endtype,
    5015              :                                         cache ? cache + 2 : NULL);
    5016              :   /* Both initializers must be known.  */
    5017          865 :   if (op1)
    5018              :     {
    5019          198 :       if (op0 == op1
    5020           30 :           && (op0 == null_pointer_node
    5021           11 :               || TREE_CODE (value) == MINUS_EXPR))
    5022              :         return null_pointer_node;
    5023              : 
    5024              :       /* Support differences between labels.  */
    5025          179 :       if (TREE_CODE (op0) == LABEL_DECL
    5026          166 :           && TREE_CODE (op1) == LABEL_DECL)
    5027          166 :         return null_pointer_node;
    5028              : 
    5029           13 :       if (TREE_CODE (op0) == STRING_CST
    5030            0 :           && TREE_CODE (op1) == STRING_CST
    5031           13 :           && operand_equal_p (op0, op1, 1))
    5032            0 :         return null_pointer_node;
    5033              :     }
    5034              : 
    5035              :   return NULL_TREE;
    5036              : }
    5037              : 
    5038              : /* Helper function of initializer_constant_valid_p.
    5039              :    Return nonzero if VALUE is a valid constant-valued expression
    5040              :    for use in initializing a static variable; one that can be an
    5041              :    element of a "constant" initializer.
    5042              : 
    5043              :    Return null_pointer_node if the value is absolute;
    5044              :    if it is relocatable, return the variable that determines the relocation.
    5045              :    We assume that VALUE has been folded as much as possible;
    5046              :    therefore, we do not need to check for such things as
    5047              :    arithmetic-combinations of integers.
    5048              : 
    5049              :    Use CACHE (pointer to 2 tree values) for caching if non-NULL.  */
    5050              : 
    5051              : static tree
    5052   1326681940 : initializer_constant_valid_p_1 (tree value, tree endtype, tree *cache)
    5053              : {
    5054   1384341514 :   tree ret;
    5055              : 
    5056   1384341514 :   switch (TREE_CODE (value))
    5057              :     {
    5058     11685611 :     case CONSTRUCTOR:
    5059     11685611 :       if (constructor_static_from_elts_p (value))
    5060              :         {
    5061     11674536 :           unsigned HOST_WIDE_INT idx;
    5062     11674536 :           tree elt;
    5063     11674536 :           bool absolute = true;
    5064              : 
    5065     11674536 :           if (cache && cache[0] == value)
    5066            0 :             return cache[1];
    5067    115643942 :           FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (value), idx, elt)
    5068              :             {
    5069    103969636 :               tree reloc;
    5070    103969636 :               reloc = initializer_constant_valid_p_1 (elt, TREE_TYPE (elt),
    5071              :                                                       NULL);
    5072    103969636 :               if (!reloc
    5073              :                   /* An absolute value is required with reverse SSO.  */
    5074    103969636 :                   || (reloc != null_pointer_node
    5075      8166883 :                       && TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (value))
    5076            1 :                       && !AGGREGATE_TYPE_P (TREE_TYPE (elt))))
    5077              :                 {
    5078          230 :                   if (cache)
    5079              :                     {
    5080            0 :                       cache[0] = value;
    5081            0 :                       cache[1] = NULL_TREE;
    5082              :                     }
    5083          230 :                   return NULL_TREE;
    5084              :                 }
    5085    103969406 :               if (reloc != null_pointer_node)
    5086      8166882 :                 absolute = false;
    5087              :             }
    5088              :           /* For a non-absolute relocation, there is no single
    5089              :              variable that can be "the variable that determines the
    5090              :              relocation."  */
    5091     11674306 :           if (cache)
    5092              :             {
    5093            0 :               cache[0] = value;
    5094            0 :               cache[1] = absolute ? null_pointer_node : error_mark_node;
    5095              :             }
    5096     11674306 :           return absolute ? null_pointer_node : error_mark_node;
    5097              :         }
    5098              : 
    5099        11075 :       return TREE_STATIC (value) ? null_pointer_node : NULL_TREE;
    5100              : 
    5101   1229399623 :     case INTEGER_CST:
    5102   1229399623 :     case VECTOR_CST:
    5103   1229399623 :     case REAL_CST:
    5104   1229399623 :     case FIXED_CST:
    5105   1229399623 :     case STRING_CST:
    5106   1229399623 :     case COMPLEX_CST:
    5107   1229399623 :     case RAW_DATA_CST:
    5108   1229399623 :       return null_pointer_node;
    5109              : 
    5110     55100693 :     case ADDR_EXPR:
    5111     55100693 :     case FDESC_EXPR:
    5112     55100693 :       {
    5113     55100693 :         tree op0 = staticp (TREE_OPERAND (value, 0));
    5114     55100693 :         if (op0)
    5115              :           {
    5116              :             /* "&(*a).f" is like unto pointer arithmetic.  If "a" turns out
    5117              :                to be a constant, this is old-skool offsetof-like nonsense.  */
    5118     48638578 :             if (TREE_CODE (op0) == INDIRECT_REF
    5119     48638578 :                 && TREE_CONSTANT (TREE_OPERAND (op0, 0)))
    5120           46 :               return null_pointer_node;
    5121              :             /* Taking the address of a nested function involves a trampoline,
    5122              :                unless we don't need or want one.  */
    5123     48638532 :             if (TREE_CODE (op0) == FUNCTION_DECL
    5124     10245021 :                 && DECL_STATIC_CHAIN (op0)
    5125     48638547 :                 && !TREE_NO_TRAMPOLINE (value))
    5126              :               return NULL_TREE;
    5127              :             /* "&{...}" requires a temporary to hold the constructed
    5128              :                object.  */
    5129     48638517 :             if (TREE_CODE (op0) == CONSTRUCTOR)
    5130              :               return NULL_TREE;
    5131              :           }
    5132              :         return op0;
    5133              :       }
    5134              : 
    5135      2152881 :     case NON_LVALUE_EXPR:
    5136      2152881 :       return initializer_constant_valid_p_1 (TREE_OPERAND (value, 0),
    5137      2152881 :                                              endtype, cache);
    5138              : 
    5139      2509370 :     case VIEW_CONVERT_EXPR:
    5140      2509370 :       {
    5141      2509370 :         tree src = TREE_OPERAND (value, 0);
    5142      2509370 :         tree src_type = TREE_TYPE (src);
    5143      2509370 :         tree dest_type = TREE_TYPE (value);
    5144              : 
    5145              :         /* Allow view-conversions from aggregate to non-aggregate type only
    5146              :            if the bit pattern is fully preserved afterwards; otherwise, the
    5147              :            RTL expander won't be able to apply a subsequent transformation
    5148              :            to the underlying constructor.  */
    5149      2509370 :         if (AGGREGATE_TYPE_P (src_type) && !AGGREGATE_TYPE_P (dest_type))
    5150              :           {
    5151            0 :             if (TYPE_MODE (endtype) == TYPE_MODE (dest_type))
    5152              :               return initializer_constant_valid_p_1 (src, endtype, cache);
    5153              :             else
    5154              :               return NULL_TREE;
    5155              :           }
    5156              : 
    5157              :         /* Allow all other kinds of view-conversion.  */
    5158              :         return initializer_constant_valid_p_1 (src, endtype, cache);
    5159              :       }
    5160              : 
    5161     53729351 :     CASE_CONVERT:
    5162     53729351 :       {
    5163     53729351 :         tree src = TREE_OPERAND (value, 0);
    5164     53729351 :         tree src_type = TREE_TYPE (src);
    5165     53729351 :         tree dest_type = TREE_TYPE (value);
    5166              : 
    5167              :         /* Allow conversions between pointer types and offset types.  */
    5168     53729351 :         if ((POINTER_TYPE_P (dest_type) && POINTER_TYPE_P (src_type))
    5169      3159350 :             || (TREE_CODE (dest_type) == OFFSET_TYPE
    5170           85 :                 && TREE_CODE (src_type) == OFFSET_TYPE))
    5171              :           return initializer_constant_valid_p_1 (src, endtype, cache);
    5172              : 
    5173              :         /* Allow length-preserving conversions between integer types and
    5174              :            floating-point types.  */
    5175      2903617 :         if (((INTEGRAL_TYPE_P (dest_type) && INTEGRAL_TYPE_P (src_type))
    5176       343005 :              || (SCALAR_FLOAT_TYPE_P (dest_type)
    5177        63794 :                  && SCALAR_FLOAT_TYPE_P (src_type)))
    5178      6039355 :             && (TYPE_PRECISION (dest_type) == TYPE_PRECISION (src_type)))
    5179              :           return initializer_constant_valid_p_1 (src, endtype, cache);
    5180              : 
    5181              :         /* Allow conversions between other integer types only if
    5182              :            explicit value.  Don't allow sign-extension to a type larger
    5183              :            than word and pointer, there aren't relocations that would
    5184              :            allow to sign extend it to a wider type.  */
    5185       937214 :         if (INTEGRAL_TYPE_P (dest_type)
    5186       743439 :             && INTEGRAL_TYPE_P (src_type)
    5187      1593314 :             && (TYPE_UNSIGNED (src_type)
    5188       255922 :                 || TYPE_PRECISION (dest_type) <= TYPE_PRECISION (src_type)
    5189        99957 :                 || TYPE_PRECISION (dest_type) <= BITS_PER_WORD
    5190          757 :                 || TYPE_PRECISION (dest_type) <= POINTER_SIZE))
    5191              :           {
    5192       655704 :             tree inner = initializer_constant_valid_p_1 (src, endtype, cache);
    5193       655704 :             if (inner == null_pointer_node)
    5194              :               return null_pointer_node;
    5195              :             break;
    5196              :           }
    5197              : 
    5198              :         /* Allow (int) &foo provided int is as wide as a pointer.  */
    5199        87735 :         if (INTEGRAL_TYPE_P (dest_type) && POINTER_TYPE_P (src_type)
    5200       368834 :             && (TYPE_PRECISION (dest_type) >= TYPE_PRECISION (src_type)))
    5201              :           return initializer_constant_valid_p_1 (src, endtype, cache);
    5202              : 
    5203              :         /* Likewise conversions from int to pointers, but also allow
    5204              :            conversions from 0.  */
    5205       194372 :         if ((POINTER_TYPE_P (dest_type)
    5206       120388 :              || TREE_CODE (dest_type) == OFFSET_TYPE)
    5207        74002 :             && INTEGRAL_TYPE_P (src_type))
    5208              :           {
    5209          553 :             if (TREE_CODE (src) == INTEGER_CST
    5210          553 :                 && TYPE_PRECISION (dest_type) >= TYPE_PRECISION (src_type))
    5211            8 :               return null_pointer_node;
    5212          545 :             if (integer_zerop (src))
    5213            0 :               return null_pointer_node;
    5214          545 :             else if (TYPE_PRECISION (dest_type) <= TYPE_PRECISION (src_type))
    5215              :               return initializer_constant_valid_p_1 (src, endtype, cache);
    5216              :           }
    5217              : 
    5218              :         /* Allow conversions to struct or union types if the value
    5219              :            inside is okay.  */
    5220       193819 :         if (TREE_CODE (dest_type) == RECORD_TYPE
    5221       193819 :             || TREE_CODE (dest_type) == UNION_TYPE)
    5222              :           return initializer_constant_valid_p_1 (src, endtype, cache);
    5223              :       }
    5224              :       break;
    5225              : 
    5226     10135676 :     case POINTER_PLUS_EXPR:
    5227     10135676 :     case PLUS_EXPR:
    5228              :       /* Any valid floating-point constants will have been folded by now;
    5229              :          with -frounding-math we hit this with addition of two constants.  */
    5230     10135676 :       if (TREE_CODE (endtype) == REAL_TYPE)
    5231              :         return NULL_TREE;
    5232      9177226 :       if (cache && cache[0] == value)
    5233       144263 :         return cache[1];
    5234      9032963 :       if (! INTEGRAL_TYPE_P (endtype)
    5235       837011 :           || ! INTEGRAL_TYPE_P (TREE_TYPE (value))
    5236      9869412 :           || TYPE_PRECISION (endtype) >= TYPE_PRECISION (TREE_TYPE (value)))
    5237              :         {
    5238      9015043 :           tree ncache[4] = { NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE };
    5239      9015043 :           tree valid0
    5240      9015043 :             = initializer_constant_valid_p_1 (TREE_OPERAND (value, 0),
    5241              :                                               endtype, ncache);
    5242      9015043 :           tree valid1
    5243      9015043 :             = initializer_constant_valid_p_1 (TREE_OPERAND (value, 1),
    5244              :                                               endtype, ncache + 2);
    5245              :           /* If either term is absolute, use the other term's relocation.  */
    5246      9015043 :           if (valid0 == null_pointer_node)
    5247              :             ret = valid1;
    5248      9005690 :           else if (valid1 == null_pointer_node)
    5249              :             ret = valid0;
    5250              :           /* Support narrowing pointer differences.  */
    5251              :           else
    5252       501242 :             ret = narrowing_initializer_constant_valid_p (value, endtype,
    5253              :                                                           ncache);
    5254              :         }
    5255              :       else
    5256              :       /* Support narrowing pointer differences.  */
    5257        17920 :         ret = narrowing_initializer_constant_valid_p (value, endtype, NULL);
    5258      9032963 :       if (cache)
    5259              :         {
    5260       144550 :           cache[0] = value;
    5261       144550 :           cache[1] = ret;
    5262              :         }
    5263              :       return ret;
    5264              : 
    5265      1758144 :     case POINTER_DIFF_EXPR:
    5266      1758144 :     case MINUS_EXPR:
    5267      1758144 :       if (TREE_CODE (endtype) == REAL_TYPE)
    5268              :         return NULL_TREE;
    5269      1274857 :       if (cache && cache[0] == value)
    5270       170307 :         return cache[1];
    5271      1104550 :       if (! INTEGRAL_TYPE_P (endtype)
    5272      1104473 :           || ! INTEGRAL_TYPE_P (TREE_TYPE (value))
    5273      2209020 :           || TYPE_PRECISION (endtype) >= TYPE_PRECISION (TREE_TYPE (value)))
    5274              :         {
    5275      1049445 :           tree ncache[4] = { NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE };
    5276      1049445 :           tree valid0
    5277      1049445 :             = initializer_constant_valid_p_1 (TREE_OPERAND (value, 0),
    5278              :                                               endtype, ncache);
    5279      1049445 :           tree valid1
    5280      1049445 :             = initializer_constant_valid_p_1 (TREE_OPERAND (value, 1),
    5281              :                                               endtype, ncache + 2);
    5282              :           /* Win if second argument is absolute.  */
    5283      1049445 :           if (valid1 == null_pointer_node)
    5284              :             ret = valid0;
    5285              :           /* Win if both arguments have the same relocation.
    5286              :              Then the value is absolute.  */
    5287       863010 :           else if (valid0 == valid1 && valid0 != 0)
    5288              :             ret = null_pointer_node;
    5289              :           /* Since GCC guarantees that string constants are unique in the
    5290              :              generated code, a subtraction between two copies of the same
    5291              :              constant string is absolute.  */
    5292          741 :           else if (valid0 && TREE_CODE (valid0) == STRING_CST
    5293            0 :                    && valid1 && TREE_CODE (valid1) == STRING_CST
    5294       863010 :                    && operand_equal_p (valid0, valid1, 1))
    5295            0 :             ret = null_pointer_node;
    5296              :           /* Support narrowing differences.  */
    5297              :           else
    5298       863010 :             ret = narrowing_initializer_constant_valid_p (value, endtype,
    5299              :                                                           ncache);
    5300              :         }
    5301              :       else
    5302              :         /* Support narrowing differences.  */
    5303        55105 :         ret = narrowing_initializer_constant_valid_p (value, endtype, NULL);
    5304      1104550 :       if (cache)
    5305              :         {
    5306       171914 :           cache[0] = value;
    5307       171914 :           cache[1] = ret;
    5308              :         }
    5309              :       return ret;
    5310              : 
    5311              :     default:
    5312              :       break;
    5313              :     }
    5314              : 
    5315              :   return NULL_TREE;
    5316              : }
    5317              : 
    5318              : /* Return nonzero if VALUE is a valid constant-valued expression
    5319              :    for use in initializing a static variable; one that can be an
    5320              :    element of a "constant" initializer.
    5321              : 
    5322              :    Return null_pointer_node if the value is absolute;
    5323              :    if it is relocatable, return the variable that determines the relocation.
    5324              :    We assume that VALUE has been folded as much as possible;
    5325              :    therefore, we do not need to check for such things as
    5326              :    arithmetic-combinations of integers.  */
    5327              : tree
    5328   1200586328 : initializer_constant_valid_p (tree value, tree endtype, bool reverse)
    5329              : {
    5330   1200586328 :   tree reloc = initializer_constant_valid_p_1 (value, endtype, NULL);
    5331              : 
    5332              :   /* An absolute value is required with reverse storage order.  */
    5333   1200586328 :   if (reloc
    5334   1177050409 :       && reloc != null_pointer_node
    5335     46089697 :       && reverse
    5336            1 :       && !AGGREGATE_TYPE_P (endtype)
    5337            1 :       && !VECTOR_TYPE_P (endtype))
    5338   1200586328 :     reloc = NULL_TREE;
    5339              : 
    5340   1200586328 :   return reloc;
    5341              : }
    5342              : 
    5343              : /* Return true if VALUE is a valid constant-valued expression
    5344              :    for use in initializing a static bit-field; one that can be
    5345              :    an element of a "constant" initializer.  */
    5346              : 
    5347              : bool
    5348          867 : initializer_constant_valid_for_bitfield_p (const_tree value)
    5349              : {
    5350              :   /* For bitfields we support integer constants or possibly nested aggregates
    5351              :      of such.  */
    5352          867 :   switch (TREE_CODE (value))
    5353              :     {
    5354              :     case CONSTRUCTOR:
    5355              :       {
    5356              :         unsigned HOST_WIDE_INT idx;
    5357              :         const_tree elt;
    5358              : 
    5359          927 :         FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (value), idx, elt)
    5360          681 :           if (!initializer_constant_valid_for_bitfield_p (elt))
    5361              :             return false;
    5362              :         return true;
    5363              :       }
    5364              : 
    5365              :     case INTEGER_CST:
    5366              :     case REAL_CST:
    5367              :       return true;
    5368              : 
    5369            0 :     case VIEW_CONVERT_EXPR:
    5370            0 :     case NON_LVALUE_EXPR:
    5371            0 :       return
    5372            0 :         initializer_constant_valid_for_bitfield_p (TREE_OPERAND (value, 0));
    5373              : 
    5374              :     default:
    5375              :       break;
    5376              :     }
    5377              : 
    5378              :   return false;
    5379              : }
    5380              : 
    5381              : /* Check if a STRING_CST fits into the field.
    5382              :    Tolerate only the case when the NUL termination
    5383              :    does not fit into the field.   */
    5384              : 
    5385              : static bool
    5386      1317139 : check_string_literal (tree string, unsigned HOST_WIDE_INT size)
    5387              : {
    5388      1317139 :   tree type = TREE_TYPE (string);
    5389      1317139 :   tree eltype = TREE_TYPE (type);
    5390      1317139 :   unsigned HOST_WIDE_INT elts = tree_to_uhwi (TYPE_SIZE_UNIT (eltype));
    5391      1317139 :   unsigned HOST_WIDE_INT mem_size = tree_to_uhwi (TYPE_SIZE_UNIT (type));
    5392      1317139 :   int len = TREE_STRING_LENGTH (string);
    5393              : 
    5394      1317139 :   if (elts != 1 && elts != 2 && elts != 4)
    5395              :     return false;
    5396      1317139 :   if (len < 0 || len % elts != 0)
    5397              :     return false;
    5398      1317139 :   if (size < (unsigned)len)
    5399              :     return false;
    5400      1317139 :   if (mem_size != size)
    5401            0 :     return false;
    5402              :   return true;
    5403              : }
    5404              : 
    5405              : /* output_constructor outer state of relevance in recursive calls, typically
    5406              :    for nested aggregate bitfields.  */
    5407              : 
    5408              : struct oc_outer_state {
    5409              :   unsigned int bit_offset;  /* current position in ...  */
    5410              :   int byte;                 /* ... the outer byte buffer.  */
    5411              : };
    5412              : 
    5413              : static unsigned HOST_WIDE_INT
    5414              : output_constructor (tree, unsigned HOST_WIDE_INT, unsigned int, bool,
    5415              :                     oc_outer_state *);
    5416              : 
    5417              : /* Output assembler code for constant EXP, with no label.
    5418              :    This includes the pseudo-op such as ".int" or ".byte", and a newline.
    5419              :    Assumes output_addressed_constants has been done on EXP already.
    5420              : 
    5421              :    Generate at least SIZE bytes of assembler data, padding at the end
    5422              :    with zeros if necessary.  SIZE must always be specified.  The returned
    5423              :    value is the actual number of bytes of assembler data generated, which
    5424              :    may be bigger than SIZE if the object contains a variable length field.
    5425              : 
    5426              :    SIZE is important for structure constructors,
    5427              :    since trailing members may have been omitted from the constructor.
    5428              :    It is also important for initialization of arrays from string constants
    5429              :    since the full length of the string constant might not be wanted.
    5430              :    It is also needed for initialization of unions, where the initializer's
    5431              :    type is just one member, and that may not be as long as the union.
    5432              : 
    5433              :    There a case in which we would fail to output exactly SIZE bytes:
    5434              :    for a structure constructor that wants to produce more than SIZE bytes.
    5435              :    But such constructors will never be generated for any possible input.
    5436              : 
    5437              :    ALIGN is the alignment of the data in bits.
    5438              : 
    5439              :    If REVERSE is true, EXP is output in reverse storage order.  */
    5440              : 
    5441              : static unsigned HOST_WIDE_INT
    5442     17824374 : output_constant (tree exp, unsigned HOST_WIDE_INT size, unsigned int align,
    5443              :                  bool reverse, bool merge_strings)
    5444              : {
    5445     17824374 :   enum tree_code code;
    5446     17824374 :   unsigned HOST_WIDE_INT thissize;
    5447     17824374 :   rtx cst;
    5448              : 
    5449     17824374 :   if (size == 0 || flag_syntax_only)
    5450              :     return size;
    5451              : 
    5452              :   /* See if we're trying to initialize a pointer in a non-default mode
    5453              :      to the address of some declaration somewhere.  If the target says
    5454              :      the mode is valid for pointers, assume the target has a way of
    5455              :      resolving it.  */
    5456     17824140 :   if (TREE_CODE (exp) == NOP_EXPR
    5457          175 :       && POINTER_TYPE_P (TREE_TYPE (exp))
    5458     17824283 :       && targetm.addr_space.valid_pointer_mode
    5459          143 :            (SCALAR_INT_TYPE_MODE (TREE_TYPE (exp)),
    5460          143 :             TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (exp)))))
    5461              :     {
    5462          143 :       tree saved_type = TREE_TYPE (exp);
    5463              : 
    5464              :       /* Peel off any intermediate conversions-to-pointer for valid
    5465              :          pointer modes.  */
    5466          143 :       while (TREE_CODE (exp) == NOP_EXPR
    5467          143 :              && POINTER_TYPE_P (TREE_TYPE (exp))
    5468          429 :              && targetm.addr_space.valid_pointer_mode
    5469          143 :                   (SCALAR_INT_TYPE_MODE (TREE_TYPE (exp)),
    5470          143 :                    TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (exp)))))
    5471          143 :         exp = TREE_OPERAND (exp, 0);
    5472              : 
    5473              :       /* If what we're left with is the address of something, we can
    5474              :          convert the address to the final type and output it that
    5475              :          way.  */
    5476          143 :       if (TREE_CODE (exp) == ADDR_EXPR)
    5477            8 :         exp = build1 (ADDR_EXPR, saved_type, TREE_OPERAND (exp, 0));
    5478              :       /* Likewise for constant ints.  */
    5479          135 :       else if (TREE_CODE (exp) == INTEGER_CST)
    5480          135 :         exp = fold_convert (saved_type, exp);
    5481              : 
    5482              :     }
    5483              : 
    5484              :   /* Eliminate any conversions since we'll be outputting the underlying
    5485              :      constant.  */
    5486     17827409 :   while (CONVERT_EXPR_P (exp)
    5487     17827370 :          || TREE_CODE (exp) == NON_LVALUE_EXPR
    5488     35654811 :          || TREE_CODE (exp) == VIEW_CONVERT_EXPR)
    5489              :     {
    5490         3307 :       HOST_WIDE_INT type_size = int_size_in_bytes (TREE_TYPE (exp));
    5491         3307 :       HOST_WIDE_INT op_size = int_size_in_bytes (TREE_TYPE (TREE_OPERAND (exp, 0)));
    5492              : 
    5493              :       /* Make sure eliminating the conversion is really a no-op, except with
    5494              :          VIEW_CONVERT_EXPRs to allow for wild Ada unchecked conversions and
    5495              :          union types to allow for Ada unchecked unions.  */
    5496         3307 :       if (type_size > op_size
    5497            6 :           && TREE_CODE (exp) != VIEW_CONVERT_EXPR
    5498         3313 :           && TREE_CODE (TREE_TYPE (exp)) != UNION_TYPE)
    5499              :         /* Keep the conversion. */
    5500              :         break;
    5501              :       else
    5502         3301 :         exp = TREE_OPERAND (exp, 0);
    5503              :     }
    5504              : 
    5505     17824140 :   code = TREE_CODE (TREE_TYPE (exp));
    5506     17824140 :   thissize = int_size_in_bytes (TREE_TYPE (exp));
    5507              : 
    5508              :   /* Allow a constructor with no elements for any data type.
    5509              :      This means to fill the space with zeros.  */
    5510     17824140 :   if (TREE_CODE (exp) == CONSTRUCTOR
    5511     17824140 :       && vec_safe_is_empty (CONSTRUCTOR_ELTS (exp)))
    5512              :     {
    5513         3030 :       assemble_zeros (size);
    5514         3030 :       return size;
    5515              :     }
    5516              : 
    5517     17821110 :   if (TREE_CODE (exp) == FDESC_EXPR)
    5518              :     {
    5519              : #ifdef ASM_OUTPUT_FDESC
    5520              :       HOST_WIDE_INT part = tree_to_shwi (TREE_OPERAND (exp, 1));
    5521              :       tree decl = TREE_OPERAND (exp, 0);
    5522              :       ASM_OUTPUT_FDESC (asm_out_file, decl, part);
    5523              : #else
    5524            0 :       gcc_unreachable ();
    5525              : #endif
    5526              :       return size;
    5527              :     }
    5528              : 
    5529              :   /* Now output the underlying data.  If we've handling the padding, return.
    5530              :      Otherwise, break and ensure SIZE is the size written.  */
    5531     17821110 :   switch (code)
    5532              :     {
    5533     12109836 :     case BOOLEAN_TYPE:
    5534     12109836 :     case INTEGER_TYPE:
    5535     12109836 :     case ENUMERAL_TYPE:
    5536     12109836 :     case POINTER_TYPE:
    5537     12109836 :     case REFERENCE_TYPE:
    5538     12109836 :     case OFFSET_TYPE:
    5539     12109836 :     case FIXED_POINT_TYPE:
    5540     12109836 :     case NULLPTR_TYPE:
    5541     12109836 :       cst = expand_expr (exp, NULL_RTX, VOIDmode, EXPAND_INITIALIZER);
    5542     12109836 :       if (reverse)
    5543          558 :         cst = flip_storage_order (TYPE_MODE (TREE_TYPE (exp)), cst);
    5544     12109836 :       if (!assemble_integer (cst, MIN (size, thissize), align, 0))
    5545            0 :         error ("initializer for integer/fixed-point value is too complicated");
    5546              :       break;
    5547              : 
    5548       600974 :     case REAL_TYPE:
    5549       600974 :       gcc_assert (size == thissize);
    5550       600974 :       if (TREE_CODE (exp) != REAL_CST)
    5551            1 :         error ("initializer for floating value is not a floating constant");
    5552              :       else
    5553       600973 :         assemble_real (TREE_REAL_CST (exp),
    5554       600973 :                        SCALAR_FLOAT_TYPE_MODE (TREE_TYPE (exp)),
    5555              :                        align, reverse);
    5556              :       break;
    5557              : 
    5558        12099 :     case COMPLEX_TYPE:
    5559        12099 :       output_constant (TREE_REALPART (exp), thissize / 2, align,
    5560              :                        reverse, false);
    5561        12099 :       output_constant (TREE_IMAGPART (exp), thissize / 2,
    5562              :                        min_align (align, BITS_PER_UNIT * (thissize / 2)),
    5563              :                        reverse, false);
    5564        12099 :       break;
    5565              : 
    5566         8094 :     case BITINT_TYPE:
    5567         8094 :       if (TREE_CODE (exp) != INTEGER_CST)
    5568            0 :         error ("initializer for %<_BitInt(%d)%> value is not an integer "
    5569            0 :                "constant", TYPE_PRECISION (TREE_TYPE (exp)));
    5570              :       else
    5571              :         {
    5572         8094 :           struct bitint_info info;
    5573         8094 :           tree type = TREE_TYPE (exp);
    5574         8094 :           bool ok = targetm.c.bitint_type_info (TYPE_PRECISION (type), &info);
    5575         8094 :           gcc_assert (ok);
    5576         8094 :           scalar_int_mode limb_mode
    5577         8094 :             = as_a <scalar_int_mode> (info.abi_limb_mode);
    5578         8094 :           if (TYPE_PRECISION (type) <= GET_MODE_PRECISION (limb_mode))
    5579              :             {
    5580          444 :               cst = expand_expr (exp, NULL_RTX, VOIDmode, EXPAND_INITIALIZER);
    5581          444 :               if (reverse)
    5582            0 :                 cst = flip_storage_order (TYPE_MODE (TREE_TYPE (exp)), cst);
    5583          444 :               if (!assemble_integer (cst, MIN (size, thissize), align, 0))
    5584            0 :                 error ("initializer for integer/fixed-point value is too "
    5585              :                        "complicated");
    5586          444 :               break;
    5587              :             }
    5588         7650 :           int prec = GET_MODE_PRECISION (limb_mode);
    5589         7650 :           int cnt = CEIL (TYPE_PRECISION (type), prec);
    5590         7650 :           tree limb_type = build_nonstandard_integer_type (prec, 1);
    5591         7650 :           int elt_size = GET_MODE_SIZE (limb_mode);
    5592         7650 :           unsigned int nalign = MIN (align, GET_MODE_ALIGNMENT (limb_mode));
    5593         7650 :           thissize = 0;
    5594         7650 :           if (prec == HOST_BITS_PER_WIDE_INT)
    5595        79137 :             for (int i = 0; i < cnt; i++)
    5596              :               {
    5597        71487 :                 int idx = (info.big_endian ^ reverse) ? cnt - 1 - i : i;
    5598        71487 :                 tree c;
    5599        71487 :                 if (idx >= TREE_INT_CST_EXT_NUNITS (exp))
    5600        16278 :                   c = build_int_cst (limb_type,
    5601        30389 :                                      tree_int_cst_sgn (exp) < 0 ? -1 : 0);
    5602              :                 else
    5603        55209 :                   c = build_int_cst (limb_type,
    5604        55209 :                                      TREE_INT_CST_ELT (exp, idx));
    5605        71487 :                 output_constant (c, elt_size, nalign, reverse, false);
    5606        71487 :                 thissize += elt_size;
    5607              :               }
    5608              :           else
    5609            0 :             for (int i = 0; i < cnt; i++)
    5610              :               {
    5611            0 :                 int idx = (info.big_endian ^ reverse) ? cnt - 1 - i : i;
    5612            0 :                 wide_int w = wi::rshift (wi::to_wide (exp), idx * prec,
    5613            0 :                                          TYPE_SIGN (TREE_TYPE (exp)));
    5614            0 :                 tree c = wide_int_to_tree (limb_type,
    5615            0 :                                            wide_int::from (w, prec, UNSIGNED));
    5616            0 :                 output_constant (c, elt_size, nalign, reverse, false);
    5617            0 :                 thissize += elt_size;
    5618            0 :               }
    5619              :         }
    5620              :       break;
    5621              : 
    5622      1892885 :     case ARRAY_TYPE:
    5623      1892885 :     case VECTOR_TYPE:
    5624      1892885 :       switch (TREE_CODE (exp))
    5625              :         {
    5626       563693 :         case CONSTRUCTOR:
    5627       563693 :           return output_constructor (exp, size, align, reverse, NULL);
    5628      1317139 :         case STRING_CST:
    5629      1317139 :           thissize = (unsigned HOST_WIDE_INT)TREE_STRING_LENGTH (exp);
    5630      1317139 :           if (merge_strings
    5631      1317139 :               && (thissize == 0
    5632       402996 :                   || TREE_STRING_POINTER (exp) [thissize - 1] != '\0'))
    5633        33350 :             thissize++;
    5634      1317139 :           gcc_checking_assert (check_string_literal (exp, size));
    5635      1317139 :           assemble_string (TREE_STRING_POINTER (exp), thissize);
    5636      1317139 :           break;
    5637        12053 :         case VECTOR_CST:
    5638        12053 :           {
    5639        12053 :             scalar_mode inner = SCALAR_TYPE_MODE (TREE_TYPE (TREE_TYPE (exp)));
    5640        12053 :             unsigned int nalign = MIN (align, GET_MODE_ALIGNMENT (inner));
    5641        12053 :             int elt_size = GET_MODE_SIZE (inner);
    5642        12053 :             output_constant (VECTOR_CST_ELT (exp, 0), elt_size, align,
    5643              :                              reverse, false);
    5644        12053 :             thissize = elt_size;
    5645              :             /* Static constants must have a fixed size.  */
    5646        12053 :             unsigned int nunits = VECTOR_CST_NELTS (exp).to_constant ();
    5647        67930 :             for (unsigned int i = 1; i < nunits; i++)
    5648              :               {
    5649        55877 :                 output_constant (VECTOR_CST_ELT (exp, i), elt_size, nalign,
    5650              :                                  reverse, false);
    5651        55877 :                 thissize += elt_size;
    5652              :               }
    5653              :             break;
    5654              :           }
    5655            0 :         default:
    5656            0 :           gcc_unreachable ();
    5657              :         }
    5658              :       break;
    5659              : 
    5660      3197222 :     case RECORD_TYPE:
    5661      3197222 :     case UNION_TYPE:
    5662      3197222 :       gcc_assert (TREE_CODE (exp) == CONSTRUCTOR);
    5663      3197222 :       return output_constructor (exp, size, align, reverse, NULL);
    5664              : 
    5665              :     case ERROR_MARK:
    5666              :       return 0;
    5667              : 
    5668            0 :     default:
    5669            0 :       gcc_unreachable ();
    5670              :     }
    5671              : 
    5672     14060195 :   if (size > thissize)
    5673       715061 :     assemble_zeros (size - thissize);
    5674              : 
    5675              :   return size;
    5676              : }
    5677              : 
    5678              : /* Subroutine of output_constructor, used for computing the size of
    5679              :    arrays of unspecified length.  VAL must be a CONSTRUCTOR of an array
    5680              :    type with an unspecified upper bound.  */
    5681              : 
    5682              : static unsigned HOST_WIDE_INT
    5683         5408 : array_size_for_constructor (tree val)
    5684              : {
    5685         5408 :   tree max_index;
    5686         5408 :   unsigned HOST_WIDE_INT cnt;
    5687         5408 :   tree index, value, tmp;
    5688         5408 :   offset_int i;
    5689              : 
    5690              :   /* This code used to attempt to handle string constants that are not
    5691              :      arrays of single-bytes, but nothing else does, so there's no point in
    5692              :      doing it here.  */
    5693         5408 :   if (TREE_CODE (val) == STRING_CST)
    5694         5238 :     return TREE_STRING_LENGTH (val);
    5695              : 
    5696              :   max_index = NULL_TREE;
    5697          486 :   FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (val), cnt, index, value)
    5698              :     {
    5699          316 :       if (TREE_CODE (index) == RANGE_EXPR)
    5700            0 :         index = TREE_OPERAND (index, 1);
    5701          316 :       if (value && TREE_CODE (value) == RAW_DATA_CST)
    5702            8 :         index = size_binop (PLUS_EXPR, index,
    5703              :                             build_int_cst (TREE_TYPE (index),
    5704              :                                            RAW_DATA_LENGTH (value) - 1));
    5705          316 :       if (max_index == NULL_TREE || tree_int_cst_lt (max_index, index))
    5706              :         max_index = index;
    5707              :     }
    5708              : 
    5709          170 :   if (max_index == NULL_TREE)
    5710              :     return 0;
    5711              : 
    5712              :   /* Compute the total number of array elements.  */
    5713          136 :   tmp = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (val)));
    5714          136 :   i = wi::to_offset (max_index) - wi::to_offset (tmp) + 1;
    5715              : 
    5716              :   /* Multiply by the array element unit size to find number of bytes.  */
    5717          136 :   i *= wi::to_offset (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (val))));
    5718              : 
    5719          136 :   gcc_assert (wi::fits_uhwi_p (i));
    5720          136 :   return i.to_uhwi ();
    5721              : }
    5722              : 
    5723              : /* Other datastructures + helpers for output_constructor.  */
    5724              : 
    5725              : /* output_constructor local state to support interaction with helpers.  */
    5726              : 
    5727              : struct oc_local_state {
    5728              : 
    5729              :   /* Received arguments.  */
    5730              :   tree exp;                     /* Constructor expression.  */
    5731              :   tree type;                    /* Type of constructor expression.  */
    5732              :   unsigned HOST_WIDE_INT size;  /* # bytes to output - pad if necessary.  */
    5733              :   unsigned int align;           /* Known initial alignment.  */
    5734              :   tree min_index;               /* Lower bound if specified for an array.  */
    5735              : 
    5736              :   /* Output processing state.  */
    5737              :   HOST_WIDE_INT total_bytes;  /* # bytes output so far / current position.  */
    5738              :   int byte;                   /* Part of a bitfield byte yet to be output.  */
    5739              :   int last_relative_index;    /* Implicit or explicit index of the last
    5740              :                                  array element output within a bitfield.  */
    5741              :   bool byte_buffer_in_use;    /* Whether BYTE is in use.  */
    5742              :   bool reverse;               /* Whether reverse storage order is in use.  */
    5743              : 
    5744              :   /* Current element.  */
    5745              :   tree field;      /* Current field decl in a record.  */
    5746              :   tree val;        /* Current element value.  */
    5747              :   tree index;      /* Current element index.  */
    5748              : 
    5749              : };
    5750              : 
    5751              : /* Helper for output_constructor.  From the current LOCAL state, output a
    5752              :    RANGE_EXPR element.  */
    5753              : 
    5754              : static void
    5755          776 : output_constructor_array_range (oc_local_state *local)
    5756              : {
    5757              :   /* Perform the index calculation in modulo arithmetic but
    5758              :      sign-extend the result because Ada has negative DECL_FIELD_OFFSETs
    5759              :      but we are using an unsigned sizetype.  */
    5760          776 :   unsigned prec = TYPE_PRECISION (sizetype);
    5761          776 :   offset_int idx = wi::sext (wi::to_offset (TREE_OPERAND (local->index, 0))
    5762         1552 :                              - wi::to_offset (local->min_index), prec);
    5763          776 :   tree valtype = TREE_TYPE (local->val);
    5764          776 :   HOST_WIDE_INT fieldpos
    5765          776 :     = (idx * wi::to_offset (TYPE_SIZE_UNIT (valtype))).to_short_addr ();
    5766              : 
    5767              :   /* Advance to offset of this element.  */
    5768          776 :   if (fieldpos > local->total_bytes)
    5769              :     {
    5770            8 :       assemble_zeros (fieldpos - local->total_bytes);
    5771            8 :       local->total_bytes = fieldpos;
    5772              :     }
    5773              :   else
    5774              :     /* Must not go backwards.  */
    5775          768 :     gcc_assert (fieldpos == local->total_bytes);
    5776              : 
    5777          776 :   unsigned HOST_WIDE_INT fieldsize
    5778          776 :     = int_size_in_bytes (TREE_TYPE (local->type));
    5779              : 
    5780          776 :   HOST_WIDE_INT lo_index
    5781          776 :     = tree_to_shwi (TREE_OPERAND (local->index, 0));
    5782          776 :   HOST_WIDE_INT hi_index
    5783          776 :     = tree_to_shwi (TREE_OPERAND (local->index, 1));
    5784          776 :   HOST_WIDE_INT index;
    5785              : 
    5786          776 :   unsigned int align2
    5787          776 :     = min_align (local->align, fieldsize * BITS_PER_UNIT);
    5788              : 
    5789       274762 :   for (index = lo_index; index <= hi_index; index++)
    5790              :     {
    5791              :       /* Output the element's initial value.  */
    5792       273986 :       if (local->val == NULL_TREE)
    5793            0 :         assemble_zeros (fieldsize);
    5794              :       else
    5795       273986 :         fieldsize = output_constant (local->val, fieldsize, align2,
    5796       273986 :                                      local->reverse, false);
    5797              : 
    5798              :       /* Count its size.  */
    5799       273986 :       local->total_bytes += fieldsize;
    5800              :     }
    5801          776 : }
    5802              : 
    5803              : /* Helper for output_constructor.  From the current LOCAL state, output a
    5804              :    field element that is not true bitfield or part of an outer one.  */
    5805              : 
    5806              : static void
    5807     14320104 : output_constructor_regular_field (oc_local_state *local)
    5808              : {
    5809              :   /* Field size and position.  Since this structure is static, we know the
    5810              :      positions are constant.  */
    5811     14320104 :   unsigned HOST_WIDE_INT fieldsize;
    5812     14320104 :   HOST_WIDE_INT fieldpos;
    5813              : 
    5814     14320104 :   unsigned int align2;
    5815              : 
    5816              :   /* Output any buffered-up bit-fields preceding this element.  */
    5817     14320104 :   if (local->byte_buffer_in_use)
    5818              :     {
    5819          504 :       assemble_integer (GEN_INT (local->byte), 1, BITS_PER_UNIT, 1);
    5820          504 :       local->total_bytes++;
    5821          504 :       local->byte_buffer_in_use = false;
    5822              :     }
    5823              : 
    5824     14320104 :   if (local->index != NULL_TREE)
    5825              :     {
    5826              :       /* Perform the index calculation in modulo arithmetic but
    5827              :          sign-extend the result because Ada has negative DECL_FIELD_OFFSETs
    5828              :          but we are using an unsigned sizetype.  */
    5829      3995611 :       unsigned prec = TYPE_PRECISION (sizetype);
    5830      3995611 :       offset_int idx = wi::sext (wi::to_offset (local->index)
    5831      7991222 :                                  - wi::to_offset (local->min_index), prec);
    5832      3995611 :       fieldpos = (idx * wi::to_offset (TYPE_SIZE_UNIT (TREE_TYPE (local->val))))
    5833      3995611 :         .to_short_addr ();
    5834              :     }
    5835     10324493 :   else if (local->field != NULL_TREE)
    5836      9491336 :     fieldpos = int_byte_position (local->field);
    5837              :   else
    5838              :     fieldpos = 0;
    5839              : 
    5840              :   /* Advance to offset of this element.
    5841              :      Note no alignment needed in an array, since that is guaranteed
    5842              :      if each element has the proper size.  */
    5843     14320104 :   if (local->field != NULL_TREE || local->index != NULL_TREE)
    5844              :     {
    5845     13486947 :       if (fieldpos > local->total_bytes)
    5846              :         {
    5847       178591 :           assemble_zeros (fieldpos - local->total_bytes);
    5848       178591 :           local->total_bytes = fieldpos;
    5849              :         }
    5850              :       else
    5851              :         /* Must not go backwards.  */
    5852     13308356 :         gcc_assert (fieldpos == local->total_bytes);
    5853              :     }
    5854              : 
    5855              :   /* Find the alignment of this element.  */
    5856     14320104 :   align2 = min_align (local->align, BITS_PER_UNIT * fieldpos);
    5857              : 
    5858              :   /* Determine size this element should occupy.  */
    5859     14320104 :   if (local->field)
    5860              :     {
    5861      9491336 :       fieldsize = 0;
    5862              : 
    5863              :       /* If this is an array with an unspecified upper bound,
    5864              :          the initializer determines the size.  */
    5865              :       /* ??? This ought to only checked if DECL_SIZE_UNIT is NULL,
    5866              :          but we cannot do this until the deprecated support for
    5867              :          initializing zero-length array members is removed.  */
    5868      9491336 :       if (TREE_CODE (TREE_TYPE (local->field)) == ARRAY_TYPE
    5869      9491336 :           && (!TYPE_DOMAIN (TREE_TYPE (local->field))
    5870       181060 :               || !TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (local->field)))))
    5871              :         {
    5872         5408 :           unsigned HOST_WIDE_INT fldsize
    5873         5408 :             = array_size_for_constructor (local->val);
    5874         5408 :           fieldsize = int_size_in_bytes (TREE_TYPE (local->val));
    5875              :           /* In most cases fieldsize == fldsize as the size of the initializer
    5876              :              determines how many elements the flexible array member has.  For
    5877              :              C++ fldsize can be smaller though, if the last or several last or
    5878              :              all initializers of the flexible array member have side-effects
    5879              :              and the FE splits them into dynamic initialization.  */
    5880         5408 :           gcc_checking_assert (fieldsize >= fldsize);
    5881              :           /* Given a non-empty initialization, this field had better
    5882              :              be last except in unions.  Given a flexible array member, the next
    5883              :              field on the chain is a TYPE_DECL of the enclosing struct.  */
    5884         5408 :           const_tree next = DECL_CHAIN (local->field);
    5885         5408 :           gcc_assert (!fieldsize
    5886              :                       || !next
    5887              :                       || TREE_CODE (next) != FIELD_DECL
    5888              :                       || TREE_CODE (local->type) == UNION_TYPE);
    5889              :         }
    5890              :       else
    5891      9485928 :         fieldsize = tree_to_uhwi (DECL_SIZE_UNIT (local->field));
    5892              :     }
    5893              :   else
    5894      4828768 :     fieldsize = int_size_in_bytes (TREE_TYPE (local->type));
    5895              : 
    5896              :   /* Output the element's initial value.  */
    5897     14320104 :   if (local->val == NULL_TREE)
    5898            0 :     assemble_zeros (fieldsize);
    5899     14320104 :   else if (local->val && TREE_CODE (local->val) == RAW_DATA_CST)
    5900              :     {
    5901          417 :       fieldsize *= RAW_DATA_LENGTH (local->val);
    5902          417 :       assemble_string (RAW_DATA_POINTER (local->val),
    5903          417 :                        RAW_DATA_LENGTH (local->val));
    5904              :     }
    5905              :   else
    5906     14319687 :     fieldsize = output_constant (local->val, fieldsize, align2,
    5907     14319687 :                                  local->reverse, false);
    5908              : 
    5909              :   /* Count its size.  */
    5910     14320104 :   local->total_bytes += fieldsize;
    5911     14320104 : }
    5912              : 
    5913              : /* Helper for output_constructor.  From the LOCAL state, output an element
    5914              :    that is a true bitfield or part of an outer one.  BIT_OFFSET is the offset
    5915              :    from the start of a possibly ongoing outer byte buffer.  */
    5916              : 
    5917              : static void
    5918         9907 : output_constructor_bitfield (oc_local_state *local, unsigned int bit_offset)
    5919              : {
    5920              :   /* Bit size of this element.  */
    5921         9907 :   HOST_WIDE_INT ebitsize
    5922         9907 :     = (local->field
    5923         9907 :        ? tree_to_uhwi (DECL_SIZE (local->field))
    5924         9907 :        : tree_to_uhwi (TYPE_SIZE (TREE_TYPE (local->type))));
    5925              : 
    5926              :   /* Relative index of this element if this is an array component.  */
    5927         9907 :   HOST_WIDE_INT relative_index
    5928              :     = (local->field
    5929         9907 :        ? 0
    5930            0 :        : (local->index
    5931            0 :           ? tree_to_uhwi (local->index) - tree_to_uhwi (local->min_index)
    5932            0 :           : local->last_relative_index + 1));
    5933              : 
    5934              :   /* Bit position of this element from the start of the containing
    5935              :      constructor.  */
    5936         9907 :   HOST_WIDE_INT constructor_relative_ebitpos
    5937              :     = (local->field
    5938         9907 :        ? int_bit_position (local->field)
    5939            0 :        : ebitsize * relative_index);
    5940              : 
    5941              :   /* Bit position of this element from the start of a possibly ongoing
    5942              :      outer byte buffer.  */
    5943         9907 :   HOST_WIDE_INT byte_relative_ebitpos
    5944         9907 :     = bit_offset + constructor_relative_ebitpos;
    5945              : 
    5946              :   /* From the start of a possibly ongoing outer byte buffer, offsets to
    5947              :      the first bit of this element and to the first bit past the end of
    5948              :      this element.  */
    5949         9907 :   HOST_WIDE_INT next_offset = byte_relative_ebitpos;
    5950         9907 :   HOST_WIDE_INT end_offset = byte_relative_ebitpos + ebitsize;
    5951              : 
    5952         9907 :   local->last_relative_index = relative_index;
    5953              : 
    5954         9907 :   if (local->val == NULL_TREE)
    5955            0 :     local->val = integer_zero_node;
    5956              : 
    5957         9907 :   while (TREE_CODE (local->val) == VIEW_CONVERT_EXPR
    5958         9907 :          || TREE_CODE (local->val) == NON_LVALUE_EXPR)
    5959            0 :     local->val = TREE_OPERAND (local->val, 0);
    5960              : 
    5961         9907 :   if (TREE_CODE (local->val) != INTEGER_CST
    5962            0 :       && TREE_CODE (local->val) != CONSTRUCTOR)
    5963              :     {
    5964            0 :       error ("invalid initial value for member %qE", DECL_NAME (local->field));
    5965            0 :       return;
    5966              :     }
    5967              : 
    5968              :   /* If this field does not start in this (or next) byte, skip some bytes.  */
    5969         9907 :   if (next_offset / BITS_PER_UNIT != local->total_bytes)
    5970              :     {
    5971              :       /* Output remnant of any bit field in previous bytes.  */
    5972         1304 :       if (local->byte_buffer_in_use)
    5973              :         {
    5974         1277 :           assemble_integer (GEN_INT (local->byte), 1, BITS_PER_UNIT, 1);
    5975         1277 :           local->total_bytes++;
    5976         1277 :           local->byte_buffer_in_use = false;
    5977              :         }
    5978              : 
    5979              :       /* If still not at proper byte, advance to there.  */
    5980         1304 :       if (next_offset / BITS_PER_UNIT != local->total_bytes)
    5981              :         {
    5982          118 :           gcc_assert (next_offset / BITS_PER_UNIT >= local->total_bytes);
    5983          118 :           assemble_zeros (next_offset / BITS_PER_UNIT - local->total_bytes);
    5984          118 :           local->total_bytes = next_offset / BITS_PER_UNIT;
    5985              :         }
    5986              :     }
    5987              : 
    5988              :   /* Set up the buffer if necessary.  */
    5989         9907 :   if (!local->byte_buffer_in_use)
    5990              :     {
    5991         4196 :       local->byte = 0;
    5992         4196 :       if (ebitsize > 0)
    5993         4196 :         local->byte_buffer_in_use = true;
    5994              :     }
    5995              : 
    5996              :   /* If this is nested constructor, recurse passing the bit offset and the
    5997              :      pending data, then retrieve the new pending data afterwards.  */
    5998         9907 :   if (TREE_CODE (local->val) == CONSTRUCTOR)
    5999              :     {
    6000            0 :       oc_outer_state temp_state;
    6001            0 :       temp_state.bit_offset = next_offset % BITS_PER_UNIT;
    6002            0 :       temp_state.byte = local->byte;
    6003            0 :       local->total_bytes
    6004            0 :         += output_constructor (local->val, 0, 0, local->reverse, &temp_state);
    6005            0 :       local->byte = temp_state.byte;
    6006            0 :       return;
    6007              :     }
    6008              : 
    6009              :   /* Otherwise, we must split the element into pieces that fall within
    6010              :      separate bytes, and combine each byte with previous or following
    6011              :      bit-fields.  */
    6012        41029 :   while (next_offset < end_offset)
    6013              :     {
    6014        31122 :       int this_time;
    6015        31122 :       int shift;
    6016        31122 :       unsigned HOST_WIDE_INT value;
    6017        31122 :       HOST_WIDE_INT next_byte = next_offset / BITS_PER_UNIT;
    6018        31122 :       HOST_WIDE_INT next_bit = next_offset % BITS_PER_UNIT;
    6019              : 
    6020              :       /* Advance from byte to byte within this element when necessary.  */
    6021        51793 :       while (next_byte != local->total_bytes)
    6022              :         {
    6023        20671 :           assemble_integer (GEN_INT (local->byte), 1, BITS_PER_UNIT, 1);
    6024        20671 :           local->total_bytes++;
    6025        20671 :           local->byte = 0;
    6026              :         }
    6027              : 
    6028              :       /* Number of bits we can process at once (all part of the same byte).  */
    6029        31122 :       this_time = MIN (end_offset - next_offset, BITS_PER_UNIT - next_bit);
    6030        31122 :       if (local->reverse ? !BYTES_BIG_ENDIAN : BYTES_BIG_ENDIAN)
    6031              :         {
    6032              :           /* For big-endian data, take the most significant bits (of the
    6033              :              bits that are significant) first and put them into bytes from
    6034              :              the most significant end.  */
    6035          778 :           shift = end_offset - next_offset - this_time;
    6036              : 
    6037              :           /* Don't try to take a bunch of bits that cross
    6038              :              the word boundary in the INTEGER_CST.  We can
    6039              :              only select bits from one element.  */
    6040          778 :           if ((shift / HOST_BITS_PER_WIDE_INT)
    6041          778 :               != ((shift + this_time - 1) / HOST_BITS_PER_WIDE_INT))
    6042              :             {
    6043            0 :               const int end = shift + this_time - 1;
    6044            0 :               shift = end & -HOST_BITS_PER_WIDE_INT;
    6045            0 :               this_time = end - shift + 1;
    6046              :             }
    6047              : 
    6048              :           /* Now get the bits we want to insert.  */
    6049          778 :           value = wi::extract_uhwi (wi::to_widest (local->val),
    6050              :                                     shift, this_time);
    6051              : 
    6052              :           /* Get the result.  This works only when:
    6053              :              1 <= this_time <= HOST_BITS_PER_WIDE_INT.  */
    6054          778 :           local->byte |= value << (BITS_PER_UNIT - this_time - next_bit);
    6055              :         }
    6056              :       else
    6057              :         {
    6058              :           /* On little-endian machines, take the least significant bits of
    6059              :              the value first and pack them starting at the least significant
    6060              :              bits of the bytes.  */
    6061        30344 :           shift = next_offset - byte_relative_ebitpos;
    6062              : 
    6063              :           /* Don't try to take a bunch of bits that cross
    6064              :              the word boundary in the INTEGER_CST.  We can
    6065              :              only select bits from one element.  */
    6066        30344 :           if ((shift / HOST_BITS_PER_WIDE_INT)
    6067        30344 :               != ((shift + this_time - 1) / HOST_BITS_PER_WIDE_INT))
    6068          544 :             this_time
    6069          544 :               = HOST_BITS_PER_WIDE_INT - (shift & (HOST_BITS_PER_WIDE_INT - 1));
    6070              : 
    6071              :           /* Now get the bits we want to insert.  */
    6072        30344 :           value = wi::extract_uhwi (wi::to_widest (local->val),
    6073              :                                     shift, this_time);
    6074              : 
    6075              :           /* Get the result.  This works only when:
    6076              :              1 <= this_time <= HOST_BITS_PER_WIDE_INT.  */
    6077        30344 :           local->byte |= value << next_bit;
    6078              :         }
    6079              : 
    6080        31122 :       next_offset += this_time;
    6081        31122 :       local->byte_buffer_in_use = true;
    6082              :     }
    6083              : }
    6084              : 
    6085              : /* Subroutine of output_constant, used for CONSTRUCTORs (aggregate constants).
    6086              :    Generate at least SIZE bytes, padding if necessary.  OUTER designates the
    6087              :    caller output state of relevance in recursive invocations.  */
    6088              : 
    6089              : static unsigned HOST_WIDE_INT
    6090      3760915 : output_constructor (tree exp, unsigned HOST_WIDE_INT size, unsigned int align,
    6091              :                     bool reverse, oc_outer_state *outer)
    6092              : {
    6093      3760915 :   unsigned HOST_WIDE_INT cnt;
    6094      3760915 :   constructor_elt *ce;
    6095      3760915 :   oc_local_state local;
    6096              : 
    6097              :   /* Setup our local state to communicate with helpers.  */
    6098      3760915 :   local.exp = exp;
    6099      3760915 :   local.type = TREE_TYPE (exp);
    6100      3760915 :   local.size = size;
    6101      3760915 :   local.align = align;
    6102      3760915 :   if (TREE_CODE (local.type) == ARRAY_TYPE && TYPE_DOMAIN (local.type))
    6103       563693 :     local.min_index = TYPE_MIN_VALUE (TYPE_DOMAIN (local.type));
    6104              :   else
    6105      3197222 :     local.min_index = integer_zero_node;
    6106              : 
    6107      3760915 :   local.total_bytes = 0;
    6108      3760915 :   local.byte_buffer_in_use = outer != NULL;
    6109      3760915 :   local.byte = outer ? outer->byte : 0;
    6110      3760915 :   local.last_relative_index = -1;
    6111              :   /* The storage order is specified for every aggregate type.  */
    6112      3760915 :   if (AGGREGATE_TYPE_P (local.type))
    6113      3760915 :     local.reverse = TYPE_REVERSE_STORAGE_ORDER (local.type);
    6114              :   else
    6115            0 :     local.reverse = reverse;
    6116              : 
    6117      3760915 :   gcc_assert (HOST_BITS_PER_WIDE_INT >= BITS_PER_UNIT);
    6118              : 
    6119              :   /* As CE goes through the elements of the constant, FIELD goes through the
    6120              :      structure fields if the constant is a structure.  If the constant is a
    6121              :      union, we override this by getting the field from the TREE_LIST element.
    6122              :      But the constant could also be an array.  Then FIELD is zero.
    6123              : 
    6124              :      There is always a maximum of one element in the chain LINK for unions
    6125              :      (even if the initializer in a source program incorrectly contains
    6126              :      more one).  */
    6127              : 
    6128      3760915 :   if (TREE_CODE (local.type) == RECORD_TYPE)
    6129      3179522 :     local.field = TYPE_FIELDS (local.type);
    6130              :   else
    6131       581393 :     local.field = NULL_TREE;
    6132              : 
    6133              :   for (cnt = 0;
    6134     18091702 :        vec_safe_iterate (CONSTRUCTOR_ELTS (exp), cnt, &ce);
    6135     14330787 :        cnt++, local.field = local.field ? DECL_CHAIN (local.field) : 0)
    6136              :     {
    6137     14330787 :       local.val = ce->value;
    6138     14330787 :       local.index = NULL_TREE;
    6139              : 
    6140              :       /* The element in a union constructor specifies the proper field
    6141              :          or index.  */
    6142     14330787 :       if (RECORD_OR_UNION_TYPE_P (local.type) && ce->index != NULL_TREE)
    6143      9306308 :         local.field = ce->index;
    6144              : 
    6145      5024479 :       else if (TREE_CODE (local.type) == ARRAY_TYPE)
    6146      4829544 :         local.index = ce->index;
    6147              : 
    6148     14330787 :       if (local.field && flag_verbose_asm)
    6149            0 :         fprintf (asm_out_file, "%s %s:\n",
    6150              :                  ASM_COMMENT_START,
    6151            0 :                  DECL_NAME (local.field)
    6152            0 :                  ? IDENTIFIER_POINTER (DECL_NAME (local.field))
    6153              :                  : "<anonymous>");
    6154              : 
    6155              :       /* Eliminate the marker that makes a cast not be an lvalue.  */
    6156     14330787 :       if (local.val != NULL_TREE)
    6157     14330787 :         STRIP_NOPS (local.val);
    6158              : 
    6159              :       /* Output the current element, using the appropriate helper ...  */
    6160              : 
    6161              :       /* For an array slice not part of an outer bitfield.  */
    6162     14330787 :       if (!outer
    6163     14330787 :           && local.index != NULL_TREE
    6164      3996387 :           && TREE_CODE (local.index) == RANGE_EXPR)
    6165          776 :         output_constructor_array_range (&local);
    6166              : 
    6167              :       /* For a field that is neither a true bitfield nor part of an outer one,
    6168              :          known to be at least byte aligned and multiple-of-bytes long.  */
    6169     14330011 :       else if (!outer
    6170     14330011 :                && (local.field == NULL_TREE
    6171      9501243 :                    || !CONSTRUCTOR_BITFIELD_P (local.field)))
    6172     14320104 :         output_constructor_regular_field (&local);
    6173              : 
    6174              :       /* For a true bitfield or part of an outer one.  Only INTEGER_CSTs are
    6175              :          supported for scalar fields, so we may need to convert first.  */
    6176              :       else
    6177              :         {
    6178         9907 :           if (TREE_CODE (local.val) == REAL_CST)
    6179            0 :             local.val
    6180            0 :               = fold_unary (VIEW_CONVERT_EXPR,
    6181              :                             build_nonstandard_integer_type
    6182              :                             (TYPE_PRECISION (TREE_TYPE (local.val)), 0),
    6183              :                             local.val);
    6184         9907 :           output_constructor_bitfield (&local, outer ? outer->bit_offset : 0);
    6185              :         }
    6186              :     }
    6187              : 
    6188              :   /* If we are not at toplevel, save the pending data for our caller.
    6189              :      Otherwise output the pending data and padding zeros as needed. */
    6190      3760915 :   if (outer)
    6191            0 :     outer->byte = local.byte;
    6192              :   else
    6193              :     {
    6194      3760915 :       if (local.byte_buffer_in_use)
    6195              :         {
    6196         2415 :           assemble_integer (GEN_INT (local.byte), 1, BITS_PER_UNIT, 1);
    6197         2415 :           local.total_bytes++;
    6198              :         }
    6199              : 
    6200      3760915 :       if ((unsigned HOST_WIDE_INT)local.total_bytes < local.size)
    6201              :         {
    6202        52564 :           assemble_zeros (local.size - local.total_bytes);
    6203        52564 :           local.total_bytes = local.size;
    6204              :         }
    6205              :     }
    6206              : 
    6207      3760915 :   return local.total_bytes;
    6208              : }
    6209              : 
    6210              : /* Mark DECL as weak.  */
    6211              : 
    6212              : static void
    6213       116069 : mark_weak (tree decl)
    6214              : {
    6215       116069 :   if (DECL_WEAK (decl))
    6216              :     return;
    6217              : 
    6218       116055 :   struct symtab_node *n = symtab_node::get (decl);
    6219       116055 :   if (n && n->refuse_visibility_changes)
    6220            3 :     error ("%qD declared weak after being used", decl);
    6221       116055 :   DECL_WEAK (decl) = 1;
    6222              : 
    6223       116055 :   if (DECL_RTL_SET_P (decl)
    6224            0 :       && MEM_P (DECL_RTL (decl))
    6225            0 :       && XEXP (DECL_RTL (decl), 0)
    6226       116055 :       && GET_CODE (XEXP (DECL_RTL (decl), 0)) == SYMBOL_REF)
    6227            0 :     SYMBOL_REF_WEAK (XEXP (DECL_RTL (decl), 0)) = 1;
    6228              : }
    6229              : 
    6230              : /* Merge weak status between NEWDECL and OLDDECL.  */
    6231              : 
    6232              : void
    6233     20226704 : merge_weak (tree newdecl, tree olddecl)
    6234              : {
    6235     20226704 :   if (DECL_WEAK (newdecl) == DECL_WEAK (olddecl))
    6236              :     {
    6237     20217227 :       if (DECL_WEAK (newdecl) && TARGET_SUPPORTS_WEAK)
    6238              :         {
    6239              :           tree *pwd;
    6240              :           /* We put the NEWDECL on the weak_decls list at some point
    6241              :              and OLDDECL as well.  Keep just OLDDECL on the list.  */
    6242          158 :           for (pwd = &weak_decls; *pwd; pwd = &TREE_CHAIN (*pwd))
    6243            0 :             if (TREE_VALUE (*pwd) == newdecl)
    6244              :               {
    6245            0 :                 *pwd = TREE_CHAIN (*pwd);
    6246            0 :                 break;
    6247              :               }
    6248              :         }
    6249     20217227 :       return;
    6250              :     }
    6251              : 
    6252         9477 :   if (DECL_WEAK (newdecl))
    6253              :     {
    6254          295 :       tree wd;
    6255              : 
    6256              :       /* NEWDECL is weak, but OLDDECL is not.  */
    6257              : 
    6258              :       /* If we already output the OLDDECL, we're in trouble; we can't
    6259              :          go back and make it weak.  This should never happen in
    6260              :          unit-at-a-time compilation.  */
    6261          295 :       gcc_assert (!TREE_ASM_WRITTEN (olddecl));
    6262              : 
    6263              :       /* If we've already generated rtl referencing OLDDECL, we may
    6264              :          have done so in a way that will not function properly with
    6265              :          a weak symbol.  Again in unit-at-a-time this should be
    6266              :          impossible.  */
    6267          295 :       gcc_assert (!TREE_USED (olddecl)
    6268              :                   || !TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (olddecl)));
    6269              : 
    6270              :       /* PR 49899: You cannot convert a static function into a weak, public function.  */
    6271          295 :       if (! TREE_PUBLIC (olddecl) && TREE_PUBLIC (newdecl))
    6272            1 :         error ("weak declaration of %q+D being applied to a already "
    6273              :                "existing, static definition", newdecl);
    6274              : 
    6275          295 :       if (TARGET_SUPPORTS_WEAK)
    6276              :         {
    6277              :           /* We put the NEWDECL on the weak_decls list at some point.
    6278              :              Replace it with the OLDDECL.  */
    6279          295 :           for (wd = weak_decls; wd; wd = TREE_CHAIN (wd))
    6280            0 :             if (TREE_VALUE (wd) == newdecl)
    6281              :               {
    6282            0 :                 TREE_VALUE (wd) = olddecl;
    6283            0 :                 break;
    6284              :               }
    6285              :           /* We may not find the entry on the list.  If NEWDECL is a
    6286              :              weak alias, then we will have already called
    6287              :              globalize_decl to remove the entry; in that case, we do
    6288              :              not need to do anything.  */
    6289              :         }
    6290              : 
    6291              :       /* Make the OLDDECL weak; it's OLDDECL that we'll be keeping.  */
    6292          295 :       mark_weak (olddecl);
    6293              :     }
    6294              :   else
    6295              :     /* OLDDECL was weak, but NEWDECL was not explicitly marked as
    6296              :        weak.  Just update NEWDECL to indicate that it's weak too.  */
    6297         9182 :     mark_weak (newdecl);
    6298              : }
    6299              : 
    6300              : /* Declare DECL to be a weak symbol.  */
    6301              : 
    6302              : void
    6303       106597 : declare_weak (tree decl)
    6304              : {
    6305              :   /* With -fsyntax-only, TREE_ASM_WRITTEN might be set on certain function
    6306              :      decls earlier than normally, but as with -fsyntax-only nothing is really
    6307              :      emitted, there is no harm in marking it weak later.  */
    6308       106597 :   gcc_assert (TREE_CODE (decl) != FUNCTION_DECL
    6309              :               || !TREE_ASM_WRITTEN (decl)
    6310              :               || flag_syntax_only);
    6311       106597 :   if (! TREE_PUBLIC (decl))
    6312              :     {
    6313            5 :       error ("weak declaration of %q+D must be public", decl);
    6314            5 :       return;
    6315              :     }
    6316       106592 :   else if (!TARGET_SUPPORTS_WEAK)
    6317              :     warning (0, "weak declaration of %q+D not supported", decl);
    6318              : 
    6319       106592 :   mark_weak (decl);
    6320       106592 :   if (!lookup_attribute ("weak", DECL_ATTRIBUTES (decl)))
    6321       106578 :     DECL_ATTRIBUTES (decl)
    6322       213156 :       = tree_cons (get_identifier ("weak"), NULL, DECL_ATTRIBUTES (decl));
    6323              : }
    6324              : 
    6325              : static void
    6326         1005 : weak_finish_1 (tree decl)
    6327              : {
    6328              : #if defined (ASM_WEAKEN_DECL) || defined (ASM_WEAKEN_LABEL)
    6329         1005 :   const char *const name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
    6330              : #endif
    6331              : 
    6332         1005 :   if (! TREE_USED (decl))
    6333              :     return;
    6334              : 
    6335              : #ifdef ASM_WEAKEN_DECL
    6336              :   ASM_WEAKEN_DECL (asm_out_file, decl, name, NULL);
    6337              : #else
    6338              : #ifdef ASM_WEAKEN_LABEL
    6339         1005 :   ASM_WEAKEN_LABEL (asm_out_file, name);
    6340              : #else
    6341              : #ifdef ASM_OUTPUT_WEAK_ALIAS
    6342              :   {
    6343              :     static bool warn_once = 0;
    6344              :     if (! warn_once)
    6345              :       {
    6346              :         warning (0, "only weak aliases are supported in this configuration");
    6347              :         warn_once = 1;
    6348              :       }
    6349              :     return;
    6350              :   }
    6351              : #endif
    6352              : #endif
    6353              : #endif
    6354              : }
    6355              : 
    6356              : /* Fiven an assembly name, find the decl it is associated with.  */
    6357              : static tree
    6358            0 : find_decl (tree target)
    6359              : {
    6360            0 :   symtab_node *node = symtab_node::get_for_asmname (target);
    6361            0 :   if (node)
    6362            0 :     return node->decl;
    6363              :   return NULL_TREE;
    6364              : }
    6365              : 
    6366              : /* This TREE_LIST contains weakref targets.  */
    6367              : 
    6368              : static GTY(()) tree weakref_targets;
    6369              : 
    6370              : /* Emit any pending weak declarations.  */
    6371              : 
    6372              : void
    6373       230133 : weak_finish (void)
    6374              : {
    6375       230133 :   tree t;
    6376              : 
    6377       230233 :   for (t = weakref_targets; t; t = TREE_CHAIN (t))
    6378              :     {
    6379          100 :       tree alias_decl = TREE_PURPOSE (t);
    6380          100 :       tree target = ultimate_transparent_alias_target (&TREE_VALUE (t));
    6381              : 
    6382          100 :       if (! TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (alias_decl))
    6383          200 :          || TREE_SYMBOL_REFERENCED (target))
    6384              :         /* Remove alias_decl from the weak list, but leave entries for
    6385              :            the target alone.  */
    6386              :         target = NULL_TREE;
    6387              : #ifndef ASM_OUTPUT_WEAKREF
    6388              :       else if (! TREE_SYMBOL_REFERENCED (target))
    6389              :         {
    6390              :           /* Use ASM_WEAKEN_LABEL only if ASM_WEAKEN_DECL is not
    6391              :              defined, otherwise we and weak_finish_1 would use
    6392              :              different macros.  */
    6393              : # if defined ASM_WEAKEN_LABEL && ! defined ASM_WEAKEN_DECL
    6394              :           ASM_WEAKEN_LABEL (asm_out_file, IDENTIFIER_POINTER (target));
    6395              : # else
    6396              :           tree decl = find_decl (target);
    6397              : 
    6398              :           if (! decl)
    6399              :             {
    6400              :               decl = build_decl (DECL_SOURCE_LOCATION (alias_decl),
    6401              :                                  TREE_CODE (alias_decl), target,
    6402              :                                  TREE_TYPE (alias_decl));
    6403              : 
    6404              :               DECL_EXTERNAL (decl) = 1;
    6405              :               TREE_PUBLIC (decl) = 1;
    6406              :               DECL_ARTIFICIAL (decl) = 1;
    6407              :               TREE_NOTHROW (decl) = TREE_NOTHROW (alias_decl);
    6408              :               TREE_USED (decl) = 1;
    6409              :             }
    6410              : 
    6411              :           weak_finish_1 (decl);
    6412              : # endif
    6413              :         }
    6414              : #endif
    6415              : 
    6416          100 :       {
    6417          100 :         tree *p;
    6418          100 :         tree t2;
    6419              : 
    6420              :         /* Remove the alias and the target from the pending weak list
    6421              :            so that we do not emit any .weak directives for the former,
    6422              :            nor multiple .weak directives for the latter.  */
    6423          168 :         for (p = &weak_decls; (t2 = *p) ; )
    6424              :           {
    6425           68 :             if (TREE_VALUE (t2) == alias_decl
    6426           68 :                 || target == DECL_ASSEMBLER_NAME (TREE_VALUE (t2)))
    6427            0 :               *p = TREE_CHAIN (t2);
    6428              :             else
    6429           68 :               p = &TREE_CHAIN (t2);
    6430              :           }
    6431              : 
    6432              :         /* Remove other weakrefs to the same target, to speed things up.  */
    6433          212 :         for (p = &TREE_CHAIN (t); (t2 = *p) ; )
    6434              :           {
    6435          112 :             if (target == ultimate_transparent_alias_target (&TREE_VALUE (t2)))
    6436            0 :               *p = TREE_CHAIN (t2);
    6437              :             else
    6438          112 :               p = &TREE_CHAIN (t2);
    6439              :           }
    6440              :       }
    6441              :     }
    6442              : 
    6443       231138 :   for (t = weak_decls; t; t = TREE_CHAIN (t))
    6444              :     {
    6445         1005 :       tree decl = TREE_VALUE (t);
    6446              : 
    6447         1005 :       weak_finish_1 (decl);
    6448              :     }
    6449       230133 : }
    6450              : 
    6451              : /* Emit the assembly bits to indicate that DECL is globally visible.  */
    6452              : 
    6453              : static void
    6454      2656968 : globalize_decl (tree decl)
    6455              : {
    6456              : 
    6457              : #if defined (ASM_WEAKEN_LABEL) || defined (ASM_WEAKEN_DECL)
    6458      2656968 :   if (DECL_WEAK (decl))
    6459              :     {
    6460       531577 :       const char *name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
    6461       531577 :       tree *p, t;
    6462              : 
    6463              : #ifdef ASM_WEAKEN_DECL
    6464              :       ASM_WEAKEN_DECL (asm_out_file, decl, name, 0);
    6465              : #else
    6466       531577 :       ASM_WEAKEN_LABEL (asm_out_file, name);
    6467              : #endif
    6468              : 
    6469              :       /* Remove this function from the pending weak list so that
    6470              :          we do not emit multiple .weak directives for it.  */
    6471      1067149 :       for (p = &weak_decls; (t = *p) ; )
    6472              :         {
    6473         3995 :           if (DECL_ASSEMBLER_NAME (decl) == DECL_ASSEMBLER_NAME (TREE_VALUE (t)))
    6474            0 :             *p = TREE_CHAIN (t);
    6475              :           else
    6476         3995 :             p = &TREE_CHAIN (t);
    6477              :         }
    6478              : 
    6479              :       /* Remove weakrefs to the same target from the pending weakref
    6480              :          list, for the same reason.  */
    6481       531577 :       for (p = &weakref_targets; (t = *p) ; )
    6482              :         {
    6483            0 :           if (DECL_ASSEMBLER_NAME (decl)
    6484            0 :               == ultimate_transparent_alias_target (&TREE_VALUE (t)))
    6485            0 :             *p = TREE_CHAIN (t);
    6486              :           else
    6487            0 :             p = &TREE_CHAIN (t);
    6488              :         }
    6489              : 
    6490              :       return;
    6491              :     }
    6492              : #endif
    6493              : 
    6494      2125391 :   targetm.asm_out.globalize_decl_name (asm_out_file, decl);
    6495              : }
    6496              : 
    6497              : vec<alias_pair, va_gc> *alias_pairs;
    6498              : 
    6499              : /* Output the assembler code for a define (equate) using ASM_OUTPUT_DEF
    6500              :    or ASM_OUTPUT_DEF_FROM_DECLS.  The function defines the symbol whose
    6501              :    tree node is DECL to have the value of the tree node TARGET.  */
    6502              : 
    6503              : void
    6504        65489 : do_assemble_alias (tree decl, tree target)
    6505              : {
    6506        65489 :   tree id;
    6507              : 
    6508              :   /* Emulated TLS had better not get this var.  */
    6509        65489 :   gcc_assert (!(!targetm.have_tls
    6510              :                 && VAR_P (decl)
    6511              :                 && DECL_THREAD_LOCAL_P (decl)));
    6512              : 
    6513        65489 :   if (TREE_ASM_WRITTEN (decl))
    6514          127 :     return;
    6515              : 
    6516        65489 :   id = DECL_ASSEMBLER_NAME (decl);
    6517        65489 :   ultimate_transparent_alias_target (&id);
    6518        65489 :   ultimate_transparent_alias_target (&target);
    6519              : 
    6520              :   /* We must force creation of DECL_RTL for debug info generation, even though
    6521              :      we don't use it here.  */
    6522        65489 :   make_decl_rtl (decl);
    6523              : 
    6524        65489 :   TREE_ASM_WRITTEN (decl) = 1;
    6525        65489 :   TREE_ASM_WRITTEN (DECL_ASSEMBLER_NAME (decl)) = 1;
    6526        65489 :   TREE_ASM_WRITTEN (id) = 1;
    6527              : 
    6528        65489 :   if (lookup_attribute ("weakref", DECL_ATTRIBUTES (decl)))
    6529              :     {
    6530          127 :       if (!TREE_SYMBOL_REFERENCED (target))
    6531          100 :         weakref_targets = tree_cons (decl, target, weakref_targets);
    6532              : 
    6533              : #ifdef ASM_OUTPUT_WEAKREF
    6534          127 :       ASM_OUTPUT_WEAKREF (asm_out_file, decl,
    6535              :                           IDENTIFIER_POINTER (id),
    6536              :                           IDENTIFIER_POINTER (target));
    6537              : #else
    6538              :       if (!TARGET_SUPPORTS_WEAK)
    6539              :         {
    6540              :           error_at (DECL_SOURCE_LOCATION (decl),
    6541              :                     "%qs is not supported in this configuration", "weakref ");
    6542              :           return;
    6543              :         }
    6544              : #endif
    6545          127 :       return;
    6546              :     }
    6547              : 
    6548              : #ifdef ASM_OUTPUT_DEF
    6549        65362 :   tree orig_decl = decl;
    6550              : 
    6551              :   /* Make name accessible from other files, if appropriate.  */
    6552              : 
    6553        65362 :   if (TREE_PUBLIC (decl) || TREE_PUBLIC (orig_decl))
    6554              :     {
    6555        46149 :       globalize_decl (decl);
    6556        46149 :       maybe_assemble_visibility (decl);
    6557              :     }
    6558        65362 :   if (TREE_CODE (decl) == FUNCTION_DECL
    6559        65362 :       && cgraph_node::get (decl)->ifunc_resolver)
    6560              :     {
    6561              : #if defined (ASM_OUTPUT_TYPE_DIRECTIVE)
    6562          283 :       if (targetm.has_ifunc_p ())
    6563          283 :         ASM_OUTPUT_TYPE_DIRECTIVE
    6564              :           (asm_out_file, IDENTIFIER_POINTER (id),
    6565              :            IFUNC_ASM_TYPE);
    6566              :       else
    6567              : #endif
    6568            0 :         error_at (DECL_SOURCE_LOCATION (decl),
    6569              :                   "%qs is not supported on this target", "ifunc");
    6570              :     }
    6571              : 
    6572              : # ifdef ASM_OUTPUT_DEF_FROM_DECLS
    6573              :   ASM_OUTPUT_DEF_FROM_DECLS (asm_out_file, decl, target);
    6574              : # else
    6575        65362 :   ASM_OUTPUT_DEF (asm_out_file,
    6576              :                   IDENTIFIER_POINTER (id),
    6577              :                   IDENTIFIER_POINTER (target));
    6578              : # endif
    6579              :   /* If symbol aliases aren't actually supported...  */
    6580        65362 :   if (!TARGET_SUPPORTS_ALIASES
    6581              : # ifdef ACCEL_COMPILER
    6582              :       /* ..., and unless special-cased...  */
    6583              :       && !lookup_attribute ("symbol alias handled", DECL_ATTRIBUTES (decl))
    6584              : # endif
    6585              :       )
    6586              :     /* ..., 'ASM_OUTPUT_DEF{,_FROM_DECLS}' better have raised an error.  */
    6587              :     gcc_checking_assert (seen_error ());
    6588              : #elif defined (ASM_OUTPUT_WEAK_ALIAS) || defined (ASM_WEAKEN_DECL)
    6589              :   {
    6590              :     const char *name;
    6591              :     tree *p, t;
    6592              : 
    6593              :     name = IDENTIFIER_POINTER (id);
    6594              : # ifdef ASM_WEAKEN_DECL
    6595              :     ASM_WEAKEN_DECL (asm_out_file, decl, name, IDENTIFIER_POINTER (target));
    6596              : # else
    6597              :     ASM_OUTPUT_WEAK_ALIAS (asm_out_file, name, IDENTIFIER_POINTER (target));
    6598              : # endif
    6599              :     /* Remove this function from the pending weak list so that
    6600              :        we do not emit multiple .weak directives for it.  */
    6601              :     for (p = &weak_decls; (t = *p) ; )
    6602              :       if (DECL_ASSEMBLER_NAME (decl) == DECL_ASSEMBLER_NAME (TREE_VALUE (t))
    6603              :           || id == DECL_ASSEMBLER_NAME (TREE_VALUE (t)))
    6604              :         *p = TREE_CHAIN (t);
    6605              :       else
    6606              :         p = &TREE_CHAIN (t);
    6607              : 
    6608              :     /* Remove weakrefs to the same target from the pending weakref
    6609              :        list, for the same reason.  */
    6610              :     for (p = &weakref_targets; (t = *p) ; )
    6611              :       {
    6612              :         if (id == ultimate_transparent_alias_target (&TREE_VALUE (t)))
    6613              :           *p = TREE_CHAIN (t);
    6614              :         else
    6615              :           p = &TREE_CHAIN (t);
    6616              :       }
    6617              :   }
    6618              : #endif
    6619              : }
    6620              : 
    6621              : /* Output .symver directive.  */
    6622              : 
    6623              : void
    6624            2 : do_assemble_symver (tree decl, tree target)
    6625              : {
    6626            2 :   tree id = DECL_ASSEMBLER_NAME (decl);
    6627            2 :   ultimate_transparent_alias_target (&id);
    6628            2 :   ultimate_transparent_alias_target (&target);
    6629              : #ifdef ASM_OUTPUT_SYMVER_DIRECTIVE
    6630            2 :   ASM_OUTPUT_SYMVER_DIRECTIVE (asm_out_file,
    6631              :                                IDENTIFIER_POINTER (target),
    6632              :                                IDENTIFIER_POINTER (id));
    6633              : #else
    6634              :   error ("symver is only supported on ELF platforms");
    6635              : #endif
    6636            2 : }
    6637              : 
    6638              : /* Emit an assembler directive to make the symbol for DECL an alias to
    6639              :    the symbol for TARGET.  */
    6640              : 
    6641              : void
    6642         5685 : assemble_alias (tree decl, tree target)
    6643              : {
    6644         5685 :   tree target_decl;
    6645              : 
    6646         5685 :   if (lookup_attribute ("weakref", DECL_ATTRIBUTES (decl)))
    6647              :     {
    6648          457 :       tree alias = DECL_ASSEMBLER_NAME (decl);
    6649              : 
    6650          457 :       ultimate_transparent_alias_target (&target);
    6651              : 
    6652          457 :       if (alias == target)
    6653            0 :         error ("%qs symbol %q+D ultimately targets itself", "weakref", decl);
    6654          457 :       if (TREE_PUBLIC (decl))
    6655            1 :         error ("%qs symbol %q+D must have static linkage", "weakref", decl);
    6656              :     }
    6657              :   else if (!TARGET_SUPPORTS_ALIASES)
    6658              :     {
    6659              : # if !defined(ASM_OUTPUT_WEAK_ALIAS) && !defined (ASM_WEAKEN_DECL)
    6660              :       error_at (DECL_SOURCE_LOCATION (decl),
    6661              :                 "alias definitions not supported in this configuration");
    6662              :       TREE_ASM_WRITTEN (decl) = 1;
    6663              :       return;
    6664              : # else
    6665              :       if (!DECL_WEAK (decl))
    6666              :         {
    6667              :           /* NB: ifunc_resolver isn't set when an error is detected.  */
    6668              :           if (TREE_CODE (decl) == FUNCTION_DECL
    6669              :               && lookup_attribute ("ifunc", DECL_ATTRIBUTES (decl)))
    6670              :             error_at (DECL_SOURCE_LOCATION (decl),
    6671              :                       "%qs is not supported in this configuration", "ifunc");
    6672              :           else
    6673              :             error_at (DECL_SOURCE_LOCATION (decl),
    6674              :                       "only weak aliases are supported in this configuration");
    6675              :           TREE_ASM_WRITTEN (decl) = 1;
    6676              :           return;
    6677              :         }
    6678              : # endif
    6679              :       gcc_unreachable ();
    6680              :     }
    6681         5685 :   TREE_USED (decl) = 1;
    6682              : 
    6683              :   /* Allow aliases to aliases.  */
    6684         5685 :   if (TREE_CODE (decl) == FUNCTION_DECL)
    6685         5490 :     cgraph_node::get_create (decl)->alias = true;
    6686              :   else
    6687          195 :     varpool_node::get_create (decl)->alias = true;
    6688              : 
    6689              :   /* If the target has already been emitted, we don't have to queue the
    6690              :      alias.  This saves a tad of memory.  */
    6691         5685 :   if (symtab->global_info_ready)
    6692            0 :     target_decl = find_decl (target);
    6693              :   else
    6694              :     target_decl= NULL;
    6695            0 :   if ((target_decl && TREE_ASM_WRITTEN (target_decl))
    6696         5685 :       || symtab->state >= EXPANSION)
    6697            0 :     do_assemble_alias (decl, target);
    6698              :   else
    6699              :     {
    6700         5685 :       alias_pair p = {decl, target};
    6701         5685 :       vec_safe_push (alias_pairs, p);
    6702              :     }
    6703              : }
    6704              : 
    6705              : /* Record and output a table of translations from original function
    6706              :    to its transaction aware clone.  Note that tm_pure functions are
    6707              :    considered to be their own clone.  */
    6708              : 
    6709              : struct tm_clone_hasher : ggc_cache_ptr_hash<tree_map>
    6710              : {
    6711          210 :   static hashval_t hash (tree_map *m) { return tree_map_hash (m); }
    6712          244 :   static bool equal (tree_map *a, tree_map *b) { return tree_map_eq (a, b); }
    6713              : 
    6714              :   static int
    6715            0 :   keep_cache_entry (tree_map *&e)
    6716              :   {
    6717            0 :     return ggc_marked_p (e->base.from);
    6718              :   }
    6719              : };
    6720              : 
    6721              : static GTY((cache)) hash_table<tm_clone_hasher> *tm_clone_hash;
    6722              : 
    6723              : void
    6724          463 : record_tm_clone_pair (tree o, tree n)
    6725              : {
    6726          463 :   struct tree_map **slot, *h;
    6727              : 
    6728          463 :   if (tm_clone_hash == NULL)
    6729          165 :     tm_clone_hash = hash_table<tm_clone_hasher>::create_ggc (32);
    6730              : 
    6731          463 :   h = ggc_alloc<tree_map> ();
    6732          463 :   h->hash = htab_hash_pointer (o);
    6733          463 :   h->base.from = o;
    6734          463 :   h->to = n;
    6735              : 
    6736          463 :   slot = tm_clone_hash->find_slot_with_hash (h, h->hash, INSERT);
    6737          463 :   *slot = h;
    6738          463 : }
    6739              : 
    6740              : tree
    6741            7 : get_tm_clone_pair (tree o)
    6742              : {
    6743            7 :   if (tm_clone_hash)
    6744              :     {
    6745            7 :       struct tree_map *h, in;
    6746              : 
    6747            7 :       in.base.from = o;
    6748            7 :       in.hash = htab_hash_pointer (o);
    6749            7 :       h = tm_clone_hash->find_with_hash (&in, in.hash);
    6750            7 :       if (h)
    6751            0 :         return h->to;
    6752              :     }
    6753              :   return NULL_TREE;
    6754              : }
    6755              : 
    6756              : struct tm_alias_pair
    6757              : {
    6758              :   unsigned int uid;
    6759              :   tree from;
    6760              :   tree to;
    6761              : };
    6762              : 
    6763              : 
    6764              : /* Dump the actual pairs to the .tm_clone_table section.  */
    6765              : 
    6766              : static void
    6767          148 : dump_tm_clone_pairs (vec<tm_alias_pair> tm_alias_pairs)
    6768              : {
    6769          148 :   unsigned i;
    6770          148 :   tm_alias_pair *p;
    6771          148 :   bool switched = false;
    6772              : 
    6773          565 :   FOR_EACH_VEC_ELT (tm_alias_pairs, i, p)
    6774              :     {
    6775          417 :       tree src = p->from;
    6776          417 :       tree dst = p->to;
    6777          417 :       struct cgraph_node *src_n = cgraph_node::get (src);
    6778          417 :       struct cgraph_node *dst_n = cgraph_node::get (dst);
    6779              : 
    6780              :       /* The function ipa_tm_create_version() marks the clone as needed if
    6781              :          the original function was needed.  But we also mark the clone as
    6782              :          needed if we ever called the clone indirectly through
    6783              :          TM_GETTMCLONE.  If neither of these are true, we didn't generate
    6784              :          a clone, and we didn't call it indirectly... no sense keeping it
    6785              :          in the clone table.  */
    6786          417 :       if (!dst_n || !dst_n->definition)
    6787          135 :         continue;
    6788              : 
    6789              :       /* This covers the case where we have optimized the original
    6790              :          function away, and only access the transactional clone.  */
    6791          282 :       if (!src_n || !src_n->definition)
    6792            9 :         continue;
    6793              : 
    6794          273 :       if (!switched)
    6795              :         {
    6796          120 :           switch_to_section (targetm.asm_out.tm_clone_table_section ());
    6797          120 :           assemble_align (POINTER_SIZE);
    6798          120 :           switched = true;
    6799              :         }
    6800              : 
    6801          546 :       assemble_integer (XEXP (DECL_RTL (src), 0),
    6802          546 :                         POINTER_SIZE_UNITS, POINTER_SIZE, 1);
    6803          546 :       assemble_integer (XEXP (DECL_RTL (dst), 0),
    6804          546 :                         POINTER_SIZE_UNITS, POINTER_SIZE, 1);
    6805              :     }
    6806          148 : }
    6807              : 
    6808              : /* Provide a default for the tm_clone_table section.  */
    6809              : 
    6810              : section *
    6811          120 : default_clone_table_section (void)
    6812              : {
    6813          120 :   return get_named_section (NULL, ".tm_clone_table", 3);
    6814              : }
    6815              : 
    6816              : /* Helper comparison function for qsorting by the DECL_UID stored in
    6817              :    alias_pair->emitted_diags.  */
    6818              : 
    6819              : static int
    6820         3536 : tm_alias_pair_cmp (const void *x, const void *y)
    6821              : {
    6822         3536 :   const tm_alias_pair *p1 = (const tm_alias_pair *) x;
    6823         3536 :   const tm_alias_pair *p2 = (const tm_alias_pair *) y;
    6824         3536 :   if (p1->uid < p2->uid)
    6825              :     return -1;
    6826         1577 :   if (p1->uid > p2->uid)
    6827         1577 :     return 1;
    6828              :   return 0;
    6829              : }
    6830              : 
    6831              : void
    6832       230133 : finish_tm_clone_pairs (void)
    6833              : {
    6834       230133 :   vec<tm_alias_pair> tm_alias_pairs = vNULL;
    6835              : 
    6836       230133 :   if (tm_clone_hash == NULL)
    6837       229985 :     return;
    6838              : 
    6839              :   /* We need a determenistic order for the .tm_clone_table, otherwise
    6840              :      we will get bootstrap comparison failures, so dump the hash table
    6841              :      to a vector, sort it, and dump the vector.  */
    6842              : 
    6843              :   /* Dump the hashtable to a vector.  */
    6844          148 :   tree_map *map;
    6845          148 :   hash_table<tm_clone_hasher>::iterator iter;
    6846          982 :   FOR_EACH_HASH_TABLE_ELEMENT (*tm_clone_hash, map, tree_map *, iter)
    6847              :     {
    6848          417 :       tm_alias_pair p = {DECL_UID (map->base.from), map->base.from, map->to};
    6849          417 :       tm_alias_pairs.safe_push (p);
    6850              :     }
    6851              :   /* Sort it.  */
    6852          148 :   tm_alias_pairs.qsort (tm_alias_pair_cmp);
    6853              : 
    6854              :   /* Dump it.  */
    6855          148 :   dump_tm_clone_pairs (tm_alias_pairs);
    6856              : 
    6857          148 :   tm_clone_hash->empty ();
    6858          148 :   tm_clone_hash = NULL;
    6859          148 :   tm_alias_pairs.release ();
    6860              : }
    6861              : 
    6862              : 
    6863              : /* Emit an assembler directive to set symbol for DECL visibility to
    6864              :    the visibility type VIS, which must not be VISIBILITY_DEFAULT.  */
    6865              : 
    6866              : void
    6867        29489 : default_assemble_visibility (tree decl ATTRIBUTE_UNUSED,
    6868              :                              int vis ATTRIBUTE_UNUSED)
    6869              : {
    6870              : #ifdef HAVE_GAS_HIDDEN
    6871        29489 :   static const char * const visibility_types[] = {
    6872              :     NULL, "protected", "hidden", "internal"
    6873              :   };
    6874              : 
    6875        29489 :   const char *name, *type;
    6876        29489 :   tree id;
    6877              : 
    6878        29489 :   id = DECL_ASSEMBLER_NAME (decl);
    6879        29489 :   ultimate_transparent_alias_target (&id);
    6880        29489 :   name = IDENTIFIER_POINTER (id);
    6881              : 
    6882        29489 :   type = visibility_types[vis];
    6883              : 
    6884        29489 :   fprintf (asm_out_file, "\t.%s\t", type);
    6885        29489 :   assemble_name (asm_out_file, name);
    6886        29489 :   fprintf (asm_out_file, "\n");
    6887              : #else
    6888              :   if (!DECL_ARTIFICIAL (decl))
    6889              :     warning (OPT_Wattributes, "visibility attribute not supported "
    6890              :              "in this configuration; ignored");
    6891              : #endif
    6892        29489 : }
    6893              : 
    6894              : /* A helper function to call assemble_visibility when needed for a decl.  */
    6895              : 
    6896              : bool
    6897      2849637 : maybe_assemble_visibility (tree decl)
    6898              : {
    6899      2849637 :   enum symbol_visibility vis = DECL_VISIBILITY (decl);
    6900      2849637 :   if (vis != VISIBILITY_DEFAULT)
    6901              :     {
    6902        28178 :       targetm.asm_out.assemble_visibility (decl, vis);
    6903        28178 :       return true;
    6904              :     }
    6905              :   else
    6906              :     return false;
    6907              : }
    6908              : 
    6909              : /* Returns true if the target configuration supports defining public symbols
    6910              :    so that one of them will be chosen at link time instead of generating a
    6911              :    multiply-defined symbol error, whether through the use of weak symbols or
    6912              :    a target-specific mechanism for having duplicates discarded.  */
    6913              : 
    6914              : bool
    6915        97402 : supports_one_only (void)
    6916              : {
    6917        97402 :   if (SUPPORTS_ONE_ONLY)
    6918        97402 :     return true;
    6919              :   if (TARGET_SUPPORTS_WEAK)
    6920              :     return true;
    6921              :   return false;
    6922              : }
    6923              : 
    6924              : /* Set up DECL as a public symbol that can be defined in multiple
    6925              :    translation units without generating a linker error.  */
    6926              : 
    6927              : void
    6928    127769214 : make_decl_one_only (tree decl, tree comdat_group)
    6929              : {
    6930    127769214 :   struct symtab_node *symbol;
    6931    127769214 :   gcc_assert (VAR_OR_FUNCTION_DECL_P (decl));
    6932              : 
    6933    127769214 :   TREE_PUBLIC (decl) = 1;
    6934              : 
    6935    127769214 :   if (VAR_P (decl))
    6936     70482345 :     symbol = varpool_node::get_create (decl);
    6937              :   else
    6938     57286869 :     symbol = cgraph_node::get_create (decl);
    6939              : 
    6940    127769214 :   if (SUPPORTS_ONE_ONLY)
    6941              :     {
    6942              : #ifdef MAKE_DECL_ONE_ONLY
    6943    127769214 :       MAKE_DECL_ONE_ONLY (decl);
    6944              : #endif
    6945    127769214 :       symbol->set_comdat_group (comdat_group);
    6946              :     }
    6947              :   else if (VAR_P (decl)
    6948              :            && (DECL_INITIAL (decl) == 0
    6949              :                || (!in_lto_p && DECL_INITIAL (decl) == error_mark_node)))
    6950              :     DECL_COMMON (decl) = 1;
    6951              :   else
    6952              :     {
    6953              :       gcc_assert (TARGET_SUPPORTS_WEAK);
    6954              :       DECL_WEAK (decl) = 1;
    6955              :     }
    6956    127769214 : }
    6957              : 
    6958              : void
    6959       278641 : init_varasm_once (void)
    6960              : {
    6961       278641 :   section_htab = hash_table<section_hasher>::create_ggc (31);
    6962       278641 :   object_block_htab = hash_table<object_block_hasher>::create_ggc (31);
    6963       278641 :   const_desc_htab = hash_table<tree_descriptor_hasher>::create_ggc (1009);
    6964              : 
    6965       278641 :   shared_constant_pool = create_constant_pool ();
    6966              : 
    6967              : #ifdef TEXT_SECTION_ASM_OP
    6968       278641 :   text_section = get_unnamed_section (SECTION_CODE, output_section_asm_op,
    6969              :                                       TEXT_SECTION_ASM_OP);
    6970              : #endif
    6971              : 
    6972              : #ifdef DATA_SECTION_ASM_OP
    6973       278641 :   data_section = get_unnamed_section (SECTION_WRITE, output_section_asm_op,
    6974              :                                       DATA_SECTION_ASM_OP);
    6975              : #endif
    6976              : 
    6977              : #ifdef SDATA_SECTION_ASM_OP
    6978              :   sdata_section = get_unnamed_section (SECTION_WRITE, output_section_asm_op,
    6979              :                                        SDATA_SECTION_ASM_OP);
    6980              : #endif
    6981              : 
    6982              : #ifdef READONLY_DATA_SECTION_ASM_OP
    6983       278641 :   readonly_data_section = get_unnamed_section (0, output_section_asm_op,
    6984              :                                                READONLY_DATA_SECTION_ASM_OP);
    6985              : #endif
    6986              : 
    6987              : #ifdef CTORS_SECTION_ASM_OP
    6988              :   ctors_section = get_unnamed_section (0, output_section_asm_op,
    6989              :                                        CTORS_SECTION_ASM_OP);
    6990              : #endif
    6991              : 
    6992              : #ifdef DTORS_SECTION_ASM_OP
    6993              :   dtors_section = get_unnamed_section (0, output_section_asm_op,
    6994              :                                        DTORS_SECTION_ASM_OP);
    6995              : #endif
    6996              : 
    6997              : #ifdef BSS_SECTION_ASM_OP
    6998       278641 :   bss_section = get_unnamed_section (SECTION_WRITE | SECTION_BSS,
    6999              :                                      output_section_asm_op,
    7000              :                                      BSS_SECTION_ASM_OP);
    7001              : #endif
    7002              : 
    7003              : #ifdef SBSS_SECTION_ASM_OP
    7004              :   sbss_section = get_unnamed_section (SECTION_WRITE | SECTION_BSS,
    7005              :                                       output_section_asm_op,
    7006              :                                       SBSS_SECTION_ASM_OP);
    7007              : #endif
    7008              : 
    7009       278641 :   tls_comm_section = get_noswitch_section (SECTION_WRITE | SECTION_BSS
    7010              :                                            | SECTION_COMMON, emit_tls_common);
    7011       278641 :   lcomm_section = get_noswitch_section (SECTION_WRITE | SECTION_BSS
    7012              :                                         | SECTION_COMMON, emit_local);
    7013       278641 :   comm_section = get_noswitch_section (SECTION_WRITE | SECTION_BSS
    7014              :                                        | SECTION_COMMON, emit_common);
    7015              : 
    7016              : #if defined ASM_OUTPUT_ALIGNED_BSS
    7017       278641 :   bss_noswitch_section = get_noswitch_section (SECTION_WRITE | SECTION_BSS,
    7018              :                                                emit_bss);
    7019              : #endif
    7020              : 
    7021       278641 :   targetm.asm_out.init_sections ();
    7022              : 
    7023       278641 :   if (readonly_data_section == NULL)
    7024            0 :     readonly_data_section = text_section;
    7025              : 
    7026              : #ifdef ASM_OUTPUT_EXTERNAL
    7027       278641 :   pending_assemble_externals_set = new hash_set<tree>;
    7028              : #endif
    7029       278641 : }
    7030              : 
    7031              : /* Determine whether SYMBOL is used in any optimized function.  */
    7032              : 
    7033              : static bool
    7034          169 : have_optimized_refs (struct symtab_node *symbol)
    7035              : {
    7036          169 :   struct ipa_ref *ref;
    7037              : 
    7038          193 :   for (int i = 0; symbol->iterate_referring (i, ref); i++)
    7039              :     {
    7040          209 :       cgraph_node *cnode = dyn_cast <cgraph_node *> (ref->referring);
    7041              : 
    7042          185 :       if (cnode && opt_for_fn (cnode->decl, optimize))
    7043              :         return true;
    7044              :     }
    7045              : 
    7046              :   return false;
    7047              : }
    7048              : 
    7049              : /* Check if promoting general-dynamic TLS access model to local-dynamic is
    7050              :    desirable for DECL.  */
    7051              : 
    7052              : static bool
    7053          311 : optimize_dyn_tls_for_decl_p (const_tree decl)
    7054              : {
    7055          311 :   if (cfun)
    7056           30 :     return optimize;
    7057          281 :   return symtab->state >= IPA && have_optimized_refs (symtab_node::get (decl));
    7058              : }
    7059              : 
    7060              : 
    7061              : enum tls_model
    7062        28019 : decl_default_tls_model (const_tree decl)
    7063              : {
    7064        28019 :   enum tls_model kind;
    7065        28019 :   bool is_local;
    7066              : 
    7067        28019 :   is_local = targetm.binds_local_p (decl);
    7068        28019 :   if (!flag_shlib)
    7069              :     {
    7070        25626 :       if (is_local)
    7071              :         kind = TLS_MODEL_LOCAL_EXEC;
    7072              :       else
    7073        19648 :         kind = TLS_MODEL_INITIAL_EXEC;
    7074              :     }
    7075              : 
    7076              :   /* Local dynamic is inefficient when we're not combining the
    7077              :      parts of the address.  */
    7078         2393 :   else if (is_local && optimize_dyn_tls_for_decl_p (decl))
    7079              :     kind = TLS_MODEL_LOCAL_DYNAMIC;
    7080              :   else
    7081              :     kind = TLS_MODEL_GLOBAL_DYNAMIC;
    7082        28019 :   if (kind < flag_tls_default)
    7083          178 :     kind = flag_tls_default;
    7084              : 
    7085        28019 :   return kind;
    7086              : }
    7087              : 
    7088              : /* Select a set of attributes for section NAME based on the properties
    7089              :    of DECL and whether or not RELOC indicates that DECL's initializer
    7090              :    might contain runtime relocations.
    7091              : 
    7092              :    We make the section read-only and executable for a function decl,
    7093              :    read-only for a const data decl, and writable for a non-const data decl.  */
    7094              : 
    7095              : unsigned int
    7096     66667127 : default_section_type_flags (tree decl, const char *name, int reloc)
    7097              : {
    7098     66667127 :   unsigned int flags;
    7099              : 
    7100     66667127 :   if (decl && TREE_CODE (decl) == FUNCTION_DECL)
    7101              :     flags = SECTION_CODE;
    7102      2960667 :   else if (strcmp (name, ".data.rel.ro") == 0
    7103      2960551 :            || strcmp (name, ".data.rel.ro.local") == 0)
    7104              :     flags = SECTION_WRITE | SECTION_RELRO;
    7105      2960176 :   else if (decl)
    7106              :     {
    7107      2960056 :       enum section_category category
    7108      2960056 :         = categorize_decl_for_section (decl, reloc);
    7109      6556950 :       if (decl_readonly_section_1 (category))
    7110              :         flags = 0;
    7111       636347 :       else if (category == SECCAT_DATA_REL_RO
    7112       636347 :                || category == SECCAT_DATA_REL_RO_LOCAL)
    7113              :         flags = SECTION_WRITE | SECTION_RELRO;
    7114              :       else
    7115      2960547 :         flags = SECTION_WRITE;
    7116              :     }
    7117              :   else
    7118              :     flags = SECTION_WRITE;
    7119              : 
    7120     66667007 :   if (decl && DECL_P (decl) && DECL_COMDAT_GROUP (decl))
    7121     35408364 :     flags |= SECTION_LINKONCE;
    7122              : 
    7123     66667127 :   if (strcmp (name, ".vtable_map_vars") == 0)
    7124            6 :     flags |= SECTION_LINKONCE;
    7125              : 
    7126     66667127 :   if (decl && VAR_P (decl) && DECL_THREAD_LOCAL_P (decl))
    7127         3864 :     flags |= SECTION_TLS | SECTION_WRITE;
    7128              : 
    7129     66667127 :   if (strcmp (name, ".bss") == 0
    7130     66667127 :       || startswith (name, ".bss.")
    7131     66652211 :       || startswith (name, ".gnu.linkonce.b.")
    7132     66652211 :       || strcmp (name, ".persistent.bss") == 0
    7133     66652211 :       || strcmp (name, ".sbss") == 0
    7134     66652211 :       || startswith (name, ".sbss.")
    7135    133319338 :       || startswith (name, ".gnu.linkonce.sb."))
    7136        14916 :     flags |= SECTION_BSS;
    7137              : 
    7138     66667127 :   if (strcmp (name, ".tdata") == 0
    7139     66666813 :       || startswith (name, ".tdata.")
    7140    133333901 :       || startswith (name, ".gnu.linkonce.td."))
    7141          353 :     flags |= SECTION_TLS;
    7142              : 
    7143     66667127 :   if (strcmp (name, ".tbss") == 0
    7144     66663810 :       || startswith (name, ".tbss.")
    7145    133330749 :       || startswith (name, ".gnu.linkonce.tb."))
    7146         3505 :     flags |= SECTION_TLS | SECTION_BSS;
    7147              : 
    7148     66667127 :   if (strcmp (name, ".noinit") == 0)
    7149            0 :     flags |= SECTION_WRITE | SECTION_BSS | SECTION_NOTYPE;
    7150              : 
    7151     66667127 :   if (strcmp (name, ".persistent") == 0)
    7152            0 :     flags |= SECTION_WRITE | SECTION_NOTYPE;
    7153              : 
    7154              :   /* Various sections have special ELF types that the assembler will
    7155              :      assign by default based on the name.  They are neither SHT_PROGBITS
    7156              :      nor SHT_NOBITS, so when changing sections we don't want to print a
    7157              :      section type (@progbits or @nobits).  Rather than duplicating the
    7158              :      assembler's knowledge of what those special name patterns are, just
    7159              :      let the assembler choose the type if we don't know a specific
    7160              :      reason to set it to something other than the default.  SHT_PROGBITS
    7161              :      is the default for sections whose name is not specially known to
    7162              :      the assembler, so it does no harm to leave the choice to the
    7163              :      assembler when @progbits is the best thing we know to use.  If
    7164              :      someone is silly enough to emit code or TLS variables to one of
    7165              :      these sections, then don't handle them specially.
    7166              : 
    7167              :      default_elf_asm_named_section (below) handles the BSS, TLS, ENTSIZE, and
    7168              :      LINKONCE cases when NOTYPE is not set, so leave those to its logic.  */
    7169     66667127 :   if (!(flags & (SECTION_CODE | SECTION_BSS | SECTION_TLS | SECTION_ENTSIZE))
    7170      2941887 :       && !(HAVE_COMDAT_GROUP && (flags & SECTION_LINKONCE)))
    7171      2394240 :     flags |= SECTION_NOTYPE;
    7172              : 
    7173     66667127 :   return flags;
    7174              : }
    7175              : 
    7176              : /* Return true if the target supports some form of global BSS,
    7177              :    either through bss_noswitch_section, or by selecting a BSS
    7178              :    section in TARGET_ASM_SELECT_SECTION.  */
    7179              : 
    7180              : bool
    7181            0 : have_global_bss_p (void)
    7182              : {
    7183            0 :   return bss_noswitch_section || targetm.have_switchable_bss_sections;
    7184              : }
    7185              : 
    7186              : /* Output assembly to switch to section NAME with attribute FLAGS.
    7187              :    Four variants for common object file formats.  */
    7188              : 
    7189              : void
    7190            0 : default_no_named_section (const char *name ATTRIBUTE_UNUSED,
    7191              :                           unsigned int flags ATTRIBUTE_UNUSED,
    7192              :                           tree decl ATTRIBUTE_UNUSED)
    7193              : {
    7194              :   /* Some object formats don't support named sections at all.  The
    7195              :      front-end should already have flagged this as an error.  */
    7196            0 :   gcc_unreachable ();
    7197              : }
    7198              : 
    7199              : #ifndef TLS_SECTION_ASM_FLAG
    7200              : #define TLS_SECTION_ASM_FLAG 'T'
    7201              : #endif
    7202              : 
    7203              : void
    7204      3565797 : default_elf_asm_named_section (const char *name, unsigned int flags,
    7205              :                                tree decl)
    7206              : {
    7207      3565797 :   char flagchars[11], *f = flagchars;
    7208      3565797 :   unsigned int numeric_value = 0;
    7209              : 
    7210              :   /* If we have already declared this section, we can use an
    7211              :      abbreviated form to switch back to it -- unless this section is
    7212              :      part of a COMDAT groups or with SHF_GNU_RETAIN or with SHF_LINK_ORDER,
    7213              :      in which case GAS requires the full declaration every time.  */
    7214      3565797 :   if (!(HAVE_COMDAT_GROUP && (flags & SECTION_LINKONCE))
    7215      2997097 :       && !(flags & (SECTION_RETAIN | SECTION_LINK_ORDER))
    7216      2996798 :       && (flags & SECTION_DECLARED))
    7217              :     {
    7218       386426 :       fprintf (asm_out_file, "\t.section\t%s\n", name);
    7219       386426 :       return;
    7220              :     }
    7221              : 
    7222              :   /* If we have a machine specific flag, then use the numeric value to pass
    7223              :      this on to GAS.  */
    7224      3179371 :   if (targetm.asm_out.elf_flags_numeric (flags, &numeric_value))
    7225            0 :       snprintf (f, sizeof (flagchars), "0x%08x", numeric_value);
    7226              :   else
    7227              :     {
    7228      3179371 :       if (!(flags & SECTION_DEBUG))
    7229      2121018 :         *f++ = 'a';
    7230              : #if HAVE_GAS_SECTION_EXCLUDE
    7231      3179371 :       if (flags & SECTION_EXCLUDE)
    7232       430934 :         *f++ = 'e';
    7233              : #endif
    7234      3179371 :       if (flags & SECTION_WRITE)
    7235       348086 :         *f++ = 'w';
    7236      3179371 :       if (flags & SECTION_CODE)
    7237       385207 :         *f++ = 'x';
    7238      3179371 :       if (flags & SECTION_SMALL)
    7239            0 :         *f++ = 's';
    7240      3179371 :       if (flags & SECTION_MERGE)
    7241       222572 :         *f++ = 'M';
    7242      3179371 :       if (flags & SECTION_STRINGS)
    7243       181833 :         *f++ = 'S';
    7244      3179371 :       if (flags & SECTION_TLS)
    7245         1227 :         *f++ = TLS_SECTION_ASM_FLAG;
    7246      3179371 :       if (HAVE_COMDAT_GROUP && (flags & SECTION_LINKONCE))
    7247       568700 :         *f++ = 'G';
    7248      3179371 :       if (flags & SECTION_RETAIN)
    7249          258 :         *f++ = 'R';
    7250      3179371 :       if (flags & SECTION_LINK_ORDER)
    7251           53 :         *f++ = 'o';
    7252              : #ifdef MACH_DEP_SECTION_ASM_FLAG
    7253              :       if (flags & SECTION_MACH_DEP)
    7254              :         *f++ = MACH_DEP_SECTION_ASM_FLAG;
    7255              : #endif
    7256      3179371 :       *f = '\0';
    7257              :     }
    7258              : 
    7259      3179371 :   fprintf (asm_out_file, "\t.section\t%s,\"%s\"", name, flagchars);
    7260              : 
    7261              :   /* default_section_type_flags (above) knows which flags need special
    7262              :      handling here, and sets NOTYPE when none of these apply so that the
    7263              :      assembler's logic for default types can apply to user-chosen
    7264              :      section names.  */
    7265      3179371 :   if (!(flags & SECTION_NOTYPE))
    7266              :     {
    7267      1937519 :       const char *type;
    7268      1937519 :       const char *format;
    7269              : 
    7270      1937519 :       if (flags & SECTION_BSS)
    7271              :         type = "nobits";
    7272              :       else
    7273      1923511 :         type = "progbits";
    7274              : 
    7275      1937519 :       format = ",@%s";
    7276              :       /* On platforms that use "@" as the assembly comment character,
    7277              :          use "%" instead.  */
    7278      1937519 :       if (strcmp (ASM_COMMENT_START, "@") == 0)
    7279              :         format = ",%%%s";
    7280      1937519 :       fprintf (asm_out_file, format, type);
    7281              : 
    7282      1937519 :       if (flags & SECTION_ENTSIZE)
    7283       222572 :         fprintf (asm_out_file, ",%d", flags & SECTION_ENTSIZE);
    7284      1937519 :       if (flags & SECTION_LINK_ORDER)
    7285              :         {
    7286              :           /* For now, only section "__patchable_function_entries"
    7287              :              adopts flag SECTION_LINK_ORDER, internal label LPFE*
    7288              :              was emitted in default_print_patchable_function_entry,
    7289              :              just place it here for linked_to section.  */
    7290           53 :           gcc_assert (!strcmp (name, "__patchable_function_entries"));
    7291           53 :           fprintf (asm_out_file, ",");
    7292           53 :           char buf[256];
    7293           53 :           ASM_GENERATE_INTERNAL_LABEL (buf, "LPFE",
    7294              :                                        current_function_funcdef_no);
    7295           53 :           assemble_name_raw (asm_out_file, buf);
    7296              :         }
    7297      1937519 :       if (HAVE_COMDAT_GROUP && (flags & SECTION_LINKONCE))
    7298              :         {
    7299       568700 :           if (TREE_CODE (decl) == IDENTIFIER_NODE)
    7300         1601 :             fprintf (asm_out_file, ",%s,comdat", IDENTIFIER_POINTER (decl));
    7301              :           else
    7302      1134198 :             fprintf (asm_out_file, ",%s,comdat",
    7303       567099 :                      IDENTIFIER_POINTER (DECL_COMDAT_GROUP (decl)));
    7304              :         }
    7305              :     }
    7306              : 
    7307      3179371 :   putc ('\n', asm_out_file);
    7308              : }
    7309              : 
    7310              : void
    7311            0 : default_coff_asm_named_section (const char *name, unsigned int flags,
    7312              :                                 tree decl ATTRIBUTE_UNUSED)
    7313              : {
    7314            0 :   char flagchars[8], *f = flagchars;
    7315              : 
    7316            0 :   if (flags & SECTION_WRITE)
    7317            0 :     *f++ = 'w';
    7318            0 :   if (flags & SECTION_CODE)
    7319            0 :     *f++ = 'x';
    7320            0 :   *f = '\0';
    7321              : 
    7322            0 :   fprintf (asm_out_file, "\t.section\t%s,\"%s\"\n", name, flagchars);
    7323            0 : }
    7324              : 
    7325              : void
    7326            0 : default_pe_asm_named_section (const char *name, unsigned int flags,
    7327              :                               tree decl)
    7328              : {
    7329            0 :   default_coff_asm_named_section (name, flags, decl);
    7330              : 
    7331            0 :   if (flags & SECTION_LINKONCE)
    7332              :     {
    7333              :       /* Functions may have been compiled at various levels of
    7334              :          optimization so we can't use `same_size' here.
    7335              :          Instead, have the linker pick one.  */
    7336            0 :       fprintf (asm_out_file, "\t.linkonce %s\n",
    7337            0 :                (flags & SECTION_CODE ? "discard" : "same_size"));
    7338              :     }
    7339            0 : }
    7340              : 
    7341              : /* The lame default section selector.  */
    7342              : 
    7343              : section *
    7344            0 : default_select_section (tree decl, int reloc,
    7345              :                         unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED)
    7346              : {
    7347            0 :   if (DECL_P (decl))
    7348              :     {
    7349            0 :       if (decl_readonly_section (decl, reloc))
    7350            0 :         return readonly_data_section;
    7351              :     }
    7352            0 :   else if (TREE_CODE (decl) == CONSTRUCTOR)
    7353              :     {
    7354            0 :       if (! ((flag_pic && reloc)
    7355            0 :              || !TREE_READONLY (decl)
    7356            0 :              || !TREE_CONSTANT (decl)))
    7357            0 :         return readonly_data_section;
    7358              :     }
    7359            0 :   else if (TREE_CODE (decl) == STRING_CST)
    7360            0 :     return readonly_data_section;
    7361            0 :   else if (! (flag_pic && reloc))
    7362            0 :     return readonly_data_section;
    7363              : 
    7364            0 :   return data_section;
    7365              : }
    7366              : 
    7367              : enum section_category
    7368      6430371 : categorize_decl_for_section (const_tree decl, int reloc)
    7369              : {
    7370      6430371 :   enum section_category ret;
    7371              : 
    7372      6430371 :   if (TREE_CODE (decl) == FUNCTION_DECL)
    7373              :     return SECCAT_TEXT;
    7374      6185044 :   else if (TREE_CODE (decl) == STRING_CST)
    7375              :     {
    7376      1253022 :       if ((flag_sanitize & SANITIZE_ADDRESS)
    7377      1253022 :           && asan_protect_global (const_cast<tree> (decl)))
    7378              :       /* or !flag_merge_constants */
    7379              :         return SECCAT_RODATA;
    7380              :       else
    7381      1251368 :         return SECCAT_RODATA_MERGE_STR;
    7382              :     }
    7383      4932022 :   else if (VAR_P (decl))
    7384              :     {
    7385      4901926 :       tree d = const_cast<tree> (decl);
    7386      4901926 :       if (bss_initializer_p (decl))
    7387              :         ret = SECCAT_BSS;
    7388      4865017 :       else if (! TREE_READONLY (decl)
    7389      4865017 :                || (DECL_INITIAL (decl)
    7390      4545445 :                    && ! TREE_CONSTANT (DECL_INITIAL (decl))))
    7391              :         {
    7392              :           /* Here the reloc_rw_mask is not testing whether the section should
    7393              :              be read-only or not, but whether the dynamic link will have to
    7394              :              do something.  If so, we wish to segregate the data in order to
    7395              :              minimize cache misses inside the dynamic linker.  */
    7396       319406 :           if (reloc & targetm.asm_out.reloc_rw_mask ())
    7397         6169 :             ret = reloc == 1 ? SECCAT_DATA_REL_LOCAL : SECCAT_DATA_REL;
    7398              :           else
    7399              :             ret = SECCAT_DATA;
    7400              :         }
    7401      4545611 :       else if (reloc & targetm.asm_out.reloc_rw_mask ())
    7402       918566 :         ret = reloc == 1 ? SECCAT_DATA_REL_RO_LOCAL : SECCAT_DATA_REL_RO;
    7403       732031 :       else if (reloc || (flag_merge_constants < 2 && !DECL_MERGEABLE (decl))
    7404      3629262 :                || ((flag_sanitize & SANITIZE_ADDRESS)
    7405              :                    /* PR 81697: for architectures that use section anchors we
    7406              :                       need to ignore DECL_RTL_SET_P (decl) for string constants
    7407              :                       inside this asan_protect_global call because otherwise
    7408              :                       we'll wrongly put them into SECCAT_RODATA_MERGE_CONST
    7409              :                       section, set DECL_RTL (decl) later on and add DECL to
    7410              :                       protected globals via successive asan_protect_global
    7411              :                       calls.  In this scenario we'll end up with wrong
    7412              :                       alignment of these strings at runtime and possible ASan
    7413              :                       false positives.  */
    7414           91 :                    && asan_protect_global (d, use_object_blocks_p ()
    7415           91 :                                               && use_blocks_for_decl_p (d))))
    7416              :         /* C and C++ don't allow different variables to share the same
    7417              :            location.  -fmerge-all-constants allows even that (at the
    7418              :            expense of not conforming).  */
    7419              :         ret = SECCAT_RODATA;
    7420         2138 :       else if (DECL_INITIAL (decl)
    7421         2138 :                && TREE_CODE (DECL_INITIAL (decl)) == STRING_CST)
    7422              :         ret = SECCAT_RODATA_MERGE_STR_INIT;
    7423              :       else
    7424              :         ret = SECCAT_RODATA_MERGE_CONST;
    7425              :     }
    7426        30096 :   else if (TREE_CODE (decl) == CONSTRUCTOR)
    7427              :     {
    7428         1539 :       if ((reloc & targetm.asm_out.reloc_rw_mask ())
    7429         1539 :           || ! TREE_CONSTANT (decl))
    7430              :         ret = SECCAT_DATA;
    7431              :       else
    7432              :         ret = SECCAT_RODATA;
    7433              :     }
    7434              :   else
    7435              :     ret = SECCAT_RODATA;
    7436              : 
    7437              :   /* There are no read-only thread-local sections.  */
    7438      4932022 :   if (VAR_P (decl) && DECL_THREAD_LOCAL_P (decl))
    7439              :     {
    7440              :       /* Note that this would be *just* SECCAT_BSS, except that there's
    7441              :          no concept of a read-only thread-local-data section.  */
    7442         7720 :       if (ret == SECCAT_BSS
    7443          712 :           || DECL_INITIAL (decl) == NULL
    7444         8426 :           || (flag_zero_initialized_in_bss
    7445          706 :               && initializer_zerop (DECL_INITIAL (decl))))
    7446              :         ret = SECCAT_TBSS;
    7447              :       else
    7448              :         ret = SECCAT_TDATA;
    7449              :     }
    7450              : 
    7451              :   /* If the target uses small data sections, select it.  */
    7452      4924302 :   else if (targetm.in_small_data_p (decl))
    7453              :     {
    7454            0 :       if (ret == SECCAT_BSS)
    7455              :         ret = SECCAT_SBSS;
    7456            0 :       else if (targetm.have_srodata_section && ret == SECCAT_RODATA)
    7457              :         ret = SECCAT_SRODATA;
    7458              :       else
    7459            0 :         ret = SECCAT_SDATA;
    7460              :     }
    7461              : 
    7462              :   return ret;
    7463              : }
    7464              : 
    7465              : static bool
    7466      2982288 : decl_readonly_section_1 (enum section_category category)
    7467              : {
    7468      2960056 :   switch (category)
    7469              :     {
    7470              :     case SECCAT_RODATA:
    7471              :     case SECCAT_RODATA_MERGE_STR:
    7472              :     case SECCAT_RODATA_MERGE_STR_INIT:
    7473              :     case SECCAT_RODATA_MERGE_CONST:
    7474              :     case SECCAT_SRODATA:
    7475              :       return true;
    7476       638907 :     default:
    7477       638907 :       return false;
    7478              :     }
    7479              : }
    7480              : 
    7481              : bool
    7482        22232 : decl_readonly_section (const_tree decl, int reloc)
    7483              : {
    7484        22232 :   return decl_readonly_section_1 (categorize_decl_for_section (decl, reloc));
    7485              : }
    7486              : 
    7487              : /* Select a section based on the above categorization.  */
    7488              : 
    7489              : section *
    7490      1650097 : default_elf_select_section (tree decl, int reloc,
    7491              :                             unsigned HOST_WIDE_INT align)
    7492              : {
    7493      1650097 :   const char *sname;
    7494              : 
    7495      1650097 :   switch (categorize_decl_for_section (decl, reloc))
    7496              :     {
    7497            0 :     case SECCAT_TEXT:
    7498              :       /* We're not supposed to be called on FUNCTION_DECLs.  */
    7499            0 :       gcc_unreachable ();
    7500       130325 :     case SECCAT_RODATA:
    7501       130325 :       return readonly_data_section;
    7502      1231853 :     case SECCAT_RODATA_MERGE_STR:
    7503      1231853 :       return mergeable_string_section (decl, align, 0);
    7504           14 :     case SECCAT_RODATA_MERGE_STR_INIT:
    7505           14 :       return mergeable_string_section (DECL_INITIAL (decl), align, 0);
    7506          476 :     case SECCAT_RODATA_MERGE_CONST:
    7507          476 :       return mergeable_constant_section (DECL_SIZE (decl), align, 0);
    7508              :     case SECCAT_SRODATA:
    7509              :       sname = ".sdata2";
    7510              :       break;
    7511       282462 :     case SECCAT_DATA:
    7512       282462 :       if (DECL_P (decl) && DECL_PERSISTENT_P (decl))
    7513              :         {
    7514              :           sname = ".persistent";
    7515              :           break;
    7516              :         }
    7517       282462 :       return data_section;
    7518          125 :     case SECCAT_DATA_REL:
    7519          125 :       sname = ".data.rel";
    7520          125 :       break;
    7521          973 :     case SECCAT_DATA_REL_LOCAL:
    7522          973 :       sname = ".data.rel.local";
    7523          973 :       break;
    7524          102 :     case SECCAT_DATA_REL_RO:
    7525          102 :       sname = ".data.rel.ro";
    7526          102 :       break;
    7527          131 :     case SECCAT_DATA_REL_RO_LOCAL:
    7528          131 :       sname = ".data.rel.ro.local";
    7529          131 :       break;
    7530            0 :     case SECCAT_SDATA:
    7531            0 :       sname = ".sdata";
    7532            0 :       break;
    7533          314 :     case SECCAT_TDATA:
    7534          314 :       sname = ".tdata";
    7535          314 :       break;
    7536            5 :     case SECCAT_BSS:
    7537            5 :       if (DECL_P (decl) && DECL_NOINIT_P (decl))
    7538              :         {
    7539              :           sname = ".noinit";
    7540              :           break;
    7541              :         }
    7542            5 :       if (bss_section)
    7543              :         return bss_section;
    7544              :       sname = ".bss";
    7545              :       break;
    7546            0 :     case SECCAT_SBSS:
    7547            0 :       sname = ".sbss";
    7548            0 :       break;
    7549         3317 :     case SECCAT_TBSS:
    7550         3317 :       sname = ".tbss";
    7551         3317 :       break;
    7552            0 :     default:
    7553            0 :       gcc_unreachable ();
    7554              :     }
    7555              : 
    7556         4962 :   return get_named_section (decl, sname, reloc);
    7557              : }
    7558              : 
    7559              : /* Construct a unique section name based on the decl name and the
    7560              :    categorization performed above.  */
    7561              : 
    7562              : void
    7563      1797882 : default_unique_section (tree decl, int reloc)
    7564              : {
    7565              :   /* We only need to use .gnu.linkonce if we don't have COMDAT groups.  */
    7566      1797882 :   bool one_only = DECL_ONE_ONLY (decl) && !HAVE_COMDAT_GROUP;
    7567      1797882 :   const char *prefix, *name, *linkonce;
    7568      1797882 :   char *string;
    7569      1797882 :   tree id;
    7570              : 
    7571      1797882 :   switch (categorize_decl_for_section (decl, reloc))
    7572              :     {
    7573              :     case SECCAT_TEXT:
    7574              :       prefix = one_only ? ".t" : ".text";
    7575              :       break;
    7576      1204037 :     case SECCAT_RODATA:
    7577      1204037 :     case SECCAT_RODATA_MERGE_STR:
    7578      1204037 :     case SECCAT_RODATA_MERGE_STR_INIT:
    7579      1204037 :     case SECCAT_RODATA_MERGE_CONST:
    7580      1204037 :       prefix = one_only ? ".r" : ".rodata";
    7581              :       break;
    7582            0 :     case SECCAT_SRODATA:
    7583            0 :       prefix = one_only ? ".s2" : ".sdata2";
    7584              :       break;
    7585         9557 :     case SECCAT_DATA:
    7586         9557 :       prefix = one_only ? ".d" : ".data";
    7587         9557 :       if (DECL_P (decl) && DECL_PERSISTENT_P (decl))
    7588              :         {
    7589              :           prefix = one_only ? ".p" : ".persistent";
    7590              :           break;
    7591              :         }
    7592              :       break;
    7593         1137 :     case SECCAT_DATA_REL:
    7594         1137 :       prefix = one_only ? ".d.rel" : ".data.rel";
    7595              :       break;
    7596          874 :     case SECCAT_DATA_REL_LOCAL:
    7597          874 :       prefix = one_only ? ".d.rel.local" : ".data.rel.local";
    7598              :       break;
    7599       155831 :     case SECCAT_DATA_REL_RO:
    7600       155831 :       prefix = one_only ? ".d.rel.ro" : ".data.rel.ro";
    7601              :       break;
    7602       167621 :     case SECCAT_DATA_REL_RO_LOCAL:
    7603       167621 :       prefix = one_only ? ".d.rel.ro.local" : ".data.rel.ro.local";
    7604              :       break;
    7605            0 :     case SECCAT_SDATA:
    7606            0 :       prefix = one_only ? ".s" : ".sdata";
    7607              :       break;
    7608        13274 :     case SECCAT_BSS:
    7609        13274 :       if (DECL_P (decl) && DECL_NOINIT_P (decl))
    7610              :         {
    7611              :           prefix = one_only ? ".n" : ".noinit";
    7612              :           break;
    7613              :         }
    7614              :       prefix = one_only ? ".b" : ".bss";
    7615              :       break;
    7616            0 :     case SECCAT_SBSS:
    7617            0 :       prefix = one_only ? ".sb" : ".sbss";
    7618              :       break;
    7619           39 :     case SECCAT_TDATA:
    7620           39 :       prefix = one_only ? ".td" : ".tdata";
    7621              :       break;
    7622          186 :     case SECCAT_TBSS:
    7623          186 :       prefix = one_only ? ".tb" : ".tbss";
    7624              :       break;
    7625            0 :     default:
    7626            0 :       gcc_unreachable ();
    7627              :     }
    7628              : 
    7629      1797882 :   id = DECL_ASSEMBLER_NAME (decl);
    7630      1797882 :   ultimate_transparent_alias_target (&id);
    7631      1797882 :   name = IDENTIFIER_POINTER (id);
    7632      1797882 :   name = targetm.strip_name_encoding (name);
    7633              : 
    7634              :   /* If we're using one_only, then there needs to be a .gnu.linkonce
    7635              :      prefix to the section name.  */
    7636      1797882 :   linkonce = one_only ? ".gnu.linkonce" : "";
    7637              : 
    7638      1797882 :   string = ACONCAT ((linkonce, prefix, ".", name, NULL));
    7639              : 
    7640      1797882 :   set_decl_section_name (decl, string);
    7641      1797882 : }
    7642              : 
    7643              : /* Subroutine of compute_reloc_for_rtx for leaf rtxes.  */
    7644              : 
    7645              : static int
    7646        42396 : compute_reloc_for_rtx_1 (const_rtx x)
    7647              : {
    7648        42396 :   switch (GET_CODE (x))
    7649              :     {
    7650        30904 :     case SYMBOL_REF:
    7651        30904 :       return SYMBOL_REF_LOCAL_P (x) ? 1 : 2;
    7652              :     case LABEL_REF:
    7653              :       return 1;
    7654              :     default:
    7655              :       return 0;
    7656              :     }
    7657              : }
    7658              : 
    7659              : /* Like compute_reloc_for_constant, except for an RTX.  The return value
    7660              :    is a mask for which bit 1 indicates a global relocation, and bit 0
    7661              :    indicates a local relocation.  Used by default_select_rtx_section
    7662              :    and default_elf_select_rtx_section.  */
    7663              : 
    7664              : static int
    7665       248503 : compute_reloc_for_rtx (const_rtx x)
    7666              : {
    7667       248503 :   switch (GET_CODE (x))
    7668              :     {
    7669        27112 :     case SYMBOL_REF:
    7670        27112 :     case LABEL_REF:
    7671        27112 :       return compute_reloc_for_rtx_1 (x);
    7672              : 
    7673         3821 :     case CONST:
    7674         3821 :       {
    7675         3821 :         int reloc = 0;
    7676         3821 :         subrtx_iterator::array_type array;
    7677        19105 :         FOR_EACH_SUBRTX (iter, array, x, ALL)
    7678        15284 :           reloc |= compute_reloc_for_rtx_1 (*iter);
    7679         3821 :         return reloc;
    7680         3821 :       }
    7681              : 
    7682              :     default:
    7683              :       return 0;
    7684              :     }
    7685              : }
    7686              : 
    7687              : section *
    7688            0 : default_select_rtx_section (machine_mode mode ATTRIBUTE_UNUSED,
    7689              :                             rtx x,
    7690              :                             unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED)
    7691              : {
    7692            0 :   if (compute_reloc_for_rtx (x) & targetm.asm_out.reloc_rw_mask ())
    7693            0 :     return data_section;
    7694              :   else
    7695            0 :     return readonly_data_section;
    7696              : }
    7697              : 
    7698              : section *
    7699       248503 : default_elf_select_rtx_section (machine_mode mode, rtx x,
    7700              :                                 unsigned HOST_WIDE_INT align)
    7701              : {
    7702       248503 :   int reloc = compute_reloc_for_rtx (x);
    7703       248503 :   tree decl = nullptr;
    7704       248503 :   const char *prefix = nullptr;
    7705       248503 :   int flags = 0;
    7706              : 
    7707              :   /* If it is a private COMDAT function symbol reference, call
    7708              :      function_rodata_section for the read-only or relocated read-only
    7709              :      data section associated with function DECL so that the COMDAT
    7710              :      section will be used for the private COMDAT function symbol.  */
    7711       248503 :   if (HAVE_COMDAT_GROUP)
    7712              :     {
    7713       248503 :       if (GET_CODE (x) == CONST
    7714         3821 :          && GET_CODE (XEXP (x, 0)) == PLUS
    7715         3821 :          && CONST_INT_P (XEXP (XEXP (x, 0), 1)))
    7716         3821 :        x = XEXP (XEXP (x, 0), 0);
    7717              : 
    7718       248503 :       if (GET_CODE (x) == SYMBOL_REF)
    7719              :        {
    7720        30904 :          decl = SYMBOL_REF_DECL (x);
    7721        30904 :          if (decl
    7722        30904 :              && (TREE_CODE (decl) != FUNCTION_DECL
    7723         7377 :                  || !DECL_COMDAT_GROUP (decl)
    7724         5292 :                  || TREE_PUBLIC (decl)))
    7725              :            decl = nullptr;
    7726              :        }
    7727              :     }
    7728              : 
    7729              :   /* ??? Handle small data here somehow.  */
    7730              : 
    7731       248503 :   if (reloc & targetm.asm_out.reloc_rw_mask ())
    7732              :     {
    7733          250 :       if (decl)
    7734              :         {
    7735            0 :           prefix = reloc == 1 ? ".data.rel.ro.local" : ".data.rel.ro";
    7736              :           flags = SECTION_WRITE | SECTION_RELRO;
    7737              :         }
    7738          250 :       else if (reloc == 1)
    7739          244 :         return get_named_section (NULL, ".data.rel.ro.local", 1);
    7740              :       else
    7741            6 :         return get_named_section (NULL, ".data.rel.ro", 3);
    7742              :     }
    7743              : 
    7744       248253 :   if (decl)
    7745              :     {
    7746           16 :       const char *comdat = IDENTIFIER_POINTER (DECL_COMDAT_GROUP (decl));
    7747           16 :       if (!prefix)
    7748           16 :         prefix = ".rodata";
    7749           16 :       size_t prefix_len = strlen (prefix);
    7750           16 :       size_t comdat_len = strlen (comdat);
    7751           16 :       size_t len = prefix_len + sizeof (".pool.") + comdat_len;
    7752           16 :       char *name = XALLOCAVEC (char, len);
    7753           16 :       memcpy (name, prefix, prefix_len);
    7754           16 :       memcpy (name + prefix_len, ".pool.", sizeof (".pool.") - 1);
    7755           16 :       memcpy (name + prefix_len + sizeof (".pool.") - 1, comdat,
    7756              :               comdat_len + 1);
    7757           16 :       return get_section (name, flags | SECTION_LINKONCE, decl);
    7758              :     }
    7759              : 
    7760       248237 :   return mergeable_constant_section (mode, align, 0);
    7761              : }
    7762              : 
    7763              : /* Set the generally applicable flags on the SYMBOL_REF for EXP.  */
    7764              : 
    7765              : void
    7766      9846721 : default_encode_section_info (tree decl, rtx rtl, int first ATTRIBUTE_UNUSED)
    7767              : {
    7768      9846721 :   rtx symbol;
    7769      9846721 :   int flags;
    7770              : 
    7771              :   /* Careful not to prod global register variables.  */
    7772      9846721 :   if (!MEM_P (rtl))
    7773              :     return;
    7774      9846721 :   symbol = XEXP (rtl, 0);
    7775      9846721 :   if (GET_CODE (symbol) != SYMBOL_REF)
    7776              :     return;
    7777              : 
    7778      9846721 :   flags = SYMBOL_REF_FLAGS (symbol) & SYMBOL_FLAG_HAS_BLOCK_INFO;
    7779      9846721 :   if (TREE_CODE (decl) == FUNCTION_DECL)
    7780      5355931 :     flags |= SYMBOL_FLAG_FUNCTION;
    7781      9846721 :   if (targetm.binds_local_p (decl))
    7782      5587788 :     flags |= SYMBOL_FLAG_LOCAL;
    7783      9846721 :   if (VAR_P (decl) && DECL_THREAD_LOCAL_P (decl))
    7784         4549 :     flags |= DECL_TLS_MODEL (decl) << SYMBOL_FLAG_TLS_SHIFT;
    7785      9842172 :   else if (targetm.in_small_data_p (decl))
    7786            0 :     flags |= SYMBOL_FLAG_SMALL;
    7787              :   /* ??? Why is DECL_EXTERNAL ever set for non-PUBLIC names?  Without
    7788              :      being PUBLIC, the thing *must* be defined in this translation unit.
    7789              :      Prevent this buglet from being propagated into rtl code as well.  */
    7790      9846721 :   if (DECL_P (decl) && DECL_EXTERNAL (decl) && TREE_PUBLIC (decl))
    7791      4096153 :     flags |= SYMBOL_FLAG_EXTERNAL;
    7792              : 
    7793      9846721 :   SYMBOL_REF_FLAGS (symbol) = flags;
    7794              : }
    7795              : 
    7796              : /* By default, we do nothing for encode_section_info, so we need not
    7797              :    do anything but discard the '*' marker.  */
    7798              : 
    7799              : const char *
    7800    402454941 : default_strip_name_encoding (const char *str)
    7801              : {
    7802    402454941 :   return str + (*str == '*');
    7803              : }
    7804              : 
    7805              : #ifdef ASM_OUTPUT_DEF
    7806              : /* The default implementation of TARGET_ASM_OUTPUT_ANCHOR.  Define the
    7807              :    anchor relative to ".", the current section position.  */
    7808              : 
    7809              : void
    7810            0 : default_asm_output_anchor (rtx symbol)
    7811              : {
    7812            0 :   gcc_checking_assert (TARGET_SUPPORTS_ALIASES);
    7813              : 
    7814            0 :   char buffer[100];
    7815              : 
    7816            0 :   sprintf (buffer, "*. + " HOST_WIDE_INT_PRINT_DEC,
    7817              :            SYMBOL_REF_BLOCK_OFFSET (symbol));
    7818            0 :   ASM_OUTPUT_DEF (asm_out_file, XSTR (symbol, 0), buffer);
    7819            0 : }
    7820              : #endif
    7821              : 
    7822              : /* The default implementation of TARGET_USE_ANCHORS_FOR_SYMBOL_P.  */
    7823              : 
    7824              : bool
    7825            0 : default_use_anchors_for_symbol_p (const_rtx symbol)
    7826              : {
    7827            0 :   tree decl;
    7828            0 :   section *sect = SYMBOL_REF_BLOCK (symbol)->sect;
    7829              : 
    7830              :   /* This function should only be called with non-zero SYMBOL_REF_BLOCK,
    7831              :      furthermore get_block_for_section should not create object blocks
    7832              :      for mergeable sections.  */
    7833            0 :   gcc_checking_assert (sect && !(sect->common.flags & SECTION_MERGE));
    7834              : 
    7835              :   /* Don't use anchors for small data sections.  The small data register
    7836              :      acts as an anchor for such sections.  */
    7837            0 :   if (sect->common.flags & SECTION_SMALL)
    7838              :     return false;
    7839              : 
    7840            0 :   decl = SYMBOL_REF_DECL (symbol);
    7841            0 :   if (decl && DECL_P (decl))
    7842              :     {
    7843              :       /* Don't use section anchors for decls that might be defined or
    7844              :          usurped by other modules.  */
    7845            0 :       if (TREE_PUBLIC (decl) && !decl_binds_to_current_def_p (decl))
    7846              :         return false;
    7847              : 
    7848              :       /* Don't use section anchors for decls that will be placed in a
    7849              :          small data section.  */
    7850              :       /* ??? Ideally, this check would be redundant with the SECTION_SMALL
    7851              :          one above.  The problem is that we only use SECTION_SMALL for
    7852              :          sections that should be marked as small in the section directive.  */
    7853            0 :       if (targetm.in_small_data_p (decl))
    7854              :         return false;
    7855              : 
    7856              :       /* Don't use section anchors for decls that won't fit inside a single
    7857              :          anchor range to reduce the amount of instructions required to refer
    7858              :          to the entire declaration.  */
    7859            0 :       if (DECL_SIZE_UNIT (decl) == NULL_TREE
    7860            0 :           || !tree_fits_uhwi_p (DECL_SIZE_UNIT (decl))
    7861            0 :           || (tree_to_uhwi (DECL_SIZE_UNIT (decl))
    7862            0 :               >= (unsigned HOST_WIDE_INT) targetm.max_anchor_offset))
    7863              :         return false;
    7864              : 
    7865              :     }
    7866              :   return true;
    7867              : }
    7868              : 
    7869              : /* Return true when RESOLUTION indicate that symbol will be bound to the
    7870              :    definition provided by current .o file.  */
    7871              : 
    7872              : static bool
    7873    285661760 : resolution_to_local_definition_p (enum ld_plugin_symbol_resolution resolution)
    7874              : {
    7875    285661760 :   return (resolution == LDPR_PREVAILING_DEF
    7876    285661760 :           || resolution == LDPR_PREVAILING_DEF_IRONLY_EXP
    7877            0 :           || resolution == LDPR_PREVAILING_DEF_IRONLY);
    7878              : }
    7879              : 
    7880              : /* Return true when RESOLUTION indicate that symbol will be bound locally
    7881              :    within current executable or DSO.  */
    7882              : 
    7883              : static bool
    7884    284718075 : resolution_local_p (enum ld_plugin_symbol_resolution resolution)
    7885              : {
    7886    284718075 :   return (resolution == LDPR_PREVAILING_DEF
    7887    284718075 :           || resolution == LDPR_PREVAILING_DEF_IRONLY
    7888    284718075 :           || resolution == LDPR_PREVAILING_DEF_IRONLY_EXP
    7889              :           || resolution == LDPR_PREEMPTED_REG
    7890    284718075 :           || resolution == LDPR_PREEMPTED_IR
    7891              :           || resolution == LDPR_RESOLVED_IR
    7892    569436142 :           || resolution == LDPR_RESOLVED_EXEC);
    7893              : }
    7894              : 
    7895              : /* COMMON_LOCAL_P is true means that the linker can guarantee that an
    7896              :    uninitialized common symbol in the executable will still be defined
    7897              :    (through COPY relocation) in the executable.  */
    7898              : 
    7899              : bool
    7900    768052975 : default_binds_local_p_3 (const_tree exp, bool shlib, bool weak_dominate,
    7901              :                          bool extern_protected_data, bool common_local_p)
    7902              : {
    7903              :   /* A non-decl is an entry in the constant pool.  */
    7904    768052975 :   if (!DECL_P (exp))
    7905              :     return true;
    7906              : 
    7907              :   /* Weakrefs may not bind locally, even though the weakref itself is always
    7908              :      static and therefore local.  Similarly, the resolver for ifunc functions
    7909              :      might resolve to a non-local function.
    7910              :      FIXME: We can resolve the weakref case more curefuly by looking at the
    7911              :      weakref alias.  */
    7912    764561612 :   if (lookup_attribute ("weakref", DECL_ATTRIBUTES (exp))
    7913    764561612 :       || (!targetm.ifunc_ref_local_ok ()
    7914     54413133 :           && TREE_CODE (exp) == FUNCTION_DECL
    7915     21489656 :           && cgraph_node::get (exp)
    7916     20470325 :           && cgraph_node::get (exp)->ifunc_resolver))
    7917         7656 :     return false;
    7918              : 
    7919              :   /* Static variables are always local.  */
    7920    764553956 :   if (! TREE_PUBLIC (exp))
    7921              :     return true;
    7922              : 
    7923              :   /* With resolution file in hand, take look into resolutions.
    7924              :      We can't just return true for resolved_locally symbols,
    7925              :      because dynamic linking might overwrite symbols
    7926              :      in shared libraries.  */
    7927    614751396 :   bool resolved_locally = false;
    7928              : 
    7929    614751396 :   bool uninited_common = (DECL_COMMON (exp)
    7930    614751396 :                           && (DECL_INITIAL (exp) == NULL
    7931       236268 :                               || (!in_lto_p
    7932       236268 :                                   && DECL_INITIAL (exp) == error_mark_node)));
    7933              : 
    7934              :   /* A non-external variable is defined locally only if it isn't
    7935              :      uninitialized COMMON variable or common_local_p is true.  */
    7936    614751396 :   bool defined_locally = (!DECL_EXTERNAL (exp)
    7937    614751396 :                           && (!uninited_common || common_local_p));
    7938    614751396 :   if (symtab_node *node = symtab_node::get (exp))
    7939              :     {
    7940    598779637 :       if (node->in_other_partition)
    7941         3706 :         defined_locally = true;
    7942    598779637 :       if (node->can_be_discarded_p ())
    7943              :         ;
    7944    285198498 :       else if (resolution_to_local_definition_p (node->resolution))
    7945              :         defined_locally = resolved_locally = true;
    7946    284718075 :       else if (resolution_local_p (node->resolution))
    7947    614751396 :         resolved_locally = true;
    7948              :     }
    7949    614751396 :   if (defined_locally && weak_dominate && !shlib)
    7950    614751396 :     resolved_locally = true;
    7951              : 
    7952              :   /* Undefined weak symbols are never defined locally.  */
    7953    614751396 :   if (DECL_WEAK (exp) && !defined_locally)
    7954              :     return false;
    7955              : 
    7956              :   /* A symbol is local if the user has said explicitly that it will be,
    7957              :      or if we have a definition for the symbol.  We cannot infer visibility
    7958              :      for undefined symbols.  */
    7959    614710574 :   if (DECL_VISIBILITY (exp) != VISIBILITY_DEFAULT
    7960     10527550 :       && (TREE_CODE (exp) == FUNCTION_DECL
    7961      1050068 :           || !extern_protected_data
    7962      1050020 :           || DECL_VISIBILITY (exp) != VISIBILITY_PROTECTED)
    7963    625238082 :       && (DECL_VISIBILITY_SPECIFIED (exp) || defined_locally))
    7964              :     return true;
    7965              : 
    7966              :   /* If PIC, then assume that any global name can be overridden by
    7967              :      symbols resolved from other modules.  */
    7968    610133486 :   if (shlib)
    7969              :     return false;
    7970              : 
    7971              :   /* Variables defined outside this object might not be local.  */
    7972    512332886 :   if (DECL_EXTERNAL (exp) && !resolved_locally)
    7973              :     return false;
    7974              : 
    7975              :   /* Non-dominant weak symbols are not defined locally.  */
    7976    302914444 :   if (DECL_WEAK (exp) && !resolved_locally)
    7977              :     return false;
    7978              : 
    7979              :   /* Uninitialized COMMON variable may be unified with symbols
    7980              :      resolved from other modules.  */
    7981    302914444 :   if (uninited_common && !resolved_locally)
    7982              :     return false;
    7983              : 
    7984              :   /* Otherwise we're left with initialized (or non-common) global data
    7985              :      which is of necessity defined locally.  */
    7986              :   return true;
    7987              : }
    7988              : 
    7989              : /* Assume ELF-ish defaults, since that's pretty much the most liberal
    7990              :    wrt cross-module name binding.  */
    7991              : 
    7992              : bool
    7993            0 : default_binds_local_p (const_tree exp)
    7994              : {
    7995            0 :   return default_binds_local_p_3 (exp, flag_shlib != 0, true, false, false);
    7996              : }
    7997              : 
    7998              : /* Similar to default_binds_local_p, but common symbol may be local and
    7999              :    extern protected data is non-local.  */
    8000              : 
    8001              : bool
    8002            0 : default_binds_local_p_2 (const_tree exp)
    8003              : {
    8004            0 :   return default_binds_local_p_3 (exp, flag_shlib != 0, true, true,
    8005            0 :                                   !flag_pic);
    8006              : }
    8007              : 
    8008              : bool
    8009            0 : default_binds_local_p_1 (const_tree exp, int shlib)
    8010              : {
    8011            0 :   return default_binds_local_p_3 (exp, shlib != 0, false, false, false);
    8012              : }
    8013              : 
    8014              : /* Return true when references to DECL must bind to current definition in
    8015              :    final executable.
    8016              : 
    8017              :    The condition is usually equivalent to whether the function binds to the
    8018              :    current module (shared library or executable), that is to binds_local_p.
    8019              :    We use this fact to avoid need for another target hook and implement
    8020              :    the logic using binds_local_p and just special cases where
    8021              :    decl_binds_to_current_def_p is stronger than binds_local_p.  In particular
    8022              :    the weak definitions (that can be overwritten at linktime by other
    8023              :    definition from different object file) and when resolution info is available
    8024              :    we simply use the knowledge passed to us by linker plugin.  */
    8025              : bool
    8026    746109995 : decl_binds_to_current_def_p (const_tree decl)
    8027              : {
    8028    746109995 :   gcc_assert (DECL_P (decl));
    8029    746109995 :   if (!targetm.binds_local_p (decl))
    8030              :     return false;
    8031    447456447 :   if (!TREE_PUBLIC (decl))
    8032              :     return true;
    8033              : 
    8034              :   /* When resolution is available, just use it.  */
    8035    302241899 :   if (symtab_node *node = symtab_node::get (decl))
    8036              :     {
    8037    302236105 :       if (node->resolution != LDPR_UNKNOWN
    8038    302236105 :           && !node->can_be_discarded_p ())
    8039       463262 :         return resolution_to_local_definition_p (node->resolution);
    8040              :     }
    8041              : 
    8042              :   /* Otherwise we have to assume the worst for DECL_WEAK (hidden weaks
    8043              :      binds locally but still can be overwritten), DECL_COMMON (can be merged
    8044              :      with a non-common definition somewhere in the same module) or
    8045              :      DECL_EXTERNAL.
    8046              :      This rely on fact that binds_local_p behave as decl_replaceable_p
    8047              :      for all other declaration types.  */
    8048    301778637 :   if (DECL_WEAK (decl))
    8049              :     return false;
    8050    220325638 :   if (DECL_COMDAT_GROUP (decl))
    8051              :     return false;
    8052    220322018 :   if (DECL_COMMON (decl)
    8053    220322018 :       && (DECL_INITIAL (decl) == NULL
    8054            6 :           || (!in_lto_p && DECL_INITIAL (decl) == error_mark_node)))
    8055              :     return false;
    8056    219491500 :   if (DECL_EXTERNAL (decl))
    8057              :     return false;
    8058              :   return true;
    8059              : }
    8060              : 
    8061              : /* A replaceable function or variable is one which may be replaced
    8062              :    at link-time with an entirely different definition, provided that the
    8063              :    replacement has the same type.  For example, functions declared
    8064              :    with __attribute__((weak)) on most systems are replaceable.
    8065              :    If SEMANTIC_INTERPOSITION_P is false allow interposition only on
    8066              :    symbols explicitly declared weak.
    8067              : 
    8068              :    COMDAT functions are not replaceable, since all definitions of the
    8069              :    function must be equivalent.  It is important that COMDAT functions
    8070              :    not be treated as replaceable so that use of C++ template
    8071              :    instantiations is not penalized.  */
    8072              : 
    8073              : bool
    8074    232575698 : decl_replaceable_p (tree decl, bool semantic_interposition_p)
    8075              : {
    8076    232575698 :   gcc_assert (DECL_P (decl));
    8077    232575698 :   if (!TREE_PUBLIC (decl) || DECL_COMDAT (decl))
    8078              :     return false;
    8079    167031881 :   if (!semantic_interposition_p
    8080    167031881 :       && !DECL_WEAK (decl))
    8081              :     return false;
    8082    166844891 :   return !decl_binds_to_current_def_p (decl);
    8083              : }
    8084              : 
    8085              : /* Default function to output code that will globalize a label.  A
    8086              :    target must define GLOBAL_ASM_OP or provide its own function to
    8087              :    globalize a label.  */
    8088              : #ifdef GLOBAL_ASM_OP
    8089              : void
    8090      2155583 : default_globalize_label (FILE * stream, const char *name)
    8091              : {
    8092      2155583 :   fputs (GLOBAL_ASM_OP, stream);
    8093      2155583 :   assemble_name (stream, name);
    8094      2155583 :   putc ('\n', stream);
    8095      2155583 : }
    8096              : #endif /* GLOBAL_ASM_OP */
    8097              : 
    8098              : /* Default function to output code that will globalize a declaration.  */
    8099              : void
    8100      2125391 : default_globalize_decl_name (FILE * stream, tree decl)
    8101              : {
    8102      2125391 :   const char *name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
    8103      2125391 :   targetm.asm_out.globalize_label (stream, name);
    8104      2125391 : }
    8105              : 
    8106              : /* Default function to output a label for unwind information.  The
    8107              :    default is to do nothing.  A target that needs nonlocal labels for
    8108              :    unwind information must provide its own function to do this.  */
    8109              : void
    8110           52 : default_emit_unwind_label (FILE * stream ATTRIBUTE_UNUSED,
    8111              :                            tree decl ATTRIBUTE_UNUSED,
    8112              :                            int for_eh ATTRIBUTE_UNUSED,
    8113              :                            int empty ATTRIBUTE_UNUSED)
    8114              : {
    8115           52 : }
    8116              : 
    8117              : /* Default function to output a label to divide up the exception table.
    8118              :    The default is to do nothing.  A target that needs/wants to divide
    8119              :    up the table must provide it's own function to do this.  */
    8120              : void
    8121        75984 : default_emit_except_table_label (FILE * stream ATTRIBUTE_UNUSED)
    8122              : {
    8123        75984 : }
    8124              : 
    8125              : /* This is how to output an internal numbered label where PREFIX is
    8126              :    the class of label and LABELNO is the number within the class.  */
    8127              : 
    8128              : void
    8129         4357 : default_generate_internal_label (char *buf, const char *prefix,
    8130              :                                  unsigned long labelno)
    8131              : {
    8132         4357 :   ASM_GENERATE_INTERNAL_LABEL (buf, prefix, labelno);
    8133         4357 : }
    8134              : 
    8135              : /* This is how to output an internal numbered label where PREFIX is
    8136              :    the class of label and LABELNO is the number within the class.  */
    8137              : 
    8138              : void
    8139     73276145 : default_internal_label (FILE *stream, const char *prefix,
    8140              :                         unsigned long labelno)
    8141              : {
    8142     73276145 :   char *const buf = (char *) alloca (40 + strlen (prefix));
    8143     73276145 :   ASM_GENERATE_INTERNAL_LABEL (buf, prefix, labelno);
    8144     73276145 :   ASM_OUTPUT_INTERNAL_LABEL (stream, buf);
    8145     73276145 : }
    8146              : 
    8147              : 
    8148              : /* The default implementation of ASM_DECLARE_CONSTANT_NAME.  */
    8149              : 
    8150              : void
    8151      1263576 : default_asm_declare_constant_name (FILE *file, const char *name,
    8152              :                                    const_tree exp ATTRIBUTE_UNUSED,
    8153              :                                    HOST_WIDE_INT size ATTRIBUTE_UNUSED)
    8154              : {
    8155      1263576 :   assemble_label (file, name);
    8156      1263576 : }
    8157              : 
    8158              : /* This is the default behavior at the beginning of a file.  It's
    8159              :    controlled by two other target-hook toggles.  */
    8160              : void
    8161       270554 : default_file_start (void)
    8162              : {
    8163       270554 :   if (targetm.asm_file_start_app_off
    8164            0 :       && !(flag_verbose_asm || flag_debug_asm || flag_dump_rtl_in_asm))
    8165            0 :     fputs (ASM_APP_OFF, asm_out_file);
    8166              : 
    8167       270554 :   if (targetm.asm_file_start_file_directive)
    8168              :     {
    8169              :       /* LTO produced units have no meaningful main_input_filename.  */
    8170       270554 :       if (in_lto_p)
    8171        12575 :         output_file_directive (asm_out_file, "<artificial>");
    8172              :       else
    8173       257979 :         output_file_directive (asm_out_file, main_input_filename);
    8174              :     }
    8175       270554 : }
    8176              : 
    8177              : /* This is a generic routine suitable for use as TARGET_ASM_FILE_END
    8178              :    which emits a special section directive used to indicate whether or
    8179              :    not this object file needs an executable stack.  This is primarily
    8180              :    a GNU extension to ELF but could be used on other targets.  */
    8181              : 
    8182              : int trampolines_created;
    8183              : 
    8184              : void
    8185       242078 : file_end_indicate_exec_stack (void)
    8186              : {
    8187       242078 :   unsigned int flags = SECTION_DEBUG;
    8188       242078 :   if (trampolines_created)
    8189          233 :     flags |= SECTION_CODE;
    8190              : 
    8191       242078 :   switch_to_section (get_section (".note.GNU-stack", flags, NULL));
    8192       242078 : }
    8193              : 
    8194              : /* Emit a special section directive to indicate that this object file
    8195              :    was compiled with -fsplit-stack.  This is used to let the linker
    8196              :    detect calls between split-stack code and non-split-stack code, so
    8197              :    that it can modify the split-stack code to allocate a sufficiently
    8198              :    large stack.  We emit another special section if there are any
    8199              :    functions in this file which have the no_split_stack attribute, to
    8200              :    prevent the linker from warning about being unable to convert the
    8201              :    functions if they call non-split-stack code.  */
    8202              : 
    8203              : void
    8204         4712 : file_end_indicate_split_stack (void)
    8205              : {
    8206         4712 :   if (flag_split_stack)
    8207              :     {
    8208         4712 :       switch_to_section (get_section (".note.GNU-split-stack", SECTION_DEBUG,
    8209              :                                       NULL));
    8210         4712 :       if (saw_no_split_stack)
    8211          399 :         switch_to_section (get_section (".note.GNU-no-split-stack",
    8212              :                                         SECTION_DEBUG, NULL));
    8213              :     }
    8214         4712 : }
    8215              : 
    8216              : /* Output DIRECTIVE (a C string) followed by a newline.  This is used as
    8217              :    a get_unnamed_section callback.  */
    8218              : 
    8219              : void
    8220      1759901 : output_section_asm_op (const char *directive)
    8221              : {
    8222      1759901 :   fprintf (asm_out_file, "%s\n", directive);
    8223      1759901 : }
    8224              : 
    8225              : /* Emit assembly code to switch to section NEW_SECTION.  Do nothing if
    8226              :    the current section is NEW_SECTION.  */
    8227              : 
    8228              : void
    8229     97592060 : switch_to_section (section *new_section, tree decl)
    8230              : {
    8231     97592060 :   bool retain_p;
    8232     97592060 :   if ((new_section->common.flags & SECTION_NAMED)
    8233     70402263 :       && decl != nullptr
    8234      1839407 :       && DECL_P (decl)
    8235     99431467 :       && ((retain_p = !!lookup_attribute ("retain",
    8236      1839407 :                                           DECL_ATTRIBUTES (decl)))
    8237      1839407 :           != !!(new_section->common.flags & SECTION_RETAIN)))
    8238              :     {
    8239              :       /* If the SECTION_RETAIN bit doesn't match, switch to a new
    8240              :          section.  */
    8241           24 :       tree used_decl, no_used_decl;
    8242              : 
    8243           24 :       if (retain_p)
    8244              :         {
    8245           12 :           new_section->common.flags |= SECTION_RETAIN;
    8246           12 :           used_decl = decl;
    8247           12 :           no_used_decl = new_section->named.decl;
    8248              :         }
    8249              :       else
    8250              :         {
    8251           12 :           new_section->common.flags &= ~(SECTION_RETAIN
    8252              :                                          | SECTION_DECLARED);
    8253           12 :           used_decl = new_section->named.decl;
    8254           12 :           no_used_decl = decl;
    8255              :         }
    8256           24 :       if (no_used_decl != used_decl)
    8257              :         {
    8258           24 :           warning (OPT_Wattributes,
    8259              :                    "%+qD without %<retain%> attribute and %qD with "
    8260              :                    "%<retain%> attribute are placed in a section with "
    8261              :                    "the same name", no_used_decl, used_decl);
    8262           24 :           inform (DECL_SOURCE_LOCATION (used_decl),
    8263              :                   "%qD was declared here", used_decl);
    8264              :         }
    8265              :     }
    8266     97592036 :   else if (in_section == new_section)
    8267              :     return;
    8268              : 
    8269      5324085 :   in_section = new_section;
    8270              : 
    8271      5324085 :   switch (SECTION_STYLE (new_section))
    8272              :     {
    8273      3564184 :     case SECTION_NAMED:
    8274      3564184 :       targetm.asm_out.named_section (new_section->named.name,
    8275              :                                      new_section->named.common.flags,
    8276              :                                      new_section->named.decl);
    8277      3564184 :       break;
    8278              : 
    8279      1759901 :     case SECTION_UNNAMED:
    8280      1759901 :       new_section->unnamed.callback (new_section->unnamed.data);
    8281      1759901 :       break;
    8282              : 
    8283            0 :     case SECTION_NOSWITCH:
    8284            0 :       gcc_unreachable ();
    8285      5324085 :       break;
    8286              :     }
    8287              : 
    8288      5324085 :   new_section->common.flags |= SECTION_DECLARED;
    8289              : }
    8290              : 
    8291              : /* If block symbol SYMBOL has not yet been assigned an offset, place
    8292              :    it at the end of its block.  */
    8293              : 
    8294              : void
    8295            0 : place_block_symbol (rtx symbol)
    8296              : {
    8297            0 :   unsigned HOST_WIDE_INT size, mask, offset;
    8298            0 :   class constant_descriptor_rtx *desc;
    8299            0 :   unsigned int alignment;
    8300            0 :   struct object_block *block;
    8301            0 :   tree decl;
    8302              : 
    8303            0 :   gcc_assert (SYMBOL_REF_BLOCK (symbol));
    8304            0 :   if (SYMBOL_REF_BLOCK_OFFSET (symbol) >= 0)
    8305              :     return;
    8306              : 
    8307              :   /* Work out the symbol's size and alignment.  */
    8308            0 :   if (CONSTANT_POOL_ADDRESS_P (symbol))
    8309              :     {
    8310            0 :       desc = SYMBOL_REF_CONSTANT (symbol);
    8311            0 :       alignment = desc->align;
    8312            0 :       size = GET_MODE_SIZE (desc->mode);
    8313              :     }
    8314            0 :   else if (TREE_CONSTANT_POOL_ADDRESS_P (symbol))
    8315              :     {
    8316            0 :       decl = SYMBOL_REF_DECL (symbol);
    8317            0 :       gcc_checking_assert (DECL_IN_CONSTANT_POOL (decl));
    8318            0 :       alignment = DECL_ALIGN (decl);
    8319            0 :       size = get_constant_size (DECL_INITIAL (decl));
    8320            0 :       if ((flag_sanitize & SANITIZE_ADDRESS)
    8321            0 :           && TREE_CODE (DECL_INITIAL (decl)) == STRING_CST
    8322            0 :           && asan_protect_global (DECL_INITIAL (decl)))
    8323              :         {
    8324            0 :           size += asan_red_zone_size (size);
    8325            0 :           alignment = MAX (alignment,
    8326              :                            ASAN_RED_ZONE_SIZE * BITS_PER_UNIT);
    8327              :         }
    8328              :     }
    8329              :   else
    8330              :     {
    8331            0 :       struct symtab_node *snode;
    8332            0 :       decl = SYMBOL_REF_DECL (symbol);
    8333              : 
    8334            0 :       snode = symtab_node::get (decl);
    8335            0 :       if (snode->alias)
    8336              :         {
    8337            0 :           rtx target = DECL_RTL (snode->ultimate_alias_target ()->decl);
    8338              : 
    8339            0 :           gcc_assert (MEM_P (target)
    8340              :                       && GET_CODE (XEXP (target, 0)) == SYMBOL_REF
    8341              :                       && SYMBOL_REF_HAS_BLOCK_INFO_P (XEXP (target, 0)));
    8342            0 :           target = XEXP (target, 0);
    8343            0 :           place_block_symbol (target);
    8344            0 :           SYMBOL_REF_BLOCK_OFFSET (symbol) = SYMBOL_REF_BLOCK_OFFSET (target);
    8345            0 :           return;
    8346              :         }
    8347            0 :       alignment = get_variable_align (decl);
    8348            0 :       size = tree_to_uhwi (DECL_SIZE_UNIT (decl));
    8349            0 :       if ((flag_sanitize & SANITIZE_ADDRESS)
    8350            0 :           && asan_protect_global (decl))
    8351              :         {
    8352            0 :           size += asan_red_zone_size (size);
    8353            0 :           alignment = MAX (alignment,
    8354              :                            ASAN_RED_ZONE_SIZE * BITS_PER_UNIT);
    8355              :         }
    8356              :     }
    8357              : 
    8358              :   /* Calculate the object's offset from the start of the block.  */
    8359            0 :   block = SYMBOL_REF_BLOCK (symbol);
    8360            0 :   mask = alignment / BITS_PER_UNIT - 1;
    8361            0 :   offset = (block->size + mask) & ~mask;
    8362            0 :   SYMBOL_REF_BLOCK_OFFSET (symbol) = offset;
    8363              : 
    8364              :   /* Record the block's new alignment and size.  */
    8365            0 :   block->alignment = MAX (block->alignment, alignment);
    8366            0 :   block->size = offset + size;
    8367              : 
    8368            0 :   vec_safe_push (block->objects, symbol);
    8369              : }
    8370              : 
    8371              : /* Return the anchor that should be used to address byte offset OFFSET
    8372              :    from the first object in BLOCK.  MODEL is the TLS model used
    8373              :    to access it.  */
    8374              : 
    8375              : rtx
    8376            0 : get_section_anchor (struct object_block *block, HOST_WIDE_INT offset,
    8377              :                     enum tls_model model)
    8378              : {
    8379            0 :   char label[100];
    8380            0 :   unsigned int begin, middle, end;
    8381            0 :   unsigned HOST_WIDE_INT min_offset, max_offset, range, bias, delta;
    8382            0 :   rtx anchor;
    8383              : 
    8384              :   /* Work out the anchor's offset.  Use an offset of 0 for the first
    8385              :      anchor so that we don't pessimize the case where we take the address
    8386              :      of a variable at the beginning of the block.  This is particularly
    8387              :      useful when a block has only one variable assigned to it.
    8388              : 
    8389              :      We try to place anchors RANGE bytes apart, so there can then be
    8390              :      anchors at +/-RANGE, +/-2 * RANGE, and so on, up to the limits of
    8391              :      a ptr_mode offset.  With some target settings, the lowest such
    8392              :      anchor might be out of range for the lowest ptr_mode offset;
    8393              :      likewise the highest anchor for the highest offset.  Use anchors
    8394              :      at the extreme ends of the ptr_mode range in such cases.
    8395              : 
    8396              :      All arithmetic uses unsigned integers in order to avoid
    8397              :      signed overflow.  */
    8398            0 :   max_offset = (unsigned HOST_WIDE_INT) targetm.max_anchor_offset;
    8399            0 :   min_offset = (unsigned HOST_WIDE_INT) targetm.min_anchor_offset;
    8400            0 :   range = max_offset - min_offset + 1;
    8401            0 :   if (range == 0)
    8402              :     offset = 0;
    8403              :   else
    8404              :     {
    8405            0 :       bias = HOST_WIDE_INT_1U << (GET_MODE_BITSIZE (ptr_mode) - 1);
    8406            0 :       if (offset < 0)
    8407              :         {
    8408            0 :           delta = -(unsigned HOST_WIDE_INT) offset + max_offset;
    8409            0 :           delta -= delta % range;
    8410            0 :           if (delta > bias)
    8411              :             delta = bias;
    8412            0 :           offset = (HOST_WIDE_INT) (-delta);
    8413              :         }
    8414              :       else
    8415              :         {
    8416            0 :           delta = (unsigned HOST_WIDE_INT) offset - min_offset;
    8417            0 :           delta -= delta % range;
    8418            0 :           if (delta > bias - 1)
    8419              :             delta = bias - 1;
    8420            0 :           offset = (HOST_WIDE_INT) delta;
    8421              :         }
    8422              :     }
    8423              : 
    8424              :   /* Do a binary search to see if there's already an anchor we can use.
    8425              :      Set BEGIN to the new anchor's index if not.  */
    8426            0 :   begin = 0;
    8427            0 :   end = vec_safe_length (block->anchors);
    8428            0 :   while (begin != end)
    8429              :     {
    8430            0 :       middle = (end + begin) / 2;
    8431            0 :       anchor = (*block->anchors)[middle];
    8432            0 :       if (SYMBOL_REF_BLOCK_OFFSET (anchor) > offset)
    8433              :         end = middle;
    8434            0 :       else if (SYMBOL_REF_BLOCK_OFFSET (anchor) < offset)
    8435            0 :         begin = middle + 1;
    8436            0 :       else if (SYMBOL_REF_TLS_MODEL (anchor) > model)
    8437              :         end = middle;
    8438            0 :       else if (SYMBOL_REF_TLS_MODEL (anchor) < model)
    8439            0 :         begin = middle + 1;
    8440              :       else
    8441              :         return anchor;
    8442              :     }
    8443              : 
    8444              :   /* Create a new anchor with a unique label.  */
    8445            0 :   ASM_GENERATE_INTERNAL_LABEL (label, "LANCHOR", anchor_labelno++);
    8446            0 :   anchor = create_block_symbol (ggc_strdup (label), block, offset);
    8447            0 :   SYMBOL_REF_FLAGS (anchor) |= SYMBOL_FLAG_LOCAL | SYMBOL_FLAG_ANCHOR;
    8448            0 :   SYMBOL_REF_FLAGS (anchor) |= model << SYMBOL_FLAG_TLS_SHIFT;
    8449              : 
    8450              :   /* Insert it at index BEGIN.  */
    8451            0 :   vec_safe_insert (block->anchors, begin, anchor);
    8452            0 :   return anchor;
    8453              : }
    8454              : 
    8455              : /* Output the objects in BLOCK.  */
    8456              : 
    8457              : static void
    8458            0 : output_object_block (struct object_block *block)
    8459              : {
    8460            0 :   class constant_descriptor_rtx *desc;
    8461            0 :   unsigned int i;
    8462            0 :   HOST_WIDE_INT offset;
    8463            0 :   tree decl;
    8464            0 :   rtx symbol;
    8465              : 
    8466            0 :   if (!block->objects)
    8467            0 :     return;
    8468              : 
    8469              :   /* Switch to the section and make sure that the first byte is
    8470              :      suitably aligned.  */
    8471              :   /* Special case VTV comdat sections similar to assemble_variable.  */
    8472            0 :   if (SECTION_STYLE (block->sect) == SECTION_NAMED
    8473            0 :       && block->sect->named.name
    8474            0 :       && (strcmp (block->sect->named.name, ".vtable_map_vars") == 0))
    8475            0 :     handle_vtv_comdat_section (block->sect, block->sect->named.decl);
    8476              :   else
    8477            0 :     switch_to_section (block->sect, SYMBOL_REF_DECL ((*block->objects)[0]));
    8478              : 
    8479            0 :   gcc_checking_assert (!(block->sect->common.flags & SECTION_MERGE));
    8480            0 :   assemble_align (block->alignment);
    8481              : 
    8482              :   /* Define the values of all anchors relative to the current section
    8483              :      position.  */
    8484            0 :   FOR_EACH_VEC_SAFE_ELT (block->anchors, i, symbol)
    8485            0 :     targetm.asm_out.output_anchor (symbol);
    8486              : 
    8487              :   /* Output the objects themselves.  */
    8488              :   offset = 0;
    8489            0 :   FOR_EACH_VEC_ELT (*block->objects, i, symbol)
    8490              :     {
    8491              :       /* Move to the object's offset, padding with zeros if necessary.  */
    8492            0 :       assemble_zeros (SYMBOL_REF_BLOCK_OFFSET (symbol) - offset);
    8493            0 :       offset = SYMBOL_REF_BLOCK_OFFSET (symbol);
    8494            0 :       if (CONSTANT_POOL_ADDRESS_P (symbol))
    8495              :         {
    8496            0 :           desc = SYMBOL_REF_CONSTANT (symbol);
    8497              :           /* Pass 1 for align as we have already laid out everything in the block.
    8498              :              So aligning shouldn't be necessary.  */
    8499            0 :           output_constant_pool_1 (desc, 1);
    8500            0 :           offset += GET_MODE_SIZE (desc->mode);
    8501              :         }
    8502            0 :       else if (TREE_CONSTANT_POOL_ADDRESS_P (symbol))
    8503              :         {
    8504            0 :           HOST_WIDE_INT size;
    8505            0 :           decl = SYMBOL_REF_DECL (symbol);
    8506            0 :           assemble_constant_contents (DECL_INITIAL (decl), XSTR (symbol, 0),
    8507            0 :                                       DECL_ALIGN (decl), false);
    8508              : 
    8509            0 :           size = get_constant_size (DECL_INITIAL (decl));
    8510            0 :           offset += size;
    8511            0 :           if ((flag_sanitize & SANITIZE_ADDRESS)
    8512            0 :               && TREE_CODE (DECL_INITIAL (decl)) == STRING_CST
    8513            0 :               && asan_protect_global (DECL_INITIAL (decl)))
    8514              :             {
    8515            0 :               size = asan_red_zone_size (size);
    8516            0 :               assemble_zeros (size);
    8517            0 :               offset += size;
    8518              :             }
    8519              :         }
    8520              :       else
    8521              :         {
    8522            0 :           HOST_WIDE_INT size;
    8523            0 :           decl = SYMBOL_REF_DECL (symbol);
    8524            0 :           assemble_variable_contents (decl, XSTR (symbol, 0), false, false);
    8525            0 :           size = tree_to_uhwi (DECL_SIZE_UNIT (decl));
    8526            0 :           offset += size;
    8527            0 :           if ((flag_sanitize & SANITIZE_ADDRESS)
    8528            0 :               && asan_protect_global (decl))
    8529              :             {
    8530            0 :               size = asan_red_zone_size (size);
    8531            0 :               assemble_zeros (size);
    8532            0 :               offset += size;
    8533              :             }
    8534              :         }
    8535              :     }
    8536              : }
    8537              : 
    8538              : /* A callback for qsort to compare object_blocks.  */
    8539              : 
    8540              : static int
    8541            0 : output_object_block_compare (const void *x, const void *y)
    8542              : {
    8543            0 :   object_block *p1 = *(object_block * const*)x;
    8544            0 :   object_block *p2 = *(object_block * const*)y;
    8545              : 
    8546            0 :   if (p1->sect->common.flags & SECTION_NAMED
    8547            0 :       && !(p2->sect->common.flags & SECTION_NAMED))
    8548              :     return 1;
    8549              : 
    8550            0 :   if (!(p1->sect->common.flags & SECTION_NAMED)
    8551            0 :       && p2->sect->common.flags & SECTION_NAMED)
    8552              :     return -1;
    8553              : 
    8554            0 :   if (p1->sect->common.flags & SECTION_NAMED
    8555            0 :       && p2->sect->common.flags & SECTION_NAMED)
    8556            0 :     return strcmp (p1->sect->named.name, p2->sect->named.name);
    8557              : 
    8558            0 :   unsigned f1 = p1->sect->common.flags;
    8559            0 :   unsigned f2 = p2->sect->common.flags;
    8560            0 :   if (f1 == f2)
    8561              :     return 0;
    8562            0 :   return f1 < f2 ? -1 : 1;
    8563              : }
    8564              : 
    8565              : /* Output the definitions of all object_blocks.  */
    8566              : 
    8567              : void
    8568       230133 : output_object_blocks (void)
    8569              : {
    8570       230133 :   vec<object_block *, va_heap> v;
    8571       230133 :   v.create (object_block_htab->elements ());
    8572       230133 :   object_block *obj;
    8573       230133 :   hash_table<object_block_hasher>::iterator hi;
    8574              : 
    8575       230133 :   FOR_EACH_HASH_TABLE_ELEMENT (*object_block_htab, obj, object_block *, hi)
    8576            0 :     v.quick_push (obj);
    8577              : 
    8578              :   /* Sort them in order to output them in a deterministic manner,
    8579              :      otherwise we may get .rodata sections in different orders with
    8580              :      and without -g.  */
    8581       230133 :   v.qsort (output_object_block_compare);
    8582              :   unsigned i;
    8583       230133 :   FOR_EACH_VEC_ELT (v, i, obj)
    8584            0 :     output_object_block (obj);
    8585              : 
    8586       230133 :   v.release ();
    8587       230133 : }
    8588              : 
    8589              : /* This function provides a possible implementation of the
    8590              :    TARGET_ASM_RECORD_GCC_SWITCHES target hook for ELF targets.  When triggered
    8591              :    by -frecord-gcc-switches it creates a new mergeable, string section in the
    8592              :    assembler output file called TARGET_ASM_RECORD_GCC_SWITCHES_SECTION which
    8593              :    contains the switches in ASCII format.
    8594              : 
    8595              :    FIXME: This code does not correctly handle double quote characters
    8596              :    that appear inside strings, (it strips them rather than preserving them).
    8597              :    FIXME: ASM_OUTPUT_ASCII, as defined in config/elfos.h will not emit NUL
    8598              :    characters - instead it treats them as sub-string separators.  Since
    8599              :    we want to emit NUL strings terminators into the object file we have to use
    8600              :    ASM_OUTPUT_SKIP.  */
    8601              : 
    8602              : void
    8603            0 : elf_record_gcc_switches (const char *options)
    8604              : {
    8605            0 :   section *sec = get_section (targetm.asm_out.record_gcc_switches_section,
    8606              :                               SECTION_DEBUG | SECTION_MERGE
    8607              :                               | SECTION_STRINGS | (SECTION_ENTSIZE & 1), NULL);
    8608            0 :   switch_to_section (sec);
    8609            0 :   ASM_OUTPUT_ASCII (asm_out_file, options, strlen (options) + 1);
    8610            0 : }
    8611              : 
    8612              : /* Emit text to declare externally defined symbols. It is needed to
    8613              :    properly support non-default visibility.  */
    8614              : void
    8615      1800686 : default_elf_asm_output_external (FILE *file ATTRIBUTE_UNUSED,
    8616              :                                  tree decl,
    8617              :                                  const char *name ATTRIBUTE_UNUSED)
    8618              : {
    8619              :   /* We output the name if and only if TREE_SYMBOL_REFERENCED is
    8620              :      set in order to avoid putting out names that are never really
    8621              :      used.  Always output visibility specified in the source.  */
    8622      1800686 :   if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))
    8623      1800686 :       && (DECL_VISIBILITY_SPECIFIED (decl)
    8624      1598883 :           || targetm.binds_local_p (decl)))
    8625       191329 :     maybe_assemble_visibility (decl);
    8626      1800686 : }
    8627              : 
    8628              : /* The default hook for TARGET_ASM_OUTPUT_SOURCE_FILENAME.  */
    8629              : 
    8630              : void
    8631       270554 : default_asm_output_source_filename (FILE *file, const char *name)
    8632              : {
    8633              : #ifdef ASM_OUTPUT_SOURCE_FILENAME
    8634              :   ASM_OUTPUT_SOURCE_FILENAME (file, name);
    8635              : #else
    8636       270554 :   fprintf (file, "\t.file\t");
    8637       270554 :   output_quoted_string (file, name);
    8638       270554 :   putc ('\n', file);
    8639              : #endif
    8640       270554 : }
    8641              : 
    8642              : /* Output a file name in the form wanted by System V.  */
    8643              : 
    8644              : void
    8645       270554 : output_file_directive (FILE *asm_file, const char *input_name)
    8646              : {
    8647       270554 :   int len;
    8648       270554 :   const char *na;
    8649              : 
    8650       270554 :   if (input_name == NULL)
    8651              :     input_name = "<stdin>";
    8652              :   else
    8653       270554 :     input_name = remap_debug_filename (input_name);
    8654              : 
    8655       270554 :   len = strlen (input_name);
    8656       270554 :   na = input_name + len;
    8657              : 
    8658              :   /* NA gets INPUT_NAME sans directory names.  */
    8659      3857784 :   while (na > input_name)
    8660              :     {
    8661      3827969 :       if (IS_DIR_SEPARATOR (na[-1]))
    8662              :         break;
    8663      3587230 :       na--;
    8664              :     }
    8665              : 
    8666       270554 :   targetm.asm_out.output_source_filename (asm_file, na);
    8667       270554 : }
    8668              : 
    8669              : /* Create a DEBUG_EXPR_DECL / DEBUG_EXPR pair from RTL expression
    8670              :    EXP.  */
    8671              : rtx
    8672       285664 : make_debug_expr_from_rtl (const_rtx exp)
    8673              : {
    8674       285664 :   tree ddecl = make_node (DEBUG_EXPR_DECL), type;
    8675       285664 :   machine_mode mode = GET_MODE (exp);
    8676       285664 :   rtx dval;
    8677              : 
    8678       285664 :   DECL_ARTIFICIAL (ddecl) = 1;
    8679       285664 :   if (REG_P (exp) && REG_EXPR (exp))
    8680       234798 :     type = TREE_TYPE (REG_EXPR (exp));
    8681        54582 :   else if (MEM_P (exp) && MEM_EXPR (exp))
    8682         3716 :     type = TREE_TYPE (MEM_EXPR (exp));
    8683              :   else
    8684              :     type = NULL_TREE;
    8685       238514 :   if (type && TYPE_MODE (type) == mode)
    8686       187658 :     TREE_TYPE (ddecl) = type;
    8687              :   else
    8688        98006 :     TREE_TYPE (ddecl) = lang_hooks.types.type_for_mode (mode, 1);
    8689       285664 :   SET_DECL_MODE (ddecl, mode);
    8690       285664 :   dval = gen_rtx_DEBUG_EXPR (mode);
    8691       285664 :   DEBUG_EXPR_TREE_DECL (dval) = ddecl;
    8692       285664 :   SET_DECL_RTL (ddecl, dval);
    8693       285664 :   return dval;
    8694              : }
    8695              : 
    8696              : #ifdef ELF_ASCII_ESCAPES
    8697              : /* Default ASM_OUTPUT_LIMITED_STRING for ELF targets.  */
    8698              : 
    8699              : void
    8700     25715555 : default_elf_asm_output_limited_string (FILE *f, const char *s)
    8701              : {
    8702     25715555 :   int escape;
    8703     25715555 :   unsigned char c;
    8704              : 
    8705     25715555 :   fputs (STRING_ASM_OP "\"", f);
    8706    789312070 :   while (*s != '\0')
    8707              :     {
    8708    737880960 :       c = *s;
    8709    737880960 :       escape = ELF_ASCII_ESCAPES[c];
    8710    737880960 :       switch (escape)
    8711              :         {
    8712    737682266 :         case 0:
    8713    737682266 :           putc (c, f);
    8714    737682266 :           break;
    8715        89361 :         case 1:
    8716        89361 :           putc ('\\', f);
    8717        89361 :           putc ('0'+((c>>6)&7), f);
    8718        89361 :           putc ('0'+((c>>3)&7), f);
    8719        89361 :           putc ('0'+(c&7), f);
    8720        89361 :           break;
    8721       109333 :         default:
    8722       109333 :           putc ('\\', f);
    8723       109333 :           putc (escape, f);
    8724       109333 :           break;
    8725              :         }
    8726    737880960 :       s++;
    8727              :     }
    8728     25715555 :   putc ('\"', f);
    8729     25715555 :   putc ('\n', f);
    8730     25715555 : }
    8731              : 
    8732              : /* Default ASM_OUTPUT_ASCII for ELF targets.  */
    8733              : 
    8734              : void
    8735     35930778 : default_elf_asm_output_ascii (FILE *f, const char *s, unsigned int len)
    8736              : {
    8737     35930778 :   const char *limit = s + len;
    8738     35930778 :   const char *last_null = NULL;
    8739     35930778 :   const char *last_base64 = s;
    8740     35930778 :   unsigned bytes_in_chunk = 0;
    8741     35930778 :   unsigned char c;
    8742     35930778 :   int escape;
    8743     35930778 :   bool prev_base64 = false;
    8744              : 
    8745    295227686 :   for (; s < limit; s++)
    8746              :     {
    8747    259296908 :       const char *p;
    8748              : 
    8749    259296908 :       if (bytes_in_chunk >= 60)
    8750              :         {
    8751      3268789 :           putc ('\"', f);
    8752      3268789 :           putc ('\n', f);
    8753      3268789 :           bytes_in_chunk = 0;
    8754              :         }
    8755              : 
    8756    259296908 :       if ((uintptr_t) s > (uintptr_t) last_null)
    8757              :         {
    8758   1064910049 :           for (p = s; p < limit && *p != '\0'; p++)
    8759   1028659404 :             continue;
    8760              :           last_null = p;
    8761              :         }
    8762              :       else
    8763              :         p = last_null;
    8764              : 
    8765              : #if defined(BASE64_ASM_OP) \
    8766              :     && BITS_PER_UNIT == 8 \
    8767              :     && CHAR_BIT == 8 \
    8768              :     && 'A' == 65 \
    8769              :     && 'a' == 97 \
    8770              :     && '0' == 48 \
    8771              :     && '+' == 43 \
    8772              :     && '/' == 47 \
    8773              :     && '=' == 61
    8774    259296908 :       if (s >= last_base64)
    8775              :         {
    8776              :           unsigned cnt = 0;
    8777              :           unsigned char prev_c = ' ';
    8778              :           const char *t;
    8779   1128547940 :           for (t = s; t < limit && (t - s) < (long) ELF_STRING_LIMIT - 1; t++)
    8780              :             {
    8781   1115255855 :               if (t == p && t != s)
    8782              :                 {
    8783     24848853 :                   if (cnt <= ((unsigned) (t - s) + 1 + 2) / 3 * 4
    8784     23884779 :                       && (!prev_base64 || (t - s) >= 16)
    8785     23880311 :                       && ((t - s) > 1 || cnt <= 2))
    8786              :                     {
    8787     23790834 :                       last_base64 = p;
    8788     23790834 :                       goto no_base64;
    8789              :                     }
    8790              :                 }
    8791   1091465021 :               c = *t;
    8792   1091465021 :               escape = ELF_ASCII_ESCAPES[c];
    8793   1091465021 :               switch (escape)
    8794              :                 {
    8795    998194794 :                 case 0:
    8796    998194794 :                   ++cnt;
    8797    998194794 :                   break;
    8798     87899232 :                 case 1:
    8799     87899232 :                   if (c == 0)
    8800              :                     {
    8801     10850839 :                       if (prev_c == 0
    8802      5605413 :                           && t + 1 < limit
    8803      4754058 :                           && (t + 1 - s) < (long) ELF_STRING_LIMIT - 1)
    8804              :                         break;
    8805      6098797 :                       cnt += 2 + strlen (STRING_ASM_OP) + 1;
    8806              :                     }
    8807              :                   else
    8808     77048393 :                     cnt += 4;
    8809              :                   break;
    8810      5370995 :                 default:
    8811      5370995 :                   cnt += 2;
    8812      5370995 :                   break;
    8813              :                 }
    8814   1091465021 :               prev_c = c;
    8815              :             }
    8816     13292085 :           if (cnt > ((unsigned) (t - s) + 2) / 3 * 4 && (t - s) >= 3)
    8817              :             {
    8818      1778108 :               if (bytes_in_chunk > 0)
    8819              :                 {
    8820          540 :                   putc ('\"', f);
    8821          540 :                   putc ('\n', f);
    8822          540 :                   bytes_in_chunk = 0;
    8823              :                 }
    8824              : 
    8825      1778108 :               unsigned char buf[(ELF_STRING_LIMIT + 2) / 3 * 4 + 3];
    8826      1778108 :               unsigned j = 0;
    8827      1778108 :               static const char base64_enc[] =
    8828              :                 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
    8829              :                 "0123456789+/";
    8830              : 
    8831      1778108 :               fputs (BASE64_ASM_OP "\"", f);
    8832     47075626 :               while (s < t)
    8833              :                 {
    8834     44795742 :                   unsigned char a = *s;
    8835     44795742 :                   unsigned char b = 0, c = 0;
    8836     44795742 :                   if (s < t - 1)
    8837     44221142 :                     b = s[1];
    8838     44795742 :                   if (s < t - 2)
    8839     43519410 :                     c = s[2];
    8840     44795742 :                   unsigned long v = ((((unsigned long) a) << 16)
    8841     44795742 :                                      | (((unsigned long) b) << 8)
    8842     44795742 :                                      | c);
    8843     44795742 :                   buf[j++] = base64_enc[(v >> 18) & 63];
    8844     44795742 :                   buf[j++] = base64_enc[(v >> 12) & 63];
    8845     44795742 :                   buf[j++] = base64_enc[(v >> 6) & 63];
    8846     44795742 :                   buf[j++] = base64_enc[v & 63];
    8847     44795742 :                   if (s >= t - 2)
    8848              :                     {
    8849      1276332 :                       buf[j - 1] = '=';
    8850      1276332 :                       if (s >= t - 1)
    8851       574600 :                         buf[j - 2] = '=';
    8852              :                       break;
    8853              :                     }
    8854     43519410 :                   s += 3;
    8855              :                 }
    8856      1778108 :               memcpy (buf + j, "\"\n", 3);
    8857      1778108 :               fputs ((const char *) buf, f);
    8858      1778108 :               s = t - 1;
    8859      1778108 :               prev_base64 = true;
    8860      1778108 :               continue;
    8861      1778108 :             }
    8862              :           last_base64 = t;
    8863              :         no_base64:
    8864              :           prev_base64 = false;
    8865              :         }
    8866              : #else
    8867              :       (void) last_base64;
    8868              :       (void) prev_base64;
    8869              : #endif
    8870              : 
    8871    257518800 :       if (p < limit && (p - s) <= (long) ELF_STRING_LIMIT)
    8872              :         {
    8873     25717367 :           if (bytes_in_chunk > 0)
    8874              :             {
    8875       187408 :               putc ('\"', f);
    8876       187408 :               putc ('\n', f);
    8877       187408 :               bytes_in_chunk = 0;
    8878              :             }
    8879              : 
    8880     25717367 :           if (p == s && p + 1 < limit && p[1] == '\0')
    8881              :             {
    8882        34742 :               for (p = s + 2; p < limit && *p == '\0'; p++)
    8883        32930 :                 continue;
    8884         1812 :               ASM_OUTPUT_SKIP (f, (unsigned HOST_WIDE_INT) (p - s));
    8885         1812 :               s = p - 1;
    8886              :             }
    8887              :           else
    8888              :             {
    8889     25715555 :               default_elf_asm_output_limited_string (f, s);
    8890     25715555 :               s = p;
    8891              :             }
    8892              :         }
    8893              :       else
    8894              :         {
    8895    231801433 :           if (bytes_in_chunk == 0)
    8896     12334579 :             fputs (ASCII_DATA_ASM_OP "\"", f);
    8897              : 
    8898    231801433 :           c = *s;
    8899    231801433 :           escape = ELF_ASCII_ESCAPES[c];
    8900    231801433 :           switch (escape)
    8901              :             {
    8902    229037323 :             case 0:
    8903    229037323 :               putc (c, f);
    8904    229037323 :               bytes_in_chunk++;
    8905    229037323 :               break;
    8906      1062671 :             case 1:
    8907      1062671 :               putc ('\\', f);
    8908      1062671 :               putc ('0'+((c>>6)&7), f);
    8909      1062671 :               putc ('0'+((c>>3)&7), f);
    8910      1062671 :               putc ('0'+(c&7), f);
    8911      1062671 :               bytes_in_chunk += 4;
    8912      1062671 :               break;
    8913      1701439 :             default:
    8914      1701439 :               putc ('\\', f);
    8915      1701439 :               putc (escape, f);
    8916      1701439 :               bytes_in_chunk += 2;
    8917      1701439 :               break;
    8918              :             }
    8919              : 
    8920              :         }
    8921              :     }
    8922              : 
    8923     35930778 :   if (bytes_in_chunk > 0)
    8924              :     {
    8925      8877842 :       putc ('\"', f);
    8926      8877842 :       putc ('\n', f);
    8927              :     }
    8928     35930778 : }
    8929              : #endif
    8930              : 
    8931              : static GTY(()) section *elf_init_array_section;
    8932              : static GTY(()) section *elf_fini_array_section;
    8933              : 
    8934              : static section *
    8935        23526 : get_elf_initfini_array_priority_section (int priority,
    8936              :                                          bool constructor_p)
    8937              : {
    8938        23526 :   section *sec;
    8939        23526 :   if (priority != DEFAULT_INIT_PRIORITY)
    8940              :     {
    8941         4853 :       char buf[18];
    8942         4853 :       sprintf (buf, "%s.%.5u",
    8943              :                constructor_p ? ".init_array" : ".fini_array",
    8944              :                priority);
    8945         4853 :       sec = get_section (buf, SECTION_WRITE | SECTION_NOTYPE, NULL_TREE);
    8946              :     }
    8947              :   else
    8948              :     {
    8949        18673 :       if (constructor_p)
    8950              :         {
    8951        18614 :           if (elf_init_array_section == NULL)
    8952        17791 :             elf_init_array_section
    8953        17791 :               = get_section (".init_array",
    8954              :                              SECTION_WRITE | SECTION_NOTYPE, NULL_TREE);
    8955        18614 :           sec = elf_init_array_section;
    8956              :         }
    8957              :       else
    8958              :         {
    8959           59 :           if (elf_fini_array_section == NULL)
    8960           51 :             elf_fini_array_section
    8961           51 :               = get_section (".fini_array",
    8962              :                              SECTION_WRITE | SECTION_NOTYPE, NULL_TREE);
    8963           59 :           sec = elf_fini_array_section;
    8964              :         }
    8965              :     }
    8966        23526 :   return sec;
    8967              : }
    8968              : 
    8969              : /* Use .init_array section for constructors. */
    8970              : 
    8971              : void
    8972        21945 : default_elf_init_array_asm_out_constructor (rtx symbol, int priority)
    8973              : {
    8974        21945 :   section *sec = get_elf_initfini_array_priority_section (priority,
    8975              :                                                           true);
    8976        21945 :   assemble_addr_to_section (symbol, sec);
    8977        21945 : }
    8978              : 
    8979              : /* Use .fini_array section for destructors. */
    8980              : 
    8981              : void
    8982         1581 : default_elf_fini_array_asm_out_destructor (rtx symbol, int priority)
    8983              : {
    8984         1581 :   section *sec = get_elf_initfini_array_priority_section (priority,
    8985              :                                                           false);
    8986         1581 :   assemble_addr_to_section (symbol, sec);
    8987         1581 : }
    8988              : 
    8989              : /* Default TARGET_ASM_OUTPUT_IDENT hook.
    8990              : 
    8991              :    This is a bit of a cheat.  The real default is a no-op, but this
    8992              :    hook is the default for all targets with a .ident directive.  */
    8993              : 
    8994              : void
    8995       234287 : default_asm_output_ident_directive (const char *ident_str)
    8996              : {
    8997       234287 :   const char *ident_asm_op = "\t.ident\t";
    8998              : 
    8999              :   /* If we are still in the front end, do not write out the string
    9000              :      to asm_out_file.  Instead, add a fake top-level asm statement.
    9001              :      This allows the front ends to use this hook without actually
    9002              :      writing to asm_out_file, to handle #ident or Pragma Ident.  */
    9003       234287 :   if (symtab->state == PARSING)
    9004              :     {
    9005           27 :       char *buf = ACONCAT ((ident_asm_op, "\"", ident_str, "\"\n", NULL));
    9006           27 :       symtab->finalize_toplevel_asm (build_string (strlen (buf), buf));
    9007              :     }
    9008              :   else
    9009       234260 :     fprintf (asm_out_file, "%s\"%s\"\n", ident_asm_op, ident_str);
    9010       234287 : }
    9011              : 
    9012              : /* Switch to a COMDAT section with COMDAT name of decl.
    9013              : 
    9014              :    FIXME:  resolve_unique_section needs to deal better with
    9015              :    decls with both DECL_SECTION_NAME and DECL_ONE_ONLY.  Once
    9016              :    that is fixed, this if-else statement can be replaced with
    9017              :    a single call to "switch_to_section (sect)".  */
    9018              : 
    9019              : void
    9020           15 : switch_to_comdat_section (section *sect, tree decl)
    9021              : {
    9022              : #if defined (OBJECT_FORMAT_ELF)
    9023           15 :   targetm.asm_out.named_section (sect->named.name,
    9024           15 :                                  sect->named.common.flags
    9025              :                                  | SECTION_LINKONCE,
    9026              :                                  decl);
    9027           15 :   in_section = sect;
    9028              : #else
    9029              :   /* Neither OBJECT_FORMAT_PE, nor OBJECT_FORMAT_COFF is set here.
    9030              :      Therefore the following check is used.
    9031              :      In case a the target is PE or COFF a comdat group section
    9032              :      is created, e.g. .vtable_map_vars$foo. The linker places
    9033              :      everything in .vtable_map_vars at the end.
    9034              : 
    9035              :      A fix could be made in
    9036              :      gcc/config/i386/winnt.cc: mingw_pe_unique_section.  */
    9037              :   if (TARGET_PECOFF)
    9038              :     {
    9039              :       char *name;
    9040              : 
    9041              :       if (TREE_CODE (decl) == IDENTIFIER_NODE)
    9042              :         name = ACONCAT ((sect->named.name, "$",
    9043              :                          IDENTIFIER_POINTER (decl), NULL));
    9044              :       else
    9045              :         name = ACONCAT ((sect->named.name, "$",
    9046              :                          IDENTIFIER_POINTER (DECL_COMDAT_GROUP (decl)),
    9047              :                          NULL));
    9048              : 
    9049              :       targetm.asm_out.named_section (name,
    9050              :                                      sect->named.common.flags
    9051              :                                      | SECTION_LINKONCE,
    9052              :                                      decl);
    9053              :       in_section = sect;
    9054              :     }
    9055              :   else
    9056              :     switch_to_section (sect);
    9057              : #endif
    9058           15 : }
    9059              : 
    9060              : /* This function ensures that vtable_map variables are not only
    9061              :    in the comdat section, but that each variable has its own unique
    9062              :    comdat name.  Without this the variables end up in the same section
    9063              :    with a single comdat name.  */
    9064              : 
    9065              : static void
    9066            3 : handle_vtv_comdat_section (section *sect, const_tree decl ATTRIBUTE_UNUSED)
    9067              : {
    9068            3 :   switch_to_comdat_section(sect, DECL_NAME (decl));
    9069            3 : }
    9070              : 
    9071              : void
    9072       256621 : varasm_cc_finalize ()
    9073              : {
    9074       256621 :   first_global_object_name = nullptr;
    9075       256621 :   weak_global_object_name = nullptr;
    9076              : 
    9077       256621 :   const_labelno = 0;
    9078       256621 :   size_directive_output = 0;
    9079              : 
    9080       256621 :   last_assemble_variable_decl = NULL_TREE;
    9081       256621 :   first_function_block_is_cold = false;
    9082       256621 :   saw_no_split_stack = false;
    9083       256621 :   text_section = nullptr;
    9084       256621 :   data_section = nullptr;
    9085       256621 :   readonly_data_section = nullptr;
    9086       256621 :   sdata_section = nullptr;
    9087       256621 :   ctors_section = nullptr;
    9088       256621 :   dtors_section = nullptr;
    9089       256621 :   bss_section = nullptr;
    9090       256621 :   sbss_section = nullptr;
    9091       256621 :   tls_comm_section = nullptr;
    9092       256621 :   comm_section = nullptr;
    9093       256621 :   lcomm_section = nullptr;
    9094       256621 :   bss_noswitch_section = nullptr;
    9095       256621 :   exception_section = nullptr;
    9096       256621 :   eh_frame_section = nullptr;
    9097       256621 :   in_section = nullptr;
    9098       256621 :   in_cold_section_p = false;
    9099       256621 :   cold_function_name = NULL_TREE;
    9100       256621 :   unnamed_sections = nullptr;
    9101       256621 :   section_htab = nullptr;
    9102       256621 :   object_block_htab = nullptr;
    9103       256621 :   anchor_labelno = 0;
    9104       256621 :   shared_constant_pool = nullptr;
    9105       256621 :   pending_assemble_externals = NULL_TREE;
    9106       256621 :   pending_libcall_symbols = nullptr;
    9107              : 
    9108              : #ifdef ASM_OUTPUT_EXTERNAL
    9109       256621 :   pending_assemble_externals_processed = false;
    9110       276904 :   delete pending_assemble_externals_set;
    9111       256621 :   pending_assemble_externals_set = nullptr;
    9112              : #endif
    9113              : 
    9114       256621 :   weak_decls = NULL_TREE;
    9115       256621 :   initial_trampoline = nullptr;
    9116       256621 :   const_desc_htab = nullptr;
    9117       256621 :   weakref_targets = NULL_TREE;
    9118       256621 :   alias_pairs = nullptr;
    9119       256621 :   tm_clone_hash = nullptr;
    9120       256621 :   trampolines_created = 0;
    9121       256621 :   elf_init_array_section = nullptr;
    9122       256621 :   elf_fini_array_section = nullptr;
    9123       256621 : }
    9124              : 
    9125              : #include "gt-varasm.h"
        

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.