LCOV - code coverage report
Current view: top level - gcc - varasm.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 81.8 % 3789 3098
Test Date: 2026-05-30 15:37:04 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    439713352 : section_hasher::equal (section *old, const char *new_name)
     215              : {
     216    439713352 :   return strcmp (old->named.name, new_name) == 0;
     217              : }
     218              : 
     219              : hashval_t
     220    319165998 : section_hasher::hash (section *old)
     221              : {
     222    319165998 :   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      1124940 : get_unnamed_section (unsigned int flags, void (*callback) (const char *),
     253              :                      const char *data)
     254              : {
     255      1124940 :   section *sect;
     256              : 
     257      1124940 :   sect = ggc_alloc<section> ();
     258      1124940 :   sect->unnamed.common.flags = flags | SECTION_UNNAMED;
     259      1124940 :   sect->unnamed.callback = callback;
     260      1124940 :   sect->unnamed.data = data;
     261      1124940 :   sect->unnamed.next = unnamed_sections;
     262              : 
     263      1124940 :   unnamed_sections = sect;
     264      1124940 :   return sect;
     265              : }
     266              : 
     267              : /* Return a SECTION_NOSWITCH section with the given fields.  */
     268              : 
     269              : static section *
     270      1124940 : get_noswitch_section (unsigned int flags, noswitch_section_callback callback)
     271              : {
     272      1124940 :   section *sect;
     273              : 
     274            0 :   sect = ggc_alloc<section> ();
     275      1124940 :   sect->noswitch.common.flags = flags | SECTION_NOSWITCH;
     276      1124940 :   sect->noswitch.callback = callback;
     277              : 
     278      1124940 :   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     69567586 : get_section (const char *name, unsigned int flags, tree decl,
     292              :              bool not_existing)
     293              : {
     294     69567586 :   section *sect, **slot;
     295              : 
     296     69567586 :   slot = section_htab->find_slot_with_hash (name, htab_hash_string (name),
     297              :                                             INSERT);
     298     69567586 :   flags |= SECTION_NAMED;
     299     69567586 :   if (decl != nullptr
     300     67589307 :       && DECL_P (decl)
     301    137156893 :       && lookup_attribute ("retain", DECL_ATTRIBUTES (decl)))
     302          454 :     flags |= SECTION_RETAIN;
     303     69567586 :   if (*slot == NULL)
     304              :     {
     305      3442224 :       sect = ggc_alloc<section> ();
     306      3442224 :       sect->named.common.flags = flags;
     307      3442224 :       sect->named.name = ggc_strdup (name);
     308      3442224 :       sect->named.decl = decl;
     309      3442224 :       *slot = sect;
     310              :     }
     311              :   else
     312              :     {
     313     66125362 :       if (not_existing)
     314            0 :         internal_error ("section already exists: %qs", name);
     315              : 
     316     66125362 :       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     66125362 :       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     66125362 :       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     10219452 : use_object_blocks_p (void)
     386              : {
     387     10219452 :   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     67413942 : get_named_section (tree decl, const char *name, int reloc)
     460              : {
     461     67413942 :   unsigned int flags;
     462              : 
     463     67413942 :   if (name == NULL)
     464              :     {
     465     59450600 :       gcc_assert (decl && DECL_P (decl) && DECL_SECTION_NAME (decl));
     466     59450600 :       name = DECL_SECTION_NAME (decl);
     467              :     }
     468              : 
     469     67413942 :   flags = targetm.section_type_flags (decl, name, reloc);
     470     67413942 :   return get_section (name, flags, decl);
     471              : }
     472              : 
     473              : /* Worker for resolve_unique_section.  */
     474              : 
     475              : static bool
     476      1842625 : set_implicit_section (struct symtab_node *n, void *data ATTRIBUTE_UNUSED)
     477              : {
     478      1842625 :   n->implicit_section = true;
     479      1842625 :   return false;
     480              : }
     481              : 
     482              : /* If required, set DECL_SECTION_NAME to a unique name.  */
     483              : 
     484              : void
     485      7482404 : resolve_unique_section (tree decl, int reloc ATTRIBUTE_UNUSED,
     486              :                         int flag_function_or_data_sections)
     487              : {
     488      7482404 :   if (DECL_SECTION_NAME (decl) == NULL
     489      4601890 :       && targetm_common.have_named_sections
     490     12084294 :       && (flag_function_or_data_sections
     491      2917733 :           || lookup_attribute ("retain", DECL_ATTRIBUTES (decl))
     492      2917615 :           || DECL_COMDAT_GROUP (decl)))
     493              :     {
     494      1801263 :       targetm.asm_out.unique_section (decl, reloc);
     495      1801263 :       if (DECL_SECTION_NAME (decl))
     496      1801263 :         symtab_node::get (decl)->call_for_symbol_and_aliases
     497      1801263 :           (set_implicit_section, NULL, true);
     498              :     }
     499      7482404 : }
     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     81241090 : hot_function_section (tree decl)
     537              : {
     538     81241090 :   if (decl != NULL_TREE
     539     81241090 :       && DECL_SECTION_NAME (decl) != NULL
     540    137722915 :       && targetm_common.have_named_sections)
     541     56481825 :     return get_named_section (decl, NULL, 0);
     542              :   else
     543     24759265 :     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      7958041 : get_named_text_section (tree decl,
     557              :                         const char *text_section_name,
     558              :                         const char *named_section_suffix)
     559              : {
     560      7958041 :   if (decl && DECL_SECTION_NAME (decl))
     561              :     {
     562      7026601 :       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      7026601 :       else if (symtab_node::get (decl)->implicit_section)
     578              :         {
     579      7026580 :           const char *name;
     580              : 
     581              :           /* Do not try to split gnu_linkonce functions.  This gets somewhat
     582              :              slipperly.  */
     583      7026580 :           if (DECL_COMDAT_GROUP (decl) && !HAVE_COMDAT_GROUP)
     584              :             return NULL;
     585      7026580 :           name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
     586      7026580 :           name = targetm.strip_name_encoding (name);
     587      7026580 :           return get_named_section (decl, ACONCAT ((text_section_name, ".",
     588      7026580 :                                                    name, NULL)), 0);
     589              :         }
     590              :       else
     591              :         return NULL;
     592              :     }
     593       931440 :   return get_named_section (decl, text_section_name, 0);
     594              : }
     595              : 
     596              : /* Choose named function section based on its frequency.  */
     597              : 
     598              : section *
     599     89199110 : 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     89199110 :   if (!flag_reorder_functions
     611     86815853 :       || !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     86815853 :   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      1736979 :     if (!in_lto_p
     623        37779 :         || !cgraph_node::get (decl)->tp_first_run
     624      1736987 :         || !opt_for_fn (decl, flag_profile_reorder_functions))
     625      1736971 :       return get_named_text_section (decl, ".text.startup", NULL);
     626              :     else
     627              :       return NULL;
     628              :   }
     629              : 
     630              :   /* Similarly for exit.  */
     631     85078874 :   if (exit && freq != NODE_FREQUENCY_UNLIKELY_EXECUTED)
     632         3984 :     return get_named_text_section (decl, ".text.exit", NULL);
     633              : 
     634              :   /* Group cold functions together, similarly for hot code.  */
     635     85074890 :   switch (freq)
     636              :     {
     637      6216389 :       case NODE_FREQUENCY_UNLIKELY_EXECUTED:
     638      6216389 :         return get_named_text_section (decl, ".text.unlikely", NULL);
     639          697 :       case NODE_FREQUENCY_HOT:
     640          697 :         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     89199110 : function_section_1 (tree decl, bool force_cold)
     657              : {
     658     89199110 :   section *section = NULL;
     659     89199110 :   enum node_frequency freq = NODE_FREQUENCY_NORMAL;
     660     89199110 :   bool startup = false, exit = false;
     661              : 
     662     89199110 :   if (decl)
     663              :     {
     664     89199110 :       struct cgraph_node *node = cgraph_node::get (decl);
     665              : 
     666     89199110 :       if (node)
     667              :         {
     668     89199110 :           freq = node->frequency;
     669     89199110 :           startup = node->only_called_at_startup;
     670     89199110 :           exit = node->only_called_at_exit;
     671              :         }
     672              :     }
     673     89199110 :   if (force_cold)
     674      6049958 :     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     89199110 :   if (targetm.asm_out.function_section)
     693     89199110 :     section = targetm.asm_out.function_section (decl, freq, startup, exit);
     694     89199110 :   if (section)
     695              :     return section;
     696     81241090 :   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      3660784 : 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      3660784 :   return function_section_1 (decl,
     714      3660784 :                              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     85399945 : current_function_section (void)
     722              : {
     723     85399945 :   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       138381 : unlikely_text_section (void)
     730              : {
     731       138381 :   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       626815 : default_function_rodata_section (tree decl, bool relocatable)
     760              : {
     761       626815 :   const char* sname;
     762       626815 :   unsigned int flags;
     763              : 
     764       626815 :   flags = 0;
     765              : 
     766       626815 :   if (relocatable)
     767              :     {
     768              :       sname = ".data.rel.ro.local";
     769              :       flags = (SECTION_WRITE | SECTION_RELRO);
     770              :     }
     771              :   else
     772       626815 :     sname = ".rodata";
     773              : 
     774       626815 :   if (decl && DECL_SECTION_NAME (decl))
     775              :     {
     776       123131 :       const char *name = DECL_SECTION_NAME (decl);
     777              : 
     778       123131 :       if (DECL_COMDAT_GROUP (decl) && HAVE_COMDAT_GROUP)
     779              :         {
     780        33926 :           const char *dot;
     781        33926 :           size_t len;
     782        33926 :           char* rname;
     783              : 
     784        33926 :           dot = strchr (name + 1, '.');
     785        33926 :           if (!dot)
     786            0 :             dot = name;
     787        33926 :           len = strlen (dot) + strlen (sname) + 1;
     788        33926 :           rname = (char *) alloca (len);
     789              : 
     790        33926 :           strcpy (rname, sname);
     791        33926 :           strcat (rname, dot);
     792        33926 :           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        89205 :       else if (DECL_COMDAT_GROUP (decl)
     797        89205 :                && 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        89201 :       else if (flag_function_sections && flag_data_sections
     822       178406 :                && startswith (name, ".text."))
     823              :         {
     824        89201 :           size_t len = strlen (name) + 1;
     825        89201 :           char *rname = (char *) alloca (len + strlen (sname) - 5);
     826              : 
     827        89201 :           memcpy (rname, sname, strlen (sname));
     828        89201 :           memcpy (rname + strlen (sname), name + 5, len - 5);
     829        89201 :           return get_section (rname, flags, decl);
     830              :         }
     831              :     }
     832              : 
     833       503688 :   if (relocatable)
     834            0 :     return get_section (sname, flags, decl);
     835              :   else
     836       503688 :     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       614193 : function_mergeable_rodata_prefix (void)
     853              : {
     854       614193 :   section *s = targetm.asm_out.function_rodata_section (current_function_decl,
     855              :                                                         false);
     856       614193 :   if (SECTION_STYLE (s) == SECTION_NAMED)
     857       116499 :     return s->named.name;
     858              :   else
     859       497694 :     return targetm.asm_out.mergeable_rodata_prefix;
     860              : }
     861              : 
     862              : /* Return the section to use for string merging.  */
     863              : 
     864              : static section *
     865      1242205 : mergeable_string_section (tree decl ATTRIBUTE_UNUSED,
     866              :                           unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED,
     867              :                           unsigned int flags ATTRIBUTE_UNUSED)
     868              : {
     869      1242205 :   HOST_WIDE_INT len;
     870              : 
     871      1242205 :   if (HAVE_GAS_SHF_MERGE && flag_merge_constants
     872      1057261 :       && TREE_CODE (decl) == STRING_CST
     873      1057261 :       && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE
     874      1057261 :       && align <= MAX_MERGEABLE_BITSIZE
     875      1057261 :       && (len = int_size_in_bytes (TREE_TYPE (decl))) > 0
     876      2299330 :       && TREE_STRING_LENGTH (decl) == len)
     877              :     {
     878       410573 :       scalar_int_mode mode;
     879       410573 :       unsigned int modesize;
     880       410573 :       const char *str;
     881       410573 :       HOST_WIDE_INT i;
     882       410573 :       int j, unit;
     883       410573 :       const char *prefix = function_mergeable_rodata_prefix ();
     884       410573 :       char *name = (char *) alloca (strlen (prefix) + 30);
     885              : 
     886       410573 :       mode = SCALAR_INT_TYPE_MODE (TREE_TYPE (TREE_TYPE (decl)));
     887       410573 :       modesize = GET_MODE_BITSIZE (mode);
     888       410573 :       if (modesize >= 8 && modesize <= MAX_MERGEABLE_BITSIZE
     889       410573 :           && (modesize & (modesize - 1)) == 0)
     890              :         {
     891       410573 :           if (align < modesize)
     892              :             align = modesize;
     893              : 
     894       410573 :           str = TREE_STRING_POINTER (decl);
     895       410573 :           unit = GET_MODE_SIZE (mode);
     896              : 
     897              :           /* Check for embedded NUL characters.  */
     898    115928314 :           for (i = 0; i < len; i += unit)
     899              :             {
     900    116279431 :               for (j = 0; j < unit; j++)
     901    115905181 :                 if (str[i + j] != '\0')
     902              :                   break;
     903    115891991 :               if (j == unit)
     904              :                 break;
     905              :             }
     906       410573 :           if (i == len - unit || (unit == 1 && i == len))
     907              :             {
     908       406810 :               sprintf (name, "%s.str%d.%d", prefix,
     909       406810 :                        modesize / BITS_PER_UNIT, (int) (align / BITS_PER_UNIT));
     910       406810 :               flags |= (modesize / BITS_PER_UNIT) | SECTION_MERGE | SECTION_STRINGS;
     911       406810 :               return get_section (name, flags, NULL);
     912              :             }
     913              :         }
     914              :     }
     915              : 
     916       835395 :   return readonly_data_section;
     917              : }
     918              : 
     919              : /* Return the section to use for constant merging.  */
     920              : 
     921              : section *
     922       246960 : mergeable_constant_section (unsigned HOST_WIDE_INT size_bits,
     923              :                             unsigned HOST_WIDE_INT align,
     924              :                             unsigned int flags)
     925              : {
     926       246960 :   unsigned HOST_WIDE_INT newsize;
     927       246960 :   newsize = HOST_WIDE_INT_1U << ceil_log2 (size_bits);
     928       246960 :   if (HAVE_GAS_SHF_MERGE && flag_merge_constants
     929       207956 :       && newsize <= MAX_MERGEABLE_BITSIZE
     930       207956 :       && align >= 8
     931       203621 :       && align <= newsize
     932       203620 :       && (align & (align - 1)) == 0)
     933              :     {
     934       203620 :       const char *prefix = function_mergeable_rodata_prefix ();
     935       203620 :       char *name = (char *) alloca (strlen (prefix) + 30);
     936              : 
     937       203620 :       sprintf (name, "%s.cst%d", prefix, (int) (newsize / BITS_PER_UNIT));
     938       203620 :       flags |= (newsize / BITS_PER_UNIT) | SECTION_MERGE;
     939       203620 :       return get_section (name, flags, NULL);
     940              :     }
     941        43340 :   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       246484 : 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       246484 :   if (mode == BLKmode || mode == VOIDmode)
     968            0 :     return readonly_data_section;
     969       246484 :   unsigned HOST_WIDE_INT size;
     970       492968 :   if (!GET_MODE_BITSIZE (mode).is_constant (&size))
     971              :     return readonly_data_section;
     972       246484 :   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     15169722 : 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     15169101 :   if (name[0] == '%' || name[0] == '#')
     986          621 :     name++;
     987     15169722 :   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      2871559 : set_user_assembler_name (tree decl, const char *name)
     995              : {
     996      2871559 :   char *starred = (char *) alloca (strlen (name) + 2);
     997      2871559 :   starred[0] = '*';
     998      2871559 :   strcpy (starred + 1, name);
     999      2871559 :   symtab->change_decl_assembler_name (decl, get_identifier (starred));
    1000      2871559 :   SET_DECL_RTL (decl, NULL_RTX);
    1001      2871559 : }
    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       197427 : decode_reg_name_and_count (const char *asmspec, int *pnregs)
    1015              : {
    1016              :   /* Presume just one register is clobbered.  */
    1017       197427 :   *pnregs = 1;
    1018              : 
    1019       197427 :   if (asmspec != 0)
    1020              :     {
    1021       197427 :       int i;
    1022              : 
    1023              :       /* Get rid of confusing prefixes.  */
    1024       197427 :       asmspec = strip_reg_name (asmspec);
    1025              : 
    1026              :       /* Allow a decimal number as a "register name".  */
    1027       197427 :       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     15105190 :       for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
    1045     14972295 :         if (reg_names[i][0]
    1046     29944590 :             && ! 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     10490601 :         for (i = 0; i < (int) ARRAY_SIZE (table); i++)
    1074     10380866 :           if (table[i].name[0]
    1075     10380866 :               && ! 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       109735 :       if (!strcmp (asmspec, "redzone"))
    1082              :         return -5;
    1083              : 
    1084       109731 :       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       100254 : decode_reg_name (const char *name)
    1098              : {
    1099       100254 :   int count;
    1100       100254 :   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      6471469 : 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     11131555 :   return ((!TREE_READONLY (decl) || DECL_COMMON (decl) || named)
    1112      6495103 :           && (DECL_INITIAL (decl) == NULL
    1113              :               /* In LTO we have no errors in program; error_mark_node is used
    1114              :                  to mark offlined constructors.  */
    1115       672876 :               || (DECL_INITIAL (decl) == error_mark_node
    1116            4 :                   && !in_lto_p)
    1117       672872 :               || (flag_zero_initialized_in_bss
    1118       672814 :                   && 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        41047 :                   && !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      5939254 : align_variable (tree decl, bool dont_output_data)
    1130              : {
    1131      5939254 :   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          883 :   if (dont_output_data && DECL_SIZE (decl) == 0
    1137      5939254 :       && 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      5939254 :   if (! DECL_USER_ALIGN (decl))
    1151              :     {
    1152              : #ifdef DATA_ABI_ALIGNMENT
    1153      5813516 :       unsigned int data_abi_align
    1154      5813516 :         = DATA_ABI_ALIGNMENT (TREE_TYPE (decl), align);
    1155              :       /* For backwards compatibility, don't assume the ABI alignment for
    1156              :          TLS variables.  */
    1157      5813608 :       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      5813516 :       if (decl_binds_to_current_def_p (decl)
    1167      5813516 :           && !DECL_VIRTUAL_P (decl))
    1168              :         {
    1169              : #ifdef DATA_ALIGNMENT
    1170      5200442 :           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      5200510 :           if (! DECL_THREAD_LOCAL_P (decl) || data_align <= BITS_PER_WORD)
    1174              :             align = data_align;
    1175              : #endif
    1176      5200442 :           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      5200442 :               && (in_lto_p || DECL_INITIAL (decl) != error_mark_node))
    1180              :             {
    1181      3256521 :               unsigned int const_align
    1182      3256521 :                 = targetm.constant_alignment (DECL_INITIAL (decl), align);
    1183              :               /* Don't increase alignment too much for TLS variables - TLS
    1184              :                  space is too precious.  */
    1185      3256527 :               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      5939254 :   SET_DECL_ALIGN (decl, align);
    1194      5939254 : }
    1195              : 
    1196              : /* Return DECL_ALIGN (decl), possibly increased for optimization purposes
    1197              :    beyond what align_variable returned.  */
    1198              : 
    1199              : static unsigned int
    1200      5804340 : get_variable_align (tree decl)
    1201              : {
    1202      5804340 :   unsigned int align = DECL_ALIGN (decl);
    1203              : 
    1204              :   /* For user aligned vars or static vars align_variable already did
    1205              :      everything.  */
    1206      5804340 :   if (DECL_USER_ALIGN (decl) || !TREE_PUBLIC (decl))
    1207              :     return align;
    1208              : 
    1209              : #ifdef DATA_ABI_ALIGNMENT
    1210      2875559 :   if (DECL_THREAD_LOCAL_P (decl))
    1211         6144 :     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      2875559 :   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       594177 :       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       594198 :       if (! DECL_THREAD_LOCAL_P (decl) || data_align <= BITS_PER_WORD)
    1226              :         align = data_align;
    1227              : #endif
    1228       594177 :       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       594177 :           && (in_lto_p || DECL_INITIAL (decl) != error_mark_node))
    1232              :         {
    1233       579496 :           unsigned int const_align
    1234       579496 :             = targetm.constant_alignment (DECL_INITIAL (decl), align);
    1235              :           /* Don't increase alignment too much for TLS variables - TLS space
    1236              :              is too precious.  */
    1237       579501 :           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      4503434 : compute_reloc_for_var (tree decl)
    1251              : {
    1252      4503434 :   int reloc;
    1253              : 
    1254      4503434 :   if (DECL_INITIAL (decl) == error_mark_node)
    1255      1140452 :     reloc = contains_pointers_p (TREE_TYPE (decl)) ? 3 : 0;
    1256      4503432 :   else if (DECL_INITIAL (decl))
    1257      3362982 :     reloc = compute_reloc_for_constant (DECL_INITIAL (decl));
    1258              :   else
    1259              :     reloc = 0;
    1260              : 
    1261      4503434 :   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      4504836 : get_variable_section (tree decl, bool prefer_noswitch_p)
    1270              : {
    1271      4504836 :   addr_space_t as = ADDR_SPACE_GENERIC;
    1272      4504836 :   int reloc;
    1273      4504836 :   varpool_node *vnode = varpool_node::get (decl);
    1274      4504836 :   if (vnode)
    1275              :     {
    1276      4504821 :       vnode = vnode->ultimate_alias_target ();
    1277      4504821 :       decl = vnode->decl;
    1278              :     }
    1279              : 
    1280      4504836 :   if (TREE_TYPE (decl) != error_mark_node)
    1281      4504836 :     as = TYPE_ADDR_SPACE (TREE_TYPE (decl));
    1282              : 
    1283              :   /* We need the constructor to figure out reloc flag.  */
    1284      4504836 :   if (vnode)
    1285      4504821 :     vnode->get_constructor ();
    1286              : 
    1287      4504836 :   if (DECL_COMMON (decl)
    1288      4504836 :       && !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      4503434 :   reloc = compute_reloc_for_var (decl);
    1302              : 
    1303      4503434 :   resolve_unique_section (decl, reloc, flag_data_sections);
    1304      4503434 :   if (IN_NAMED_SECTION (decl))
    1305              :     {
    1306      2965169 :       section *sect = get_named_section (decl, NULL, reloc);
    1307              : 
    1308      2965169 :       if ((sect->common.flags & SECTION_BSS)
    1309      2965169 :           && !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      2965169 :       return sect;
    1322              :     }
    1323              : 
    1324      1538265 :   if (ADDR_SPACE_GENERIC_P (as)
    1325      1538259 :       && !DECL_THREAD_LOCAL_P (decl)
    1326      1534653 :       && !DECL_NOINIT_P (decl)
    1327      1534653 :       && !(prefer_noswitch_p && targetm.have_switchable_bss_sections)
    1328      3072918 :       && bss_initializer_p (decl))
    1329              :     {
    1330      1149215 :       if (!TREE_PUBLIC (decl)
    1331      1149398 :           && !((flag_sanitize & SANITIZE_ADDRESS)
    1332          183 :                && asan_protect_global (decl)))
    1333       157248 :         return lcomm_section;
    1334       991967 :       if (bss_noswitch_section)
    1335              :         return bss_noswitch_section;
    1336              :     }
    1337              : 
    1338       389050 :   return targetm.asm_out.select_section (decl, reloc,
    1339       778100 :                                          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     36966976 : ultimate_transparent_alias_target (tree *alias)
    1437              : {
    1438     36966976 :   tree target = *alias;
    1439              : 
    1440     36966976 :   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     36966976 :   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      8597806 : make_decl_rtl (tree decl)
    1480              : {
    1481      8597806 :   const char *name = 0;
    1482      8597806 :   int reg_number;
    1483      8597806 :   tree id;
    1484      8597806 :   rtx x;
    1485              : 
    1486              :   /* Check that we are not being given an automatic variable.  */
    1487      8597806 :   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      8597806 :   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      8597806 :   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      8597806 :   if (DECL_RTL_SET_P (decl))
    1504              :     {
    1505              :       /* If the old RTL had the wrong mode, fix the mode.  */
    1506        12456 :       x = DECL_RTL (decl);
    1507        12456 :       if (GET_MODE (x) != DECL_MODE (decl))
    1508            0 :         SET_DECL_RTL (decl, adjust_address_nv (x, DECL_MODE (decl), 0));
    1509              : 
    1510        12456 :       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        12388 :       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        12388 :       if (MEM_P (x)
    1526        12388 :           && GET_CODE (XEXP (x, 0)) == SYMBOL_REF
    1527        24776 :           && SYMBOL_REF_HAS_BLOCK_INFO_P (XEXP (x, 0)))
    1528            0 :         change_symbol_block (XEXP (x, 0), get_block_for_decl (decl));
    1529              : 
    1530        12388 :       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      8585350 :   if (VAR_P (decl) && DECL_IN_CONSTANT_POOL (decl))
    1536              :     {
    1537         6061 :       SET_DECL_RTL (decl, output_constant_def (DECL_INITIAL (decl), 1));
    1538         6061 :       return;
    1539              :     }
    1540              : 
    1541      8579289 :   id = DECL_ASSEMBLER_NAME (decl);
    1542      8579289 :   name = IDENTIFIER_POINTER (id);
    1543              : 
    1544      8519056 :   if (name[0] != '*' && TREE_CODE (decl) != FUNCTION_DECL
    1545     11725167 :       && DECL_REGISTER (decl))
    1546              :     {
    1547           13 :       error ("register name not specified for %q+D", decl);
    1548              :     }
    1549      8579276 :   else if (TREE_CODE (decl) != FUNCTION_DECL && DECL_REGISTER (decl))
    1550              :     {
    1551         1204 :       const char *asmspec = name+1;
    1552         1204 :       machine_mode mode = DECL_MODE (decl);
    1553         1204 :       reg_number = decode_reg_name (asmspec);
    1554              :       /* First detect errors in declaring global registers.  */
    1555         1204 :       if (reg_number == -1)
    1556            0 :         error ("register name not specified for %q+D", decl);
    1557         1204 :       else if (reg_number < 0)
    1558           28 :         error ("invalid register name for %q+D", decl);
    1559         1176 :       else if (mode == BLKmode)
    1560            5 :         error ("data type of %q+D isn%'t suitable for a register",
    1561              :                decl);
    1562         1171 :       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         1169 :       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         1169 :       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         1167 :       else if (reg_number != HARD_FRAME_POINTER_REGNUM
    1572         1161 :                && (reg_number == FRAME_POINTER_REGNUM
    1573              : #ifdef RETURN_ADDRESS_POINTER_REGNUM
    1574              :                    || reg_number == RETURN_ADDRESS_POINTER_REGNUM
    1575              : #endif
    1576         1161 :                    || reg_number == ARG_POINTER_REGNUM)
    1577         1172 :                && 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         1162 :           int nregs;
    1584              : 
    1585         1162 :           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         1162 :           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         1162 :           SET_DECL_RTL (decl, gen_raw_REG (mode, reg_number));
    1601         1162 :           ORIGINAL_REGNO (DECL_RTL (decl)) = reg_number;
    1602         1162 :           REG_USERVAR_P (DECL_RTL (decl)) = 1;
    1603              : 
    1604         1162 :           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         1162 :           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      8578085 :   if (VAR_P (decl)
    1650      3186486 :       && (TREE_STATIC (decl) || DECL_EXTERNAL (decl))
    1651      3186486 :       && DECL_SECTION_NAME (decl) != NULL
    1652      1436634 :       && DECL_INITIAL (decl) == NULL_TREE
    1653      8578211 :       && DECL_COMMON (decl))
    1654            0 :     DECL_COMMON (decl) = 0;
    1655              : 
    1656              :   /* Variables can't be both common and weak.  */
    1657      8578085 :   if (VAR_P (decl) && DECL_WEAK (decl))
    1658       328291 :     DECL_COMMON (decl) = 0;
    1659              : 
    1660      8578085 :   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      8578085 :       machine_mode address_mode = Pmode;
    1665      8578085 :       if (TREE_TYPE (decl) != error_mark_node)
    1666              :         {
    1667      8578085 :           addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (decl));
    1668      8578085 :           address_mode = targetm.addr_space.address_mode (as);
    1669              :         }
    1670      8578085 :       x = gen_rtx_SYMBOL_REF (address_mode, name);
    1671              :     }
    1672      8578085 :   SYMBOL_REF_WEAK (x) = DECL_WEAK (decl);
    1673      8578085 :   SET_SYMBOL_REF_DECL (x, decl);
    1674              : 
    1675      8578085 :   x = gen_rtx_MEM (DECL_MODE (decl), x);
    1676      8578085 :   if (TREE_CODE (decl) != FUNCTION_DECL)
    1677      3186486 :     set_mem_attributes (x, decl, 1);
    1678      8578085 :   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      8578085 :   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        33148 : make_decl_rtl_for_debug (tree decl)
    1693              : {
    1694        33148 :   unsigned int save_aliasing_flag;
    1695        33148 :   rtx rtl;
    1696              : 
    1697        33148 :   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        33148 :   save_aliasing_flag = flag_strict_aliasing;
    1707        33148 :   flag_strict_aliasing = 0;
    1708              : 
    1709        33148 :   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        33148 :   SET_DECL_RTL (decl, NULL);
    1713              : 
    1714        33148 :   flag_strict_aliasing = save_aliasing_flag;
    1715        33148 :   return rtl;
    1716              : }
    1717              : 
    1718              : /* Output a string of literal assembler code
    1719              :    for an `asm' keyword used between functions.  */
    1720              : 
    1721              : void
    1722        12429 : assemble_asm (tree asm_str)
    1723              : {
    1724        12429 :   const char *p;
    1725              : 
    1726        12429 :   if (TREE_CODE (asm_str) != ASM_EXPR)
    1727              :     {
    1728        12364 :       app_enable ();
    1729        12364 :       if (TREE_CODE (asm_str) == ADDR_EXPR)
    1730            0 :         asm_str = TREE_OPERAND (asm_str, 0);
    1731              : 
    1732        12364 :       p = TREE_STRING_POINTER (asm_str);
    1733        24693 :       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        12429 : }
    1885              : 
    1886              : /* Write the address of the entity given by SYMBOL to SEC.  */
    1887              : void
    1888        24333 : assemble_addr_to_section (rtx symbol, section *sec)
    1889              : {
    1890        24333 :   switch_to_section (sec);
    1891        24738 :   assemble_align (POINTER_SIZE);
    1892        25143 :   assemble_integer (symbol, POINTER_SIZE_UNITS, POINTER_SIZE, 1);
    1893        24333 : }
    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    122591844 : notice_global_symbol (tree decl)
    1976              : {
    1977    122591844 :   const char **t = &first_global_object_name;
    1978              : 
    1979    122591844 :   if (first_global_object_name
    1980     82616989 :       || !TREE_PUBLIC (decl)
    1981     81732057 :       || DECL_EXTERNAL (decl)
    1982     21862818 :       || !DECL_NAME (decl)
    1983     21862742 :       || (VAR_P (decl) && DECL_HARD_REGISTER (decl))
    1984    144454546 :       || (TREE_CODE (decl) != FUNCTION_DECL
    1985     15115343 :           && (!VAR_P (decl)
    1986     15115343 :               || (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     21862436 :   if (DECL_WEAK (decl) || DECL_ONE_ONLY (decl) || flag_shlib)
    1994              :     t = &weak_global_object_name;
    1995              : 
    1996     21862436 :   if (!*t)
    1997              :     {
    1998       275313 :       tree id = DECL_ASSEMBLER_NAME (decl);
    1999       275313 :       ultimate_transparent_alias_target (&id);
    2000       275313 :       *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      1487807 : decide_function_section (tree decl)
    2011              : {
    2012      1487807 :   first_function_block_is_cold = false;
    2013              : 
    2014      1487807 :  if (DECL_SECTION_NAME (decl))
    2015              :     {
    2016         8586 :       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         8586 :       first_function_block_is_cold = (node
    2020         8586 :                                       && node->frequency
    2021         8586 :                                       == NODE_FREQUENCY_UNLIKELY_EXECUTED);
    2022              :     }
    2023              : 
    2024      1487807 :   in_cold_section_p = first_function_block_is_cold;
    2025      1487807 : }
    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      1557811 : get_fnname_from_decl (tree decl)
    2031              : {
    2032      1557811 :   rtx x = DECL_RTL (decl);
    2033      1557811 :   gcc_assert (MEM_P (x));
    2034      1557811 :   x = XEXP (x, 0);
    2035      1557811 :   gcc_assert (GET_CODE (x) == SYMBOL_REF);
    2036      1557811 :   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      1551588 : assemble_function_label_raw (FILE *file, const char *name)
    2044              : {
    2045      1551588 :   ASM_OUTPUT_LABEL (file, name);
    2046      1551588 :   assemble_function_label_final ();
    2047      1551588 : }
    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      1551588 : assemble_function_label_final (void)
    2054              : {
    2055      1551588 :   if ((flag_sanitize & SANITIZE_ADDRESS)
    2056              :       /* Notify ASAN only about the first function label.  */
    2057         6333 :       && (in_cold_section_p == first_function_block_is_cold)
    2058              :       /* Do not notify ASAN when called from, e.g., code_end ().  */
    2059         6158 :       && cfun)
    2060         6158 :     asan_function_start ();
    2061      1551588 : }
    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      1483246 : assemble_start_function (tree decl, const char *fnname)
    2070              : {
    2071      1483246 :   int align;
    2072      1483246 :   char tmp_label[100];
    2073      1483246 :   bool hot_label_written = false;
    2074              : 
    2075      1483246 :   if (crtl->has_bb_partition)
    2076              :     {
    2077        64736 :       ASM_GENERATE_INTERNAL_LABEL (tmp_label, "LHOTB", const_labelno);
    2078        64736 :       crtl->subsections.hot_section_label = ggc_strdup (tmp_label);
    2079        64736 :       ASM_GENERATE_INTERNAL_LABEL (tmp_label, "LCOLDB", const_labelno);
    2080        64736 :       crtl->subsections.cold_section_label = ggc_strdup (tmp_label);
    2081        64736 :       ASM_GENERATE_INTERNAL_LABEL (tmp_label, "LHOTE", const_labelno);
    2082        64736 :       crtl->subsections.hot_section_end_label = ggc_strdup (tmp_label);
    2083        64736 :       ASM_GENERATE_INTERNAL_LABEL (tmp_label, "LCOLDE", const_labelno);
    2084        64736 :       crtl->subsections.cold_section_end_label = ggc_strdup (tmp_label);
    2085        64736 :       const_labelno++;
    2086        64736 :       cold_function_name = NULL_TREE;
    2087              :     }
    2088              :   else
    2089              :     {
    2090      1418510 :       crtl->subsections.hot_section_label = NULL;
    2091      1418510 :       crtl->subsections.cold_section_label = NULL;
    2092      1418510 :       crtl->subsections.hot_section_end_label = NULL;
    2093      1418510 :       crtl->subsections.cold_section_end_label = NULL;
    2094              :     }
    2095              : 
    2096              :   /* The following code does not need preprocessing in the assembler.  */
    2097              : 
    2098      1483246 :   app_disable ();
    2099              : 
    2100      1483246 :   if (CONSTANT_POOL_BEFORE_FUNCTION)
    2101      1483246 :     output_constant_pool (fnname, decl);
    2102              : 
    2103      1483246 :   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      1483246 :   if (crtl->has_bb_partition)
    2111              :     {
    2112        64736 :       first_function_block_is_cold = false;
    2113              : 
    2114        64736 :       switch_to_section (unlikely_text_section ());
    2115        64736 :       assemble_align (align);
    2116        64736 :       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        64736 :       if (!cfun->is_thunk
    2122        64736 :           && 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        64736 :       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      1483246 :   switch_to_section (function_section (decl), decl);
    2137      1483246 :   if (crtl->has_bb_partition && !hot_label_written)
    2138        64736 :     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      1483246 :   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      1483246 :   if (flag_min_function_alignment)
    2145            0 :     align = MAX (align, floor_log2 (flag_min_function_alignment));
    2146              : 
    2147      1483246 :   if (align > 0)
    2148              :     {
    2149       170288 :       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      1483246 :   if (! DECL_USER_ALIGN (decl)
    2156      1483212 :       && align_functions.levels[0].log > align
    2157      2403597 :       && optimize_function_for_speed_p (cfun))
    2158              :     {
    2159              : #ifdef ASM_OUTPUT_MAX_SKIP_ALIGN
    2160       901974 :       int align_log = align_functions.levels[0].log;
    2161              : #endif
    2162       901974 :       int max_skip = align_functions.levels[0].maxskip;
    2163       901974 :       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       901974 :       ASM_OUTPUT_MAX_SKIP_ALIGN (asm_out_file, align_log, max_skip);
    2169       901974 :       if (max_skip == align_functions.levels[0].maxskip)
    2170       901973 :         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      1483246 :   if (!DECL_IGNORED_P (decl))
    2183      1458594 :     (*debug_hooks->begin_function) (decl);
    2184              : 
    2185              :   /* Make function name accessible from other files, if appropriate.  */
    2186              : 
    2187      1483246 :   if (TREE_PUBLIC (decl))
    2188              :     {
    2189      1210661 :       notice_global_symbol (decl);
    2190              : 
    2191      1210661 :       globalize_decl (decl);
    2192              : 
    2193      1210661 :       maybe_assemble_visibility (decl);
    2194              :     }
    2195              : 
    2196      1483246 :   if (DECL_PRESERVE_P (decl))
    2197         4287 :     targetm.asm_out.mark_decl_preserved (fnname);
    2198              : 
    2199      1483246 :   unsigned short patch_area_size = crtl->patch_area_size;
    2200      1483246 :   unsigned short patch_area_entry = crtl->patch_area_entry;
    2201              : 
    2202              :   /* Emit the patching area before the entry label, if any.  */
    2203      1483246 :   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      1483246 :   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      1483246 :   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      1483246 :   if (lookup_attribute ("no_split_stack", DECL_ATTRIBUTES (decl)))
    2223         2458 :     saw_no_split_stack = true;
    2224      1483246 : }
    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      1483246 : 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      1483246 :   if (crtl->has_bb_partition)
    2235        64736 :     switch_to_section (function_section (decl));
    2236      1483246 :   ASM_DECLARE_FUNCTION_SIZE (asm_out_file, fnname, decl);
    2237              : #endif
    2238      1483246 :   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      1483246 :   if (crtl->has_bb_partition)
    2246              :     {
    2247        64736 :       section *save_text_section;
    2248              : 
    2249        64736 :       save_text_section = in_section;
    2250        64736 :       switch_to_section (unlikely_text_section ());
    2251              : #ifdef ASM_DECLARE_COLD_FUNCTION_SIZE
    2252        64736 :       if (cold_function_name != NULL_TREE)
    2253        64736 :         ASM_DECLARE_COLD_FUNCTION_SIZE (asm_out_file,
    2254              :                                         IDENTIFIER_POINTER (cold_function_name),
    2255              :                                         decl);
    2256              : #endif
    2257        64736 :       ASM_OUTPUT_LABEL (asm_out_file, crtl->subsections.cold_section_end_label);
    2258        64736 :       if (first_function_block_is_cold)
    2259            0 :         switch_to_section (text_section);
    2260              :       else
    2261        64736 :         switch_to_section (function_section (decl));
    2262        64736 :       ASM_OUTPUT_LABEL (asm_out_file, crtl->subsections.hot_section_end_label);
    2263        64736 :       switch_to_section (save_text_section);
    2264              :     }
    2265      1483246 : }
    2266              : 
    2267              : /* Assemble code to leave SIZE bytes of zeros.  */
    2268              : 
    2269              : void
    2270      1053326 : assemble_zeros (unsigned HOST_WIDE_INT size)
    2271              : {
    2272              :   /* Do no output if -fsyntax-only.  */
    2273      1053326 :   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      1053326 :   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      1053326 :     if (size > 0)
    2288       981750 :       ASM_OUTPUT_SKIP (asm_out_file, size);
    2289              : }
    2290              : 
    2291              : /* Assemble an alignment pseudo op for an ALIGN-bit boundary.  */
    2292              : 
    2293              : void
    2294       384179 : assemble_align (unsigned int align)
    2295              : {
    2296       384179 :   if (align > BITS_PER_UNIT)
    2297              :     {
    2298       324870 :       ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
    2299              :     }
    2300       384179 : }
    2301              : 
    2302              : /* Assemble a string constant with the specified C string as contents.  */
    2303              : 
    2304              : void
    2305     33011128 : assemble_string (const char *p, int size)
    2306              : {
    2307     33011128 :   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     33011128 :   int maximum = 16384;
    2318              : #else
    2319              :   int maximum = 2000;
    2320              : #endif
    2321              : 
    2322              :   /* If the string is very long, split it up.  */
    2323              : 
    2324     66018555 :   while (pos < size)
    2325              :     {
    2326     33007427 :       int thissize = size - pos;
    2327     33007427 :       if (thissize > maximum)
    2328              :         thissize = maximum;
    2329              : 
    2330     33007427 :       ASM_OUTPUT_ASCII (asm_out_file, p, thissize);
    2331              : 
    2332     33007427 :       pos += thissize;
    2333     33007427 :       p += thissize;
    2334              :     }
    2335     33011128 : }
    2336              : 
    2337              : 
    2338              : /* A noswitch_section_callback for lcomm_section.  */
    2339              : 
    2340              : static bool
    2341       157244 : 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       157244 :   unsigned int align = symtab_node::get (decl)->definition_alignment ();
    2348       157244 :   ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file, decl, name,
    2349              :                                  size, align);
    2350       157244 :   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       768255 : 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       768255 :   ASM_OUTPUT_ALIGNED_BSS (asm_out_file, decl, name, size,
    2371              :                           get_variable_align (decl));
    2372       768255 :   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       926839 : assemble_noswitch_variable (tree decl, const char *name, section *sect,
    2420              :                             unsigned int align)
    2421              : {
    2422       926839 :   unsigned HOST_WIDE_INT size, rounded;
    2423              : 
    2424       926839 :   size = tree_to_uhwi (DECL_SIZE_UNIT (decl));
    2425       926839 :   rounded = size;
    2426              : 
    2427       926839 :   if ((flag_sanitize & SANITIZE_ADDRESS) && asan_protect_global (decl))
    2428         1900 :     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       926839 :   if (size == 0)
    2433         1586 :     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       926839 :   rounded += (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1;
    2438       926839 :   rounded = (rounded / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
    2439       926839 :              * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
    2440              : 
    2441       926839 :   if (!sect->noswitch.callback (decl, name, size, rounded)
    2442       926839 :       && (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       926839 : }
    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      1907564 : 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      1907564 :   last_assemble_variable_decl = decl;
    2458      1907564 :   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      1907564 :   if (!dont_output_data)
    2465              :     {
    2466              :       /* Caller is supposed to use varpool_get_constructor when it wants
    2467              :          to output the body.  */
    2468      1906681 :       gcc_assert (!in_lto_p || DECL_INITIAL (decl) != error_mark_node);
    2469      1906681 :       if (DECL_INITIAL (decl)
    2470      1894252 :           && DECL_INITIAL (decl) != error_mark_node
    2471      3800931 :           && !initializer_zerop (DECL_INITIAL (decl)))
    2472              :         /* Output the actual data.  */
    2473      3622694 :         output_constant (DECL_INITIAL (decl),
    2474      1811347 :                          tree_to_uhwi (DECL_SIZE_UNIT (decl)),
    2475              :                          get_variable_align (decl),
    2476              :                          false, merge_strings);
    2477              :       else
    2478              :         /* Leave space for it.  */
    2479        95334 :         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      1906681 :       if (in_section
    2483      1906681 :           && (in_section->common.flags & SECTION_MERGE)
    2484          105 :           && tree_fits_uhwi_p (DECL_SIZE_UNIT (decl))
    2485      1906681 :           && ((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      1906681 :       targetm.asm_out.decl_end ();
    2494              :     }
    2495      1907564 : }
    2496              : 
    2497              : /* Write out assembly for the variable DECL, which is not defined in
    2498              :    the current translation unit.  */
    2499              : void
    2500       294644 : assemble_undefined_decl (tree decl)
    2501              : {
    2502       294644 :   const char *name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
    2503       294644 :   targetm.asm_out.assemble_undefined_decl (asm_out_file, name, decl);
    2504       294644 : }
    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      2838878 : assemble_variable (tree decl, int top_level ATTRIBUTE_UNUSED,
    2518              :                    int at_end ATTRIBUTE_UNUSED, int dont_output_data)
    2519              : {
    2520      2838878 :   const char *name;
    2521      2838878 :   rtx decl_rtl, symbol;
    2522      2838878 :   section *sect;
    2523      2838878 :   unsigned int align;
    2524      2838878 :   bool asan_protected = false;
    2525              : 
    2526              :   /* This function is supposed to handle VARIABLES.  Ensure we have one.  */
    2527      2838878 :   gcc_assert (VAR_P (decl));
    2528              : 
    2529              :   /* Emulated TLS had better not get this far.  */
    2530      2838878 :   gcc_checking_assert (targetm.have_tls || !DECL_THREAD_LOCAL_P (decl));
    2531              : 
    2532      2838878 :   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      2838878 :   if (DECL_EXTERNAL (decl))
    2539              :     return;
    2540              : 
    2541              :   /* Do nothing for global register variables.  */
    2542      2836507 :   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      2836507 :   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      2836507 :   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      2836506 :   if (TREE_ASM_WRITTEN (decl))
    2570              :     return;
    2571              : 
    2572              :   /* Make sure targetm.encode_section_info is invoked before we set
    2573              :      ASM_WRITTEN.  */
    2574      2836506 :   decl_rtl = DECL_RTL (decl);
    2575              : 
    2576      2836506 :   TREE_ASM_WRITTEN (decl) = 1;
    2577              : 
    2578              :   /* Do no output if -fsyntax-only.  */
    2579      2836506 :   if (flag_syntax_only)
    2580              :     return;
    2581              : 
    2582      2836506 :   if (! dont_output_data
    2583      2836506 :       && ! 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      2836504 :   gcc_assert (MEM_P (decl_rtl));
    2590      2836504 :   gcc_assert (GET_CODE (XEXP (decl_rtl, 0)) == SYMBOL_REF);
    2591      2836504 :   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      2836504 :   if (TREE_CONSTANT_POOL_ADDRESS_P (symbol))
    2596              :     {
    2597         2101 :       tree decl = SYMBOL_REF_DECL (symbol);
    2598         2101 :       if (!TREE_ASM_WRITTEN (DECL_INITIAL (decl)))
    2599         1419 :         output_constant_def_contents (symbol);
    2600         2101 :       return;
    2601              :     }
    2602              : 
    2603      2834403 :   app_disable ();
    2604              : 
    2605      2834403 :   name = XSTR (symbol, 0);
    2606      2834403 :   if (TREE_PUBLIC (decl) && DECL_NAME (decl))
    2607      1409636 :     notice_global_symbol (decl);
    2608              : 
    2609              :   /* Compute the alignment of this data.  */
    2610              : 
    2611      2834403 :   align_variable (decl, dont_output_data);
    2612              : 
    2613      2834403 :   if ((flag_sanitize & SANITIZE_ADDRESS)
    2614      2834403 :       && asan_protect_global (decl))
    2615              :     {
    2616         2283 :       asan_protected = true;
    2617         2283 :       SET_DECL_ALIGN (decl, MAX (DECL_ALIGN (decl),
    2618              :                                  ASAN_RED_ZONE_SIZE * BITS_PER_UNIT));
    2619              :     }
    2620              : 
    2621      2834403 :   set_mem_align (decl_rtl, DECL_ALIGN (decl));
    2622              : 
    2623      2834403 :   align = get_variable_align (decl);
    2624              : 
    2625      2834403 :   if (TREE_PUBLIC (decl))
    2626      1410080 :     maybe_assemble_visibility (decl);
    2627              : 
    2628      2834403 :   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      2834403 :   sect = get_variable_section (decl, false);
    2633      2834403 :   if (TREE_PUBLIC (decl)
    2634      1410080 :       && (sect->common.flags & SECTION_COMMON) == 0)
    2635      1408740 :     globalize_decl (decl);
    2636              : 
    2637              :   /* Output any data that we will need to use the address of.  */
    2638      2834403 :   if (DECL_INITIAL (decl) && DECL_INITIAL (decl) != error_mark_node)
    2639      1916660 :     output_addressed_constants (DECL_INITIAL (decl), 0);
    2640              : 
    2641              :   /* dbxout.cc needs to know this.  */
    2642      2834403 :   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      2834403 :   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      2834403 :   else if (SECTION_STYLE (sect) == SECTION_NOSWITCH)
    2654       926839 :     assemble_noswitch_variable (decl, name, sect, align);
    2655              :   else
    2656              :     {
    2657              :       /* Special-case handling of vtv comdat sections.  */
    2658      1907564 :       if (SECTION_STYLE (sect) == SECTION_NAMED
    2659      1529467 :           && (strcmp (sect->named.name, ".vtable_map_vars") == 0))
    2660            3 :         handle_vtv_comdat_section (sect, decl);
    2661              :       else
    2662      1907561 :         switch_to_section (sect, decl);
    2663      1907564 :       if (align > BITS_PER_UNIT)
    2664      1822364 :         ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
    2665      1907564 :       assemble_variable_contents (decl, name, dont_output_data,
    2666      1907564 :                                   (sect->common.flags & SECTION_MERGE)
    2667      1907564 :                                   && (sect->common.flags & SECTION_STRINGS));
    2668      1907564 :       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      1813012 : incorporeal_function_p (tree decl)
    2738              : {
    2739      1813012 :   if (TREE_CODE (decl) == FUNCTION_DECL && fndecl_built_in_p (decl))
    2740              :     {
    2741       199830 :       const char *name;
    2742              : 
    2743       199830 :       if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL
    2744       199830 :           && ALLOCA_FUNCTION_CODE_P (DECL_FUNCTION_CODE (decl)))
    2745              :         return true;
    2746              : 
    2747       199825 :       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       199825 :       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      1824434 : assemble_external_real (tree decl)
    2760              : {
    2761      1824434 :   rtx rtl = DECL_RTL (decl);
    2762              : 
    2763      1824434 :   if (MEM_P (rtl) && GET_CODE (XEXP (rtl, 0)) == SYMBOL_REF
    2764      1824434 :       && !SYMBOL_REF_USED (XEXP (rtl, 0))
    2765      3637446 :       && !incorporeal_function_p (decl))
    2766              :     {
    2767              :       /* Some systems do require some output.  */
    2768      1813007 :       SYMBOL_REF_USED (XEXP (rtl, 0)) = 1;
    2769      1813007 :       ASM_OUTPUT_EXTERNAL (asm_out_file, decl, XSTR (XEXP (rtl, 0), 0));
    2770              :     }
    2771      1824434 : }
    2772              : #endif
    2773              : 
    2774              : void
    2775       232630 : process_pending_assemble_externals (void)
    2776              : {
    2777              : #ifdef ASM_OUTPUT_EXTERNAL
    2778       232630 :   tree list;
    2779      2057064 :   for (list = pending_assemble_externals; list; list = TREE_CHAIN (list))
    2780      1824434 :     assemble_external_real (TREE_VALUE (list));
    2781              : 
    2782       259477 :   for (rtx list = pending_libcall_symbols; list; list = XEXP (list, 1))
    2783              :     {
    2784        26847 :       rtx symbol = XEXP (list, 0);
    2785        26847 :       const char *name = targetm.strip_name_encoding (XSTR (symbol, 0));
    2786        26847 :       tree id = get_identifier (name);
    2787        26847 :       if (TREE_SYMBOL_REFERENCED (id))
    2788        26780 :         targetm.asm_out.external_libcall (symbol);
    2789              :     }
    2790              : 
    2791       232630 :   pending_assemble_externals = 0;
    2792       232630 :   pending_assemble_externals_processed = true;
    2793       232630 :   pending_libcall_symbols = NULL_RTX;
    2794       465260 :   delete pending_assemble_externals_set;
    2795       232630 :   pending_assemble_externals_set = nullptr;
    2796              : #endif
    2797       232630 : }
    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     41031198 : 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     41031198 :   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     41031198 :   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     17860538 :   if (TARGET_SUPPORTS_WEAK
    2835     17860538 :       && 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        12311 :       && !TREE_STATIC (decl)
    2842         5740 :       && lookup_attribute ("weak", DECL_ATTRIBUTES (decl))
    2843     17865815 :       && value_member (decl, weak_decls) == NULL_TREE)
    2844         1014 :     weak_decls = tree_cons (NULL, decl, weak_decls);
    2845              : 
    2846              : #ifdef ASM_OUTPUT_EXTERNAL
    2847     17860538 :   if (pending_assemble_externals_processed)
    2848              :     {
    2849            0 :       assemble_external_real (decl);
    2850            0 :       return;
    2851              :     }
    2852              : 
    2853     17860538 :   if (! pending_assemble_externals_set->add (decl))
    2854      1824480 :     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       193626 : assemble_external_libcall (rtx fun)
    2863              : {
    2864              :   /* Declare library function name external when first used, if nec.  */
    2865       193626 :   if (! SYMBOL_REF_USED (fun))
    2866              :     {
    2867              : #ifdef ASM_OUTPUT_EXTERNAL
    2868        26860 :       gcc_assert (!pending_assemble_externals_processed);
    2869              : #endif
    2870        26860 :       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        26860 :       const char *name = targetm.strip_name_encoding (XSTR (fun, 0));
    2876        26860 :       get_identifier (name);
    2877        26860 :       pending_libcall_symbols = gen_rtx_EXPR_LIST (VOIDmode, fun,
    2878              :                                                    pending_libcall_symbols);
    2879              :     }
    2880       193626 : }
    2881              : 
    2882              : /* Assemble a label named NAME.  */
    2883              : 
    2884              : void
    2885      1274766 : assemble_label (FILE *file, const char *name)
    2886              : {
    2887      1274766 :   ASM_OUTPUT_LABEL (file, name);
    2888      1274766 : }
    2889              : 
    2890              : /* Set the symbol_referenced flag for ID.  */
    2891              : void
    2892     34723292 : mark_referenced (tree id)
    2893              : {
    2894     34723292 :   TREE_SYMBOL_REFERENCED (id) = 1;
    2895     34723292 : }
    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    468661708 : assemble_name_raw (FILE *file, const char *name)
    2931              : {
    2932    468661708 :   if (name[0] == '*')
    2933    433598119 :     fputs (&name[1], file);
    2934              :   else
    2935     35063589 :     ASM_OUTPUT_LABELREF (file, name);
    2936    468661708 : }
    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    394733657 : assemble_name_resolve (const char *name)
    2944              : {
    2945    394733657 :   const char *real_name = targetm.strip_name_encoding (name);
    2946    394733657 :   tree id = maybe_get_identifier (real_name);
    2947              : 
    2948    394733657 :   if (id)
    2949              :     {
    2950     34723292 :       tree id_orig = id;
    2951              : 
    2952     34723292 :       mark_referenced (id);
    2953     34723292 :       ultimate_transparent_alias_target (&id);
    2954     34723292 :       if (id != id_orig)
    2955            0 :         name = IDENTIFIER_POINTER (id);
    2956     34723292 :       gcc_assert (!IDENTIFIER_TRANSPARENT_ALIAS (id));
    2957              :     }
    2958              : 
    2959    394733657 :   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    271479356 : assemble_name (FILE *file, const char *name)
    2969              : {
    2970    271479356 :   assemble_name_raw (file, assemble_name_resolve (name));
    2971    271479356 : }
    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     15106868 : min_align (unsigned int a, unsigned int b)
    3065              : {
    3066     15106868 :   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    449564989 : integer_asm_op (int size, int aligned_p)
    3079              : {
    3080    449564989 :   struct asm_int_op *ops;
    3081              : 
    3082    449564989 :   if (aligned_p)
    3083              :     ops = &targetm.asm_out.aligned_op;
    3084              :   else
    3085    435243679 :     ops = &targetm.asm_out.unaligned_op;
    3086              : 
    3087    449564989 :   switch (size)
    3088              :     {
    3089    230226200 :     case 1:
    3090    230226200 :       return targetm.asm_out.byte_op;
    3091     22873409 :     case 2:
    3092     22873409 :       return ops->hi;
    3093            0 :     case 3:
    3094            0 :       return ops->psi;
    3095    158485191 :     case 4:
    3096    158485191 :       return ops->si;
    3097            0 :     case 5:
    3098            0 :     case 6:
    3099            0 :     case 7:
    3100            0 :       return ops->pdi;
    3101     37953660 :     case 8:
    3102     37953660 :       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        25890 :     case 16:
    3112        25890 :       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     14050957 : assemble_integer_with_op (const char *op, rtx x)
    3123              : {
    3124     14050957 :   fputs (op, asm_out_file);
    3125     14050957 :   output_addr_const (asm_out_file, x);
    3126     14050957 :   fputc ('\n', asm_out_file);
    3127     14050957 : }
    3128              : 
    3129              : /* The default implementation of the asm_out.integer target hook.  */
    3130              : 
    3131              : bool
    3132     14349232 : default_assemble_integer (rtx x ATTRIBUTE_UNUSED,
    3133              :                           unsigned int size ATTRIBUTE_UNUSED,
    3134              :                           int aligned_p ATTRIBUTE_UNUSED)
    3135              : {
    3136     14349232 :   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     19339380 :   if (size > UNITS_PER_WORD && size > POINTER_SIZE_UNITS)
    3140              :     return false;
    3141     14050957 :   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     14349232 : assemble_integer (rtx x, unsigned int size, unsigned int align, int force)
    3151              : {
    3152     14349232 :   int aligned_p;
    3153              : 
    3154     14349232 :   aligned_p = (align >= MIN (size * BITS_PER_UNIT, BIGGEST_ALIGNMENT));
    3155              : 
    3156              :   /* See if the target hook can handle this kind of object.  */
    3157     14349232 :   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       298275 :   if (size > 1)
    3163              :     {
    3164       298275 :       machine_mode omode, imode;
    3165       298275 :       unsigned int subalign;
    3166       298275 :       unsigned int subsize, i;
    3167       298275 :       enum mode_class mclass;
    3168              : 
    3169       573270 :       subsize = size > UNITS_PER_WORD? UNITS_PER_WORD : 1;
    3170       298275 :       subalign = MIN (align, subsize * BITS_PER_UNIT);
    3171       298275 :       if (GET_CODE (x) == CONST_FIXED)
    3172            0 :         mclass = GET_MODE_CLASS (GET_MODE (x));
    3173              :       else
    3174              :         mclass = MODE_INT;
    3175              : 
    3176       298275 :       omode = mode_for_size (subsize * BITS_PER_UNIT, mclass, 0).require ();
    3177       298275 :       imode = mode_for_size (size * BITS_PER_UNIT, mclass, 0).require ();
    3178              : 
    3179       898645 :       for (i = 0; i < size; i += subsize)
    3180              :         {
    3181       600370 :           rtx partial = simplify_subreg (omode, x, imode, i);
    3182       600370 :           if (!partial || !assemble_integer (partial, subsize, subalign, 0))
    3183              :             break;
    3184              :         }
    3185       298275 :       if (i == size)
    3186     14349232 :         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       799893 : assemble_real (REAL_VALUE_TYPE d, scalar_float_mode mode, unsigned int align,
    3204              :                bool reverse)
    3205              : {
    3206       799893 :   long data[4] = {0, 0, 0, 0};
    3207       799893 :   int bitsize, nelts, nunits, units_per;
    3208       799893 :   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       799893 :   nunits = GET_MODE_SIZE (mode);
    3223       799893 :   bitsize = nunits * BITS_PER_UNIT;
    3224       799893 :   nelts = CEIL (bitsize, 32);
    3225       799893 :   units_per = 32 / BITS_PER_UNIT;
    3226              : 
    3227       799893 :   real_to_target (data, &d, mode);
    3228              : 
    3229              :   /* Put out the first word with the specified alignment.  */
    3230       799893 :   unsigned int chunk_nunits = MIN (nunits, units_per);
    3231       799893 :   if (reverse)
    3232           72 :     elt = flip_storage_order (SImode, gen_int_mode (data[nelts - 1], SImode));
    3233              :   else
    3234       799821 :     elt = GEN_INT (sext_hwi (data[0], chunk_nunits * BITS_PER_UNIT));
    3235       799893 :   assemble_integer (elt, chunk_nunits, align, 1);
    3236       799893 :   nunits -= chunk_nunits;
    3237              : 
    3238              :   /* Subsequent words need only 32-bit alignment.  */
    3239       799893 :   align = min_align (align, 32);
    3240              : 
    3241      1207835 :   for (int i = 1; i < nelts; i++)
    3242              :     {
    3243       407942 :       chunk_nunits = MIN (nunits, units_per);
    3244       407942 :       if (reverse)
    3245           18 :         elt = flip_storage_order (SImode,
    3246           18 :                                   gen_int_mode (data[nelts - 1 - i], SImode));
    3247              :       else
    3248       407924 :         elt = GEN_INT (sext_hwi (data[i], chunk_nunits * BITS_PER_UNIT));
    3249       407942 :       assemble_integer (elt, chunk_nunits, align, 1);
    3250       407942 :       nunits -= chunk_nunits;
    3251              :     }
    3252       799893 : }
    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        28682 : decode_addr_const (tree exp, class addr_const *value)
    3267              : {
    3268        28682 :   tree target = TREE_OPERAND (exp, 0);
    3269        28682 :   poly_int64 offset = 0;
    3270        29134 :   rtx x;
    3271              : 
    3272        29586 :   while (1)
    3273              :     {
    3274        29134 :       poly_int64 bytepos;
    3275        29134 :       if (TREE_CODE (target) == COMPONENT_REF
    3276        29134 :           && 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        28696 :       else if (TREE_CODE (target) == ARRAY_REF
    3283        28696 :                || 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        28682 :       else if (TREE_CODE (target) == MEM_REF
    3292        28682 :                && 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        28682 :       else if (INDIRECT_REF_P (target)
    3298            0 :                && TREE_CODE (TREE_OPERAND (target, 0)) == NOP_EXPR
    3299        28682 :                && 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        28682 :   switch (TREE_CODE (target))
    3307              :     {
    3308        28580 :     case VAR_DECL:
    3309        28580 :     case FUNCTION_DECL:
    3310        28580 :       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        28682 :   gcc_assert (MEM_P (x));
    3346        28682 :   x = XEXP (x, 0);
    3347              : 
    3348        28682 :   value->base = x;
    3349        28682 :   value->offset = offset;
    3350        28682 : }
    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         2437 : constant_pool_htab (void)
    3360              : {
    3361         2437 :   return const_desc_htab;
    3362              : }
    3363              : 
    3364              : /* Compute a hash code for a constant expression.  */
    3365              : 
    3366              : hashval_t
    3367      9199634 : tree_descriptor_hasher::hash (constant_descriptor_tree *ptr)
    3368              : {
    3369      9199634 :   return ptr->hash;
    3370              : }
    3371              : 
    3372              : static hashval_t
    3373      5566813 : const_hash_1 (const tree exp)
    3374              : {
    3375      5841198 :   const char *p;
    3376      5841198 :   hashval_t hi;
    3377      5841198 :   int len, i;
    3378      5841198 :   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      5841198 :   switch (code)
    3384              :     {
    3385       681893 :     case INTEGER_CST:
    3386       681893 :       p = (char *) &TREE_INT_CST_ELT (exp, 0);
    3387       681893 :       len = TREE_INT_CST_NUNITS (exp) * sizeof (HOST_WIDE_INT);
    3388       681893 :       break;
    3389              : 
    3390        44946 :     case REAL_CST:
    3391        44946 :       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      4582852 :     case STRING_CST:
    3397      4582852 :       p = TREE_STRING_POINTER (exp);
    3398      4582852 :       len = TREE_STRING_LENGTH (exp);
    3399      4582852 :       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          163 :     case RAW_DATA_CST:
    3416          163 :       p = RAW_DATA_POINTER (exp);
    3417          163 :       len = RAW_DATA_LENGTH (exp);
    3418          163 :       break;
    3419              : 
    3420       228282 :     case CONSTRUCTOR:
    3421       228282 :       {
    3422       228282 :         unsigned HOST_WIDE_INT idx;
    3423       228282 :         tree value;
    3424              : 
    3425       228282 :         hi = 5 + int_size_in_bytes (TREE_TYPE (exp));
    3426              : 
    3427      1199507 :         FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (exp), idx, value)
    3428       971225 :           if (value)
    3429       971225 :             hi = hi * 603 + const_hash_1 (value);
    3430              : 
    3431              :         return hi;
    3432              :       }
    3433              : 
    3434       123734 :     case ADDR_EXPR:
    3435       123734 :       if (CONSTANT_CLASS_P (TREE_OPERAND (exp, 0)))
    3436        95058 :        return const_hash_1 (TREE_OPERAND (exp, 0));
    3437              : 
    3438              :       /* Fallthru.  */
    3439        28676 :     case FDESC_EXPR:
    3440        28676 :       {
    3441        28676 :         class addr_const value;
    3442              : 
    3443        28676 :         decode_addr_const (exp, &value);
    3444        28676 :         switch (GET_CODE (value.base))
    3445              :           {
    3446        28676 :           case SYMBOL_REF:
    3447              :             /* Don't hash the address of the SYMBOL_REF;
    3448              :                only use the offset and the symbol name.  */
    3449        28676 :             hi = value.offset.coeffs[0];
    3450        28676 :             p = XSTR (value.base, 0);
    3451      1009916 :             for (i = 0; p[i] != 0; i++)
    3452       981240 :               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        28676 :       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       159786 :     CASE_CONVERT:
    3473       159786 :       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      5264908 :   hi = len;
    3482    324278670 :   for (i = 0; i < len; i++)
    3483    319013762 :     hi = ((hi * 613) + (unsigned) (p[i]));
    3484              : 
    3485              :   return hi;
    3486              : }
    3487              : 
    3488              : /* Wrapper of compare_constant, for the htab interface.  */
    3489              : bool
    3490     12926557 : tree_descriptor_hasher::equal (constant_descriptor_tree *c1,
    3491              :                                constant_descriptor_tree *c2)
    3492              : {
    3493     12926557 :   if (c1->hash != c2->hash)
    3494              :     return false;
    3495      3030008 :   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      3485084 : compare_constant (const tree t1, const tree t2)
    3503              : {
    3504      3488284 :   enum tree_code typecode;
    3505              : 
    3506      3488284 :   if (t1 == NULL_TREE)
    3507        20738 :     return t2 == NULL_TREE;
    3508      3467546 :   if (t2 == NULL_TREE)
    3509              :     return false;
    3510              : 
    3511      3467546 :   if (TREE_CODE (t1) != TREE_CODE (t2))
    3512              :     return false;
    3513              : 
    3514      3467518 :   switch (TREE_CODE (t1))
    3515              :     {
    3516       419666 :     case INTEGER_CST:
    3517              :       /* Integer constants are the same only if the same width of type.  */
    3518       419666 :       if (TYPE_PRECISION (TREE_TYPE (t1)) != TYPE_PRECISION (TREE_TYPE (t2)))
    3519              :         return false;
    3520       409353 :       if (TYPE_MODE (TREE_TYPE (t1)) != TYPE_MODE (TREE_TYPE (t2)))
    3521              :         return false;
    3522       409281 :       return tree_int_cst_equal (t1, t2);
    3523              : 
    3524        40354 :     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        40354 :       if (TYPE_PRECISION (TREE_TYPE (t1)) != TYPE_PRECISION (TREE_TYPE (t2)))
    3532              :         return false;
    3533        27550 :       if (TYPE_MODE (TREE_TYPE (t1)) != TYPE_MODE (TREE_TYPE (t2)))
    3534              :         return false;
    3535        27550 :       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      2948613 :     case STRING_CST:
    3545      2948613 :       if (TYPE_MODE (TREE_TYPE (t1)) != TYPE_MODE (TREE_TYPE (t2))
    3546      5897226 :           || int_size_in_bytes (TREE_TYPE (t1))
    3547      2948613 :              != int_size_in_bytes (TREE_TYPE (t2)))
    3548           52 :         return false;
    3549              : 
    3550      2948561 :       return (TREE_STRING_LENGTH (t1) == TREE_STRING_LENGTH (t2)
    3551      2948561 :               && ! memcmp (TREE_STRING_POINTER (t1), TREE_STRING_POINTER (t2),
    3552      2948561 :                            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           75 :     case RAW_DATA_CST:
    3578           75 :       return (RAW_DATA_LENGTH (t1) == RAW_DATA_LENGTH (t2)
    3579           75 :               && ! memcmp (RAW_DATA_POINTER (t1), RAW_DATA_POINTER (t2),
    3580           75 :                            RAW_DATA_LENGTH (t1)));
    3581              : 
    3582        30121 :     case CONSTRUCTOR:
    3583        30121 :       {
    3584        30121 :         vec<constructor_elt, va_gc> *v1, *v2;
    3585        30121 :         unsigned HOST_WIDE_INT idx;
    3586              : 
    3587        30121 :         typecode = TREE_CODE (TREE_TYPE (t1));
    3588        30121 :         if (typecode != TREE_CODE (TREE_TYPE (t2)))
    3589              :           return false;
    3590              : 
    3591        30121 :         if (typecode == ARRAY_TYPE)
    3592              :           {
    3593          847 :             HOST_WIDE_INT size_1 = int_size_in_bytes (TREE_TYPE (t1));
    3594              :             /* For arrays, check that mode, size and storage order match.  */
    3595          847 :             if (TYPE_MODE (TREE_TYPE (t1)) != TYPE_MODE (TREE_TYPE (t2))
    3596          847 :                 || size_1 == -1
    3597          847 :                 || size_1 != int_size_in_bytes (TREE_TYPE (t2))
    3598         1694 :                 || TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (t1))
    3599          847 :                    != 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        30113 :         v1 = CONSTRUCTOR_ELTS (t1);
    3611        30113 :         v2 = CONSTRUCTOR_ELTS (t2);
    3612        90339 :         if (vec_safe_length (v1) != vec_safe_length (v2))
    3613              :           return false;
    3614              : 
    3615       283310 :         for (idx = 0; idx < vec_safe_length (v1); ++idx)
    3616              :           {
    3617       253206 :             constructor_elt *c1 = &(*v1)[idx];
    3618       253206 :             constructor_elt *c2 = &(*v2)[idx];
    3619              : 
    3620              :             /* Check that each value is the same...  */
    3621       253206 :             if (!compare_constant (c1->value, c2->value))
    3622              :               return false;
    3623              :             /* ... and that they apply to the same fields!  */
    3624       253197 :             if (typecode == ARRAY_TYPE)
    3625              :               {
    3626       161687 :                 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      1274766 : get_constant_section (tree exp, unsigned int align)
    3693              : {
    3694      1274766 :   return targetm.asm_out.select_section (exp,
    3695              :                                          compute_reloc_for_constant (exp),
    3696      1274766 :                                          align);
    3697              : }
    3698              : 
    3699              : /* Return the size of constant EXP in bytes.  */
    3700              : 
    3701              : static HOST_WIDE_INT
    3702      1276389 : get_constant_size (tree exp)
    3703              : {
    3704      1276389 :   HOST_WIDE_INT size;
    3705              : 
    3706      1276389 :   size = int_size_in_bytes (TREE_TYPE (exp));
    3707      1276389 :   gcc_checking_assert (size >= 0);
    3708      1276389 :   gcc_checking_assert (TREE_CODE (exp) != STRING_CST
    3709              :                        || size >= TREE_STRING_LENGTH (exp));
    3710      1276389 :   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      1286837 : build_constant_desc (tree exp)
    3722              : {
    3723      1286837 :   struct constant_descriptor_tree *desc;
    3724      1286837 :   rtx symbol, rtl;
    3725      1286837 :   char label[256];
    3726      1286837 :   int labelno;
    3727      1286837 :   tree decl;
    3728              : 
    3729      1286837 :   desc = ggc_alloc<constant_descriptor_tree> ();
    3730      1286837 :   desc->value = exp;
    3731              : 
    3732              :   /* Create a string containing the label name, in LABEL.  */
    3733      1286837 :   labelno = const_labelno++;
    3734      1286837 :   ASM_GENERATE_INTERNAL_LABEL (label, "LC", labelno);
    3735              : 
    3736              :   /* Construct the VAR_DECL associated with the constant.  */
    3737      1286837 :   decl = build_decl (UNKNOWN_LOCATION, VAR_DECL, get_identifier (label),
    3738      1286837 :                      TREE_TYPE (exp));
    3739      1286837 :   DECL_ARTIFICIAL (decl) = 1;
    3740      1286837 :   DECL_IGNORED_P (decl) = 1;
    3741      1286837 :   TREE_READONLY (decl) = 1;
    3742      1286837 :   TREE_STATIC (decl) = 1;
    3743      1286837 :   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      1286837 :   DECL_IN_CONSTANT_POOL (decl) = 1;
    3748      1286837 :   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      1286837 :   if (TREE_CODE (exp) == STRING_CST)
    3752      1254685 :     SET_DECL_ALIGN (decl, targetm.constant_alignment (exp, DECL_ALIGN (decl)));
    3753              :   else
    3754              :     {
    3755        32152 :       align_variable (decl, 0);
    3756        32152 :       if (DECL_ALIGN (decl) < GET_MODE_ALIGNMENT (DECL_MODE (decl))
    3757        32152 :           && ((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      1286837 :   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      1583509 :     symbol = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (label));
    3777      1286837 :   SYMBOL_REF_FLAGS (symbol) |= SYMBOL_FLAG_LOCAL;
    3778      1286837 :   SET_SYMBOL_REF_DECL (symbol, decl);
    3779      1286837 :   TREE_CONSTANT_POOL_ADDRESS_P (symbol) = 1;
    3780              : 
    3781      1286837 :   rtl = gen_const_mem (TYPE_MODE (TREE_TYPE (exp)), symbol);
    3782      1286837 :   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      1286837 :   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      1286837 :   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      1286837 :   targetm.encode_section_info (exp, rtl, true);
    3798              : 
    3799      1286837 :   desc->rtl = rtl;
    3800              : 
    3801      1286837 :   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      3993178 : 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      3993178 :   output_addressed_constants (exp, defer);
    3814              : 
    3815              :   /* Sanity check to catch recursive insertion.  */
    3816      3993178 :   static bool inserting;
    3817      3993178 :   gcc_assert (!inserting);
    3818      3993178 :   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      3993178 :   struct constant_descriptor_tree key;
    3823      3993178 :   key.value = exp;
    3824      3993178 :   key.hash = const_hash_1 (exp);
    3825      3993178 :   constant_descriptor_tree **loc
    3826      3993178 :     = const_desc_htab->find_slot_with_hash (&key, key.hash, INSERT);
    3827              : 
    3828      3993178 :   inserting = false;
    3829              : 
    3830      3993178 :   struct constant_descriptor_tree *desc = *loc;
    3831      3993178 :   if (!desc)
    3832              :     {
    3833      1286837 :       desc = build_constant_desc (exp);
    3834      1286837 :       desc->hash = key.hash;
    3835      1286837 :       *loc = desc;
    3836              :     }
    3837              : 
    3838      3993178 :   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      3982857 : output_constant_def (tree exp, int defer)
    3856              : {
    3857      3982857 :   struct constant_descriptor_tree *desc = add_constant_to_table (exp, defer);
    3858      3982857 :   maybe_output_constant_def_contents (desc, defer);
    3859      3982857 :   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      3982857 : maybe_output_constant_def_contents (struct constant_descriptor_tree *desc,
    3866              :                                     int defer)
    3867              : {
    3868      3982857 :   rtx symbol = XEXP (desc->rtl, 0);
    3869      3982857 :   tree exp = desc->value;
    3870              : 
    3871      3982857 :   if (flag_syntax_only)
    3872              :     return;
    3873              : 
    3874      3982857 :   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      1468786 :   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       202900 :       if (cfun)
    3888       108412 :         n_deferred_constants++;
    3889       202900 :       return;
    3890              :     }
    3891              : 
    3892      1265886 :   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      1274766 : assemble_constant_contents (tree exp, const char *label, unsigned int align,
    3901              :                             bool merge_strings)
    3902              : {
    3903      1274766 :   HOST_WIDE_INT size;
    3904              : 
    3905      1274766 :   size = get_constant_size (exp);
    3906              : 
    3907              :   /* Do any machine/system dependent processing of the constant.  */
    3908      1274766 :   targetm.asm_out.declare_constant_name (asm_out_file, label, exp, size);
    3909              : 
    3910              :   /* Output the value of EXP.  */
    3911      1274766 :   output_constant (exp, size, align, false, merge_strings);
    3912              : 
    3913      1274766 :   targetm.asm_out.decl_end ();
    3914      1274766 : }
    3915              : 
    3916              : /* We must output the constant data referred to by SYMBOL; do so.  */
    3917              : 
    3918              : static void
    3919      1274766 : output_constant_def_contents (rtx symbol)
    3920              : {
    3921      1274766 :   tree decl = SYMBOL_REF_DECL (symbol);
    3922      1274766 :   tree exp = DECL_INITIAL (decl);
    3923      1274766 :   bool asan_protected = false;
    3924              : 
    3925              :   /* Make sure any other constants whose addresses appear in EXP
    3926              :      are assigned label numbers.  */
    3927      1274766 :   output_addressed_constants (exp, 0);
    3928              : 
    3929              :   /* We are no longer deferring this constant.  */
    3930      1274766 :   TREE_ASM_WRITTEN (decl) = TREE_ASM_WRITTEN (exp) = 1;
    3931              : 
    3932      1274766 :   if ((flag_sanitize & SANITIZE_ADDRESS)
    3933         3250 :       && TREE_CODE (exp) == STRING_CST
    3934      1277994 :       && asan_protect_global (exp))
    3935              :     {
    3936         1623 :       asan_protected = true;
    3937         1623 :       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      1274766 :   if (SYMBOL_REF_HAS_BLOCK_INFO_P (symbol) && SYMBOL_REF_BLOCK (symbol))
    3945            0 :     place_block_symbol (symbol);
    3946              :   else
    3947              :     {
    3948      1274766 :       int align = (TREE_CODE (decl) == CONST_DECL
    3949      1274766 :                    || (VAR_P (decl) && DECL_IN_CONSTANT_POOL (decl))
    3950      2549532 :                    ? DECL_ALIGN (decl)
    3951      1274766 :                    : symtab_node::get (decl)->definition_alignment ());
    3952      1274766 :       section *sect = get_constant_section (exp, align);
    3953      1274766 :       switch_to_section (sect);
    3954      1274766 :       if (align > BITS_PER_UNIT)
    3955       398424 :         ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
    3956      1274766 :       assemble_constant_contents (exp, XSTR (symbol, 0), align,
    3957      1274766 :                                   (sect->common.flags & SECTION_MERGE)
    3958      1274766 :                                   && (sect->common.flags & SECTION_STRINGS));
    3959      1274766 :       if (asan_protected)
    3960              :         {
    3961         1623 :           HOST_WIDE_INT size = get_constant_size (exp);
    3962         3211 :           assemble_zeros (asan_red_zone_size (size));
    3963              :         }
    3964              :     }
    3965      1274766 : }
    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       582869 : lookup_constant_def (tree exp)
    3972              : {
    3973       582869 :   struct constant_descriptor_tree key;
    3974              : 
    3975       582869 :   key.value = exp;
    3976       582869 :   key.hash = const_hash_1 (exp);
    3977       582869 :   constant_descriptor_tree *desc
    3978       582869 :     = const_desc_htab->find_with_hash (&key, key.hash);
    3979              : 
    3980       582869 :   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        10321 : tree_output_constant_def (tree exp)
    3990              : {
    3991        10321 :   struct constant_descriptor_tree *desc = add_constant_to_table (exp, 1);
    3992        10321 :   tree decl = SYMBOL_REF_DECL (XEXP (desc->rtl, 0));
    3993        10321 :   varpool_node::finalize_decl (decl);
    3994        10321 :   return decl;
    3995              : }
    3996              : 
    3997      4191804 : 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     16516163 : const_rtx_desc_hasher::hash (constant_descriptor_rtx *desc)
    4044              : {
    4045     16516163 :   return desc->hash;
    4046              : }
    4047              : 
    4048              : bool
    4049     20632084 : const_rtx_desc_hasher::equal (constant_descriptor_rtx *x,
    4050              :                               constant_descriptor_rtx *y)
    4051              : {
    4052     20632084 :   if (x->mode != y->mode)
    4053              :     return false;
    4054     11155989 :   return rtx_equal_p (x->constant, y->constant);
    4055              : }
    4056              : 
    4057              : /* Hash one component of a constant.  */
    4058              : 
    4059              : static hashval_t
    4060     15617334 : const_rtx_hash_1 (const_rtx x)
    4061              : {
    4062     15617334 :   unsigned HOST_WIDE_INT hwi;
    4063     15617334 :   machine_mode mode;
    4064     15617334 :   enum rtx_code code;
    4065     15617334 :   hashval_t h;
    4066     15617334 :   int i;
    4067              : 
    4068     15617334 :   code = GET_CODE (x);
    4069     15617334 :   mode = GET_MODE (x);
    4070     15617334 :   h = (hashval_t) code * 1048573 + mode;
    4071              : 
    4072     15617334 :   switch (code)
    4073              :     {
    4074     10284242 :     case CONST_INT:
    4075     10284242 :       hwi = INTVAL (x);
    4076              : 
    4077     10400925 :     fold_hwi:
    4078     10400925 :       {
    4079     10400925 :         int shift = sizeof (hashval_t) * CHAR_BIT;
    4080     10400925 :         const int n = sizeof (HOST_WIDE_INT) / sizeof (hashval_t);
    4081              : 
    4082     10400925 :         h ^= (hashval_t) hwi;
    4083     20801850 :         for (i = 1; i < n; ++i)
    4084              :           {
    4085     10400925 :             hwi >>= shift;
    4086     10400925 :             h ^= (hashval_t) hwi;
    4087              :           }
    4088              :       }
    4089              :       break;
    4090              : 
    4091              :     case CONST_WIDE_INT:
    4092              :       hwi = 0;
    4093              :       {
    4094       360689 :         for (i = 0; i < CONST_WIDE_INT_NUNITS (x); i++)
    4095       244006 :           hwi ^= CONST_WIDE_INT_ELT (x, i);
    4096       116683 :         goto fold_hwi;
    4097              :       }
    4098              : 
    4099      2853818 :     case CONST_DOUBLE:
    4100      2853818 :       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      2853818 :         h ^= real_hash (CONST_DOUBLE_REAL_VALUE (x));
    4107      2853818 :       break;
    4108              : 
    4109            0 :     case CONST_FIXED:
    4110            0 :       h ^= fixed_hash (CONST_FIXED_VALUE (x));
    4111            0 :       break;
    4112              : 
    4113        94291 :     case SYMBOL_REF:
    4114        94291 :       h ^= htab_hash_string (XSTR (x, 0));
    4115        94291 :       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     15617334 :   return h;
    4131              : }
    4132              : 
    4133              : /* Compute a hash value for X, which should be a constant.  */
    4134              : 
    4135              : static hashval_t
    4136      4170612 : const_rtx_hash (rtx x)
    4137              : {
    4138      4170612 :   hashval_t h = 0;
    4139      4170612 :   subrtx_iterator::array_type array;
    4140     19787946 :   FOR_EACH_SUBRTX (iter, array, x, ALL)
    4141     15617334 :     h = h * 509 + const_rtx_hash_1 (*iter);
    4142      4170612 :   return h;
    4143      4170612 : }
    4144              : 
    4145              : 
    4146              : /* Create and return a new rtx constant pool.  */
    4147              : 
    4148              : static struct rtx_constant_pool *
    4149      1985140 : create_constant_pool (void)
    4150              : {
    4151      1985140 :   struct rtx_constant_pool *pool;
    4152              : 
    4153      1985140 :   pool = ggc_alloc<rtx_constant_pool> ();
    4154      1985140 :   pool->const_rtx_htab = hash_table<const_rtx_desc_hasher>::create_ggc (31);
    4155      1985140 :   pool->first = NULL;
    4156      1985140 :   pool->last = NULL;
    4157      1985140 :   pool->offset = 0;
    4158      1985140 :   return pool;
    4159              : }
    4160              : 
    4161              : /* Initialize constant pool hashing for a new function.  */
    4162              : 
    4163              : void
    4164      1703905 : init_varasm_status (void)
    4165              : {
    4166      1703905 :   crtl->varasm.pool = create_constant_pool ();
    4167      1703905 :   crtl->varasm.deferred_constants = 0;
    4168      1703905 : }
    4169              : 
    4170              : /* Given a MINUS expression, simplify it if both sides
    4171              :    include the same symbol.  */
    4172              : 
    4173              : rtx
    4174      4838223 : simplify_subtraction (rtx x)
    4175              : {
    4176      4838223 :   rtx r = simplify_rtx (x);
    4177      4838223 :   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      4191804 : force_const_mem (machine_mode in_mode, rtx x)
    4186              : {
    4187      4191804 :   class constant_descriptor_rtx *desc, tmp;
    4188      4191804 :   struct rtx_constant_pool *pool;
    4189      4191804 :   char label[256];
    4190      4191804 :   rtx def, symbol;
    4191      4191804 :   hashval_t hash;
    4192      4191804 :   unsigned int align;
    4193      4191804 :   constant_descriptor_rtx **slot;
    4194      4191804 :   fixed_size_mode mode;
    4195              : 
    4196              :   /* We can't force variable-sized objects to memory.  */
    4197      4191804 :   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      4191804 :   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      4170612 :   crtl->uses_const_pool = 1;
    4206              : 
    4207              :   /* Decide which pool to use.  */
    4208      8341224 :   pool = (targetm.use_blocks_for_constant_p (mode, x)
    4209      4170612 :           ? shared_constant_pool
    4210              :           : crtl->varasm.pool);
    4211              : 
    4212              :   /* Lookup the value in the hashtable.  */
    4213      4170612 :   tmp.constant = x;
    4214      4170612 :   tmp.mode = mode;
    4215      4170612 :   hash = const_rtx_hash (x);
    4216      4170612 :   slot = pool->const_rtx_htab->find_slot_with_hash (&tmp, hash, INSERT);
    4217      4170612 :   desc = *slot;
    4218              : 
    4219              :   /* If the constant was already present, return its memory.  */
    4220      4170612 :   if (desc)
    4221      3816173 :     return copy_rtx (desc->mem);
    4222              : 
    4223              :   /* Otherwise, create a new descriptor.  */
    4224       354439 :   desc = ggc_alloc<constant_descriptor_rtx> ();
    4225       354439 :   *slot = desc;
    4226              : 
    4227              :   /* Align the location counter as required by EXP's data type.  */
    4228       354439 :   machine_mode align_mode = (mode == VOIDmode ? word_mode : mode);
    4229       354439 :   align = targetm.static_rtx_alignment (align_mode);
    4230              : 
    4231       354439 :   pool->offset += (align / BITS_PER_UNIT) - 1;
    4232       354439 :   pool->offset &= ~ ((align / BITS_PER_UNIT) - 1);
    4233              : 
    4234       354439 :   desc->next = NULL;
    4235       354439 :   desc->constant = copy_rtx (tmp.constant);
    4236       354439 :   desc->offset = pool->offset;
    4237       354439 :   desc->hash = hash;
    4238       354439 :   desc->mode = mode;
    4239       354439 :   desc->align = align;
    4240       354439 :   desc->labelno = const_labelno;
    4241       354439 :   desc->mark = 0;
    4242              : 
    4243       354439 :   pool->offset += GET_MODE_SIZE (mode);
    4244       354439 :   if (pool->last)
    4245       309643 :     pool->last->next = desc;
    4246              :   else
    4247        44796 :     pool->first = pool->last = desc;
    4248       354439 :   pool->last = desc;
    4249              : 
    4250              :   /* Create a string containing the label name, in LABEL.  */
    4251       354439 :   ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno);
    4252       354439 :   ++const_labelno;
    4253              : 
    4254              :   /* Construct the SYMBOL_REF.  Make sure to mark it as belonging to
    4255              :      the constants pool.  */
    4256       354439 :   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       386942 :     symbol = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (label));
    4264       354439 :   desc->sym = symbol;
    4265       354439 :   SYMBOL_REF_FLAGS (symbol) |= SYMBOL_FLAG_LOCAL;
    4266       354439 :   CONSTANT_POOL_ADDRESS_P (symbol) = 1;
    4267       354439 :   SET_SYMBOL_REF_CONSTANT (symbol, desc);
    4268              : 
    4269              :   /* Construct the MEM.  */
    4270       354439 :   desc->mem = def = gen_const_mem (mode, symbol);
    4271       354439 :   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       354439 :   if (GET_CODE (x) == LABEL_REF)
    4276           29 :     LABEL_PRESERVE_P (XEXP (x, 0)) = 1;
    4277              : 
    4278       354439 :   return copy_rtx (def);
    4279              : }
    4280              : 
    4281              : /* Given a constant pool SYMBOL_REF, return the corresponding constant.  */
    4282              : 
    4283              : rtx
    4284     11844579 : get_pool_constant (const_rtx addr)
    4285              : {
    4286     11844579 :   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      5319567 : get_pool_mode (const_rtx addr)
    4306              : {
    4307      5319567 :   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       648282 : output_constant_pool_2 (fixed_size_mode mode, rtx x, unsigned int align)
    4325              : {
    4326       648282 :   switch (GET_MODE_CLASS (mode))
    4327              :     {
    4328       199255 :     case MODE_FLOAT:
    4329       199255 :     case MODE_DECIMAL_FLOAT:
    4330       199255 :       {
    4331       199255 :         gcc_assert (CONST_DOUBLE_AS_FLOAT_P (x));
    4332       199255 :         assemble_real (*CONST_DOUBLE_REAL_VALUE (x),
    4333              :                        as_a <scalar_float_mode> (mode), align, false);
    4334       199255 :         break;
    4335              :       }
    4336              : 
    4337       361541 :     case MODE_INT:
    4338       361541 :     case MODE_PARTIAL_INT:
    4339       361541 :     case MODE_FRACT:
    4340       361541 :     case MODE_UFRACT:
    4341       361541 :     case MODE_ACCUM:
    4342       361541 :     case MODE_UACCUM:
    4343       361541 :       assemble_integer (x, GET_MODE_SIZE (mode), align, 1);
    4344       361541 :       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        87486 :     case MODE_VECTOR_FLOAT:
    4365        87486 :     case MODE_VECTOR_INT:
    4366        87486 :     case MODE_VECTOR_FRACT:
    4367        87486 :     case MODE_VECTOR_UFRACT:
    4368        87486 :     case MODE_VECTOR_ACCUM:
    4369        87486 :     case MODE_VECTOR_UACCUM:
    4370        87486 :       {
    4371        87486 :         int i, units;
    4372        87486 :         scalar_mode submode = GET_MODE_INNER (mode);
    4373       262458 :         unsigned int subalign = MIN (align, GET_MODE_BITSIZE (submode));
    4374              : 
    4375        87486 :         gcc_assert (GET_CODE (x) == CONST_VECTOR);
    4376        87486 :         units = GET_MODE_NUNITS (mode);
    4377              : 
    4378       489013 :         for (i = 0; i < units; i++)
    4379              :           {
    4380       401527 :             rtx elt = CONST_VECTOR_ELT (x, i);
    4381       489013 :             output_constant_pool_2 (submode, elt, i ? subalign : align);
    4382              :           }
    4383              :       }
    4384              :       break;
    4385              : 
    4386            0 :     default:
    4387            0 :       gcc_unreachable ();
    4388              :     }
    4389       648282 : }
    4390              : 
    4391              : /* Worker function for output_constant_pool.  Emit constant DESC,
    4392              :    giving it ALIGN bits of alignment.  */
    4393              : 
    4394              : static void
    4395       246755 : output_constant_pool_1 (class constant_descriptor_rtx *desc,
    4396              :                         unsigned int align)
    4397              : {
    4398       246755 :   rtx x, tmp;
    4399              : 
    4400       246755 :   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       246755 :   tmp = x;
    4412       246755 :   switch (GET_CODE (tmp))
    4413              :     {
    4414         3763 :     case CONST:
    4415         3763 :       if (GET_CODE (XEXP (tmp, 0)) != PLUS
    4416         3763 :           || 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       246755 :   assemble_align (align);
    4440              : 
    4441              :   /* Output the label.  */
    4442       246755 :   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       246755 :   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       246755 :   if (in_section
    4454       246755 :       && (in_section->common.flags & SECTION_MERGE)
    4455       246755 :       && ((in_section->common.flags & SECTION_ENTSIZE)
    4456       407028 :            > GET_MODE_SIZE (desc->mode)))
    4457              :     {
    4458           97 :       unsigned HOST_WIDE_INT entsize, constsize;
    4459           97 :       entsize = (in_section->common.flags & SECTION_ENTSIZE);
    4460           97 :       constsize = GET_MODE_SIZE (desc->mode);
    4461           97 :       assemble_zeros (entsize - constsize);
    4462              :     }
    4463              : 
    4464              : #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
    4465              :  done:
    4466              : #endif
    4467       246755 :   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      1483246 : recompute_pool_offsets (struct rtx_constant_pool *pool)
    4477              : {
    4478      1483246 :   class constant_descriptor_rtx *desc;
    4479      1483246 :   pool->offset = 0;
    4480              : 
    4481      1483246 :   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      1483246 : }
    4492              : 
    4493              : /* Mark all constants that are referenced by SYMBOL_REFs in X.
    4494              :    Emit referenced deferred strings.  */
    4495              : 
    4496              : static void
    4497     38336881 : mark_constants_in_pattern (rtx insn)
    4498              : {
    4499     38336881 :   subrtx_iterator::array_type array;
    4500    256609509 :   FOR_EACH_SUBRTX (iter, array, PATTERN (insn), ALL)
    4501              :     {
    4502    218272628 :       const_rtx x = *iter;
    4503    218272628 :       if (GET_CODE (x) == SYMBOL_REF)
    4504              :         {
    4505      7681588 :           if (CONSTANT_POOL_ADDRESS_P (x))
    4506              :             {
    4507       770693 :               class constant_descriptor_rtx *desc = SYMBOL_REF_CONSTANT (x);
    4508       770693 :               if (desc->mark == 0)
    4509              :                 {
    4510       254436 :                   desc->mark = 1;
    4511       254436 :                   iter.substitute (desc->constant);
    4512              :                 }
    4513              :             }
    4514      6910895 :           else if (TREE_CONSTANT_POOL_ADDRESS_P (x))
    4515              :             {
    4516       730247 :               tree decl = SYMBOL_REF_DECL (x);
    4517       730247 :               if (!TREE_ASM_WRITTEN (DECL_INITIAL (decl)))
    4518              :                 {
    4519         7461 :                   n_deferred_constants--;
    4520         7461 :                   output_constant_def_contents (const_cast<rtx> (x));
    4521              :                 }
    4522              :             }
    4523              :         }
    4524              :     }
    4525     38336881 : }
    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     84497000 : mark_constants (rtx_insn *insn)
    4534              : {
    4535     84497000 :   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     38336881 :   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     38336881 :     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      1483246 : mark_constant_pool (void)
    4561              : {
    4562      1483246 :   rtx_insn *insn;
    4563              : 
    4564      1483246 :   if (!crtl->uses_const_pool && n_deferred_constants == 0)
    4565              :     return;
    4566              : 
    4567     84674493 :   for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
    4568     84497000 :     mark_constants (insn);
    4569              : }
    4570              : 
    4571              : /* Write all the constants in POOL.  */
    4572              : 
    4573              : static void
    4574      1715876 : output_constant_pool_contents (struct rtx_constant_pool *pool)
    4575              : {
    4576      1715876 :   class constant_descriptor_rtx *desc;
    4577              : 
    4578      2070281 :   for (desc = pool->first; desc ; desc = desc->next)
    4579       354405 :     if (desc->mark < 0)
    4580              :       {
    4581              : #ifdef ASM_OUTPUT_DEF
    4582         7681 :         gcc_checking_assert (TARGET_SUPPORTS_ALIASES);
    4583              : 
    4584         7681 :         const char *name = XSTR (desc->sym, 0);
    4585         7681 :         char label[256];
    4586         7681 :         char buffer[256 + 32];
    4587         7681 :         const char *p;
    4588              : 
    4589         7681 :         ASM_GENERATE_INTERNAL_LABEL (label, "LC", ~desc->mark);
    4590         7681 :         p = label;
    4591         7681 :         if (desc->offset)
    4592              :           {
    4593         2745 :             sprintf (buffer, "%s+" HOST_WIDE_INT_PRINT_DEC, p, desc->offset);
    4594         2745 :             p = buffer;
    4595              :           }
    4596         7681 :         ASM_OUTPUT_DEF (asm_out_file, name, p);
    4597              : #else
    4598              :         gcc_unreachable ();
    4599              : #endif
    4600              :       }
    4601       346724 :     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       246755 :         if (SYMBOL_REF_HAS_BLOCK_INFO_P (desc->sym)
    4608       246755 :             && SYMBOL_REF_BLOCK (desc->sym))
    4609            0 :           place_block_symbol (desc->sym);
    4610              :         else
    4611              :           {
    4612       246755 :             switch_to_section (targetm.asm_out.select_rtx_section
    4613       246755 :                                (desc->mode, desc->constant, desc->align));
    4614       246755 :             output_constant_pool_1 (desc, desc->align);
    4615              :           }
    4616              :       }
    4617      1715876 : }
    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      3727139 : constant_descriptor_rtx_data_cmp (const void *p1, const void *p2)
    4632              : {
    4633      3727139 :   constant_descriptor_rtx_data *const data1
    4634              :     = *(constant_descriptor_rtx_data * const *) p1;
    4635      3727139 :   constant_descriptor_rtx_data *const data2
    4636              :     = *(constant_descriptor_rtx_data * const *) p2;
    4637      3727139 :   if (data1->size > data2->size)
    4638              :     return -1;
    4639      3446619 :   if (data1->size < data2->size)
    4640              :     return 1;
    4641      3236212 :   if (data1->hash < data2->hash)
    4642              :     return -1;
    4643      1676737 :   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      2067798 : const_rtx_data_hasher::hash (constant_descriptor_rtx_data *data)
    4658              : {
    4659      2067798 :   return data->hash;
    4660              : }
    4661              : 
    4662              : bool
    4663      2247372 : const_rtx_data_hasher::equal (constant_descriptor_rtx_data *x,
    4664              :                               constant_descriptor_rtx_data *y)
    4665              : {
    4666      2247372 :   if (x->hash != y->hash || x->size != y->size)
    4667              :     return false;
    4668       143403 :   unsigned int align1 = x->desc->align;
    4669       143403 :   unsigned int align2 = y->desc->align;
    4670       143403 :   unsigned int offset1 = (x->offset * BITS_PER_UNIT) & (align1 - 1);
    4671       143403 :   unsigned int offset2 = (y->offset * BITS_PER_UNIT) & (align2 - 1);
    4672       143403 :   if (offset1)
    4673        73299 :     align1 = least_bit_hwi (offset1);
    4674       143403 :   if (offset2)
    4675       100259 :     align2 = least_bit_hwi (offset2);
    4676       143403 :   if (align2 > align1)
    4677              :     return false;
    4678       121555 :   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       151071 : optimize_constant_pool (struct rtx_constant_pool *pool)
    4689              : {
    4690       151071 :   auto_vec<target_unit, 128> buffer;
    4691       151071 :   auto_vec<constant_descriptor_rtx_data *, 128> vec;
    4692       151071 :   object_allocator<constant_descriptor_rtx_data>
    4693       151071 :     data_pool ("constant_descriptor_rtx_data_pool");
    4694       151071 :   int idx = 0;
    4695       151071 :   size_t size = 0;
    4696       463071 :   for (constant_descriptor_rtx *desc = pool->first; desc; desc = desc->next)
    4697       312000 :     if (desc->mark > 0
    4698       312000 :         && ! (SYMBOL_REF_HAS_BLOCK_INFO_P (desc->sym)
    4699            0 :               && SYMBOL_REF_BLOCK (desc->sym)))
    4700              :       {
    4701       215644 :         buffer.truncate (0);
    4702       431288 :         buffer.reserve (GET_MODE_SIZE (desc->mode));
    4703       215644 :         if (native_encode_rtx (desc->mode, desc->constant, buffer, 0,
    4704       431288 :                                GET_MODE_SIZE (desc->mode)))
    4705              :           {
    4706       184694 :             constant_descriptor_rtx_data *data = data_pool.allocate ();
    4707       184694 :             data->desc = desc;
    4708       184694 :             data->bytes = NULL;
    4709       184694 :             data->size = GET_MODE_SIZE (desc->mode);
    4710       184694 :             data->offset = 0;
    4711       184694 :             data->hash = idx++;
    4712       184694 :             size += data->size;
    4713       184694 :             vec.safe_push (data);
    4714              :           }
    4715              :       }
    4716       151071 :   if (idx)
    4717              :     {
    4718        28043 :       vec.qsort (constant_descriptor_rtx_data_cmp);
    4719        28043 :       unsigned min_size = vec.last ()->size;
    4720        28043 :       target_unit *bytes = XNEWVEC (target_unit, size);
    4721        28043 :       unsigned int i;
    4722        28043 :       constant_descriptor_rtx_data *data;
    4723        28043 :       hash_table<const_rtx_data_hasher> * htab
    4724        28043 :         = new hash_table<const_rtx_data_hasher> (31);
    4725        28043 :       size = 0;
    4726       212737 :       FOR_EACH_VEC_ELT (vec, i, data)
    4727              :         {
    4728       184694 :           buffer.truncate (0);
    4729       184694 :           native_encode_rtx (data->desc->mode, data->desc->constant,
    4730       184694 :                              buffer, 0, data->size);
    4731       184694 :           memcpy (bytes + size, buffer.address (), data->size);
    4732       184694 :           data->bytes = bytes + size;
    4733       369388 :           data->hash = iterative_hash (data->bytes,
    4734       184694 :                                        data->size * sizeof (target_unit), 0);
    4735       184694 :           size += data->size;
    4736       184694 :           constant_descriptor_rtx_data **slot
    4737       184694 :             = htab->find_slot_with_hash (data, data->hash, INSERT);
    4738       184694 :           if (*slot)
    4739              :             {
    4740         7681 :               data->desc->mark = ~(*slot)->desc->labelno;
    4741         7681 :               data->desc->offset = (*slot)->offset;
    4742              :             }
    4743              :           else
    4744              :             {
    4745       177013 :               unsigned int sz = 1 << floor_log2 (data->size);
    4746              : 
    4747       177013 :               *slot = data;
    4748       256638 :               for (sz >>= 1; sz >= min_size; sz >>= 1)
    4749       350186 :                 for (unsigned off = 0; off + sz <= data->size; off += sz)
    4750              :                   {
    4751       270561 :                     constant_descriptor_rtx_data tmp;
    4752       270561 :                     tmp.desc = data->desc;
    4753       270561 :                     tmp.bytes = data->bytes + off;
    4754       270561 :                     tmp.size = sz;
    4755       270561 :                     tmp.offset = off;
    4756       270561 :                     tmp.hash = iterative_hash (tmp.bytes,
    4757              :                                                sz * sizeof (target_unit), 0);
    4758       270561 :                     slot = htab->find_slot_with_hash (&tmp, tmp.hash, INSERT);
    4759       270561 :                     if (*slot == NULL)
    4760              :                       {
    4761       156687 :                         *slot = data_pool.allocate ();
    4762       156687 :                         **slot = tmp;
    4763              :                       }
    4764              :                   }
    4765              :             }
    4766              :         }
    4767        28043 :       delete htab;
    4768        28043 :       XDELETE (bytes);
    4769              :     }
    4770       151071 :   data_pool.release ();
    4771       151071 : }
    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      1483246 : output_constant_pool (const char *fnname ATTRIBUTE_UNUSED,
    4778              :                       tree fndecl ATTRIBUTE_UNUSED)
    4779              : {
    4780      1483246 :   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      1483246 :   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      1483246 :   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      1483246 :   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      1483246 : }
    4802              : 
    4803              : /* Write the contents of the shared constant pool.  */
    4804              : 
    4805              : void
    4806       232630 : output_shared_constant_pool (void)
    4807              : {
    4808       232630 :   if (optimize
    4809              :       && TARGET_SUPPORTS_ALIASES)
    4810       151071 :     optimize_constant_pool (shared_constant_pool);
    4811              : 
    4812       232630 :   output_constant_pool_contents (shared_constant_pool);
    4813       232630 : }
    4814              : 
    4815              : /* Determine what kind of relocations EXP may need.  */
    4816              : 
    4817              : int
    4818     35417918 : compute_reloc_for_constant (tree exp)
    4819              : {
    4820     37899555 :   int reloc = 0, reloc2;
    4821     37899555 :   tree tem;
    4822              : 
    4823     37899555 :   switch (TREE_CODE (exp))
    4824              :     {
    4825     10085376 :     case ADDR_EXPR:
    4826     10085376 :     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     10143213 :       for (tem = TREE_OPERAND (exp, 0); handled_component_p (tem);
    4831        57837 :            tem = TREE_OPERAND (tem, 0))
    4832              :         ;
    4833              : 
    4834     10085376 :       if (TREE_CODE (tem) == MEM_REF
    4835     10085376 :           && TREE_CODE (TREE_OPERAND (tem, 0)) == ADDR_EXPR)
    4836              :         {
    4837        57152 :           reloc = compute_reloc_for_constant (TREE_OPERAND (tem, 0));
    4838        57152 :           break;
    4839              :         }
    4840              : 
    4841     10028224 :       if (!targetm.binds_local_p (tem))
    4842              :         reloc |= 2;
    4843              :       else
    4844      7699699 :         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      2424485 :     CASE_CONVERT:
    4864      2424485 :     case VIEW_CONVERT_EXPR:
    4865      2424485 :       reloc = compute_reloc_for_constant (TREE_OPERAND (exp, 0));
    4866      2424485 :       break;
    4867              : 
    4868              :     case CONSTRUCTOR:
    4869              :       {
    4870              :         unsigned HOST_WIDE_INT idx;
    4871     37546313 :         FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (exp), idx, tem)
    4872     29608671 :           if (tem != 0)
    4873     29608671 :             reloc |= compute_reloc_for_constant (tem);
    4874              :       }
    4875              :       break;
    4876              : 
    4877              :     default:
    4878              :       break;
    4879              :     }
    4880     35417918 :   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     22493406 : output_addressed_constants (tree exp, int defer)
    4889              : {
    4890     22985089 :   tree tem;
    4891              : 
    4892     22985089 :   switch (TREE_CODE (exp))
    4893              :     {
    4894      4557009 :     case ADDR_EXPR:
    4895      4557009 :     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      4615061 :       for (tem = TREE_OPERAND (exp, 0); handled_component_p (tem);
    4900        58052 :            tem = TREE_OPERAND (tem, 0))
    4901              :         ;
    4902              : 
    4903              :       /* If we have an initialized CONST_DECL, retrieve the initializer.  */
    4904      4557009 :       if (TREE_CODE (tem) == CONST_DECL && DECL_INITIAL (tem))
    4905            0 :         tem = DECL_INITIAL (tem);
    4906              : 
    4907      4557009 :       if (CONSTANT_CLASS_P (tem) || TREE_CODE (tem) == CONSTRUCTOR)
    4908       977929 :         output_constant_def (tem, defer);
    4909              : 
    4910      4557009 :       if (TREE_CODE (tem) == MEM_REF)
    4911        52630 :         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       439053 :       gcc_fallthrough ();
    4919              : 
    4920       439053 :     CASE_CONVERT:
    4921       439053 :     case VIEW_CONVERT_EXPR:
    4922       439053 :       output_addressed_constants (TREE_OPERAND (exp, 0), defer);
    4923       439053 :       break;
    4924              : 
    4925              :     case CONSTRUCTOR:
    4926              :       {
    4927              :         unsigned HOST_WIDE_INT idx;
    4928     19375532 :         FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (exp), idx, tem)
    4929     15291734 :           if (tem != 0)
    4930     15291734 :             output_addressed_constants (tem, defer);
    4931              :       }
    4932              :       break;
    4933              : 
    4934              :     default:
    4935              :       break;
    4936              :     }
    4937     22493406 : }
    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     13237410 : constructor_static_from_elts_p (const_tree ctor)
    4946              : {
    4947     13237410 :   return (TREE_CONSTANT (ctor)
    4948     13237410 :           && (TREE_CODE (TREE_TYPE (ctor)) == UNION_TYPE
    4949     12613538 :               || TREE_CODE (TREE_TYPE (ctor)) == RECORD_TYPE
    4950      1479516 :               || 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      1044797 : narrowing_initializer_constant_valid_p (tree value, tree endtype, tree *cache)
    4966              : {
    4967      1044797 :   tree op0, op1;
    4968              : 
    4969      1044797 :   if (!INTEGRAL_TYPE_P (endtype))
    4970              :     return NULL_TREE;
    4971              : 
    4972       980758 :   op0 = TREE_OPERAND (value, 0);
    4973       980758 :   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      1936038 :   while (CONVERT_EXPR_P (op0)
    4981      2265372 :          || TREE_CODE (op0) == NON_LVALUE_EXPR)
    4982              :     {
    4983       373441 :       tree inner = TREE_OPERAND (op0, 0);
    4984       746882 :       if (inner == error_mark_node
    4985       373441 :           || ! INTEGRAL_TYPE_P (TREE_TYPE (op0))
    4986       359122 :           || ! SCALAR_INT_MODE_P (TYPE_MODE (TREE_TYPE (op0)))
    4987       359122 :           || ! INTEGRAL_TYPE_P (TREE_TYPE (inner))
    4988       358966 :           || ! SCALAR_INT_MODE_P (TYPE_MODE (TREE_TYPE (inner)))
    4989       732407 :           || (GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (op0)))
    4990       752726 :               > GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (inner)))))
    4991              :         break;
    4992              :       op0 = inner;
    4993              :     }
    4994              : 
    4995       970800 :   while (CONVERT_EXPR_P (op1)
    4996      2149174 :          || TREE_CODE (op1) == NON_LVALUE_EXPR)
    4997              :     {
    4998       244928 :       tree inner = TREE_OPERAND (op1, 0);
    4999       489856 :       if (inner == error_mark_node
    5000       244928 :           || ! INTEGRAL_TYPE_P (TREE_TYPE (op1))
    5001       244819 :           || ! SCALAR_INT_MODE_P (TYPE_MODE (TREE_TYPE (op1)))
    5002       244819 :           || ! INTEGRAL_TYPE_P (TREE_TYPE (inner))
    5003       244733 :           || ! SCALAR_INT_MODE_P (TYPE_MODE (TREE_TYPE (inner)))
    5004       489661 :           || (GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (op1)))
    5005       518383 :               > GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (inner)))))
    5006              :         break;
    5007              :       op1 = inner;
    5008              :     }
    5009              : 
    5010       980758 :   op0 = initializer_constant_valid_p_1 (op0, endtype, cache);
    5011       980758 :   if (!op0)
    5012              :     return NULL_TREE;
    5013              : 
    5014          853 :   op1 = initializer_constant_valid_p_1 (op1, endtype,
    5015              :                                         cache ? cache + 2 : NULL);
    5016              :   /* Both initializers must be known.  */
    5017          853 :   if (op1)
    5018              :     {
    5019          201 :       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          182 :       if (TREE_CODE (op0) == LABEL_DECL
    5026          169 :           && TREE_CODE (op1) == LABEL_DECL)
    5027          169 :         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   1215008488 : initializer_constant_valid_p_1 (tree value, tree endtype, tree *cache)
    5053              : {
    5054   1262914642 :   tree ret;
    5055              : 
    5056   1262914642 :   switch (TREE_CODE (value))
    5057              :     {
    5058     11735338 :     case CONSTRUCTOR:
    5059     11735338 :       if (constructor_static_from_elts_p (value))
    5060              :         {
    5061     11724128 :           unsigned HOST_WIDE_INT idx;
    5062     11724128 :           tree elt;
    5063     11724128 :           bool absolute = true;
    5064              : 
    5065     11724128 :           if (cache && cache[0] == value)
    5066            0 :             return cache[1];
    5067    116699108 :           FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (value), idx, elt)
    5068              :             {
    5069    104975210 :               tree reloc;
    5070    104975210 :               reloc = initializer_constant_valid_p_1 (elt, TREE_TYPE (elt),
    5071              :                                                       NULL);
    5072    104975210 :               if (!reloc
    5073              :                   /* An absolute value is required with reverse SSO.  */
    5074    104975210 :                   || (reloc != null_pointer_node
    5075      8245332 :                       && 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    104974980 :               if (reloc != null_pointer_node)
    5086      8245331 :                 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     11723898 :           if (cache)
    5092              :             {
    5093            0 :               cache[0] = value;
    5094            0 :               cache[1] = absolute ? null_pointer_node : error_mark_node;
    5095              :             }
    5096     11723898 :           return absolute ? null_pointer_node : error_mark_node;
    5097              :         }
    5098              : 
    5099        11210 :       return TREE_STATIC (value) ? null_pointer_node : NULL_TREE;
    5100              : 
    5101   1133058241 :     case INTEGER_CST:
    5102   1133058241 :     case VECTOR_CST:
    5103   1133058241 :     case REAL_CST:
    5104   1133058241 :     case FIXED_CST:
    5105   1133058241 :     case STRING_CST:
    5106   1133058241 :     case COMPLEX_CST:
    5107   1133058241 :     case RAW_DATA_CST:
    5108   1133058241 :       return null_pointer_node;
    5109              : 
    5110     46227026 :     case ADDR_EXPR:
    5111     46227026 :     case FDESC_EXPR:
    5112     46227026 :       {
    5113     46227026 :         tree op0 = staticp (TREE_OPERAND (value, 0));
    5114     46227026 :         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     43990412 :             if (TREE_CODE (op0) == INDIRECT_REF
    5119     43990412 :                 && 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     43990366 :             if (TREE_CODE (op0) == FUNCTION_DECL
    5124      8921047 :                 && DECL_STATIC_CHAIN (op0)
    5125     43990381 :                 && !TREE_NO_TRAMPOLINE (value))
    5126              :               return NULL_TREE;
    5127              :             /* "&{...}" requires a temporary to hold the constructed
    5128              :                object.  */
    5129     43990351 :             if (TREE_CODE (op0) == CONSTRUCTOR)
    5130              :               return NULL_TREE;
    5131              :           }
    5132              :         return op0;
    5133              :       }
    5134              : 
    5135      1043391 :     case NON_LVALUE_EXPR:
    5136      1043391 :       return initializer_constant_valid_p_1 (TREE_OPERAND (value, 0),
    5137      1043391 :                                              endtype, cache);
    5138              : 
    5139      2166249 :     case VIEW_CONVERT_EXPR:
    5140      2166249 :       {
    5141      2166249 :         tree src = TREE_OPERAND (value, 0);
    5142      2166249 :         tree src_type = TREE_TYPE (src);
    5143      2166249 :         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      2166249 :         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     45179148 :     CASE_CONVERT:
    5162     45179148 :       {
    5163     45179148 :         tree src = TREE_OPERAND (value, 0);
    5164     45179148 :         tree src_type = TREE_TYPE (src);
    5165     45179148 :         tree dest_type = TREE_TYPE (value);
    5166              : 
    5167              :         /* Allow conversions between pointer types and offset types.  */
    5168     45179148 :         if ((POINTER_TYPE_P (dest_type) && POINTER_TYPE_P (src_type))
    5169      2464777 :             || (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      2205578 :         if (((INTEGRAL_TYPE_P (dest_type) && INTEGRAL_TYPE_P (src_type))
    5176       330819 :              || (SCALAR_FLOAT_TYPE_P (dest_type)
    5177        64267 :                  && SCALAR_FLOAT_TYPE_P (src_type)))
    5178      4662868 :             && (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       672168 :         if (INTEGRAL_TYPE_P (dest_type)
    5186       475296 :             && INTEGRAL_TYPE_P (src_type)
    5187      1075777 :             && (TYPE_UNSIGNED (src_type)
    5188       114388 :                 || TYPE_PRECISION (dest_type) <= TYPE_PRECISION (src_type)
    5189        58088 :                 || TYPE_PRECISION (dest_type) <= BITS_PER_WORD
    5190          757 :                 || TYPE_PRECISION (dest_type) <= POINTER_SIZE))
    5191              :           {
    5192       403213 :             tree inner = initializer_constant_valid_p_1 (src, endtype, cache);
    5193       403213 :             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        72083 :         if (INTEGRAL_TYPE_P (dest_type) && POINTER_TYPE_P (src_type)
    5200       340627 :             && (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       197469 :         if ((POINTER_TYPE_P (dest_type)
    5206       120505 :              || TREE_CODE (dest_type) == OFFSET_TYPE)
    5207        76982 :             && 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       196916 :         if (TREE_CODE (dest_type) == RECORD_TYPE
    5221       196916 :             || TREE_CODE (dest_type) == UNION_TYPE)
    5222              :           return initializer_constant_valid_p_1 (src, endtype, cache);
    5223              :       }
    5224              :       break;
    5225              : 
    5226      6972765 :     case POINTER_PLUS_EXPR:
    5227      6972765 :     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      6972765 :       if (TREE_CODE (endtype) == REAL_TYPE)
    5231              :         return NULL_TREE;
    5232      6005265 :       if (cache && cache[0] == value)
    5233       129383 :         return cache[1];
    5234      5875882 :       if (! INTEGRAL_TYPE_P (endtype)
    5235       676921 :           || ! INTEGRAL_TYPE_P (TREE_TYPE (value))
    5236      6552217 :           || TYPE_PRECISION (endtype) >= TYPE_PRECISION (TREE_TYPE (value)))
    5237              :         {
    5238      5857770 :           tree ncache[4] = { NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE };
    5239      5857770 :           tree valid0
    5240      5857770 :             = initializer_constant_valid_p_1 (TREE_OPERAND (value, 0),
    5241              :                                               endtype, ncache);
    5242      5857770 :           tree valid1
    5243      5857770 :             = 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      5857770 :           if (valid0 == null_pointer_node)
    5247              :             ret = valid1;
    5248      5856689 :           else if (valid1 == null_pointer_node)
    5249              :             ret = valid0;
    5250              :           /* Support narrowing pointer differences.  */
    5251              :           else
    5252       378827 :             ret = narrowing_initializer_constant_valid_p (value, endtype,
    5253              :                                                           ncache);
    5254              :         }
    5255              :       else
    5256              :       /* Support narrowing pointer differences.  */
    5257        18112 :         ret = narrowing_initializer_constant_valid_p (value, endtype, NULL);
    5258      5875882 :       if (cache)
    5259              :         {
    5260       129791 :           cache[0] = value;
    5261       129791 :           cache[1] = ret;
    5262              :         }
    5263              :       return ret;
    5264              : 
    5265      1481268 :     case POINTER_DIFF_EXPR:
    5266      1481268 :     case MINUS_EXPR:
    5267      1481268 :       if (TREE_CODE (endtype) == REAL_TYPE)
    5268              :         return NULL_TREE;
    5269       993433 :       if (cache && cache[0] == value)
    5270       155895 :         return cache[1];
    5271       837538 :       if (! INTEGRAL_TYPE_P (endtype)
    5272       837459 :           || ! INTEGRAL_TYPE_P (TREE_TYPE (value))
    5273      1674994 :           || TYPE_PRECISION (endtype) >= TYPE_PRECISION (TREE_TYPE (value)))
    5274              :         {
    5275       808961 :           tree ncache[4] = { NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE };
    5276       808961 :           tree valid0
    5277       808961 :             = initializer_constant_valid_p_1 (TREE_OPERAND (value, 0),
    5278              :                                               endtype, ncache);
    5279       808961 :           tree valid1
    5280       808961 :             = initializer_constant_valid_p_1 (TREE_OPERAND (value, 1),
    5281              :                                               endtype, ncache + 2);
    5282              :           /* Win if second argument is absolute.  */
    5283       808961 :           if (valid1 == null_pointer_node)
    5284              :             ret = valid0;
    5285              :           /* Win if both arguments have the same relocation.
    5286              :              Then the value is absolute.  */
    5287       619281 :           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          724 :           else if (valid0 && TREE_CODE (valid0) == STRING_CST
    5293            0 :                    && valid1 && TREE_CODE (valid1) == STRING_CST
    5294       619281 :                    && operand_equal_p (valid0, valid1, 1))
    5295            0 :             ret = null_pointer_node;
    5296              :           /* Support narrowing differences.  */
    5297              :           else
    5298       619281 :             ret = narrowing_initializer_constant_valid_p (value, endtype,
    5299              :                                                           ncache);
    5300              :         }
    5301              :       else
    5302              :         /* Support narrowing differences.  */
    5303        28577 :         ret = narrowing_initializer_constant_valid_p (value, endtype, NULL);
    5304       837538 :       if (cache)
    5305              :         {
    5306       157567 :           cache[0] = value;
    5307       157567 :           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   1095314992 : initializer_constant_valid_p (tree value, tree endtype, bool reverse)
    5329              : {
    5330   1095314992 :   tree reloc = initializer_constant_valid_p_1 (value, endtype, NULL);
    5331              : 
    5332              :   /* An absolute value is required with reverse storage order.  */
    5333   1095314992 :   if (reloc
    5334   1078136519 :       && reloc != null_pointer_node
    5335     41423896 :       && reverse
    5336            1 :       && !AGGREGATE_TYPE_P (endtype)
    5337            1 :       && !VECTOR_TYPE_P (endtype))
    5338   1095314992 :     reloc = NULL_TREE;
    5339              : 
    5340   1095314992 :   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          873 : 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          873 :   switch (TREE_CODE (value))
    5353              :     {
    5354              :     case CONSTRUCTOR:
    5355              :       {
    5356              :         unsigned HOST_WIDE_INT idx;
    5357              :         const_tree elt;
    5358              : 
    5359          933 :         FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (value), idx, elt)
    5360          684 :           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      1327498 : check_string_literal (tree string, unsigned HOST_WIDE_INT size)
    5387              : {
    5388      1327498 :   tree type = TREE_TYPE (string);
    5389      1327498 :   tree eltype = TREE_TYPE (type);
    5390      1327498 :   unsigned HOST_WIDE_INT elts = tree_to_uhwi (TYPE_SIZE_UNIT (eltype));
    5391      1327498 :   unsigned HOST_WIDE_INT mem_size = tree_to_uhwi (TYPE_SIZE_UNIT (type));
    5392      1327498 :   int len = TREE_STRING_LENGTH (string);
    5393              : 
    5394      1327498 :   if (elts != 1 && elts != 2 && elts != 4)
    5395              :     return false;
    5396      1327498 :   if (len < 0 || len % elts != 0)
    5397              :     return false;
    5398      1327498 :   if (size < (unsigned)len)
    5399              :     return false;
    5400      1327498 :   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     17839258 : output_constant (tree exp, unsigned HOST_WIDE_INT size, unsigned int align,
    5443              :                  bool reverse, bool merge_strings)
    5444              : {
    5445     17839258 :   enum tree_code code;
    5446     17839258 :   unsigned HOST_WIDE_INT thissize;
    5447     17839258 :   rtx cst;
    5448              : 
    5449     17839258 :   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     17839018 :   if (TREE_CODE (exp) == NOP_EXPR
    5457          178 :       && POINTER_TYPE_P (TREE_TYPE (exp))
    5458     17839164 :       && targetm.addr_space.valid_pointer_mode
    5459          146 :            (SCALAR_INT_TYPE_MODE (TREE_TYPE (exp)),
    5460          146 :             TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (exp)))))
    5461              :     {
    5462          146 :       tree saved_type = TREE_TYPE (exp);
    5463              : 
    5464              :       /* Peel off any intermediate conversions-to-pointer for valid
    5465              :          pointer modes.  */
    5466          146 :       while (TREE_CODE (exp) == NOP_EXPR
    5467          146 :              && POINTER_TYPE_P (TREE_TYPE (exp))
    5468          438 :              && targetm.addr_space.valid_pointer_mode
    5469          146 :                   (SCALAR_INT_TYPE_MODE (TREE_TYPE (exp)),
    5470          146 :                    TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (exp)))))
    5471          146 :         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          146 :       if (TREE_CODE (exp) == ADDR_EXPR)
    5477           11 :         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     17842287 :   while (CONVERT_EXPR_P (exp)
    5487     17842248 :          || TREE_CODE (exp) == NON_LVALUE_EXPR
    5488     35684567 :          || 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     17839018 :   code = TREE_CODE (TREE_TYPE (exp));
    5506     17839018 :   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     17839018 :   if (TREE_CODE (exp) == CONSTRUCTOR
    5511     17839018 :       && vec_safe_is_empty (CONSTRUCTOR_ELTS (exp)))
    5512              :     {
    5513         3081 :       assemble_zeros (size);
    5514         3081 :       return size;
    5515              :     }
    5516              : 
    5517     17835937 :   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     17835937 :   switch (code)
    5532              :     {
    5533        22522 :     case ENUMERAL_TYPE:
    5534        22522 :       if (BITINT_TYPE_P (TREE_TYPE (exp)))
    5535           14 :         goto do_bitint;
    5536              :       /* FALLTHRU */
    5537     12104233 :     case BOOLEAN_TYPE:
    5538     12104233 :     case INTEGER_TYPE:
    5539     12104233 :     case POINTER_TYPE:
    5540     12104233 :     case REFERENCE_TYPE:
    5541     12104233 :     case OFFSET_TYPE:
    5542     12104233 :     case FIXED_POINT_TYPE:
    5543     12104233 :     case NULLPTR_TYPE:
    5544     12104233 :       cst = expand_expr (exp, NULL_RTX, VOIDmode, EXPAND_INITIALIZER);
    5545     12104233 :       if (reverse)
    5546          558 :         cst = flip_storage_order (TYPE_MODE (TREE_TYPE (exp)), cst);
    5547     12104233 :       if (!assemble_integer (cst, MIN (size, thissize), align, 0))
    5548            0 :         error ("initializer for integer/fixed-point value is too complicated");
    5549              :       break;
    5550              : 
    5551       600639 :     case REAL_TYPE:
    5552       600639 :       gcc_assert (size == thissize);
    5553       600639 :       if (TREE_CODE (exp) != REAL_CST)
    5554            1 :         error ("initializer for floating value is not a floating constant");
    5555              :       else
    5556       600638 :         assemble_real (TREE_REAL_CST (exp),
    5557       600638 :                        SCALAR_FLOAT_TYPE_MODE (TREE_TYPE (exp)),
    5558              :                        align, reverse);
    5559              :       break;
    5560              : 
    5561        12111 :     case COMPLEX_TYPE:
    5562        12111 :       output_constant (TREE_REALPART (exp), thissize / 2, align,
    5563              :                        reverse, false);
    5564        12111 :       output_constant (TREE_IMAGPART (exp), thissize / 2,
    5565              :                        min_align (align, BITS_PER_UNIT * (thissize / 2)),
    5566              :                        reverse, false);
    5567        12111 :       break;
    5568              : 
    5569         8704 :     case BITINT_TYPE:
    5570         8704 :     do_bitint:
    5571         8704 :       if (TREE_CODE (exp) != INTEGER_CST)
    5572            0 :         error ("initializer for %<_BitInt(%d)%> value is not an integer "
    5573            0 :                "constant", TYPE_PRECISION (TREE_TYPE (exp)));
    5574              :       else
    5575              :         {
    5576         8704 :           struct bitint_info info;
    5577         8704 :           tree type = TREE_TYPE (exp);
    5578         8704 :           bool ok = targetm.c.bitint_type_info (TYPE_PRECISION (type), &info);
    5579         8704 :           gcc_assert (ok);
    5580         8704 :           scalar_int_mode limb_mode
    5581         8704 :             = as_a <scalar_int_mode> (info.abi_limb_mode);
    5582         8704 :           if (TYPE_PRECISION (type) <= GET_MODE_PRECISION (limb_mode))
    5583              :             {
    5584          451 :               cst = expand_expr (exp, NULL_RTX, VOIDmode, EXPAND_INITIALIZER);
    5585          451 :               if (reverse)
    5586            0 :                 cst = flip_storage_order (TYPE_MODE (TREE_TYPE (exp)), cst);
    5587          451 :               if (!assemble_integer (cst, MIN (size, thissize), align, 0))
    5588            0 :                 error ("initializer for integer/fixed-point value is too "
    5589              :                        "complicated");
    5590          451 :               break;
    5591              :             }
    5592         8253 :           int prec = GET_MODE_PRECISION (limb_mode);
    5593         8253 :           int cnt = CEIL (TYPE_PRECISION (type), prec);
    5594         8253 :           tree limb_type = build_nonstandard_integer_type (prec, 1);
    5595         8253 :           int elt_size = GET_MODE_SIZE (limb_mode);
    5596         8253 :           unsigned int nalign = MIN (align, GET_MODE_ALIGNMENT (limb_mode));
    5597         8253 :           thissize = 0;
    5598         8253 :           if (prec == HOST_BITS_PER_WIDE_INT)
    5599       101071 :             for (int i = 0; i < cnt; i++)
    5600              :               {
    5601        92818 :                 int idx = (info.big_endian ^ reverse) ? cnt - 1 - i : i;
    5602        92818 :                 tree c;
    5603        92818 :                 if (idx >= TREE_INT_CST_EXT_NUNITS (exp))
    5604        33799 :                   c = build_int_cst (limb_type,
    5605        65125 :                                      tree_int_cst_sgn (exp) < 0 ? -1 : 0);
    5606              :                 else
    5607        59019 :                   c = build_int_cst (limb_type,
    5608        59019 :                                      TREE_INT_CST_ELT (exp, idx));
    5609        92818 :                 output_constant (c, elt_size, nalign, reverse, false);
    5610        92818 :                 thissize += elt_size;
    5611              :               }
    5612              :           else
    5613            0 :             for (int i = 0; i < cnt; i++)
    5614              :               {
    5615            0 :                 int idx = (info.big_endian ^ reverse) ? cnt - 1 - i : i;
    5616            0 :                 wide_int w = wi::rshift (wi::to_wide (exp), idx * prec,
    5617            0 :                                          TYPE_SIGN (TREE_TYPE (exp)));
    5618            0 :                 tree c = wide_int_to_tree (limb_type,
    5619            0 :                                            wide_int::from (w, prec, UNSIGNED));
    5620            0 :                 output_constant (c, elt_size, nalign, reverse, false);
    5621            0 :                 thissize += elt_size;
    5622            0 :               }
    5623              :         }
    5624              :       break;
    5625              : 
    5626      1904785 :     case ARRAY_TYPE:
    5627      1904785 :     case VECTOR_TYPE:
    5628      1904785 :       switch (TREE_CODE (exp))
    5629              :         {
    5630       565136 :         case CONSTRUCTOR:
    5631       565136 :           return output_constructor (exp, size, align, reverse, NULL);
    5632      1327498 :         case STRING_CST:
    5633      1327498 :           thissize = (unsigned HOST_WIDE_INT)TREE_STRING_LENGTH (exp);
    5634      1327498 :           if (merge_strings
    5635      1327498 :               && (thissize == 0
    5636       406802 :                   || TREE_STRING_POINTER (exp) [thissize - 1] != '\0'))
    5637        33829 :             thissize++;
    5638      1327498 :           gcc_checking_assert (check_string_literal (exp, size));
    5639      1327498 :           assemble_string (TREE_STRING_POINTER (exp), thissize);
    5640      1327498 :           break;
    5641        12151 :         case VECTOR_CST:
    5642        12151 :           {
    5643        12151 :             scalar_mode inner = SCALAR_TYPE_MODE (TREE_TYPE (TREE_TYPE (exp)));
    5644        12151 :             unsigned int nalign = MIN (align, GET_MODE_ALIGNMENT (inner));
    5645        12151 :             int elt_size = GET_MODE_SIZE (inner);
    5646        12151 :             output_constant (VECTOR_CST_ELT (exp, 0), elt_size, align,
    5647              :                              reverse, false);
    5648        12151 :             thissize = elt_size;
    5649              :             /* Static constants must have a fixed size.  */
    5650        12151 :             unsigned int nunits = VECTOR_CST_NELTS (exp).to_constant ();
    5651        68462 :             for (unsigned int i = 1; i < nunits; i++)
    5652              :               {
    5653        56311 :                 output_constant (VECTOR_CST_ELT (exp, i), elt_size, nalign,
    5654              :                                  reverse, false);
    5655        56311 :                 thissize += elt_size;
    5656              :               }
    5657              :             break;
    5658              :           }
    5659            0 :         default:
    5660            0 :           gcc_unreachable ();
    5661              :         }
    5662              :       break;
    5663              : 
    5664      3205465 :     case RECORD_TYPE:
    5665      3205465 :     case UNION_TYPE:
    5666      3205465 :       gcc_assert (TREE_CODE (exp) == CONSTRUCTOR);
    5667      3205465 :       return output_constructor (exp, size, align, reverse, NULL);
    5668              : 
    5669              :     case ERROR_MARK:
    5670              :       return 0;
    5671              : 
    5672            0 :     default:
    5673            0 :       gcc_unreachable ();
    5674              :     }
    5675              : 
    5676     14065336 :   if (size > thissize)
    5677       719903 :     assemble_zeros (size - thissize);
    5678              : 
    5679              :   return size;
    5680              : }
    5681              : 
    5682              : /* Subroutine of output_constructor, used for computing the size of
    5683              :    arrays of unspecified length.  VAL must be a CONSTRUCTOR of an array
    5684              :    type with an unspecified upper bound.  */
    5685              : 
    5686              : static unsigned HOST_WIDE_INT
    5687         5503 : array_size_for_constructor (tree val)
    5688              : {
    5689         5503 :   tree max_index;
    5690         5503 :   unsigned HOST_WIDE_INT cnt;
    5691         5503 :   tree index, value, tmp;
    5692         5503 :   offset_int i;
    5693              : 
    5694              :   /* This code used to attempt to handle string constants that are not
    5695              :      arrays of single-bytes, but nothing else does, so there's no point in
    5696              :      doing it here.  */
    5697         5503 :   if (TREE_CODE (val) == STRING_CST)
    5698         5333 :     return TREE_STRING_LENGTH (val);
    5699              : 
    5700              :   max_index = NULL_TREE;
    5701          486 :   FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (val), cnt, index, value)
    5702              :     {
    5703          316 :       if (TREE_CODE (index) == RANGE_EXPR)
    5704            0 :         index = TREE_OPERAND (index, 1);
    5705          316 :       if (value && TREE_CODE (value) == RAW_DATA_CST)
    5706            8 :         index = size_binop (PLUS_EXPR, index,
    5707              :                             build_int_cst (TREE_TYPE (index),
    5708              :                                            RAW_DATA_LENGTH (value) - 1));
    5709          316 :       if (max_index == NULL_TREE || tree_int_cst_lt (max_index, index))
    5710              :         max_index = index;
    5711              :     }
    5712              : 
    5713          170 :   if (max_index == NULL_TREE)
    5714              :     return 0;
    5715              : 
    5716              :   /* Compute the total number of array elements.  */
    5717          136 :   tmp = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (val)));
    5718          136 :   i = wi::to_offset (max_index) - wi::to_offset (tmp) + 1;
    5719              : 
    5720              :   /* Multiply by the array element unit size to find number of bytes.  */
    5721          136 :   i *= wi::to_offset (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (val))));
    5722              : 
    5723          136 :   gcc_assert (wi::fits_uhwi_p (i));
    5724          136 :   return i.to_uhwi ();
    5725              : }
    5726              : 
    5727              : /* Other datastructures + helpers for output_constructor.  */
    5728              : 
    5729              : /* output_constructor local state to support interaction with helpers.  */
    5730              : 
    5731              : struct oc_local_state {
    5732              : 
    5733              :   /* Received arguments.  */
    5734              :   tree exp;                     /* Constructor expression.  */
    5735              :   tree type;                    /* Type of constructor expression.  */
    5736              :   unsigned HOST_WIDE_INT size;  /* # bytes to output - pad if necessary.  */
    5737              :   unsigned int align;           /* Known initial alignment.  */
    5738              :   tree min_index;               /* Lower bound if specified for an array.  */
    5739              : 
    5740              :   /* Output processing state.  */
    5741              :   HOST_WIDE_INT total_bytes;  /* # bytes output so far / current position.  */
    5742              :   int byte;                   /* Part of a bitfield byte yet to be output.  */
    5743              :   int last_relative_index;    /* Implicit or explicit index of the last
    5744              :                                  array element output within a bitfield.  */
    5745              :   bool byte_buffer_in_use;    /* Whether BYTE is in use.  */
    5746              :   bool reverse;               /* Whether reverse storage order is in use.  */
    5747              : 
    5748              :   /* Current element.  */
    5749              :   tree field;      /* Current field decl in a record.  */
    5750              :   tree val;        /* Current element value.  */
    5751              :   tree index;      /* Current element index.  */
    5752              : 
    5753              : };
    5754              : 
    5755              : /* Helper for output_constructor.  From the current LOCAL state, output a
    5756              :    RANGE_EXPR element.  */
    5757              : 
    5758              : static void
    5759          776 : output_constructor_array_range (oc_local_state *local)
    5760              : {
    5761              :   /* Perform the index calculation in modulo arithmetic but
    5762              :      sign-extend the result because Ada has negative DECL_FIELD_OFFSETs
    5763              :      but we are using an unsigned sizetype.  */
    5764          776 :   unsigned prec = TYPE_PRECISION (sizetype);
    5765          776 :   offset_int idx = wi::sext (wi::to_offset (TREE_OPERAND (local->index, 0))
    5766         1552 :                              - wi::to_offset (local->min_index), prec);
    5767          776 :   tree valtype = TREE_TYPE (local->val);
    5768          776 :   HOST_WIDE_INT fieldpos
    5769          776 :     = (idx * wi::to_offset (TYPE_SIZE_UNIT (valtype))).to_short_addr ();
    5770              : 
    5771              :   /* Advance to offset of this element.  */
    5772          776 :   if (fieldpos > local->total_bytes)
    5773              :     {
    5774            8 :       assemble_zeros (fieldpos - local->total_bytes);
    5775            8 :       local->total_bytes = fieldpos;
    5776              :     }
    5777              :   else
    5778              :     /* Must not go backwards.  */
    5779          768 :     gcc_assert (fieldpos == local->total_bytes);
    5780              : 
    5781          776 :   unsigned HOST_WIDE_INT fieldsize
    5782          776 :     = int_size_in_bytes (TREE_TYPE (local->type));
    5783              : 
    5784          776 :   HOST_WIDE_INT lo_index
    5785          776 :     = tree_to_shwi (TREE_OPERAND (local->index, 0));
    5786          776 :   HOST_WIDE_INT hi_index
    5787          776 :     = tree_to_shwi (TREE_OPERAND (local->index, 1));
    5788          776 :   HOST_WIDE_INT index;
    5789              : 
    5790          776 :   unsigned int align2
    5791          776 :     = min_align (local->align, fieldsize * BITS_PER_UNIT);
    5792              : 
    5793       274762 :   for (index = lo_index; index <= hi_index; index++)
    5794              :     {
    5795              :       /* Output the element's initial value.  */
    5796       273986 :       if (local->val == NULL_TREE)
    5797            0 :         assemble_zeros (fieldsize);
    5798              :       else
    5799       273986 :         fieldsize = output_constant (local->val, fieldsize, align2,
    5800       273986 :                                      local->reverse, false);
    5801              : 
    5802              :       /* Count its size.  */
    5803       273986 :       local->total_bytes += fieldsize;
    5804              :     }
    5805          776 : }
    5806              : 
    5807              : /* Helper for output_constructor.  From the current LOCAL state, output a
    5808              :    field element that is not true bitfield or part of an outer one.  */
    5809              : 
    5810              : static void
    5811     14294088 : output_constructor_regular_field (oc_local_state *local)
    5812              : {
    5813              :   /* Field size and position.  Since this structure is static, we know the
    5814              :      positions are constant.  */
    5815     14294088 :   unsigned HOST_WIDE_INT fieldsize;
    5816     14294088 :   HOST_WIDE_INT fieldpos;
    5817              : 
    5818     14294088 :   unsigned int align2;
    5819              : 
    5820              :   /* Output any buffered-up bit-fields preceding this element.  */
    5821     14294088 :   if (local->byte_buffer_in_use)
    5822              :     {
    5823          504 :       assemble_integer (GEN_INT (local->byte), 1, BITS_PER_UNIT, 1);
    5824          504 :       local->total_bytes++;
    5825          504 :       local->byte_buffer_in_use = false;
    5826              :     }
    5827              : 
    5828     14294088 :   if (local->index != NULL_TREE)
    5829              :     {
    5830              :       /* Perform the index calculation in modulo arithmetic but
    5831              :          sign-extend the result because Ada has negative DECL_FIELD_OFFSETs
    5832              :          but we are using an unsigned sizetype.  */
    5833      3939635 :       unsigned prec = TYPE_PRECISION (sizetype);
    5834      3939635 :       offset_int idx = wi::sext (wi::to_offset (local->index)
    5835      7879270 :                                  - wi::to_offset (local->min_index), prec);
    5836      3939635 :       fieldpos = (idx * wi::to_offset (TYPE_SIZE_UNIT (TREE_TYPE (local->val))))
    5837      3939635 :         .to_short_addr ();
    5838              :     }
    5839     10354453 :   else if (local->field != NULL_TREE)
    5840      9520124 :     fieldpos = int_byte_position (local->field);
    5841              :   else
    5842              :     fieldpos = 0;
    5843              : 
    5844              :   /* Advance to offset of this element.
    5845              :      Note no alignment needed in an array, since that is guaranteed
    5846              :      if each element has the proper size.  */
    5847     14294088 :   if (local->field != NULL_TREE || local->index != NULL_TREE)
    5848              :     {
    5849     13459759 :       if (fieldpos > local->total_bytes)
    5850              :         {
    5851       179158 :           assemble_zeros (fieldpos - local->total_bytes);
    5852       179158 :           local->total_bytes = fieldpos;
    5853              :         }
    5854              :       else
    5855              :         /* Must not go backwards.  */
    5856     13280601 :         gcc_assert (fieldpos == local->total_bytes);
    5857              :     }
    5858              : 
    5859              :   /* Find the alignment of this element.  */
    5860     14294088 :   align2 = min_align (local->align, BITS_PER_UNIT * fieldpos);
    5861              : 
    5862              :   /* Determine size this element should occupy.  */
    5863     14294088 :   if (local->field)
    5864              :     {
    5865      9520124 :       fieldsize = 0;
    5866              : 
    5867              :       /* If this is an array with an unspecified upper bound,
    5868              :          the initializer determines the size.  */
    5869              :       /* ??? This ought to only checked if DECL_SIZE_UNIT is NULL,
    5870              :          but we cannot do this until the deprecated support for
    5871              :          initializing zero-length array members is removed.  */
    5872      9520124 :       if (TREE_CODE (TREE_TYPE (local->field)) == ARRAY_TYPE
    5873      9520124 :           && (!TYPE_DOMAIN (TREE_TYPE (local->field))
    5874       181169 :               || !TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (local->field)))))
    5875              :         {
    5876         5503 :           unsigned HOST_WIDE_INT fldsize
    5877         5503 :             = array_size_for_constructor (local->val);
    5878         5503 :           fieldsize = int_size_in_bytes (TREE_TYPE (local->val));
    5879              :           /* In most cases fieldsize == fldsize as the size of the initializer
    5880              :              determines how many elements the flexible array member has.  For
    5881              :              C++ fldsize can be smaller though, if the last or several last or
    5882              :              all initializers of the flexible array member have side-effects
    5883              :              and the FE splits them into dynamic initialization.  */
    5884         5503 :           gcc_checking_assert (fieldsize >= fldsize);
    5885              :           /* Given a non-empty initialization, this field had better
    5886              :              be last except in unions.  Given a flexible array member, the next
    5887              :              field on the chain is a TYPE_DECL of the enclosing struct.  */
    5888         5503 :           const_tree next = DECL_CHAIN (local->field);
    5889         5503 :           gcc_assert (!fieldsize
    5890              :                       || !next
    5891              :                       || TREE_CODE (next) != FIELD_DECL
    5892              :                       || TREE_CODE (local->type) == UNION_TYPE);
    5893              :         }
    5894              :       else
    5895      9514621 :         fieldsize = tree_to_uhwi (DECL_SIZE_UNIT (local->field));
    5896              :     }
    5897              :   else
    5898      4773964 :     fieldsize = int_size_in_bytes (TREE_TYPE (local->type));
    5899              : 
    5900              :   /* Output the element's initial value.  */
    5901     14294088 :   if (local->val == NULL_TREE)
    5902            0 :     assemble_zeros (fieldsize);
    5903     14294088 :   else if (local->val && TREE_CODE (local->val) == RAW_DATA_CST)
    5904              :     {
    5905          431 :       fieldsize *= RAW_DATA_LENGTH (local->val);
    5906          431 :       assemble_string (RAW_DATA_POINTER (local->val),
    5907          431 :                        RAW_DATA_LENGTH (local->val));
    5908              :     }
    5909              :   else
    5910     14293657 :     fieldsize = output_constant (local->val, fieldsize, align2,
    5911     14293657 :                                  local->reverse, false);
    5912              : 
    5913              :   /* Count its size.  */
    5914     14294088 :   local->total_bytes += fieldsize;
    5915     14294088 : }
    5916              : 
    5917              : /* Helper for output_constructor.  From the LOCAL state, output an element
    5918              :    that is a true bitfield or part of an outer one.  BIT_OFFSET is the offset
    5919              :    from the start of a possibly ongoing outer byte buffer.  */
    5920              : 
    5921              : static void
    5922         9799 : output_constructor_bitfield (oc_local_state *local, unsigned int bit_offset)
    5923              : {
    5924              :   /* Bit size of this element.  */
    5925         9799 :   HOST_WIDE_INT ebitsize
    5926         9799 :     = (local->field
    5927         9799 :        ? tree_to_uhwi (DECL_SIZE (local->field))
    5928         9799 :        : tree_to_uhwi (TYPE_SIZE (TREE_TYPE (local->type))));
    5929              : 
    5930              :   /* Relative index of this element if this is an array component.  */
    5931         9799 :   HOST_WIDE_INT relative_index
    5932              :     = (local->field
    5933         9799 :        ? 0
    5934            0 :        : (local->index
    5935            0 :           ? tree_to_uhwi (local->index) - tree_to_uhwi (local->min_index)
    5936            0 :           : local->last_relative_index + 1));
    5937              : 
    5938              :   /* Bit position of this element from the start of the containing
    5939              :      constructor.  */
    5940         9799 :   HOST_WIDE_INT constructor_relative_ebitpos
    5941              :     = (local->field
    5942         9799 :        ? int_bit_position (local->field)
    5943            0 :        : ebitsize * relative_index);
    5944              : 
    5945              :   /* Bit position of this element from the start of a possibly ongoing
    5946              :      outer byte buffer.  */
    5947         9799 :   HOST_WIDE_INT byte_relative_ebitpos
    5948         9799 :     = bit_offset + constructor_relative_ebitpos;
    5949              : 
    5950              :   /* From the start of a possibly ongoing outer byte buffer, offsets to
    5951              :      the first bit of this element and to the first bit past the end of
    5952              :      this element.  */
    5953         9799 :   HOST_WIDE_INT next_offset = byte_relative_ebitpos;
    5954         9799 :   HOST_WIDE_INT end_offset = byte_relative_ebitpos + ebitsize;
    5955              : 
    5956         9799 :   local->last_relative_index = relative_index;
    5957              : 
    5958         9799 :   if (local->val == NULL_TREE)
    5959            0 :     local->val = integer_zero_node;
    5960              : 
    5961         9799 :   while (TREE_CODE (local->val) == VIEW_CONVERT_EXPR
    5962         9799 :          || TREE_CODE (local->val) == NON_LVALUE_EXPR)
    5963            0 :     local->val = TREE_OPERAND (local->val, 0);
    5964              : 
    5965         9799 :   if (TREE_CODE (local->val) != INTEGER_CST
    5966            0 :       && TREE_CODE (local->val) != CONSTRUCTOR)
    5967              :     {
    5968            0 :       error ("invalid initial value for member %qE", DECL_NAME (local->field));
    5969            0 :       return;
    5970              :     }
    5971              : 
    5972              :   /* If this field does not start in this (or next) byte, skip some bytes.  */
    5973         9799 :   if (next_offset / BITS_PER_UNIT != local->total_bytes)
    5974              :     {
    5975              :       /* Output remnant of any bit field in previous bytes.  */
    5976         1304 :       if (local->byte_buffer_in_use)
    5977              :         {
    5978         1277 :           assemble_integer (GEN_INT (local->byte), 1, BITS_PER_UNIT, 1);
    5979         1277 :           local->total_bytes++;
    5980         1277 :           local->byte_buffer_in_use = false;
    5981              :         }
    5982              : 
    5983              :       /* If still not at proper byte, advance to there.  */
    5984         1304 :       if (next_offset / BITS_PER_UNIT != local->total_bytes)
    5985              :         {
    5986          118 :           gcc_assert (next_offset / BITS_PER_UNIT >= local->total_bytes);
    5987          118 :           assemble_zeros (next_offset / BITS_PER_UNIT - local->total_bytes);
    5988          118 :           local->total_bytes = next_offset / BITS_PER_UNIT;
    5989              :         }
    5990              :     }
    5991              : 
    5992              :   /* Set up the buffer if necessary.  */
    5993         9799 :   if (!local->byte_buffer_in_use)
    5994              :     {
    5995         4178 :       local->byte = 0;
    5996         4178 :       if (ebitsize > 0)
    5997         4178 :         local->byte_buffer_in_use = true;
    5998              :     }
    5999              : 
    6000              :   /* If this is nested constructor, recurse passing the bit offset and the
    6001              :      pending data, then retrieve the new pending data afterwards.  */
    6002         9799 :   if (TREE_CODE (local->val) == CONSTRUCTOR)
    6003              :     {
    6004            0 :       oc_outer_state temp_state;
    6005            0 :       temp_state.bit_offset = next_offset % BITS_PER_UNIT;
    6006            0 :       temp_state.byte = local->byte;
    6007            0 :       local->total_bytes
    6008            0 :         += output_constructor (local->val, 0, 0, local->reverse, &temp_state);
    6009            0 :       local->byte = temp_state.byte;
    6010            0 :       return;
    6011              :     }
    6012              : 
    6013              :   /* Otherwise, we must split the element into pieces that fall within
    6014              :      separate bytes, and combine each byte with previous or following
    6015              :      bit-fields.  */
    6016        40813 :   while (next_offset < end_offset)
    6017              :     {
    6018        31014 :       int this_time;
    6019        31014 :       int shift;
    6020        31014 :       unsigned HOST_WIDE_INT value;
    6021        31014 :       HOST_WIDE_INT next_byte = next_offset / BITS_PER_UNIT;
    6022        31014 :       HOST_WIDE_INT next_bit = next_offset % BITS_PER_UNIT;
    6023              : 
    6024              :       /* Advance from byte to byte within this element when necessary.  */
    6025        51685 :       while (next_byte != local->total_bytes)
    6026              :         {
    6027        20671 :           assemble_integer (GEN_INT (local->byte), 1, BITS_PER_UNIT, 1);
    6028        20671 :           local->total_bytes++;
    6029        20671 :           local->byte = 0;
    6030              :         }
    6031              : 
    6032              :       /* Number of bits we can process at once (all part of the same byte).  */
    6033        31014 :       this_time = MIN (end_offset - next_offset, BITS_PER_UNIT - next_bit);
    6034        31014 :       if (local->reverse ? !BYTES_BIG_ENDIAN : BYTES_BIG_ENDIAN)
    6035              :         {
    6036              :           /* For big-endian data, take the most significant bits (of the
    6037              :              bits that are significant) first and put them into bytes from
    6038              :              the most significant end.  */
    6039          778 :           shift = end_offset - next_offset - this_time;
    6040              : 
    6041              :           /* Don't try to take a bunch of bits that cross
    6042              :              the word boundary in the INTEGER_CST.  We can
    6043              :              only select bits from one element.  */
    6044          778 :           if ((shift / HOST_BITS_PER_WIDE_INT)
    6045          778 :               != ((shift + this_time - 1) / HOST_BITS_PER_WIDE_INT))
    6046              :             {
    6047            0 :               const int end = shift + this_time - 1;
    6048            0 :               shift = end & -HOST_BITS_PER_WIDE_INT;
    6049            0 :               this_time = end - shift + 1;
    6050              :             }
    6051              : 
    6052              :           /* Now get the bits we want to insert.  */
    6053          778 :           value = wi::extract_uhwi (wi::to_widest (local->val),
    6054              :                                     shift, this_time);
    6055              : 
    6056              :           /* Get the result.  This works only when:
    6057              :              1 <= this_time <= HOST_BITS_PER_WIDE_INT.  */
    6058          778 :           local->byte |= value << (BITS_PER_UNIT - this_time - next_bit);
    6059              :         }
    6060              :       else
    6061              :         {
    6062              :           /* On little-endian machines, take the least significant bits of
    6063              :              the value first and pack them starting at the least significant
    6064              :              bits of the bytes.  */
    6065        30236 :           shift = next_offset - byte_relative_ebitpos;
    6066              : 
    6067              :           /* Don't try to take a bunch of bits that cross
    6068              :              the word boundary in the INTEGER_CST.  We can
    6069              :              only select bits from one element.  */
    6070        30236 :           if ((shift / HOST_BITS_PER_WIDE_INT)
    6071        30236 :               != ((shift + this_time - 1) / HOST_BITS_PER_WIDE_INT))
    6072          544 :             this_time
    6073          544 :               = HOST_BITS_PER_WIDE_INT - (shift & (HOST_BITS_PER_WIDE_INT - 1));
    6074              : 
    6075              :           /* Now get the bits we want to insert.  */
    6076        30236 :           value = wi::extract_uhwi (wi::to_widest (local->val),
    6077              :                                     shift, this_time);
    6078              : 
    6079              :           /* Get the result.  This works only when:
    6080              :              1 <= this_time <= HOST_BITS_PER_WIDE_INT.  */
    6081        30236 :           local->byte |= value << next_bit;
    6082              :         }
    6083              : 
    6084        31014 :       next_offset += this_time;
    6085        31014 :       local->byte_buffer_in_use = true;
    6086              :     }
    6087              : }
    6088              : 
    6089              : /* Subroutine of output_constant, used for CONSTRUCTORs (aggregate constants).
    6090              :    Generate at least SIZE bytes, padding if necessary.  OUTER designates the
    6091              :    caller output state of relevance in recursive invocations.  */
    6092              : 
    6093              : static unsigned HOST_WIDE_INT
    6094      3770601 : output_constructor (tree exp, unsigned HOST_WIDE_INT size, unsigned int align,
    6095              :                     bool reverse, oc_outer_state *outer)
    6096              : {
    6097      3770601 :   unsigned HOST_WIDE_INT cnt;
    6098      3770601 :   constructor_elt *ce;
    6099      3770601 :   oc_local_state local;
    6100              : 
    6101              :   /* Setup our local state to communicate with helpers.  */
    6102      3770601 :   local.exp = exp;
    6103      3770601 :   local.type = TREE_TYPE (exp);
    6104      3770601 :   local.size = size;
    6105      3770601 :   local.align = align;
    6106      3770601 :   if (TREE_CODE (local.type) == ARRAY_TYPE && TYPE_DOMAIN (local.type))
    6107       565136 :     local.min_index = TYPE_MIN_VALUE (TYPE_DOMAIN (local.type));
    6108              :   else
    6109      3205465 :     local.min_index = integer_zero_node;
    6110              : 
    6111      3770601 :   local.total_bytes = 0;
    6112      3770601 :   local.byte_buffer_in_use = outer != NULL;
    6113      3770601 :   local.byte = outer ? outer->byte : 0;
    6114      3770601 :   local.last_relative_index = -1;
    6115              :   /* The storage order is specified for every aggregate type.  */
    6116      3770601 :   if (AGGREGATE_TYPE_P (local.type))
    6117      3770601 :     local.reverse = TYPE_REVERSE_STORAGE_ORDER (local.type);
    6118              :   else
    6119            0 :     local.reverse = reverse;
    6120              : 
    6121      3770601 :   gcc_assert (HOST_BITS_PER_WIDE_INT >= BITS_PER_UNIT);
    6122              : 
    6123              :   /* As CE goes through the elements of the constant, FIELD goes through the
    6124              :      structure fields if the constant is a structure.  If the constant is a
    6125              :      union, we override this by getting the field from the TREE_LIST element.
    6126              :      But the constant could also be an array.  Then FIELD is zero.
    6127              : 
    6128              :      There is always a maximum of one element in the chain LINK for unions
    6129              :      (even if the initializer in a source program incorrectly contains
    6130              :      more one).  */
    6131              : 
    6132      3770601 :   if (TREE_CODE (local.type) == RECORD_TYPE)
    6133      3187746 :     local.field = TYPE_FIELDS (local.type);
    6134              :   else
    6135       582855 :     local.field = NULL_TREE;
    6136              : 
    6137              :   for (cnt = 0;
    6138     18075264 :        vec_safe_iterate (CONSTRUCTOR_ELTS (exp), cnt, &ce);
    6139     14304663 :        cnt++, local.field = local.field ? DECL_CHAIN (local.field) : 0)
    6140              :     {
    6141     14304663 :       local.val = ce->value;
    6142     14304663 :       local.index = NULL_TREE;
    6143              : 
    6144              :       /* The element in a union constructor specifies the proper field
    6145              :          or index.  */
    6146     14304663 :       if (RECORD_OR_UNION_TYPE_P (local.type) && ce->index != NULL_TREE)
    6147      9334226 :         local.field = ce->index;
    6148              : 
    6149      4970437 :       else if (TREE_CODE (local.type) == ARRAY_TYPE)
    6150      4774740 :         local.index = ce->index;
    6151              : 
    6152     14304663 :       if (local.field && flag_verbose_asm)
    6153            0 :         fprintf (asm_out_file, "%s %s:\n",
    6154              :                  ASM_COMMENT_START,
    6155            0 :                  DECL_NAME (local.field)
    6156            0 :                  ? IDENTIFIER_POINTER (DECL_NAME (local.field))
    6157              :                  : "<anonymous>");
    6158              : 
    6159              :       /* Eliminate the marker that makes a cast not be an lvalue.  */
    6160     14304663 :       if (local.val != NULL_TREE)
    6161     14304663 :         STRIP_NOPS (local.val);
    6162              : 
    6163              :       /* Output the current element, using the appropriate helper ...  */
    6164              : 
    6165              :       /* For an array slice not part of an outer bitfield.  */
    6166     14304663 :       if (!outer
    6167     14304663 :           && local.index != NULL_TREE
    6168      3940411 :           && TREE_CODE (local.index) == RANGE_EXPR)
    6169          776 :         output_constructor_array_range (&local);
    6170              : 
    6171              :       /* For a field that is neither a true bitfield nor part of an outer one,
    6172              :          known to be at least byte aligned and multiple-of-bytes long.  */
    6173     14303887 :       else if (!outer
    6174     14303887 :                && (local.field == NULL_TREE
    6175      9529923 :                    || !CONSTRUCTOR_BITFIELD_P (local.field)))
    6176     14294088 :         output_constructor_regular_field (&local);
    6177              : 
    6178              :       /* For a true bitfield or part of an outer one.  Only INTEGER_CSTs are
    6179              :          supported for scalar fields, so we may need to convert first.  */
    6180              :       else
    6181              :         {
    6182         9799 :           if (TREE_CODE (local.val) == REAL_CST)
    6183            0 :             local.val
    6184            0 :               = fold_unary (VIEW_CONVERT_EXPR,
    6185              :                             build_nonstandard_integer_type
    6186              :                             (TYPE_PRECISION (TREE_TYPE (local.val)), 0),
    6187              :                             local.val);
    6188         9799 :           output_constructor_bitfield (&local, outer ? outer->bit_offset : 0);
    6189              :         }
    6190              :     }
    6191              : 
    6192              :   /* If we are not at toplevel, save the pending data for our caller.
    6193              :      Otherwise output the pending data and padding zeros as needed. */
    6194      3770601 :   if (outer)
    6195            0 :     outer->byte = local.byte;
    6196              :   else
    6197              :     {
    6198      3770601 :       if (local.byte_buffer_in_use)
    6199              :         {
    6200         2397 :           assemble_integer (GEN_INT (local.byte), 1, BITS_PER_UNIT, 1);
    6201         2397 :           local.total_bytes++;
    6202              :         }
    6203              : 
    6204      3770601 :       if ((unsigned HOST_WIDE_INT)local.total_bytes < local.size)
    6205              :         {
    6206        52652 :           assemble_zeros (local.size - local.total_bytes);
    6207        52652 :           local.total_bytes = local.size;
    6208              :         }
    6209              :     }
    6210              : 
    6211      3770601 :   return local.total_bytes;
    6212              : }
    6213              : 
    6214              : /* Mark DECL as weak.  */
    6215              : 
    6216              : static void
    6217       121647 : mark_weak (tree decl)
    6218              : {
    6219       121647 :   if (DECL_WEAK (decl))
    6220              :     return;
    6221              : 
    6222       121633 :   struct symtab_node *n = symtab_node::get (decl);
    6223       121633 :   if (n && n->refuse_visibility_changes)
    6224            3 :     error ("%qD declared weak after being used", decl);
    6225       121633 :   DECL_WEAK (decl) = 1;
    6226              : 
    6227       121633 :   if (DECL_RTL_SET_P (decl)
    6228            0 :       && MEM_P (DECL_RTL (decl))
    6229            0 :       && XEXP (DECL_RTL (decl), 0)
    6230       121633 :       && GET_CODE (XEXP (DECL_RTL (decl), 0)) == SYMBOL_REF)
    6231            0 :     SYMBOL_REF_WEAK (XEXP (DECL_RTL (decl), 0)) = 1;
    6232              : }
    6233              : 
    6234              : /* Merge weak status between NEWDECL and OLDDECL.  */
    6235              : 
    6236              : void
    6237     20615338 : merge_weak (tree newdecl, tree olddecl)
    6238              : {
    6239     20615338 :   if (DECL_WEAK (newdecl) == DECL_WEAK (olddecl))
    6240              :     {
    6241     20601342 :       if (DECL_WEAK (newdecl) && TARGET_SUPPORTS_WEAK)
    6242              :         {
    6243              :           tree *pwd;
    6244              :           /* We put the NEWDECL on the weak_decls list at some point
    6245              :              and OLDDECL as well.  Keep just OLDDECL on the list.  */
    6246          158 :           for (pwd = &weak_decls; *pwd; pwd = &TREE_CHAIN (*pwd))
    6247            0 :             if (TREE_VALUE (*pwd) == newdecl)
    6248              :               {
    6249            0 :                 *pwd = TREE_CHAIN (*pwd);
    6250            0 :                 break;
    6251              :               }
    6252              :         }
    6253     20601342 :       return;
    6254              :     }
    6255              : 
    6256        13996 :   if (DECL_WEAK (newdecl))
    6257              :     {
    6258          295 :       tree wd;
    6259              : 
    6260              :       /* NEWDECL is weak, but OLDDECL is not.  */
    6261              : 
    6262              :       /* If we already output the OLDDECL, we're in trouble; we can't
    6263              :          go back and make it weak.  This should never happen in
    6264              :          unit-at-a-time compilation.  */
    6265          295 :       gcc_assert (!TREE_ASM_WRITTEN (olddecl));
    6266              : 
    6267              :       /* If we've already generated rtl referencing OLDDECL, we may
    6268              :          have done so in a way that will not function properly with
    6269              :          a weak symbol.  Again in unit-at-a-time this should be
    6270              :          impossible.  */
    6271          295 :       gcc_assert (!TREE_USED (olddecl)
    6272              :                   || !TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (olddecl)));
    6273              : 
    6274              :       /* PR 49899: You cannot convert a static function into a weak, public function.  */
    6275          295 :       if (! TREE_PUBLIC (olddecl) && TREE_PUBLIC (newdecl))
    6276            1 :         error ("weak declaration of %q+D being applied to a already "
    6277              :                "existing, static definition", newdecl);
    6278              : 
    6279          295 :       if (TARGET_SUPPORTS_WEAK)
    6280              :         {
    6281              :           /* We put the NEWDECL on the weak_decls list at some point.
    6282              :              Replace it with the OLDDECL.  */
    6283          295 :           for (wd = weak_decls; wd; wd = TREE_CHAIN (wd))
    6284            0 :             if (TREE_VALUE (wd) == newdecl)
    6285              :               {
    6286            0 :                 TREE_VALUE (wd) = olddecl;
    6287            0 :                 break;
    6288              :               }
    6289              :           /* We may not find the entry on the list.  If NEWDECL is a
    6290              :              weak alias, then we will have already called
    6291              :              globalize_decl to remove the entry; in that case, we do
    6292              :              not need to do anything.  */
    6293              :         }
    6294              : 
    6295              :       /* Make the OLDDECL weak; it's OLDDECL that we'll be keeping.  */
    6296          295 :       mark_weak (olddecl);
    6297              :     }
    6298              :   else
    6299              :     /* OLDDECL was weak, but NEWDECL was not explicitly marked as
    6300              :        weak.  Just update NEWDECL to indicate that it's weak too.  */
    6301        13701 :     mark_weak (newdecl);
    6302              : }
    6303              : 
    6304              : /* Declare DECL to be a weak symbol.  */
    6305              : 
    6306              : void
    6307       107656 : declare_weak (tree decl)
    6308              : {
    6309              :   /* With -fsyntax-only, TREE_ASM_WRITTEN might be set on certain function
    6310              :      decls earlier than normally, but as with -fsyntax-only nothing is really
    6311              :      emitted, there is no harm in marking it weak later.  */
    6312       107656 :   gcc_assert (TREE_CODE (decl) != FUNCTION_DECL
    6313              :               || !TREE_ASM_WRITTEN (decl)
    6314              :               || flag_syntax_only);
    6315       107656 :   if (! TREE_PUBLIC (decl))
    6316              :     {
    6317            5 :       error ("weak declaration of %q+D must be public", decl);
    6318            5 :       return;
    6319              :     }
    6320       107651 :   else if (!TARGET_SUPPORTS_WEAK)
    6321              :     warning (0, "weak declaration of %q+D not supported", decl);
    6322              : 
    6323       107651 :   mark_weak (decl);
    6324       107651 :   if (!lookup_attribute ("weak", DECL_ATTRIBUTES (decl)))
    6325       107637 :     DECL_ATTRIBUTES (decl)
    6326       215274 :       = tree_cons (get_identifier ("weak"), NULL, DECL_ATTRIBUTES (decl));
    6327              : }
    6328              : 
    6329              : static void
    6330         1014 : weak_finish_1 (tree decl)
    6331              : {
    6332              : #if defined (ASM_WEAKEN_DECL) || defined (ASM_WEAKEN_LABEL)
    6333         1014 :   const char *const name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
    6334              : #endif
    6335              : 
    6336         1014 :   if (! TREE_USED (decl))
    6337              :     return;
    6338              : 
    6339              : #ifdef ASM_WEAKEN_DECL
    6340              :   ASM_WEAKEN_DECL (asm_out_file, decl, name, NULL);
    6341              : #else
    6342              : #ifdef ASM_WEAKEN_LABEL
    6343         1014 :   ASM_WEAKEN_LABEL (asm_out_file, name);
    6344              : #else
    6345              : #ifdef ASM_OUTPUT_WEAK_ALIAS
    6346              :   {
    6347              :     static bool warn_once = 0;
    6348              :     if (! warn_once)
    6349              :       {
    6350              :         warning (0, "only weak aliases are supported in this configuration");
    6351              :         warn_once = 1;
    6352              :       }
    6353              :     return;
    6354              :   }
    6355              : #endif
    6356              : #endif
    6357              : #endif
    6358              : }
    6359              : 
    6360              : /* Fiven an assembly name, find the decl it is associated with.  */
    6361              : static tree
    6362            0 : find_decl (tree target)
    6363              : {
    6364            0 :   symtab_node *node = symtab_node::get_for_asmname (target);
    6365            0 :   if (node)
    6366            0 :     return node->decl;
    6367              :   return NULL_TREE;
    6368              : }
    6369              : 
    6370              : /* This TREE_LIST contains weakref targets.  */
    6371              : 
    6372              : static GTY(()) tree weakref_targets;
    6373              : 
    6374              : /* Emit any pending weak declarations.  */
    6375              : 
    6376              : void
    6377       232630 : weak_finish (void)
    6378              : {
    6379       232630 :   tree t;
    6380              : 
    6381       232730 :   for (t = weakref_targets; t; t = TREE_CHAIN (t))
    6382              :     {
    6383          100 :       tree alias_decl = TREE_PURPOSE (t);
    6384          100 :       tree target = ultimate_transparent_alias_target (&TREE_VALUE (t));
    6385              : 
    6386          100 :       if (! TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (alias_decl))
    6387          200 :          || TREE_SYMBOL_REFERENCED (target))
    6388              :         /* Remove alias_decl from the weak list, but leave entries for
    6389              :            the target alone.  */
    6390              :         target = NULL_TREE;
    6391              : #ifndef ASM_OUTPUT_WEAKREF
    6392              :       else if (! TREE_SYMBOL_REFERENCED (target))
    6393              :         {
    6394              :           /* Use ASM_WEAKEN_LABEL only if ASM_WEAKEN_DECL is not
    6395              :              defined, otherwise we and weak_finish_1 would use
    6396              :              different macros.  */
    6397              : # if defined ASM_WEAKEN_LABEL && ! defined ASM_WEAKEN_DECL
    6398              :           ASM_WEAKEN_LABEL (asm_out_file, IDENTIFIER_POINTER (target));
    6399              : # else
    6400              :           tree decl = find_decl (target);
    6401              : 
    6402              :           if (! decl)
    6403              :             {
    6404              :               decl = build_decl (DECL_SOURCE_LOCATION (alias_decl),
    6405              :                                  TREE_CODE (alias_decl), target,
    6406              :                                  TREE_TYPE (alias_decl));
    6407              : 
    6408              :               DECL_EXTERNAL (decl) = 1;
    6409              :               TREE_PUBLIC (decl) = 1;
    6410              :               DECL_ARTIFICIAL (decl) = 1;
    6411              :               TREE_NOTHROW (decl) = TREE_NOTHROW (alias_decl);
    6412              :               TREE_USED (decl) = 1;
    6413              :             }
    6414              : 
    6415              :           weak_finish_1 (decl);
    6416              : # endif
    6417              :         }
    6418              : #endif
    6419              : 
    6420          100 :       {
    6421          100 :         tree *p;
    6422          100 :         tree t2;
    6423              : 
    6424              :         /* Remove the alias and the target from the pending weak list
    6425              :            so that we do not emit any .weak directives for the former,
    6426              :            nor multiple .weak directives for the latter.  */
    6427          168 :         for (p = &weak_decls; (t2 = *p) ; )
    6428              :           {
    6429           68 :             if (TREE_VALUE (t2) == alias_decl
    6430           68 :                 || target == DECL_ASSEMBLER_NAME (TREE_VALUE (t2)))
    6431            0 :               *p = TREE_CHAIN (t2);
    6432              :             else
    6433           68 :               p = &TREE_CHAIN (t2);
    6434              :           }
    6435              : 
    6436              :         /* Remove other weakrefs to the same target, to speed things up.  */
    6437          212 :         for (p = &TREE_CHAIN (t); (t2 = *p) ; )
    6438              :           {
    6439          112 :             if (target == ultimate_transparent_alias_target (&TREE_VALUE (t2)))
    6440            0 :               *p = TREE_CHAIN (t2);
    6441              :             else
    6442          112 :               p = &TREE_CHAIN (t2);
    6443              :           }
    6444              :       }
    6445              :     }
    6446              : 
    6447       233644 :   for (t = weak_decls; t; t = TREE_CHAIN (t))
    6448              :     {
    6449         1014 :       tree decl = TREE_VALUE (t);
    6450              : 
    6451         1014 :       weak_finish_1 (decl);
    6452              :     }
    6453       232630 : }
    6454              : 
    6455              : /* Emit the assembly bits to indicate that DECL is globally visible.  */
    6456              : 
    6457              : static void
    6458      2665928 : globalize_decl (tree decl)
    6459              : {
    6460              : 
    6461              : #if defined (ASM_WEAKEN_LABEL) || defined (ASM_WEAKEN_DECL)
    6462      2665928 :   if (DECL_WEAK (decl))
    6463              :     {
    6464       530758 :       const char *name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
    6465       530758 :       tree *p, t;
    6466              : 
    6467              : #ifdef ASM_WEAKEN_DECL
    6468              :       ASM_WEAKEN_DECL (asm_out_file, decl, name, 0);
    6469              : #else
    6470       530758 :       ASM_WEAKEN_LABEL (asm_out_file, name);
    6471              : #endif
    6472              : 
    6473              :       /* Remove this function from the pending weak list so that
    6474              :          we do not emit multiple .weak directives for it.  */
    6475      1065554 :       for (p = &weak_decls; (t = *p) ; )
    6476              :         {
    6477         4038 :           if (DECL_ASSEMBLER_NAME (decl) == DECL_ASSEMBLER_NAME (TREE_VALUE (t)))
    6478            0 :             *p = TREE_CHAIN (t);
    6479              :           else
    6480         4038 :             p = &TREE_CHAIN (t);
    6481              :         }
    6482              : 
    6483              :       /* Remove weakrefs to the same target from the pending weakref
    6484              :          list, for the same reason.  */
    6485       530758 :       for (p = &weakref_targets; (t = *p) ; )
    6486              :         {
    6487            0 :           if (DECL_ASSEMBLER_NAME (decl)
    6488            0 :               == ultimate_transparent_alias_target (&TREE_VALUE (t)))
    6489            0 :             *p = TREE_CHAIN (t);
    6490              :           else
    6491            0 :             p = &TREE_CHAIN (t);
    6492              :         }
    6493              : 
    6494              :       return;
    6495              :     }
    6496              : #endif
    6497              : 
    6498      2135170 :   targetm.asm_out.globalize_decl_name (asm_out_file, decl);
    6499              : }
    6500              : 
    6501              : vec<alias_pair, va_gc> *alias_pairs;
    6502              : 
    6503              : /* Output the assembler code for a define (equate) using ASM_OUTPUT_DEF
    6504              :    or ASM_OUTPUT_DEF_FROM_DECLS.  The function defines the symbol whose
    6505              :    tree node is DECL to have the value of the tree node TARGET.  */
    6506              : 
    6507              : void
    6508        66121 : do_assemble_alias (tree decl, tree target)
    6509              : {
    6510        66121 :   tree id;
    6511              : 
    6512              :   /* Emulated TLS had better not get this var.  */
    6513        66121 :   gcc_assert (!(!targetm.have_tls
    6514              :                 && VAR_P (decl)
    6515              :                 && DECL_THREAD_LOCAL_P (decl)));
    6516              : 
    6517        66121 :   if (TREE_ASM_WRITTEN (decl))
    6518          127 :     return;
    6519              : 
    6520        66121 :   id = DECL_ASSEMBLER_NAME (decl);
    6521        66121 :   ultimate_transparent_alias_target (&id);
    6522        66121 :   ultimate_transparent_alias_target (&target);
    6523              : 
    6524              :   /* We must force creation of DECL_RTL for debug info generation, even though
    6525              :      we don't use it here.  */
    6526        66121 :   make_decl_rtl (decl);
    6527              : 
    6528        66121 :   TREE_ASM_WRITTEN (decl) = 1;
    6529        66121 :   TREE_ASM_WRITTEN (DECL_ASSEMBLER_NAME (decl)) = 1;
    6530        66121 :   TREE_ASM_WRITTEN (id) = 1;
    6531              : 
    6532        66121 :   if (lookup_attribute ("weakref", DECL_ATTRIBUTES (decl)))
    6533              :     {
    6534          127 :       if (!TREE_SYMBOL_REFERENCED (target))
    6535          100 :         weakref_targets = tree_cons (decl, target, weakref_targets);
    6536              : 
    6537              : #ifdef ASM_OUTPUT_WEAKREF
    6538          127 :       ASM_OUTPUT_WEAKREF (asm_out_file, decl,
    6539              :                           IDENTIFIER_POINTER (id),
    6540              :                           IDENTIFIER_POINTER (target));
    6541              : #else
    6542              :       if (!TARGET_SUPPORTS_WEAK)
    6543              :         {
    6544              :           error_at (DECL_SOURCE_LOCATION (decl),
    6545              :                     "%qs is not supported in this configuration", "weakref ");
    6546              :           return;
    6547              :         }
    6548              : #endif
    6549          127 :       return;
    6550              :     }
    6551              : 
    6552              : #ifdef ASM_OUTPUT_DEF
    6553        65994 :   tree orig_decl = decl;
    6554              : 
    6555              :   /* Make name accessible from other files, if appropriate.  */
    6556              : 
    6557        65994 :   if (TREE_PUBLIC (decl) || TREE_PUBLIC (orig_decl))
    6558              :     {
    6559        46527 :       globalize_decl (decl);
    6560        46527 :       maybe_assemble_visibility (decl);
    6561              :     }
    6562        65994 :   if (TREE_CODE (decl) == FUNCTION_DECL
    6563        65994 :       && cgraph_node::get (decl)->ifunc_resolver)
    6564              :     {
    6565              : #if defined (ASM_OUTPUT_TYPE_DIRECTIVE)
    6566          292 :       if (targetm.has_ifunc_p ())
    6567          292 :         ASM_OUTPUT_TYPE_DIRECTIVE
    6568              :           (asm_out_file, IDENTIFIER_POINTER (id),
    6569              :            IFUNC_ASM_TYPE);
    6570              :       else
    6571              : #endif
    6572            0 :         error_at (DECL_SOURCE_LOCATION (decl),
    6573              :                   "%qs is not supported on this target", "ifunc");
    6574              :     }
    6575              : 
    6576              : # ifdef ASM_OUTPUT_DEF_FROM_DECLS
    6577              :   ASM_OUTPUT_DEF_FROM_DECLS (asm_out_file, decl, target);
    6578              : # else
    6579        65994 :   ASM_OUTPUT_DEF (asm_out_file,
    6580              :                   IDENTIFIER_POINTER (id),
    6581              :                   IDENTIFIER_POINTER (target));
    6582              : # endif
    6583              :   /* If symbol aliases aren't actually supported...  */
    6584        65994 :   if (!TARGET_SUPPORTS_ALIASES
    6585              : # ifdef ACCEL_COMPILER
    6586              :       /* ..., and unless special-cased...  */
    6587              :       && !lookup_attribute ("symbol alias handled", DECL_ATTRIBUTES (decl))
    6588              : # endif
    6589              :       )
    6590              :     /* ..., 'ASM_OUTPUT_DEF{,_FROM_DECLS}' better have raised an error.  */
    6591              :     gcc_checking_assert (seen_error ());
    6592              : #elif defined (ASM_OUTPUT_WEAK_ALIAS) || defined (ASM_WEAKEN_DECL)
    6593              :   {
    6594              :     const char *name;
    6595              :     tree *p, t;
    6596              : 
    6597              :     name = IDENTIFIER_POINTER (id);
    6598              : # ifdef ASM_WEAKEN_DECL
    6599              :     ASM_WEAKEN_DECL (asm_out_file, decl, name, IDENTIFIER_POINTER (target));
    6600              : # else
    6601              :     ASM_OUTPUT_WEAK_ALIAS (asm_out_file, name, IDENTIFIER_POINTER (target));
    6602              : # endif
    6603              :     /* Remove this function from the pending weak list so that
    6604              :        we do not emit multiple .weak directives for it.  */
    6605              :     for (p = &weak_decls; (t = *p) ; )
    6606              :       if (DECL_ASSEMBLER_NAME (decl) == DECL_ASSEMBLER_NAME (TREE_VALUE (t))
    6607              :           || id == DECL_ASSEMBLER_NAME (TREE_VALUE (t)))
    6608              :         *p = TREE_CHAIN (t);
    6609              :       else
    6610              :         p = &TREE_CHAIN (t);
    6611              : 
    6612              :     /* Remove weakrefs to the same target from the pending weakref
    6613              :        list, for the same reason.  */
    6614              :     for (p = &weakref_targets; (t = *p) ; )
    6615              :       {
    6616              :         if (id == ultimate_transparent_alias_target (&TREE_VALUE (t)))
    6617              :           *p = TREE_CHAIN (t);
    6618              :         else
    6619              :           p = &TREE_CHAIN (t);
    6620              :       }
    6621              :   }
    6622              : #endif
    6623              : }
    6624              : 
    6625              : /* Output .symver directive.  */
    6626              : 
    6627              : void
    6628            2 : do_assemble_symver (tree decl, tree target)
    6629              : {
    6630            2 :   tree id = DECL_ASSEMBLER_NAME (decl);
    6631            2 :   ultimate_transparent_alias_target (&id);
    6632            2 :   ultimate_transparent_alias_target (&target);
    6633              : #ifdef ASM_OUTPUT_SYMVER_DIRECTIVE
    6634            2 :   ASM_OUTPUT_SYMVER_DIRECTIVE (asm_out_file,
    6635              :                                IDENTIFIER_POINTER (target),
    6636              :                                IDENTIFIER_POINTER (id));
    6637              : #else
    6638              :   error ("symver is only supported on ELF platforms");
    6639              : #endif
    6640            2 : }
    6641              : 
    6642              : /* Emit an assembler directive to make the symbol for DECL an alias to
    6643              :    the symbol for TARGET.  */
    6644              : 
    6645              : void
    6646         5697 : assemble_alias (tree decl, tree target)
    6647              : {
    6648         5697 :   tree target_decl;
    6649              : 
    6650         5697 :   if (lookup_attribute ("weakref", DECL_ATTRIBUTES (decl)))
    6651              :     {
    6652          460 :       tree alias = DECL_ASSEMBLER_NAME (decl);
    6653              : 
    6654          460 :       ultimate_transparent_alias_target (&target);
    6655              : 
    6656          460 :       if (alias == target)
    6657            0 :         error ("%qs symbol %q+D ultimately targets itself", "weakref", decl);
    6658          460 :       if (TREE_PUBLIC (decl))
    6659            1 :         error ("%qs symbol %q+D must have static linkage", "weakref", decl);
    6660              :     }
    6661              :   else if (!TARGET_SUPPORTS_ALIASES)
    6662              :     {
    6663              : # if !defined(ASM_OUTPUT_WEAK_ALIAS) && !defined (ASM_WEAKEN_DECL)
    6664              :       error_at (DECL_SOURCE_LOCATION (decl),
    6665              :                 "alias definitions not supported in this configuration");
    6666              :       TREE_ASM_WRITTEN (decl) = 1;
    6667              :       return;
    6668              : # else
    6669              :       if (!DECL_WEAK (decl))
    6670              :         {
    6671              :           /* NB: ifunc_resolver isn't set when an error is detected.  */
    6672              :           if (TREE_CODE (decl) == FUNCTION_DECL
    6673              :               && lookup_attribute ("ifunc", DECL_ATTRIBUTES (decl)))
    6674              :             error_at (DECL_SOURCE_LOCATION (decl),
    6675              :                       "%qs is not supported in this configuration", "ifunc");
    6676              :           else
    6677              :             error_at (DECL_SOURCE_LOCATION (decl),
    6678              :                       "only weak aliases are supported in this configuration");
    6679              :           TREE_ASM_WRITTEN (decl) = 1;
    6680              :           return;
    6681              :         }
    6682              : # endif
    6683              :       gcc_unreachable ();
    6684              :     }
    6685         5697 :   TREE_USED (decl) = 1;
    6686              : 
    6687              :   /* Allow aliases to aliases.  */
    6688         5697 :   if (TREE_CODE (decl) == FUNCTION_DECL)
    6689         5502 :     cgraph_node::get_create (decl)->alias = true;
    6690              :   else
    6691          195 :     varpool_node::get_create (decl)->alias = true;
    6692              : 
    6693              :   /* If the target has already been emitted, we don't have to queue the
    6694              :      alias.  This saves a tad of memory.  */
    6695         5697 :   if (symtab->global_info_ready)
    6696            0 :     target_decl = find_decl (target);
    6697              :   else
    6698              :     target_decl= NULL;
    6699            0 :   if ((target_decl && TREE_ASM_WRITTEN (target_decl))
    6700         5697 :       || symtab->state >= EXPANSION)
    6701            0 :     do_assemble_alias (decl, target);
    6702              :   else
    6703              :     {
    6704         5697 :       alias_pair p = {decl, target};
    6705         5697 :       vec_safe_push (alias_pairs, p);
    6706              :     }
    6707              : }
    6708              : 
    6709              : /* Record and output a table of translations from original function
    6710              :    to its transaction aware clone.  Note that tm_pure functions are
    6711              :    considered to be their own clone.  */
    6712              : 
    6713              : struct tm_clone_hasher : ggc_cache_ptr_hash<tree_map>
    6714              : {
    6715          248 :   static hashval_t hash (tree_map *m) { return tree_map_hash (m); }
    6716          271 :   static bool equal (tree_map *a, tree_map *b) { return tree_map_eq (a, b); }
    6717              : 
    6718              :   static int
    6719            0 :   keep_cache_entry (tree_map *&e)
    6720              :   {
    6721            0 :     return ggc_marked_p (e->base.from);
    6722              :   }
    6723              : };
    6724              : 
    6725              : static GTY((cache)) hash_table<tm_clone_hasher> *tm_clone_hash;
    6726              : 
    6727              : void
    6728          463 : record_tm_clone_pair (tree o, tree n)
    6729              : {
    6730          463 :   struct tree_map **slot, *h;
    6731              : 
    6732          463 :   if (tm_clone_hash == NULL)
    6733          165 :     tm_clone_hash = hash_table<tm_clone_hasher>::create_ggc (32);
    6734              : 
    6735          463 :   h = ggc_alloc<tree_map> ();
    6736          463 :   h->hash = htab_hash_pointer (o);
    6737          463 :   h->base.from = o;
    6738          463 :   h->to = n;
    6739              : 
    6740          463 :   slot = tm_clone_hash->find_slot_with_hash (h, h->hash, INSERT);
    6741          463 :   *slot = h;
    6742          463 : }
    6743              : 
    6744              : tree
    6745            7 : get_tm_clone_pair (tree o)
    6746              : {
    6747            7 :   if (tm_clone_hash)
    6748              :     {
    6749            7 :       struct tree_map *h, in;
    6750              : 
    6751            7 :       in.base.from = o;
    6752            7 :       in.hash = htab_hash_pointer (o);
    6753            7 :       h = tm_clone_hash->find_with_hash (&in, in.hash);
    6754            7 :       if (h)
    6755            0 :         return h->to;
    6756              :     }
    6757              :   return NULL_TREE;
    6758              : }
    6759              : 
    6760              : struct tm_alias_pair
    6761              : {
    6762              :   unsigned int uid;
    6763              :   tree from;
    6764              :   tree to;
    6765              : };
    6766              : 
    6767              : 
    6768              : /* Dump the actual pairs to the .tm_clone_table section.  */
    6769              : 
    6770              : static void
    6771          148 : dump_tm_clone_pairs (vec<tm_alias_pair> tm_alias_pairs)
    6772              : {
    6773          148 :   unsigned i;
    6774          148 :   tm_alias_pair *p;
    6775          148 :   bool switched = false;
    6776              : 
    6777          565 :   FOR_EACH_VEC_ELT (tm_alias_pairs, i, p)
    6778              :     {
    6779          417 :       tree src = p->from;
    6780          417 :       tree dst = p->to;
    6781          417 :       struct cgraph_node *src_n = cgraph_node::get (src);
    6782          417 :       struct cgraph_node *dst_n = cgraph_node::get (dst);
    6783              : 
    6784              :       /* The function ipa_tm_create_version() marks the clone as needed if
    6785              :          the original function was needed.  But we also mark the clone as
    6786              :          needed if we ever called the clone indirectly through
    6787              :          TM_GETTMCLONE.  If neither of these are true, we didn't generate
    6788              :          a clone, and we didn't call it indirectly... no sense keeping it
    6789              :          in the clone table.  */
    6790          417 :       if (!dst_n || !dst_n->definition)
    6791          135 :         continue;
    6792              : 
    6793              :       /* This covers the case where we have optimized the original
    6794              :          function away, and only access the transactional clone.  */
    6795          282 :       if (!src_n || !src_n->definition)
    6796            9 :         continue;
    6797              : 
    6798          273 :       if (!switched)
    6799              :         {
    6800          120 :           switch_to_section (targetm.asm_out.tm_clone_table_section ());
    6801          120 :           assemble_align (POINTER_SIZE);
    6802          120 :           switched = true;
    6803              :         }
    6804              : 
    6805          546 :       assemble_integer (XEXP (DECL_RTL (src), 0),
    6806          546 :                         POINTER_SIZE_UNITS, POINTER_SIZE, 1);
    6807          546 :       assemble_integer (XEXP (DECL_RTL (dst), 0),
    6808          546 :                         POINTER_SIZE_UNITS, POINTER_SIZE, 1);
    6809              :     }
    6810          148 : }
    6811              : 
    6812              : /* Provide a default for the tm_clone_table section.  */
    6813              : 
    6814              : section *
    6815          120 : default_clone_table_section (void)
    6816              : {
    6817          120 :   return get_named_section (NULL, ".tm_clone_table", 3);
    6818              : }
    6819              : 
    6820              : /* Helper comparison function for qsorting by the DECL_UID stored in
    6821              :    alias_pair->emitted_diags.  */
    6822              : 
    6823              : static int
    6824         3534 : tm_alias_pair_cmp (const void *x, const void *y)
    6825              : {
    6826         3534 :   const tm_alias_pair *p1 = (const tm_alias_pair *) x;
    6827         3534 :   const tm_alias_pair *p2 = (const tm_alias_pair *) y;
    6828         3534 :   if (p1->uid < p2->uid)
    6829              :     return -1;
    6830         1609 :   if (p1->uid > p2->uid)
    6831         1609 :     return 1;
    6832              :   return 0;
    6833              : }
    6834              : 
    6835              : void
    6836       232630 : finish_tm_clone_pairs (void)
    6837              : {
    6838       232630 :   vec<tm_alias_pair> tm_alias_pairs = vNULL;
    6839              : 
    6840       232630 :   if (tm_clone_hash == NULL)
    6841       232482 :     return;
    6842              : 
    6843              :   /* We need a determenistic order for the .tm_clone_table, otherwise
    6844              :      we will get bootstrap comparison failures, so dump the hash table
    6845              :      to a vector, sort it, and dump the vector.  */
    6846              : 
    6847              :   /* Dump the hashtable to a vector.  */
    6848          148 :   tree_map *map;
    6849          148 :   hash_table<tm_clone_hasher>::iterator iter;
    6850          982 :   FOR_EACH_HASH_TABLE_ELEMENT (*tm_clone_hash, map, tree_map *, iter)
    6851              :     {
    6852          417 :       tm_alias_pair p = {DECL_UID (map->base.from), map->base.from, map->to};
    6853          417 :       tm_alias_pairs.safe_push (p);
    6854              :     }
    6855              :   /* Sort it.  */
    6856          148 :   tm_alias_pairs.qsort (tm_alias_pair_cmp);
    6857              : 
    6858              :   /* Dump it.  */
    6859          148 :   dump_tm_clone_pairs (tm_alias_pairs);
    6860              : 
    6861          148 :   tm_clone_hash->empty ();
    6862          148 :   tm_clone_hash = NULL;
    6863          148 :   tm_alias_pairs.release ();
    6864              : }
    6865              : 
    6866              : 
    6867              : /* Emit an assembler directive to set symbol for DECL visibility to
    6868              :    the visibility type VIS, which must not be VISIBILITY_DEFAULT.  */
    6869              : 
    6870              : void
    6871        30587 : default_assemble_visibility (tree decl ATTRIBUTE_UNUSED,
    6872              :                              int vis ATTRIBUTE_UNUSED)
    6873              : {
    6874              : #ifdef HAVE_GAS_HIDDEN
    6875        30587 :   static const char * const visibility_types[] = {
    6876              :     NULL, "protected", "hidden", "internal"
    6877              :   };
    6878              : 
    6879        30587 :   const char *name, *type;
    6880        30587 :   tree id;
    6881              : 
    6882        30587 :   id = DECL_ASSEMBLER_NAME (decl);
    6883        30587 :   ultimate_transparent_alias_target (&id);
    6884        30587 :   name = IDENTIFIER_POINTER (id);
    6885              : 
    6886        30587 :   type = visibility_types[vis];
    6887              : 
    6888        30587 :   fprintf (asm_out_file, "\t.%s\t", type);
    6889        30587 :   assemble_name (asm_out_file, name);
    6890        30587 :   fprintf (asm_out_file, "\n");
    6891              : #else
    6892              :   if (!DECL_ARTIFICIAL (decl))
    6893              :     warning (OPT_Wattributes, "visibility attribute not supported "
    6894              :              "in this configuration; ignored");
    6895              : #endif
    6896        30587 : }
    6897              : 
    6898              : /* A helper function to call assemble_visibility when needed for a decl.  */
    6899              : 
    6900              : bool
    6901      2863834 : maybe_assemble_visibility (tree decl)
    6902              : {
    6903      2863834 :   enum symbol_visibility vis = DECL_VISIBILITY (decl);
    6904      2863834 :   if (vis != VISIBILITY_DEFAULT)
    6905              :     {
    6906        29272 :       targetm.asm_out.assemble_visibility (decl, vis);
    6907        29272 :       return true;
    6908              :     }
    6909              :   else
    6910              :     return false;
    6911              : }
    6912              : 
    6913              : /* Returns true if the target configuration supports defining public symbols
    6914              :    so that one of them will be chosen at link time instead of generating a
    6915              :    multiply-defined symbol error, whether through the use of weak symbols or
    6916              :    a target-specific mechanism for having duplicates discarded.  */
    6917              : 
    6918              : bool
    6919        98453 : supports_one_only (void)
    6920              : {
    6921        98453 :   if (SUPPORTS_ONE_ONLY)
    6922        98453 :     return true;
    6923              :   if (TARGET_SUPPORTS_WEAK)
    6924              :     return true;
    6925              :   return false;
    6926              : }
    6927              : 
    6928              : /* Set up DECL as a public symbol that can be defined in multiple
    6929              :    translation units without generating a linker error.  */
    6930              : 
    6931              : void
    6932    105985050 : make_decl_one_only (tree decl, tree comdat_group)
    6933              : {
    6934    105985050 :   struct symtab_node *symbol;
    6935    105985050 :   gcc_assert (VAR_OR_FUNCTION_DECL_P (decl));
    6936              : 
    6937    105985050 :   TREE_PUBLIC (decl) = 1;
    6938              : 
    6939    105985050 :   if (VAR_P (decl))
    6940     56569647 :     symbol = varpool_node::get_create (decl);
    6941              :   else
    6942     49415403 :     symbol = cgraph_node::get_create (decl);
    6943              : 
    6944    105985050 :   if (SUPPORTS_ONE_ONLY)
    6945              :     {
    6946              : #ifdef MAKE_DECL_ONE_ONLY
    6947    105985050 :       MAKE_DECL_ONE_ONLY (decl);
    6948              : #endif
    6949    105985050 :       symbol->set_comdat_group (comdat_group);
    6950              :     }
    6951              :   else if (VAR_P (decl)
    6952              :            && (DECL_INITIAL (decl) == 0
    6953              :                || (!in_lto_p && DECL_INITIAL (decl) == error_mark_node)))
    6954              :     DECL_COMMON (decl) = 1;
    6955              :   else
    6956              :     {
    6957              :       gcc_assert (TARGET_SUPPORTS_WEAK);
    6958              :       DECL_WEAK (decl) = 1;
    6959              :     }
    6960    105985050 : }
    6961              : 
    6962              : void
    6963       281235 : init_varasm_once (void)
    6964              : {
    6965       281235 :   section_htab = hash_table<section_hasher>::create_ggc (31);
    6966       281235 :   object_block_htab = hash_table<object_block_hasher>::create_ggc (31);
    6967       281235 :   const_desc_htab = hash_table<tree_descriptor_hasher>::create_ggc (1009);
    6968              : 
    6969       281235 :   shared_constant_pool = create_constant_pool ();
    6970              : 
    6971              : #ifdef TEXT_SECTION_ASM_OP
    6972       281235 :   text_section = get_unnamed_section (SECTION_CODE, output_section_asm_op,
    6973              :                                       TEXT_SECTION_ASM_OP);
    6974              : #endif
    6975              : 
    6976              : #ifdef DATA_SECTION_ASM_OP
    6977       281235 :   data_section = get_unnamed_section (SECTION_WRITE, output_section_asm_op,
    6978              :                                       DATA_SECTION_ASM_OP);
    6979              : #endif
    6980              : 
    6981              : #ifdef SDATA_SECTION_ASM_OP
    6982              :   sdata_section = get_unnamed_section (SECTION_WRITE, output_section_asm_op,
    6983              :                                        SDATA_SECTION_ASM_OP);
    6984              : #endif
    6985              : 
    6986              : #ifdef READONLY_DATA_SECTION_ASM_OP
    6987       281235 :   readonly_data_section = get_unnamed_section (0, output_section_asm_op,
    6988              :                                                READONLY_DATA_SECTION_ASM_OP);
    6989              : #endif
    6990              : 
    6991              : #ifdef CTORS_SECTION_ASM_OP
    6992              :   ctors_section = get_unnamed_section (0, output_section_asm_op,
    6993              :                                        CTORS_SECTION_ASM_OP);
    6994              : #endif
    6995              : 
    6996              : #ifdef DTORS_SECTION_ASM_OP
    6997              :   dtors_section = get_unnamed_section (0, output_section_asm_op,
    6998              :                                        DTORS_SECTION_ASM_OP);
    6999              : #endif
    7000              : 
    7001              : #ifdef BSS_SECTION_ASM_OP
    7002       281235 :   bss_section = get_unnamed_section (SECTION_WRITE | SECTION_BSS,
    7003              :                                      output_section_asm_op,
    7004              :                                      BSS_SECTION_ASM_OP);
    7005              : #endif
    7006              : 
    7007              : #ifdef SBSS_SECTION_ASM_OP
    7008              :   sbss_section = get_unnamed_section (SECTION_WRITE | SECTION_BSS,
    7009              :                                       output_section_asm_op,
    7010              :                                       SBSS_SECTION_ASM_OP);
    7011              : #endif
    7012              : 
    7013       281235 :   tls_comm_section = get_noswitch_section (SECTION_WRITE | SECTION_BSS
    7014              :                                            | SECTION_COMMON, emit_tls_common);
    7015       281235 :   lcomm_section = get_noswitch_section (SECTION_WRITE | SECTION_BSS
    7016              :                                         | SECTION_COMMON, emit_local);
    7017       281235 :   comm_section = get_noswitch_section (SECTION_WRITE | SECTION_BSS
    7018              :                                        | SECTION_COMMON, emit_common);
    7019              : 
    7020              : #if defined ASM_OUTPUT_ALIGNED_BSS
    7021       281235 :   bss_noswitch_section = get_noswitch_section (SECTION_WRITE | SECTION_BSS,
    7022              :                                                emit_bss);
    7023              : #endif
    7024              : 
    7025       281235 :   targetm.asm_out.init_sections ();
    7026              : 
    7027       281235 :   if (readonly_data_section == NULL)
    7028            0 :     readonly_data_section = text_section;
    7029              : 
    7030              : #ifdef ASM_OUTPUT_EXTERNAL
    7031       281235 :   pending_assemble_externals_set = new hash_set<tree>;
    7032              : #endif
    7033       281235 : }
    7034              : 
    7035              : /* Determine whether SYMBOL is used in any optimized function.  */
    7036              : 
    7037              : static bool
    7038          170 : have_optimized_refs (struct symtab_node *symbol)
    7039              : {
    7040          170 :   struct ipa_ref *ref;
    7041              : 
    7042          194 :   for (int i = 0; symbol->iterate_referring (i, ref); i++)
    7043              :     {
    7044          210 :       cgraph_node *cnode = dyn_cast <cgraph_node *> (ref->referring);
    7045              : 
    7046          186 :       if (cnode && opt_for_fn (cnode->decl, optimize))
    7047              :         return true;
    7048              :     }
    7049              : 
    7050              :   return false;
    7051              : }
    7052              : 
    7053              : /* Check if promoting general-dynamic TLS access model to local-dynamic is
    7054              :    desirable for DECL.  */
    7055              : 
    7056              : static bool
    7057          313 : optimize_dyn_tls_for_decl_p (const_tree decl)
    7058              : {
    7059          313 :   if (cfun)
    7060           30 :     return optimize;
    7061          283 :   return symtab->state >= IPA && have_optimized_refs (symtab_node::get (decl));
    7062              : }
    7063              : 
    7064              : 
    7065              : enum tls_model
    7066        28203 : decl_default_tls_model (const_tree decl)
    7067              : {
    7068        28203 :   enum tls_model kind;
    7069        28203 :   bool is_local;
    7070              : 
    7071        28203 :   is_local = targetm.binds_local_p (decl);
    7072        28203 :   if (!flag_shlib)
    7073              :     {
    7074        25804 :       if (is_local)
    7075              :         kind = TLS_MODEL_LOCAL_EXEC;
    7076              :       else
    7077        19846 :         kind = TLS_MODEL_INITIAL_EXEC;
    7078              :     }
    7079              : 
    7080              :   /* Local dynamic is inefficient when we're not combining the
    7081              :      parts of the address.  */
    7082         2399 :   else if (is_local && optimize_dyn_tls_for_decl_p (decl))
    7083              :     kind = TLS_MODEL_LOCAL_DYNAMIC;
    7084              :   else
    7085              :     kind = TLS_MODEL_GLOBAL_DYNAMIC;
    7086        28203 :   if (kind < flag_tls_default)
    7087          178 :     kind = flag_tls_default;
    7088              : 
    7089        28203 :   return kind;
    7090              : }
    7091              : 
    7092              : /* Select a set of attributes for section NAME based on the properties
    7093              :    of DECL and whether or not RELOC indicates that DECL's initializer
    7094              :    might contain runtime relocations.
    7095              : 
    7096              :    We make the section read-only and executable for a function decl,
    7097              :    read-only for a const data decl, and writable for a non-const data decl.  */
    7098              : 
    7099              : unsigned int
    7100     67413942 : default_section_type_flags (tree decl, const char *name, int reloc)
    7101              : {
    7102     67413942 :   unsigned int flags;
    7103              : 
    7104     67413942 :   if (decl && TREE_CODE (decl) == FUNCTION_DECL)
    7105              :     flags = SECTION_CODE;
    7106      2970491 :   else if (strcmp (name, ".data.rel.ro") == 0
    7107      2970375 :            || strcmp (name, ".data.rel.ro.local") == 0)
    7108              :     flags = SECTION_WRITE | SECTION_RELRO;
    7109      2969995 :   else if (decl)
    7110              :     {
    7111      2969875 :       enum section_category category
    7112      2969875 :         = categorize_decl_for_section (decl, reloc);
    7113      6581207 :       if (decl_readonly_section_1 (category))
    7114              :         flags = 0;
    7115       640961 :       else if (category == SECCAT_DATA_REL_RO
    7116       640961 :                || category == SECCAT_DATA_REL_RO_LOCAL)
    7117              :         flags = SECTION_WRITE | SECTION_RELRO;
    7118              :       else
    7119      2970371 :         flags = SECTION_WRITE;
    7120              :     }
    7121              :   else
    7122              :     flags = SECTION_WRITE;
    7123              : 
    7124     67413822 :   if (decl && DECL_P (decl) && DECL_COMDAT_GROUP (decl))
    7125     35034325 :     flags |= SECTION_LINKONCE;
    7126              : 
    7127     67413942 :   if (strcmp (name, ".vtable_map_vars") == 0)
    7128            6 :     flags |= SECTION_LINKONCE;
    7129              : 
    7130     67413942 :   if (decl && VAR_P (decl) && DECL_THREAD_LOCAL_P (decl))
    7131         3839 :     flags |= SECTION_TLS | SECTION_WRITE;
    7132              : 
    7133     67413942 :   if (strcmp (name, ".bss") == 0
    7134     67413942 :       || startswith (name, ".bss.")
    7135     67398813 :       || startswith (name, ".gnu.linkonce.b.")
    7136     67398813 :       || strcmp (name, ".persistent.bss") == 0
    7137     67398813 :       || strcmp (name, ".sbss") == 0
    7138     67398813 :       || startswith (name, ".sbss.")
    7139    134812755 :       || startswith (name, ".gnu.linkonce.sb."))
    7140        15129 :     flags |= SECTION_BSS;
    7141              : 
    7142     67413942 :   if (strcmp (name, ".tdata") == 0
    7143     67413628 :       || startswith (name, ".tdata.")
    7144    134827531 :       || startswith (name, ".gnu.linkonce.td."))
    7145          353 :     flags |= SECTION_TLS;
    7146              : 
    7147     67413942 :   if (strcmp (name, ".tbss") == 0
    7148     67410650 :       || startswith (name, ".tbss.")
    7149    134824404 :       || startswith (name, ".gnu.linkonce.tb."))
    7150         3480 :     flags |= SECTION_TLS | SECTION_BSS;
    7151              : 
    7152     67413942 :   if (strcmp (name, ".noinit") == 0)
    7153            0 :     flags |= SECTION_WRITE | SECTION_BSS | SECTION_NOTYPE;
    7154              : 
    7155     67413942 :   if (strcmp (name, ".persistent") == 0)
    7156            0 :     flags |= SECTION_WRITE | SECTION_NOTYPE;
    7157              : 
    7158              :   /* Various sections have special ELF types that the assembler will
    7159              :      assign by default based on the name.  They are neither SHT_PROGBITS
    7160              :      nor SHT_NOBITS, so when changing sections we don't want to print a
    7161              :      section type (@progbits or @nobits).  Rather than duplicating the
    7162              :      assembler's knowledge of what those special name patterns are, just
    7163              :      let the assembler choose the type if we don't know a specific
    7164              :      reason to set it to something other than the default.  SHT_PROGBITS
    7165              :      is the default for sections whose name is not specially known to
    7166              :      the assembler, so it does no harm to leave the choice to the
    7167              :      assembler when @progbits is the best thing we know to use.  If
    7168              :      someone is silly enough to emit code or TLS variables to one of
    7169              :      these sections, then don't handle them specially.
    7170              : 
    7171              :      default_elf_asm_named_section (below) handles the BSS, TLS, ENTSIZE, and
    7172              :      LINKONCE cases when NOTYPE is not set, so leave those to its logic.  */
    7173     67413942 :   if (!(flags & (SECTION_CODE | SECTION_BSS | SECTION_TLS | SECTION_ENTSIZE))
    7174      2951523 :       && !(HAVE_COMDAT_GROUP && (flags & SECTION_LINKONCE)))
    7175      2403751 :     flags |= SECTION_NOTYPE;
    7176              : 
    7177     67413942 :   return flags;
    7178              : }
    7179              : 
    7180              : /* Return true if the target supports some form of global BSS,
    7181              :    either through bss_noswitch_section, or by selecting a BSS
    7182              :    section in TARGET_ASM_SELECT_SECTION.  */
    7183              : 
    7184              : bool
    7185            0 : have_global_bss_p (void)
    7186              : {
    7187            0 :   return bss_noswitch_section || targetm.have_switchable_bss_sections;
    7188              : }
    7189              : 
    7190              : /* Output assembly to switch to section NAME with attribute FLAGS.
    7191              :    Four variants for common object file formats.  */
    7192              : 
    7193              : void
    7194            0 : default_no_named_section (const char *name ATTRIBUTE_UNUSED,
    7195              :                           unsigned int flags ATTRIBUTE_UNUSED,
    7196              :                           tree decl ATTRIBUTE_UNUSED)
    7197              : {
    7198              :   /* Some object formats don't support named sections at all.  The
    7199              :      front-end should already have flagged this as an error.  */
    7200            0 :   gcc_unreachable ();
    7201              : }
    7202              : 
    7203              : #ifndef TLS_SECTION_ASM_FLAG
    7204              : #define TLS_SECTION_ASM_FLAG 'T'
    7205              : #endif
    7206              : 
    7207              : void
    7208      3581304 : default_elf_asm_named_section (const char *name, unsigned int flags,
    7209              :                                tree decl)
    7210              : {
    7211      3581304 :   char flagchars[11], *f = flagchars;
    7212      3581304 :   unsigned int numeric_value = 0;
    7213              : 
    7214              :   /* If we have already declared this section, we can use an
    7215              :      abbreviated form to switch back to it -- unless this section is
    7216              :      part of a COMDAT groups or with SHF_GNU_RETAIN or with SHF_LINK_ORDER,
    7217              :      in which case GAS requires the full declaration every time.  */
    7218      3581304 :   if (!(HAVE_COMDAT_GROUP && (flags & SECTION_LINKONCE))
    7219      3016526 :       && !(flags & (SECTION_RETAIN | SECTION_LINK_ORDER))
    7220      3016227 :       && (flags & SECTION_DECLARED))
    7221              :     {
    7222       389665 :       fprintf (asm_out_file, "\t.section\t%s\n", name);
    7223       389665 :       return;
    7224              :     }
    7225              : 
    7226              :   /* If we have a machine specific flag, then use the numeric value to pass
    7227              :      this on to GAS.  */
    7228      3191639 :   if (targetm.asm_out.elf_flags_numeric (flags, &numeric_value))
    7229            0 :       snprintf (f, sizeof (flagchars), "0x%08x", numeric_value);
    7230              :   else
    7231              :     {
    7232      3191639 :       if (!(flags & SECTION_DEBUG))
    7233      2125966 :         *f++ = 'a';
    7234              : #if HAVE_GAS_SECTION_EXCLUDE
    7235      3191639 :       if (flags & SECTION_EXCLUDE)
    7236       433490 :         *f++ = 'e';
    7237              : #endif
    7238      3191639 :       if (flags & SECTION_WRITE)
    7239       352353 :         *f++ = 'w';
    7240      3191639 :       if (flags & SECTION_CODE)
    7241       385439 :         *f++ = 'x';
    7242      3191639 :       if (flags & SECTION_SMALL)
    7243            0 :         *f++ = 's';
    7244      3191639 :       if (flags & SECTION_MERGE)
    7245       222627 :         *f++ = 'M';
    7246      3191639 :       if (flags & SECTION_STRINGS)
    7247       182548 :         *f++ = 'S';
    7248      3191639 :       if (flags & SECTION_TLS)
    7249         1226 :         *f++ = TLS_SECTION_ASM_FLAG;
    7250      3191639 :       if (HAVE_COMDAT_GROUP && (flags & SECTION_LINKONCE))
    7251       564778 :         *f++ = 'G';
    7252      3191639 :       if (flags & SECTION_RETAIN)
    7253          258 :         *f++ = 'R';
    7254      3191639 :       if (flags & SECTION_LINK_ORDER)
    7255           53 :         *f++ = 'o';
    7256              : #ifdef MACH_DEP_SECTION_ASM_FLAG
    7257      3191639 :       if (flags & SECTION_MACH_DEP)
    7258           12 :         *f++ = MACH_DEP_SECTION_ASM_FLAG;
    7259              : #endif
    7260      3191639 :       *f = '\0';
    7261              :     }
    7262              : 
    7263      3191639 :   fprintf (asm_out_file, "\t.section\t%s,\"%s\"", name, flagchars);
    7264              : 
    7265              :   /* default_section_type_flags (above) knows which flags need special
    7266              :      handling here, and sets NOTYPE when none of these apply so that the
    7267              :      assembler's logic for default types can apply to user-chosen
    7268              :      section names.  */
    7269      3191639 :   if (!(flags & SECTION_NOTYPE))
    7270              :     {
    7271      1943054 :       const char *type;
    7272      1943054 :       const char *format;
    7273              : 
    7274      1943054 :       if (flags & SECTION_BSS)
    7275              :         type = "nobits";
    7276              :       else
    7277      1928827 :         type = "progbits";
    7278              : 
    7279      1943054 :       format = ",@%s";
    7280              :       /* On platforms that use "@" as the assembly comment character,
    7281              :          use "%" instead.  */
    7282      1943054 :       if (strcmp (ASM_COMMENT_START, "@") == 0)
    7283              :         format = ",%%%s";
    7284      1943054 :       fprintf (asm_out_file, format, type);
    7285              : 
    7286      1943054 :       if (flags & SECTION_ENTSIZE)
    7287       222627 :         fprintf (asm_out_file, ",%d", flags & SECTION_ENTSIZE);
    7288      1943054 :       if (flags & SECTION_LINK_ORDER)
    7289              :         {
    7290              :           /* For now, only section "__patchable_function_entries"
    7291              :              adopts flag SECTION_LINK_ORDER, internal label LPFE*
    7292              :              was emitted in default_print_patchable_function_entry,
    7293              :              just place it here for linked_to section.  */
    7294           53 :           gcc_assert (!strcmp (name, "__patchable_function_entries"));
    7295           53 :           fprintf (asm_out_file, ",");
    7296           53 :           char buf[256];
    7297           53 :           ASM_GENERATE_INTERNAL_LABEL (buf, "LPFE",
    7298              :                                        current_function_funcdef_no);
    7299           53 :           assemble_name_raw (asm_out_file, buf);
    7300              :         }
    7301      1943054 :       if (HAVE_COMDAT_GROUP && (flags & SECTION_LINKONCE))
    7302              :         {
    7303       564778 :           if (TREE_CODE (decl) == IDENTIFIER_NODE)
    7304         1625 :             fprintf (asm_out_file, ",%s,comdat", IDENTIFIER_POINTER (decl));
    7305              :           else
    7306      1126306 :             fprintf (asm_out_file, ",%s,comdat",
    7307       563153 :                      IDENTIFIER_POINTER (DECL_COMDAT_GROUP (decl)));
    7308              :         }
    7309              :     }
    7310              : 
    7311      3191639 :   putc ('\n', asm_out_file);
    7312              : }
    7313              : 
    7314              : void
    7315            0 : default_coff_asm_named_section (const char *name, unsigned int flags,
    7316              :                                 tree decl ATTRIBUTE_UNUSED)
    7317              : {
    7318            0 :   char flagchars[8], *f = flagchars;
    7319              : 
    7320            0 :   if (flags & SECTION_WRITE)
    7321            0 :     *f++ = 'w';
    7322            0 :   if (flags & SECTION_CODE)
    7323            0 :     *f++ = 'x';
    7324            0 :   *f = '\0';
    7325              : 
    7326            0 :   fprintf (asm_out_file, "\t.section\t%s,\"%s\"\n", name, flagchars);
    7327            0 : }
    7328              : 
    7329              : void
    7330            0 : default_pe_asm_named_section (const char *name, unsigned int flags,
    7331              :                               tree decl)
    7332              : {
    7333            0 :   default_coff_asm_named_section (name, flags, decl);
    7334              : 
    7335            0 :   if (flags & SECTION_LINKONCE)
    7336              :     {
    7337              :       /* Functions may have been compiled at various levels of
    7338              :          optimization so we can't use `same_size' here.
    7339              :          Instead, have the linker pick one.  */
    7340            0 :       fprintf (asm_out_file, "\t.linkonce %s\n",
    7341            0 :                (flags & SECTION_CODE ? "discard" : "same_size"));
    7342              :     }
    7343            0 : }
    7344              : 
    7345              : /* The lame default section selector.  */
    7346              : 
    7347              : section *
    7348            0 : default_select_section (tree decl, int reloc,
    7349              :                         unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED)
    7350              : {
    7351            0 :   if (DECL_P (decl))
    7352              :     {
    7353            0 :       if (decl_readonly_section (decl, reloc))
    7354            0 :         return readonly_data_section;
    7355              :     }
    7356            0 :   else if (TREE_CODE (decl) == CONSTRUCTOR)
    7357              :     {
    7358            0 :       if (! ((flag_pic && reloc)
    7359            0 :              || !TREE_READONLY (decl)
    7360            0 :              || !TREE_CONSTANT (decl)))
    7361            0 :         return readonly_data_section;
    7362              :     }
    7363            0 :   else if (TREE_CODE (decl) == STRING_CST)
    7364            0 :     return readonly_data_section;
    7365            0 :   else if (! (flag_pic && reloc))
    7366            0 :     return readonly_data_section;
    7367              : 
    7368            0 :   return data_section;
    7369              : }
    7370              : 
    7371              : enum section_category
    7372      6460977 : categorize_decl_for_section (const_tree decl, int reloc)
    7373              : {
    7374      6460977 :   enum section_category ret;
    7375              : 
    7376      6460977 :   if (TREE_CODE (decl) == FUNCTION_DECL)
    7377              :     return SECCAT_TEXT;
    7378      6214554 :   else if (TREE_CODE (decl) == STRING_CST)
    7379              :     {
    7380      1263456 :       if ((flag_sanitize & SANITIZE_ADDRESS)
    7381      1263456 :           && asan_protect_global (const_cast<tree> (decl)))
    7382              :       /* or !flag_merge_constants */
    7383              :         return SECCAT_RODATA;
    7384              :       else
    7385      1261803 :         return SECCAT_RODATA_MERGE_STR;
    7386              :     }
    7387      4951098 :   else if (VAR_P (decl))
    7388              :     {
    7389      4920149 :       tree d = const_cast<tree> (decl);
    7390      4920149 :       if (bss_initializer_p (decl))
    7391              :         ret = SECCAT_BSS;
    7392      4882837 :       else if (! TREE_READONLY (decl)
    7393      4882837 :                || (DECL_INITIAL (decl)
    7394      4557767 :                    && ! TREE_CONSTANT (DECL_INITIAL (decl))))
    7395              :         {
    7396              :           /* Here the reloc_rw_mask is not testing whether the section should
    7397              :              be read-only or not, but whether the dynamic link will have to
    7398              :              do something.  If so, we wish to segregate the data in order to
    7399              :              minimize cache misses inside the dynamic linker.  */
    7400       324936 :           if (reloc & targetm.asm_out.reloc_rw_mask ())
    7401         6215 :             ret = reloc == 1 ? SECCAT_DATA_REL_LOCAL : SECCAT_DATA_REL;
    7402              :           else
    7403              :             ret = SECCAT_DATA;
    7404              :         }
    7405      4557901 :       else if (reloc & targetm.asm_out.reloc_rw_mask ())
    7406       922294 :         ret = reloc == 1 ? SECCAT_DATA_REL_RO_LOCAL : SECCAT_DATA_REL_RO;
    7407       734239 :       else if (reloc || (flag_merge_constants < 2 && !DECL_MERGEABLE (decl))
    7408      3637804 :                || ((flag_sanitize & SANITIZE_ADDRESS)
    7409              :                    /* PR 81697: for architectures that use section anchors we
    7410              :                       need to ignore DECL_RTL_SET_P (decl) for string constants
    7411              :                       inside this asan_protect_global call because otherwise
    7412              :                       we'll wrongly put them into SECCAT_RODATA_MERGE_CONST
    7413              :                       section, set DECL_RTL (decl) later on and add DECL to
    7414              :                       protected globals via successive asan_protect_global
    7415              :                       calls.  In this scenario we'll end up with wrong
    7416              :                       alignment of these strings at runtime and possible ASan
    7417              :                       false positives.  */
    7418           91 :                    && asan_protect_global (d, use_object_blocks_p ()
    7419           91 :                                               && use_blocks_for_decl_p (d))))
    7420              :         /* C and C++ don't allow different variables to share the same
    7421              :            location.  -fmerge-all-constants allows even that (at the
    7422              :            expense of not conforming).  */
    7423              :         ret = SECCAT_RODATA;
    7424         2118 :       else if (DECL_INITIAL (decl)
    7425         2118 :                && TREE_CODE (DECL_INITIAL (decl)) == STRING_CST)
    7426              :         ret = SECCAT_RODATA_MERGE_STR_INIT;
    7427              :       else
    7428              :         ret = SECCAT_RODATA_MERGE_CONST;
    7429              :     }
    7430        30949 :   else if (TREE_CODE (decl) == CONSTRUCTOR)
    7431              :     {
    7432         1544 :       if ((reloc & targetm.asm_out.reloc_rw_mask ())
    7433         1544 :           || ! TREE_CONSTANT (decl))
    7434              :         ret = SECCAT_DATA;
    7435              :       else
    7436              :         ret = SECCAT_RODATA;
    7437              :     }
    7438              :   else
    7439              :     ret = SECCAT_RODATA;
    7440              : 
    7441              :   /* There are no read-only thread-local sections.  */
    7442      4951098 :   if (VAR_P (decl) && DECL_THREAD_LOCAL_P (decl))
    7443              :     {
    7444              :       /* Note that this would be *just* SECCAT_BSS, except that there's
    7445              :          no concept of a read-only thread-local-data section.  */
    7446         7670 :       if (ret == SECCAT_BSS
    7447          712 :           || DECL_INITIAL (decl) == NULL
    7448         8376 :           || (flag_zero_initialized_in_bss
    7449          706 :               && initializer_zerop (DECL_INITIAL (decl))))
    7450              :         ret = SECCAT_TBSS;
    7451              :       else
    7452              :         ret = SECCAT_TDATA;
    7453              :     }
    7454              : 
    7455              :   /* If the target uses small data sections, select it.  */
    7456      4943428 :   else if (targetm.in_small_data_p (decl))
    7457              :     {
    7458            0 :       if (ret == SECCAT_BSS)
    7459              :         ret = SECCAT_SBSS;
    7460            0 :       else if (targetm.have_srodata_section && ret == SECCAT_RODATA)
    7461              :         ret = SECCAT_SRODATA;
    7462              :       else
    7463            0 :         ret = SECCAT_SDATA;
    7464              :     }
    7465              : 
    7466              :   return ret;
    7467              : }
    7468              : 
    7469              : static bool
    7470      2992197 : decl_readonly_section_1 (enum section_category category)
    7471              : {
    7472      2969875 :   switch (category)
    7473              :     {
    7474              :     case SECCAT_RODATA:
    7475              :     case SECCAT_RODATA_MERGE_STR:
    7476              :     case SECCAT_RODATA_MERGE_STR_INIT:
    7477              :     case SECCAT_RODATA_MERGE_CONST:
    7478              :     case SECCAT_SRODATA:
    7479              :       return true;
    7480       643530 :     default:
    7481       643530 :       return false;
    7482              :     }
    7483              : }
    7484              : 
    7485              : bool
    7486        22322 : decl_readonly_section (const_tree decl, int reloc)
    7487              : {
    7488        22322 :   return decl_readonly_section_1 (categorize_decl_for_section (decl, reloc));
    7489              : }
    7490              : 
    7491              : /* Select a section based on the above categorization.  */
    7492              : 
    7493              : section *
    7494      1663810 : default_elf_select_section (tree decl, int reloc,
    7495              :                             unsigned HOST_WIDE_INT align)
    7496              : {
    7497      1663810 :   const char *sname;
    7498              : 
    7499      1663810 :   switch (categorize_decl_for_section (decl, reloc))
    7500              :     {
    7501            0 :     case SECCAT_TEXT:
    7502              :       /* We're not supposed to be called on FUNCTION_DECLs.  */
    7503            0 :       gcc_unreachable ();
    7504       132148 :     case SECCAT_RODATA:
    7505       132148 :       return readonly_data_section;
    7506      1242191 :     case SECCAT_RODATA_MERGE_STR:
    7507      1242191 :       return mergeable_string_section (decl, align, 0);
    7508           14 :     case SECCAT_RODATA_MERGE_STR_INIT:
    7509           14 :       return mergeable_string_section (DECL_INITIAL (decl), align, 0);
    7510          476 :     case SECCAT_RODATA_MERGE_CONST:
    7511          476 :       return mergeable_constant_section (DECL_SIZE (decl), align, 0);
    7512              :     case SECCAT_SRODATA:
    7513              :       sname = ".sdata2";
    7514              :       break;
    7515       284036 :     case SECCAT_DATA:
    7516       284036 :       if (DECL_P (decl) && DECL_PERSISTENT_P (decl))
    7517              :         {
    7518              :           sname = ".persistent";
    7519              :           break;
    7520              :         }
    7521       284036 :       return data_section;
    7522          126 :     case SECCAT_DATA_REL:
    7523          126 :       sname = ".data.rel";
    7524          126 :       break;
    7525          975 :     case SECCAT_DATA_REL_LOCAL:
    7526          975 :       sname = ".data.rel.local";
    7527          975 :       break;
    7528          102 :     case SECCAT_DATA_REL_RO:
    7529          102 :       sname = ".data.rel.ro";
    7530          102 :       break;
    7531          131 :     case SECCAT_DATA_REL_RO_LOCAL:
    7532          131 :       sname = ".data.rel.ro.local";
    7533          131 :       break;
    7534            0 :     case SECCAT_SDATA:
    7535            0 :       sname = ".sdata";
    7536            0 :       break;
    7537          314 :     case SECCAT_TDATA:
    7538          314 :       sname = ".tdata";
    7539          314 :       break;
    7540            5 :     case SECCAT_BSS:
    7541            5 :       if (DECL_P (decl) && DECL_NOINIT_P (decl))
    7542              :         {
    7543              :           sname = ".noinit";
    7544              :           break;
    7545              :         }
    7546            5 :       if (bss_section)
    7547              :         return bss_section;
    7548              :       sname = ".bss";
    7549              :       break;
    7550            0 :     case SECCAT_SBSS:
    7551            0 :       sname = ".sbss";
    7552            0 :       break;
    7553         3292 :     case SECCAT_TBSS:
    7554         3292 :       sname = ".tbss";
    7555         3292 :       break;
    7556            0 :     default:
    7557            0 :       gcc_unreachable ();
    7558              :     }
    7559              : 
    7560         4940 :   return get_named_section (decl, sname, reloc);
    7561              : }
    7562              : 
    7563              : /* Construct a unique section name based on the decl name and the
    7564              :    categorization performed above.  */
    7565              : 
    7566              : void
    7567      1804866 : default_unique_section (tree decl, int reloc)
    7568              : {
    7569              :   /* We only need to use .gnu.linkonce if we don't have COMDAT groups.  */
    7570      1804866 :   bool one_only = DECL_ONE_ONLY (decl) && !HAVE_COMDAT_GROUP;
    7571      1804866 :   const char *prefix, *name, *linkonce;
    7572      1804866 :   char *string;
    7573      1804866 :   tree id;
    7574              : 
    7575      1804866 :   switch (categorize_decl_for_section (decl, reloc))
    7576              :     {
    7577              :     case SECCAT_TEXT:
    7578              :       prefix = one_only ? ".t" : ".text";
    7579              :       break;
    7580      1206439 :     case SECCAT_RODATA:
    7581      1206439 :     case SECCAT_RODATA_MERGE_STR:
    7582      1206439 :     case SECCAT_RODATA_MERGE_STR_INIT:
    7583      1206439 :     case SECCAT_RODATA_MERGE_CONST:
    7584      1206439 :       prefix = one_only ? ".r" : ".rodata";
    7585              :       break;
    7586            0 :     case SECCAT_SRODATA:
    7587            0 :       prefix = one_only ? ".s2" : ".sdata2";
    7588              :       break;
    7589        11512 :     case SECCAT_DATA:
    7590        11512 :       prefix = one_only ? ".d" : ".data";
    7591        11512 :       if (DECL_P (decl) && DECL_PERSISTENT_P (decl))
    7592              :         {
    7593              :           prefix = one_only ? ".p" : ".persistent";
    7594              :           break;
    7595              :         }
    7596              :       break;
    7597         1137 :     case SECCAT_DATA_REL:
    7598         1137 :       prefix = one_only ? ".d.rel" : ".data.rel";
    7599              :       break;
    7600          894 :     case SECCAT_DATA_REL_LOCAL:
    7601          894 :       prefix = one_only ? ".d.rel.local" : ".data.rel.local";
    7602              :       break;
    7603       156102 :     case SECCAT_DATA_REL_RO:
    7604       156102 :       prefix = one_only ? ".d.rel.ro" : ".data.rel.ro";
    7605              :       break;
    7606       168648 :     case SECCAT_DATA_REL_RO_LOCAL:
    7607       168648 :       prefix = one_only ? ".d.rel.ro.local" : ".data.rel.ro.local";
    7608              :       break;
    7609            0 :     case SECCAT_SDATA:
    7610            0 :       prefix = one_only ? ".s" : ".sdata";
    7611              :       break;
    7612        13487 :     case SECCAT_BSS:
    7613        13487 :       if (DECL_P (decl) && DECL_NOINIT_P (decl))
    7614              :         {
    7615              :           prefix = one_only ? ".n" : ".noinit";
    7616              :           break;
    7617              :         }
    7618              :       prefix = one_only ? ".b" : ".bss";
    7619              :       break;
    7620            0 :     case SECCAT_SBSS:
    7621            0 :       prefix = one_only ? ".sb" : ".sbss";
    7622              :       break;
    7623           39 :     case SECCAT_TDATA:
    7624           39 :       prefix = one_only ? ".td" : ".tdata";
    7625              :       break;
    7626          186 :     case SECCAT_TBSS:
    7627          186 :       prefix = one_only ? ".tb" : ".tbss";
    7628              :       break;
    7629            0 :     default:
    7630            0 :       gcc_unreachable ();
    7631              :     }
    7632              : 
    7633      1804866 :   id = DECL_ASSEMBLER_NAME (decl);
    7634      1804866 :   ultimate_transparent_alias_target (&id);
    7635      1804866 :   name = IDENTIFIER_POINTER (id);
    7636      1804866 :   name = targetm.strip_name_encoding (name);
    7637              : 
    7638              :   /* If we're using one_only, then there needs to be a .gnu.linkonce
    7639              :      prefix to the section name.  */
    7640      1804866 :   linkonce = one_only ? ".gnu.linkonce" : "";
    7641              : 
    7642      1804866 :   string = ACONCAT ((linkonce, prefix, ".", name, NULL));
    7643              : 
    7644      1804866 :   set_decl_section_name (decl, string);
    7645      1804866 : }
    7646              : 
    7647              : /* Subroutine of compute_reloc_for_rtx for leaf rtxes.  */
    7648              : 
    7649              : static int
    7650        42239 : compute_reloc_for_rtx_1 (const_rtx x)
    7651              : {
    7652        42239 :   switch (GET_CODE (x))
    7653              :     {
    7654        30921 :     case SYMBOL_REF:
    7655        30921 :       return SYMBOL_REF_LOCAL_P (x) ? 1 : 2;
    7656              :     case LABEL_REF:
    7657              :       return 1;
    7658              :     default:
    7659              :       return 0;
    7660              :     }
    7661              : }
    7662              : 
    7663              : /* Like compute_reloc_for_constant, except for an RTX.  The return value
    7664              :    is a mask for which bit 1 indicates a global relocation, and bit 0
    7665              :    indicates a local relocation.  Used by default_select_rtx_section
    7666              :    and default_elf_select_rtx_section.  */
    7667              : 
    7668              : static int
    7669       246755 : compute_reloc_for_rtx (const_rtx x)
    7670              : {
    7671       246755 :   switch (GET_CODE (x))
    7672              :     {
    7673        27187 :     case SYMBOL_REF:
    7674        27187 :     case LABEL_REF:
    7675        27187 :       return compute_reloc_for_rtx_1 (x);
    7676              : 
    7677         3763 :     case CONST:
    7678         3763 :       {
    7679         3763 :         int reloc = 0;
    7680         3763 :         subrtx_iterator::array_type array;
    7681        18815 :         FOR_EACH_SUBRTX (iter, array, x, ALL)
    7682        15052 :           reloc |= compute_reloc_for_rtx_1 (*iter);
    7683         3763 :         return reloc;
    7684         3763 :       }
    7685              : 
    7686              :     default:
    7687              :       return 0;
    7688              :     }
    7689              : }
    7690              : 
    7691              : section *
    7692            0 : default_select_rtx_section (machine_mode mode ATTRIBUTE_UNUSED,
    7693              :                             rtx x,
    7694              :                             unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED)
    7695              : {
    7696            0 :   if (compute_reloc_for_rtx (x) & targetm.asm_out.reloc_rw_mask ())
    7697            0 :     return data_section;
    7698              :   else
    7699            0 :     return readonly_data_section;
    7700              : }
    7701              : 
    7702              : section *
    7703       246755 : default_elf_select_rtx_section (machine_mode mode, rtx x,
    7704              :                                 unsigned HOST_WIDE_INT align)
    7705              : {
    7706       246755 :   int reloc = compute_reloc_for_rtx (x);
    7707       246755 :   tree decl = nullptr;
    7708       246755 :   const char *prefix = nullptr;
    7709       246755 :   int flags = 0;
    7710              : 
    7711              :   /* If it is a private COMDAT function symbol reference, call
    7712              :      function_rodata_section for the read-only or relocated read-only
    7713              :      data section associated with function DECL so that the COMDAT
    7714              :      section will be used for the private COMDAT function symbol.  */
    7715       246755 :   if (HAVE_COMDAT_GROUP)
    7716              :     {
    7717       246755 :       if (GET_CODE (x) == CONST
    7718         3763 :          && GET_CODE (XEXP (x, 0)) == PLUS
    7719         3763 :          && CONST_INT_P (XEXP (XEXP (x, 0), 1)))
    7720         3763 :        x = XEXP (XEXP (x, 0), 0);
    7721              : 
    7722       246755 :       if (GET_CODE (x) == SYMBOL_REF)
    7723              :        {
    7724        30921 :          decl = SYMBOL_REF_DECL (x);
    7725        30921 :          if (decl
    7726        30921 :              && (TREE_CODE (decl) != FUNCTION_DECL
    7727         7419 :                  || !DECL_COMDAT_GROUP (decl)
    7728         5333 :                  || TREE_PUBLIC (decl)))
    7729              :            decl = nullptr;
    7730              :        }
    7731              :     }
    7732              : 
    7733              :   /* ??? Handle small data here somehow.  */
    7734              : 
    7735       246755 :   if (reloc & targetm.asm_out.reloc_rw_mask ())
    7736              :     {
    7737          255 :       if (decl)
    7738              :         {
    7739            0 :           prefix = reloc == 1 ? ".data.rel.ro.local" : ".data.rel.ro";
    7740              :           flags = SECTION_WRITE | SECTION_RELRO;
    7741              :         }
    7742          255 :       else if (reloc == 1)
    7743          249 :         return get_named_section (NULL, ".data.rel.ro.local", 1);
    7744              :       else
    7745            6 :         return get_named_section (NULL, ".data.rel.ro", 3);
    7746              :     }
    7747              : 
    7748       246500 :   if (decl)
    7749              :     {
    7750           16 :       const char *comdat = IDENTIFIER_POINTER (DECL_COMDAT_GROUP (decl));
    7751           16 :       if (!prefix)
    7752           16 :         prefix = ".rodata";
    7753           16 :       size_t prefix_len = strlen (prefix);
    7754           16 :       size_t comdat_len = strlen (comdat);
    7755           16 :       size_t len = prefix_len + sizeof (".pool.") + comdat_len;
    7756           16 :       char *name = XALLOCAVEC (char, len);
    7757           16 :       memcpy (name, prefix, prefix_len);
    7758           16 :       memcpy (name + prefix_len, ".pool.", sizeof (".pool.") - 1);
    7759           16 :       memcpy (name + prefix_len + sizeof (".pool.") - 1, comdat,
    7760              :               comdat_len + 1);
    7761           16 :       return get_section (name, flags | SECTION_LINKONCE, decl);
    7762              :     }
    7763              : 
    7764       246484 :   return mergeable_constant_section (mode, align, 0);
    7765              : }
    7766              : 
    7767              : /* Set the generally applicable flags on the SYMBOL_REF for EXP.  */
    7768              : 
    7769              : void
    7770      9919141 : default_encode_section_info (tree decl, rtx rtl, int first ATTRIBUTE_UNUSED)
    7771              : {
    7772      9919141 :   rtx symbol;
    7773      9919141 :   int flags;
    7774              : 
    7775              :   /* Careful not to prod global register variables.  */
    7776      9919141 :   if (!MEM_P (rtl))
    7777              :     return;
    7778      9919141 :   symbol = XEXP (rtl, 0);
    7779      9919141 :   if (GET_CODE (symbol) != SYMBOL_REF)
    7780              :     return;
    7781              : 
    7782      9919141 :   flags = SYMBOL_REF_FLAGS (symbol) & SYMBOL_FLAG_HAS_BLOCK_INFO;
    7783      9919141 :   if (TREE_CODE (decl) == FUNCTION_DECL)
    7784      5398891 :     flags |= SYMBOL_FLAG_FUNCTION;
    7785      9919141 :   if (targetm.binds_local_p (decl))
    7786      5624455 :     flags |= SYMBOL_FLAG_LOCAL;
    7787      9919141 :   if (VAR_P (decl) && DECL_THREAD_LOCAL_P (decl))
    7788         4528 :     flags |= DECL_TLS_MODEL (decl) << SYMBOL_FLAG_TLS_SHIFT;
    7789      9914613 :   else if (targetm.in_small_data_p (decl))
    7790            0 :     flags |= SYMBOL_FLAG_SMALL;
    7791              :   /* ??? Why is DECL_EXTERNAL ever set for non-PUBLIC names?  Without
    7792              :      being PUBLIC, the thing *must* be defined in this translation unit.
    7793              :      Prevent this buglet from being propagated into rtl code as well.  */
    7794      9919141 :   if (DECL_P (decl) && DECL_EXTERNAL (decl) && TREE_PUBLIC (decl))
    7795      4130364 :     flags |= SYMBOL_FLAG_EXTERNAL;
    7796              : 
    7797      9919141 :   SYMBOL_REF_FLAGS (symbol) = flags;
    7798              : }
    7799              : 
    7800              : /* By default, we do nothing for encode_section_info, so we need not
    7801              :    do anything but discard the '*' marker.  */
    7802              : 
    7803              : const char *
    7804    404449589 : default_strip_name_encoding (const char *str)
    7805              : {
    7806    404449589 :   return str + (*str == '*');
    7807              : }
    7808              : 
    7809              : #ifdef ASM_OUTPUT_DEF
    7810              : /* The default implementation of TARGET_ASM_OUTPUT_ANCHOR.  Define the
    7811              :    anchor relative to ".", the current section position.  */
    7812              : 
    7813              : void
    7814            0 : default_asm_output_anchor (rtx symbol)
    7815              : {
    7816            0 :   gcc_checking_assert (TARGET_SUPPORTS_ALIASES);
    7817              : 
    7818            0 :   char buffer[100];
    7819              : 
    7820            0 :   sprintf (buffer, "*. + " HOST_WIDE_INT_PRINT_DEC,
    7821              :            SYMBOL_REF_BLOCK_OFFSET (symbol));
    7822            0 :   ASM_OUTPUT_DEF (asm_out_file, XSTR (symbol, 0), buffer);
    7823            0 : }
    7824              : #endif
    7825              : 
    7826              : /* The default implementation of TARGET_USE_ANCHORS_FOR_SYMBOL_P.  */
    7827              : 
    7828              : bool
    7829            0 : default_use_anchors_for_symbol_p (const_rtx symbol)
    7830              : {
    7831            0 :   tree decl;
    7832            0 :   section *sect = SYMBOL_REF_BLOCK (symbol)->sect;
    7833              : 
    7834              :   /* This function should only be called with non-zero SYMBOL_REF_BLOCK,
    7835              :      furthermore get_block_for_section should not create object blocks
    7836              :      for mergeable sections.  */
    7837            0 :   gcc_checking_assert (sect && !(sect->common.flags & SECTION_MERGE));
    7838              : 
    7839              :   /* Don't use anchors for small data sections.  The small data register
    7840              :      acts as an anchor for such sections.  */
    7841            0 :   if (sect->common.flags & SECTION_SMALL)
    7842              :     return false;
    7843              : 
    7844            0 :   decl = SYMBOL_REF_DECL (symbol);
    7845            0 :   if (decl && DECL_P (decl))
    7846              :     {
    7847              :       /* Don't use section anchors for decls that might be defined or
    7848              :          usurped by other modules.  */
    7849            0 :       if (TREE_PUBLIC (decl) && !decl_binds_to_current_def_p (decl))
    7850              :         return false;
    7851              : 
    7852              :       /* Don't use section anchors for decls that will be placed in a
    7853              :          small data section.  */
    7854              :       /* ??? Ideally, this check would be redundant with the SECTION_SMALL
    7855              :          one above.  The problem is that we only use SECTION_SMALL for
    7856              :          sections that should be marked as small in the section directive.  */
    7857            0 :       if (targetm.in_small_data_p (decl))
    7858              :         return false;
    7859              : 
    7860              :       /* Don't use section anchors for decls that won't fit inside a single
    7861              :          anchor range to reduce the amount of instructions required to refer
    7862              :          to the entire declaration.  */
    7863            0 :       if (DECL_SIZE_UNIT (decl) == NULL_TREE
    7864            0 :           || !tree_fits_uhwi_p (DECL_SIZE_UNIT (decl))
    7865            0 :           || (tree_to_uhwi (DECL_SIZE_UNIT (decl))
    7866            0 :               >= (unsigned HOST_WIDE_INT) targetm.max_anchor_offset))
    7867              :         return false;
    7868              : 
    7869              :     }
    7870              :   return true;
    7871              : }
    7872              : 
    7873              : /* Return true when RESOLUTION indicate that symbol will be bound to the
    7874              :    definition provided by current .o file.  */
    7875              : 
    7876              : static bool
    7877    288025732 : resolution_to_local_definition_p (enum ld_plugin_symbol_resolution resolution)
    7878              : {
    7879    288025732 :   return (resolution == LDPR_PREVAILING_DEF
    7880    288025732 :           || resolution == LDPR_PREVAILING_DEF_IRONLY_EXP
    7881            0 :           || resolution == LDPR_PREVAILING_DEF_IRONLY);
    7882              : }
    7883              : 
    7884              : /* Return true when RESOLUTION indicate that symbol will be bound locally
    7885              :    within current executable or DSO.  */
    7886              : 
    7887              : static bool
    7888    287079655 : resolution_local_p (enum ld_plugin_symbol_resolution resolution)
    7889              : {
    7890    287079655 :   return (resolution == LDPR_PREVAILING_DEF
    7891    287079655 :           || resolution == LDPR_PREVAILING_DEF_IRONLY
    7892    287079655 :           || resolution == LDPR_PREVAILING_DEF_IRONLY_EXP
    7893              :           || resolution == LDPR_PREEMPTED_REG
    7894    287079655 :           || resolution == LDPR_PREEMPTED_IR
    7895              :           || resolution == LDPR_RESOLVED_IR
    7896    574159302 :           || resolution == LDPR_RESOLVED_EXEC);
    7897              : }
    7898              : 
    7899              : /* COMMON_LOCAL_P is true means that the linker can guarantee that an
    7900              :    uninitialized common symbol in the executable will still be defined
    7901              :    (through COPY relocation) in the executable.  */
    7902              : 
    7903              : bool
    7904    773860184 : default_binds_local_p_3 (const_tree exp, bool shlib, bool weak_dominate,
    7905              :                          bool extern_protected_data, bool common_local_p)
    7906              : {
    7907              :   /* A non-decl is an entry in the constant pool.  */
    7908    773860184 :   if (!DECL_P (exp))
    7909              :     return true;
    7910              : 
    7911              :   /* Weakrefs may not bind locally, even though the weakref itself is always
    7912              :      static and therefore local.  Similarly, the resolver for ifunc functions
    7913              :      might resolve to a non-local function.
    7914              :      FIXME: We can resolve the weakref case more curefuly by looking at the
    7915              :      weakref alias.  */
    7916    770343298 :   if (lookup_attribute ("weakref", DECL_ATTRIBUTES (exp))
    7917    770343298 :       || (!targetm.ifunc_ref_local_ok ()
    7918     54623776 :           && TREE_CODE (exp) == FUNCTION_DECL
    7919     21686296 :           && cgraph_node::get (exp)
    7920     20659508 :           && cgraph_node::get (exp)->ifunc_resolver))
    7921         7656 :     return false;
    7922              : 
    7923              :   /* Static variables are always local.  */
    7924    770335642 :   if (! TREE_PUBLIC (exp))
    7925              :     return true;
    7926              : 
    7927              :   /* With resolution file in hand, take look into resolutions.
    7928              :      We can't just return true for resolved_locally symbols,
    7929              :      because dynamic linking might overwrite symbols
    7930              :      in shared libraries.  */
    7931    619269858 :   bool resolved_locally = false;
    7932              : 
    7933    619269858 :   bool uninited_common = (DECL_COMMON (exp)
    7934    619269858 :                           && (DECL_INITIAL (exp) == NULL
    7935       236391 :                               || (!in_lto_p
    7936       236391 :                                   && DECL_INITIAL (exp) == error_mark_node)));
    7937              : 
    7938              :   /* A non-external variable is defined locally only if it isn't
    7939              :      uninitialized COMMON variable or common_local_p is true.  */
    7940    619269858 :   bool defined_locally = (!DECL_EXTERNAL (exp)
    7941    619269858 :                           && (!uninited_common || common_local_p));
    7942    619269858 :   if (symtab_node *node = symtab_node::get (exp))
    7943              :     {
    7944    603146944 :       if (node->in_other_partition)
    7945         3844 :         defined_locally = true;
    7946    603146944 :       if (node->can_be_discarded_p ())
    7947              :         ;
    7948    287561284 :       else if (resolution_to_local_definition_p (node->resolution))
    7949              :         defined_locally = resolved_locally = true;
    7950    287079655 :       else if (resolution_local_p (node->resolution))
    7951    619269858 :         resolved_locally = true;
    7952              :     }
    7953    619269858 :   if (defined_locally && weak_dominate && !shlib)
    7954    619269858 :     resolved_locally = true;
    7955              : 
    7956              :   /* Undefined weak symbols are never defined locally.  */
    7957    619269858 :   if (DECL_WEAK (exp) && !defined_locally)
    7958              :     return false;
    7959              : 
    7960              :   /* A symbol is local if the user has said explicitly that it will be,
    7961              :      or if we have a definition for the symbol.  We cannot infer visibility
    7962              :      for undefined symbols.  */
    7963    619192945 :   if (DECL_VISIBILITY (exp) != VISIBILITY_DEFAULT
    7964     11125990 :       && (TREE_CODE (exp) == FUNCTION_DECL
    7965       996431 :           || !extern_protected_data
    7966       996383 :           || DECL_VISIBILITY (exp) != VISIBILITY_PROTECTED)
    7967    630318893 :       && (DECL_VISIBILITY_SPECIFIED (exp) || defined_locally))
    7968              :     return true;
    7969              : 
    7970              :   /* If PIC, then assume that any global name can be overridden by
    7971              :      symbols resolved from other modules.  */
    7972    614018125 :   if (shlib)
    7973              :     return false;
    7974              : 
    7975              :   /* Variables defined outside this object might not be local.  */
    7976    515778891 :   if (DECL_EXTERNAL (exp) && !resolved_locally)
    7977              :     return false;
    7978              : 
    7979              :   /* Non-dominant weak symbols are not defined locally.  */
    7980    299354285 :   if (DECL_WEAK (exp) && !resolved_locally)
    7981              :     return false;
    7982              : 
    7983              :   /* Uninitialized COMMON variable may be unified with symbols
    7984              :      resolved from other modules.  */
    7985    299354285 :   if (uninited_common && !resolved_locally)
    7986              :     return false;
    7987              : 
    7988              :   /* Otherwise we're left with initialized (or non-common) global data
    7989              :      which is of necessity defined locally.  */
    7990              :   return true;
    7991              : }
    7992              : 
    7993              : /* Assume ELF-ish defaults, since that's pretty much the most liberal
    7994              :    wrt cross-module name binding.  */
    7995              : 
    7996              : bool
    7997            0 : default_binds_local_p (const_tree exp)
    7998              : {
    7999            0 :   return default_binds_local_p_3 (exp, flag_shlib != 0, true, false, false);
    8000              : }
    8001              : 
    8002              : /* Similar to default_binds_local_p, but common symbol may be local and
    8003              :    extern protected data is non-local.  */
    8004              : 
    8005              : bool
    8006            0 : default_binds_local_p_2 (const_tree exp)
    8007              : {
    8008            0 :   return default_binds_local_p_3 (exp, flag_shlib != 0, true, true,
    8009            0 :                                   !flag_pic);
    8010              : }
    8011              : 
    8012              : bool
    8013            0 : default_binds_local_p_1 (const_tree exp, int shlib)
    8014              : {
    8015            0 :   return default_binds_local_p_3 (exp, shlib != 0, false, false, false);
    8016              : }
    8017              : 
    8018              : /* Return true when references to DECL must bind to current definition in
    8019              :    final executable.
    8020              : 
    8021              :    The condition is usually equivalent to whether the function binds to the
    8022              :    current module (shared library or executable), that is to binds_local_p.
    8023              :    We use this fact to avoid need for another target hook and implement
    8024              :    the logic using binds_local_p and just special cases where
    8025              :    decl_binds_to_current_def_p is stronger than binds_local_p.  In particular
    8026              :    the weak definitions (that can be overwritten at linktime by other
    8027              :    definition from different object file) and when resolution info is available
    8028              :    we simply use the knowledge passed to us by linker plugin.  */
    8029              : bool
    8030    751795734 : decl_binds_to_current_def_p (const_tree decl)
    8031              : {
    8032    751795734 :   gcc_assert (DECL_P (decl));
    8033    751795734 :   if (!targetm.binds_local_p (decl))
    8034              :     return false;
    8035    445721495 :   if (!TREE_PUBLIC (decl))
    8036              :     return true;
    8037              : 
    8038              :   /* When resolution is available, just use it.  */
    8039    299267338 :   if (symtab_node *node = symtab_node::get (decl))
    8040              :     {
    8041    299261508 :       if (node->resolution != LDPR_UNKNOWN
    8042    299261508 :           && !node->can_be_discarded_p ())
    8043       464448 :         return resolution_to_local_definition_p (node->resolution);
    8044              :     }
    8045              : 
    8046              :   /* Otherwise we have to assume the worst for DECL_WEAK (hidden weaks
    8047              :      binds locally but still can be overwritten), DECL_COMMON (can be merged
    8048              :      with a non-common definition somewhere in the same module) or
    8049              :      DECL_EXTERNAL.
    8050              :      This rely on fact that binds_local_p behave as decl_replaceable_p
    8051              :      for all other declaration types.  */
    8052    298802890 :   if (DECL_WEAK (decl))
    8053              :     return false;
    8054    222728869 :   if (DECL_COMDAT_GROUP (decl))
    8055              :     return false;
    8056    222724931 :   if (DECL_COMMON (decl)
    8057    222724931 :       && (DECL_INITIAL (decl) == NULL
    8058            6 :           || (!in_lto_p && DECL_INITIAL (decl) == error_mark_node)))
    8059              :     return false;
    8060    221832225 :   if (DECL_EXTERNAL (decl))
    8061              :     return false;
    8062              :   return true;
    8063              : }
    8064              : 
    8065              : /* A replaceable function or variable is one which may be replaced
    8066              :    at link-time with an entirely different definition, provided that the
    8067              :    replacement has the same type.  For example, functions declared
    8068              :    with __attribute__((weak)) on most systems are replaceable.
    8069              :    If SEMANTIC_INTERPOSITION_P is false allow interposition only on
    8070              :    symbols explicitly declared weak.
    8071              : 
    8072              :    COMDAT functions are not replaceable, since all definitions of the
    8073              :    function must be equivalent.  It is important that COMDAT functions
    8074              :    not be treated as replaceable so that use of C++ template
    8075              :    instantiations is not penalized.  */
    8076              : 
    8077              : bool
    8078    229669689 : decl_replaceable_p (tree decl, bool semantic_interposition_p)
    8079              : {
    8080    229669689 :   gcc_assert (DECL_P (decl));
    8081    229669689 :   if (!TREE_PUBLIC (decl) || DECL_COMDAT (decl))
    8082              :     return false;
    8083    168579291 :   if (!semantic_interposition_p
    8084    168579291 :       && !DECL_WEAK (decl))
    8085              :     return false;
    8086    168392163 :   return !decl_binds_to_current_def_p (decl);
    8087              : }
    8088              : 
    8089              : /* Default function to output code that will globalize a label.  A
    8090              :    target must define GLOBAL_ASM_OP or provide its own function to
    8091              :    globalize a label.  */
    8092              : #ifdef GLOBAL_ASM_OP
    8093              : void
    8094      2165556 : default_globalize_label (FILE * stream, const char *name)
    8095              : {
    8096      2165556 :   fputs (GLOBAL_ASM_OP, stream);
    8097      2165556 :   assemble_name (stream, name);
    8098      2165556 :   putc ('\n', stream);
    8099      2165556 : }
    8100              : #endif /* GLOBAL_ASM_OP */
    8101              : 
    8102              : /* Default function to output code that will globalize a declaration.  */
    8103              : void
    8104      2135170 : default_globalize_decl_name (FILE * stream, tree decl)
    8105              : {
    8106      2135170 :   const char *name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
    8107      2135170 :   targetm.asm_out.globalize_label (stream, name);
    8108      2135170 : }
    8109              : 
    8110              : /* Default function to output a label for unwind information.  The
    8111              :    default is to do nothing.  A target that needs nonlocal labels for
    8112              :    unwind information must provide its own function to do this.  */
    8113              : void
    8114           52 : default_emit_unwind_label (FILE * stream ATTRIBUTE_UNUSED,
    8115              :                            tree decl ATTRIBUTE_UNUSED,
    8116              :                            int for_eh ATTRIBUTE_UNUSED,
    8117              :                            int empty ATTRIBUTE_UNUSED)
    8118              : {
    8119           52 : }
    8120              : 
    8121              : /* Default function to output a label to divide up the exception table.
    8122              :    The default is to do nothing.  A target that needs/wants to divide
    8123              :    up the table must provide it's own function to do this.  */
    8124              : void
    8125        76326 : default_emit_except_table_label (FILE * stream ATTRIBUTE_UNUSED)
    8126              : {
    8127        76326 : }
    8128              : 
    8129              : /* This is how to output an internal numbered label where PREFIX is
    8130              :    the class of label and LABELNO is the number within the class.  */
    8131              : 
    8132              : void
    8133         4349 : default_generate_internal_label (char *buf, const char *prefix,
    8134              :                                  unsigned long labelno)
    8135              : {
    8136         4349 :   ASM_GENERATE_INTERNAL_LABEL (buf, prefix, labelno);
    8137         4349 : }
    8138              : 
    8139              : /* This is how to output an internal numbered label where PREFIX is
    8140              :    the class of label and LABELNO is the number within the class.  */
    8141              : 
    8142              : void
    8143     73927719 : default_internal_label (FILE *stream, const char *prefix,
    8144              :                         unsigned long labelno)
    8145              : {
    8146     73927719 :   char *const buf = (char *) alloca (40 + strlen (prefix));
    8147     73927719 :   ASM_GENERATE_INTERNAL_LABEL (buf, prefix, labelno);
    8148     73927719 :   ASM_OUTPUT_INTERNAL_LABEL (stream, buf);
    8149     73927719 : }
    8150              : 
    8151              : 
    8152              : /* The default implementation of ASM_DECLARE_CONSTANT_NAME.  */
    8153              : 
    8154              : void
    8155      1274766 : default_asm_declare_constant_name (FILE *file, const char *name,
    8156              :                                    const_tree exp ATTRIBUTE_UNUSED,
    8157              :                                    HOST_WIDE_INT size ATTRIBUTE_UNUSED)
    8158              : {
    8159      1274766 :   assemble_label (file, name);
    8160      1274766 : }
    8161              : 
    8162              : /* This is the default behavior at the beginning of a file.  It's
    8163              :    controlled by two other target-hook toggles.  */
    8164              : void
    8165       273142 : default_file_start (void)
    8166              : {
    8167       273142 :   if (targetm.asm_file_start_app_off
    8168            0 :       && !(flag_verbose_asm || flag_debug_asm || flag_dump_rtl_in_asm))
    8169            0 :     fputs (ASM_APP_OFF, asm_out_file);
    8170              : 
    8171       273142 :   if (targetm.asm_file_start_file_directive)
    8172              :     {
    8173              :       /* LTO produced units have no meaningful main_input_filename.  */
    8174       273142 :       if (in_lto_p)
    8175        12622 :         output_file_directive (asm_out_file, "<artificial>");
    8176              :       else
    8177       260520 :         output_file_directive (asm_out_file, main_input_filename);
    8178              :     }
    8179       273142 : }
    8180              : 
    8181              : /* This is a generic routine suitable for use as TARGET_ASM_FILE_END
    8182              :    which emits a special section directive used to indicate whether or
    8183              :    not this object file needs an executable stack.  This is primarily
    8184              :    a GNU extension to ELF but could be used on other targets.  */
    8185              : 
    8186              : int trampolines_created;
    8187              : 
    8188              : void
    8189       244617 : file_end_indicate_exec_stack (void)
    8190              : {
    8191       244617 :   unsigned int flags = SECTION_DEBUG;
    8192       244617 :   if (trampolines_created)
    8193          237 :     flags |= SECTION_CODE;
    8194              : 
    8195       244617 :   switch_to_section (get_section (".note.GNU-stack", flags, NULL));
    8196       244617 : }
    8197              : 
    8198              : /* Emit a special section directive to indicate that this object file
    8199              :    was compiled with -fsplit-stack.  This is used to let the linker
    8200              :    detect calls between split-stack code and non-split-stack code, so
    8201              :    that it can modify the split-stack code to allocate a sufficiently
    8202              :    large stack.  We emit another special section if there are any
    8203              :    functions in this file which have the no_split_stack attribute, to
    8204              :    prevent the linker from warning about being unable to convert the
    8205              :    functions if they call non-split-stack code.  */
    8206              : 
    8207              : void
    8208         4710 : file_end_indicate_split_stack (void)
    8209              : {
    8210         4710 :   if (flag_split_stack)
    8211              :     {
    8212         4710 :       switch_to_section (get_section (".note.GNU-split-stack", SECTION_DEBUG,
    8213              :                                       NULL));
    8214         4710 :       if (saw_no_split_stack)
    8215          399 :         switch_to_section (get_section (".note.GNU-no-split-stack",
    8216              :                                         SECTION_DEBUG, NULL));
    8217              :     }
    8218         4710 : }
    8219              : 
    8220              : /* Output DIRECTIVE (a C string) followed by a newline.  This is used as
    8221              :    a get_unnamed_section callback.  */
    8222              : 
    8223              : void
    8224      1772349 : output_section_asm_op (const char *directive)
    8225              : {
    8226      1772349 :   fprintf (asm_out_file, "%s\n", directive);
    8227      1772349 : }
    8228              : 
    8229              : /* Emit assembly code to switch to section NEW_SECTION.  Do nothing if
    8230              :    the current section is NEW_SECTION.  */
    8231              : 
    8232              : void
    8233     98256841 : switch_to_section (section *new_section, tree decl)
    8234              : {
    8235     98256841 :   bool retain_p;
    8236     98256841 :   if ((new_section->common.flags & SECTION_NAMED)
    8237     71010574 :       && decl != nullptr
    8238      1846992 :       && DECL_P (decl)
    8239    100103833 :       && ((retain_p = !!lookup_attribute ("retain",
    8240      1846992 :                                           DECL_ATTRIBUTES (decl)))
    8241      1846992 :           != !!(new_section->common.flags & SECTION_RETAIN)))
    8242              :     {
    8243              :       /* If the SECTION_RETAIN bit doesn't match, switch to a new
    8244              :          section.  */
    8245           24 :       tree used_decl, no_used_decl;
    8246              : 
    8247           24 :       if (retain_p)
    8248              :         {
    8249           12 :           new_section->common.flags |= SECTION_RETAIN;
    8250           12 :           used_decl = decl;
    8251           12 :           no_used_decl = new_section->named.decl;
    8252              :         }
    8253              :       else
    8254              :         {
    8255           12 :           new_section->common.flags &= ~(SECTION_RETAIN
    8256              :                                          | SECTION_DECLARED);
    8257           12 :           used_decl = new_section->named.decl;
    8258           12 :           no_used_decl = decl;
    8259              :         }
    8260           24 :       if (no_used_decl != used_decl)
    8261              :         {
    8262           24 :           warning (OPT_Wattributes,
    8263              :                    "%+qD without %<retain%> attribute and %qD with "
    8264              :                    "%<retain%> attribute are placed in a section with "
    8265              :                    "the same name", no_used_decl, used_decl);
    8266           24 :           inform (DECL_SOURCE_LOCATION (used_decl),
    8267              :                   "%qD was declared here", used_decl);
    8268              :         }
    8269              :     }
    8270     98256817 :   else if (in_section == new_section)
    8271              :     return;
    8272              : 
    8273      5352016 :   in_section = new_section;
    8274              : 
    8275      5352016 :   switch (SECTION_STYLE (new_section))
    8276              :     {
    8277      3579667 :     case SECTION_NAMED:
    8278      3579667 :       targetm.asm_out.named_section (new_section->named.name,
    8279              :                                      new_section->named.common.flags,
    8280              :                                      new_section->named.decl);
    8281      3579667 :       break;
    8282              : 
    8283      1772349 :     case SECTION_UNNAMED:
    8284      1772349 :       new_section->unnamed.callback (new_section->unnamed.data);
    8285      1772349 :       break;
    8286              : 
    8287            0 :     case SECTION_NOSWITCH:
    8288            0 :       gcc_unreachable ();
    8289      5352016 :       break;
    8290              :     }
    8291              : 
    8292      5352016 :   new_section->common.flags |= SECTION_DECLARED;
    8293              : }
    8294              : 
    8295              : /* If block symbol SYMBOL has not yet been assigned an offset, place
    8296              :    it at the end of its block.  */
    8297              : 
    8298              : void
    8299            0 : place_block_symbol (rtx symbol)
    8300              : {
    8301            0 :   unsigned HOST_WIDE_INT size, mask, offset;
    8302            0 :   class constant_descriptor_rtx *desc;
    8303            0 :   unsigned int alignment;
    8304            0 :   struct object_block *block;
    8305            0 :   tree decl;
    8306              : 
    8307            0 :   gcc_assert (SYMBOL_REF_BLOCK (symbol));
    8308            0 :   if (SYMBOL_REF_BLOCK_OFFSET (symbol) >= 0)
    8309              :     return;
    8310              : 
    8311              :   /* Work out the symbol's size and alignment.  */
    8312            0 :   if (CONSTANT_POOL_ADDRESS_P (symbol))
    8313              :     {
    8314            0 :       desc = SYMBOL_REF_CONSTANT (symbol);
    8315            0 :       alignment = desc->align;
    8316            0 :       size = GET_MODE_SIZE (desc->mode);
    8317              :     }
    8318            0 :   else if (TREE_CONSTANT_POOL_ADDRESS_P (symbol))
    8319              :     {
    8320            0 :       decl = SYMBOL_REF_DECL (symbol);
    8321            0 :       gcc_checking_assert (DECL_IN_CONSTANT_POOL (decl));
    8322            0 :       alignment = DECL_ALIGN (decl);
    8323            0 :       size = get_constant_size (DECL_INITIAL (decl));
    8324            0 :       if ((flag_sanitize & SANITIZE_ADDRESS)
    8325            0 :           && TREE_CODE (DECL_INITIAL (decl)) == STRING_CST
    8326            0 :           && asan_protect_global (DECL_INITIAL (decl)))
    8327              :         {
    8328            0 :           size += asan_red_zone_size (size);
    8329            0 :           alignment = MAX (alignment,
    8330              :                            ASAN_RED_ZONE_SIZE * BITS_PER_UNIT);
    8331              :         }
    8332              :     }
    8333              :   else
    8334              :     {
    8335            0 :       struct symtab_node *snode;
    8336            0 :       decl = SYMBOL_REF_DECL (symbol);
    8337              : 
    8338            0 :       snode = symtab_node::get (decl);
    8339            0 :       if (snode->alias)
    8340              :         {
    8341            0 :           rtx target = DECL_RTL (snode->ultimate_alias_target ()->decl);
    8342              : 
    8343            0 :           gcc_assert (MEM_P (target)
    8344              :                       && GET_CODE (XEXP (target, 0)) == SYMBOL_REF
    8345              :                       && SYMBOL_REF_HAS_BLOCK_INFO_P (XEXP (target, 0)));
    8346            0 :           target = XEXP (target, 0);
    8347            0 :           place_block_symbol (target);
    8348            0 :           SYMBOL_REF_BLOCK_OFFSET (symbol) = SYMBOL_REF_BLOCK_OFFSET (target);
    8349            0 :           return;
    8350              :         }
    8351            0 :       alignment = get_variable_align (decl);
    8352            0 :       size = tree_to_uhwi (DECL_SIZE_UNIT (decl));
    8353            0 :       if ((flag_sanitize & SANITIZE_ADDRESS)
    8354            0 :           && asan_protect_global (decl))
    8355              :         {
    8356            0 :           size += asan_red_zone_size (size);
    8357            0 :           alignment = MAX (alignment,
    8358              :                            ASAN_RED_ZONE_SIZE * BITS_PER_UNIT);
    8359              :         }
    8360              :     }
    8361              : 
    8362              :   /* Calculate the object's offset from the start of the block.  */
    8363            0 :   block = SYMBOL_REF_BLOCK (symbol);
    8364            0 :   mask = alignment / BITS_PER_UNIT - 1;
    8365            0 :   offset = (block->size + mask) & ~mask;
    8366            0 :   SYMBOL_REF_BLOCK_OFFSET (symbol) = offset;
    8367              : 
    8368              :   /* Record the block's new alignment and size.  */
    8369            0 :   block->alignment = MAX (block->alignment, alignment);
    8370            0 :   block->size = offset + size;
    8371              : 
    8372            0 :   vec_safe_push (block->objects, symbol);
    8373              : }
    8374              : 
    8375              : /* Return the anchor that should be used to address byte offset OFFSET
    8376              :    from the first object in BLOCK.  MODEL is the TLS model used
    8377              :    to access it.  */
    8378              : 
    8379              : rtx
    8380            0 : get_section_anchor (struct object_block *block, HOST_WIDE_INT offset,
    8381              :                     enum tls_model model)
    8382              : {
    8383            0 :   char label[100];
    8384            0 :   unsigned int begin, middle, end;
    8385            0 :   unsigned HOST_WIDE_INT min_offset, max_offset, range, bias, delta;
    8386            0 :   rtx anchor;
    8387              : 
    8388              :   /* Work out the anchor's offset.  Use an offset of 0 for the first
    8389              :      anchor so that we don't pessimize the case where we take the address
    8390              :      of a variable at the beginning of the block.  This is particularly
    8391              :      useful when a block has only one variable assigned to it.
    8392              : 
    8393              :      We try to place anchors RANGE bytes apart, so there can then be
    8394              :      anchors at +/-RANGE, +/-2 * RANGE, and so on, up to the limits of
    8395              :      a ptr_mode offset.  With some target settings, the lowest such
    8396              :      anchor might be out of range for the lowest ptr_mode offset;
    8397              :      likewise the highest anchor for the highest offset.  Use anchors
    8398              :      at the extreme ends of the ptr_mode range in such cases.
    8399              : 
    8400              :      All arithmetic uses unsigned integers in order to avoid
    8401              :      signed overflow.  */
    8402            0 :   max_offset = (unsigned HOST_WIDE_INT) targetm.max_anchor_offset;
    8403            0 :   min_offset = (unsigned HOST_WIDE_INT) targetm.min_anchor_offset;
    8404            0 :   range = max_offset - min_offset + 1;
    8405            0 :   if (range == 0)
    8406              :     offset = 0;
    8407              :   else
    8408              :     {
    8409            0 :       bias = HOST_WIDE_INT_1U << (GET_MODE_BITSIZE (ptr_mode) - 1);
    8410            0 :       if (offset < 0)
    8411              :         {
    8412            0 :           delta = -(unsigned HOST_WIDE_INT) offset + max_offset;
    8413            0 :           delta -= delta % range;
    8414            0 :           if (delta > bias)
    8415              :             delta = bias;
    8416            0 :           offset = (HOST_WIDE_INT) (-delta);
    8417              :         }
    8418              :       else
    8419              :         {
    8420            0 :           delta = (unsigned HOST_WIDE_INT) offset - min_offset;
    8421            0 :           delta -= delta % range;
    8422            0 :           if (delta > bias - 1)
    8423              :             delta = bias - 1;
    8424            0 :           offset = (HOST_WIDE_INT) delta;
    8425              :         }
    8426              :     }
    8427              : 
    8428              :   /* Do a binary search to see if there's already an anchor we can use.
    8429              :      Set BEGIN to the new anchor's index if not.  */
    8430            0 :   begin = 0;
    8431            0 :   end = vec_safe_length (block->anchors);
    8432            0 :   while (begin != end)
    8433              :     {
    8434            0 :       middle = (end + begin) / 2;
    8435            0 :       anchor = (*block->anchors)[middle];
    8436            0 :       if (SYMBOL_REF_BLOCK_OFFSET (anchor) > offset)
    8437              :         end = middle;
    8438            0 :       else if (SYMBOL_REF_BLOCK_OFFSET (anchor) < offset)
    8439            0 :         begin = middle + 1;
    8440            0 :       else if (SYMBOL_REF_TLS_MODEL (anchor) > model)
    8441              :         end = middle;
    8442            0 :       else if (SYMBOL_REF_TLS_MODEL (anchor) < model)
    8443            0 :         begin = middle + 1;
    8444              :       else
    8445              :         return anchor;
    8446              :     }
    8447              : 
    8448              :   /* Create a new anchor with a unique label.  */
    8449            0 :   ASM_GENERATE_INTERNAL_LABEL (label, "LANCHOR", anchor_labelno++);
    8450            0 :   anchor = create_block_symbol (ggc_strdup (label), block, offset);
    8451            0 :   SYMBOL_REF_FLAGS (anchor) |= SYMBOL_FLAG_LOCAL | SYMBOL_FLAG_ANCHOR;
    8452            0 :   SYMBOL_REF_FLAGS (anchor) |= model << SYMBOL_FLAG_TLS_SHIFT;
    8453              : 
    8454              :   /* Insert it at index BEGIN.  */
    8455            0 :   vec_safe_insert (block->anchors, begin, anchor);
    8456            0 :   return anchor;
    8457              : }
    8458              : 
    8459              : /* Output the objects in BLOCK.  */
    8460              : 
    8461              : static void
    8462            0 : output_object_block (struct object_block *block)
    8463              : {
    8464            0 :   class constant_descriptor_rtx *desc;
    8465            0 :   unsigned int i;
    8466            0 :   HOST_WIDE_INT offset;
    8467            0 :   tree decl;
    8468            0 :   rtx symbol;
    8469              : 
    8470            0 :   if (!block->objects)
    8471            0 :     return;
    8472              : 
    8473              :   /* Switch to the section and make sure that the first byte is
    8474              :      suitably aligned.  */
    8475              :   /* Special case VTV comdat sections similar to assemble_variable.  */
    8476            0 :   if (SECTION_STYLE (block->sect) == SECTION_NAMED
    8477            0 :       && block->sect->named.name
    8478            0 :       && (strcmp (block->sect->named.name, ".vtable_map_vars") == 0))
    8479            0 :     handle_vtv_comdat_section (block->sect, block->sect->named.decl);
    8480              :   else
    8481            0 :     switch_to_section (block->sect, SYMBOL_REF_DECL ((*block->objects)[0]));
    8482              : 
    8483            0 :   gcc_checking_assert (!(block->sect->common.flags & SECTION_MERGE));
    8484            0 :   assemble_align (block->alignment);
    8485              : 
    8486              :   /* Define the values of all anchors relative to the current section
    8487              :      position.  */
    8488            0 :   FOR_EACH_VEC_SAFE_ELT (block->anchors, i, symbol)
    8489            0 :     targetm.asm_out.output_anchor (symbol);
    8490              : 
    8491              :   /* Output the objects themselves.  */
    8492              :   offset = 0;
    8493            0 :   FOR_EACH_VEC_ELT (*block->objects, i, symbol)
    8494              :     {
    8495              :       /* Move to the object's offset, padding with zeros if necessary.  */
    8496            0 :       assemble_zeros (SYMBOL_REF_BLOCK_OFFSET (symbol) - offset);
    8497            0 :       offset = SYMBOL_REF_BLOCK_OFFSET (symbol);
    8498            0 :       if (CONSTANT_POOL_ADDRESS_P (symbol))
    8499              :         {
    8500            0 :           desc = SYMBOL_REF_CONSTANT (symbol);
    8501              :           /* Pass 1 for align as we have already laid out everything in the block.
    8502              :              So aligning shouldn't be necessary.  */
    8503            0 :           output_constant_pool_1 (desc, 1);
    8504            0 :           offset += GET_MODE_SIZE (desc->mode);
    8505              :         }
    8506            0 :       else if (TREE_CONSTANT_POOL_ADDRESS_P (symbol))
    8507              :         {
    8508            0 :           HOST_WIDE_INT size;
    8509            0 :           decl = SYMBOL_REF_DECL (symbol);
    8510            0 :           assemble_constant_contents (DECL_INITIAL (decl), XSTR (symbol, 0),
    8511            0 :                                       DECL_ALIGN (decl), false);
    8512              : 
    8513            0 :           size = get_constant_size (DECL_INITIAL (decl));
    8514            0 :           offset += size;
    8515            0 :           if ((flag_sanitize & SANITIZE_ADDRESS)
    8516            0 :               && TREE_CODE (DECL_INITIAL (decl)) == STRING_CST
    8517            0 :               && asan_protect_global (DECL_INITIAL (decl)))
    8518              :             {
    8519            0 :               size = asan_red_zone_size (size);
    8520            0 :               assemble_zeros (size);
    8521            0 :               offset += size;
    8522              :             }
    8523              :         }
    8524              :       else
    8525              :         {
    8526            0 :           HOST_WIDE_INT size;
    8527            0 :           decl = SYMBOL_REF_DECL (symbol);
    8528            0 :           assemble_variable_contents (decl, XSTR (symbol, 0), false, false);
    8529            0 :           size = tree_to_uhwi (DECL_SIZE_UNIT (decl));
    8530            0 :           offset += size;
    8531            0 :           if ((flag_sanitize & SANITIZE_ADDRESS)
    8532            0 :               && asan_protect_global (decl))
    8533              :             {
    8534            0 :               size = asan_red_zone_size (size);
    8535            0 :               assemble_zeros (size);
    8536            0 :               offset += size;
    8537              :             }
    8538              :         }
    8539              :     }
    8540              : }
    8541              : 
    8542              : /* A callback for qsort to compare object_blocks.  */
    8543              : 
    8544              : static int
    8545            0 : output_object_block_compare (const void *x, const void *y)
    8546              : {
    8547            0 :   object_block *p1 = *(object_block * const*)x;
    8548            0 :   object_block *p2 = *(object_block * const*)y;
    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              :     return -1;
    8557              : 
    8558            0 :   if (p1->sect->common.flags & SECTION_NAMED
    8559            0 :       && p2->sect->common.flags & SECTION_NAMED)
    8560            0 :     return strcmp (p1->sect->named.name, p2->sect->named.name);
    8561              : 
    8562            0 :   unsigned f1 = p1->sect->common.flags;
    8563            0 :   unsigned f2 = p2->sect->common.flags;
    8564            0 :   if (f1 == f2)
    8565              :     return 0;
    8566            0 :   return f1 < f2 ? -1 : 1;
    8567              : }
    8568              : 
    8569              : /* Output the definitions of all object_blocks.  */
    8570              : 
    8571              : void
    8572       232630 : output_object_blocks (void)
    8573              : {
    8574       232630 :   vec<object_block *, va_heap> v;
    8575       232630 :   v.create (object_block_htab->elements ());
    8576       232630 :   object_block *obj;
    8577       232630 :   hash_table<object_block_hasher>::iterator hi;
    8578              : 
    8579       232630 :   FOR_EACH_HASH_TABLE_ELEMENT (*object_block_htab, obj, object_block *, hi)
    8580            0 :     v.quick_push (obj);
    8581              : 
    8582              :   /* Sort them in order to output them in a deterministic manner,
    8583              :      otherwise we may get .rodata sections in different orders with
    8584              :      and without -g.  */
    8585       232630 :   v.qsort (output_object_block_compare);
    8586              :   unsigned i;
    8587       232630 :   FOR_EACH_VEC_ELT (v, i, obj)
    8588            0 :     output_object_block (obj);
    8589              : 
    8590       232630 :   v.release ();
    8591       232630 : }
    8592              : 
    8593              : /* This function provides a possible implementation of the
    8594              :    TARGET_ASM_RECORD_GCC_SWITCHES target hook for ELF targets.  When triggered
    8595              :    by -frecord-gcc-switches it creates a new mergeable, string section in the
    8596              :    assembler output file called TARGET_ASM_RECORD_GCC_SWITCHES_SECTION which
    8597              :    contains the switches in ASCII format.
    8598              : 
    8599              :    FIXME: This code does not correctly handle double quote characters
    8600              :    that appear inside strings, (it strips them rather than preserving them).
    8601              :    FIXME: ASM_OUTPUT_ASCII, as defined in config/elfos.h will not emit NUL
    8602              :    characters - instead it treats them as sub-string separators.  Since
    8603              :    we want to emit NUL strings terminators into the object file we have to use
    8604              :    ASM_OUTPUT_SKIP.  */
    8605              : 
    8606              : void
    8607            0 : elf_record_gcc_switches (const char *options)
    8608              : {
    8609            0 :   section *sec = get_section (targetm.asm_out.record_gcc_switches_section,
    8610              :                               SECTION_DEBUG | SECTION_MERGE
    8611              :                               | SECTION_STRINGS | (SECTION_ENTSIZE & 1), NULL);
    8612            0 :   switch_to_section (sec);
    8613            0 :   ASM_OUTPUT_ASCII (asm_out_file, options, strlen (options) + 1);
    8614            0 : }
    8615              : 
    8616              : /* Emit text to declare externally defined symbols. It is needed to
    8617              :    properly support non-default visibility.  */
    8618              : void
    8619      1813007 : default_elf_asm_output_external (FILE *file ATTRIBUTE_UNUSED,
    8620              :                                  tree decl,
    8621              :                                  const char *name ATTRIBUTE_UNUSED)
    8622              : {
    8623              :   /* We output the name if and only if TREE_SYMBOL_REFERENCED is
    8624              :      set in order to avoid putting out names that are never really
    8625              :      used.  Always output visibility specified in the source.  */
    8626      1813007 :   if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))
    8627      1813007 :       && (DECL_VISIBILITY_SPECIFIED (decl)
    8628      1606089 :           || targetm.binds_local_p (decl)))
    8629       196566 :     maybe_assemble_visibility (decl);
    8630      1813007 : }
    8631              : 
    8632              : /* The default hook for TARGET_ASM_OUTPUT_SOURCE_FILENAME.  */
    8633              : 
    8634              : void
    8635       273142 : default_asm_output_source_filename (FILE *file, const char *name)
    8636              : {
    8637              : #ifdef ASM_OUTPUT_SOURCE_FILENAME
    8638              :   ASM_OUTPUT_SOURCE_FILENAME (file, name);
    8639              : #else
    8640       273142 :   fprintf (file, "\t.file\t");
    8641       273142 :   output_quoted_string (file, name);
    8642       273142 :   putc ('\n', file);
    8643              : #endif
    8644       273142 : }
    8645              : 
    8646              : /* Output a file name in the form wanted by System V.  */
    8647              : 
    8648              : void
    8649       273142 : output_file_directive (FILE *asm_file, const char *input_name)
    8650              : {
    8651       273142 :   int len;
    8652       273142 :   const char *na;
    8653              : 
    8654       273142 :   if (input_name == NULL)
    8655              :     input_name = "<stdin>";
    8656              :   else
    8657       273142 :     input_name = remap_debug_filename (input_name);
    8658              : 
    8659       273142 :   len = strlen (input_name);
    8660       273142 :   na = input_name + len;
    8661              : 
    8662              :   /* NA gets INPUT_NAME sans directory names.  */
    8663      3895113 :   while (na > input_name)
    8664              :     {
    8665      3865582 :       if (IS_DIR_SEPARATOR (na[-1]))
    8666              :         break;
    8667      3621971 :       na--;
    8668              :     }
    8669              : 
    8670       273142 :   targetm.asm_out.output_source_filename (asm_file, na);
    8671       273142 : }
    8672              : 
    8673              : /* Create a DEBUG_EXPR_DECL / DEBUG_EXPR pair from RTL expression
    8674              :    EXP.  */
    8675              : rtx
    8676       295266 : make_debug_expr_from_rtl (const_rtx exp)
    8677              : {
    8678       295266 :   tree ddecl = make_node (DEBUG_EXPR_DECL), type;
    8679       295266 :   machine_mode mode = GET_MODE (exp);
    8680       295266 :   rtx dval;
    8681              : 
    8682       295266 :   DECL_ARTIFICIAL (ddecl) = 1;
    8683       295266 :   if (REG_P (exp) && REG_EXPR (exp))
    8684       243470 :     type = TREE_TYPE (REG_EXPR (exp));
    8685        55807 :   else if (MEM_P (exp) && MEM_EXPR (exp))
    8686         4011 :     type = TREE_TYPE (MEM_EXPR (exp));
    8687              :   else
    8688              :     type = NULL_TREE;
    8689       247481 :   if (type && TYPE_MODE (type) == mode)
    8690       196332 :     TREE_TYPE (ddecl) = type;
    8691              :   else
    8692        98934 :     TREE_TYPE (ddecl) = lang_hooks.types.type_for_mode (mode, 1);
    8693       295266 :   SET_DECL_MODE (ddecl, mode);
    8694       295266 :   dval = gen_rtx_DEBUG_EXPR (mode);
    8695       295266 :   DEBUG_EXPR_TREE_DECL (dval) = ddecl;
    8696       295266 :   SET_DECL_RTL (ddecl, dval);
    8697       295266 :   return dval;
    8698              : }
    8699              : 
    8700              : #ifdef ELF_ASCII_ESCAPES
    8701              : /* Default ASM_OUTPUT_LIMITED_STRING for ELF targets.  */
    8702              : 
    8703              : void
    8704     25859016 : default_elf_asm_output_limited_string (FILE *f, const char *s)
    8705              : {
    8706     25859016 :   int escape;
    8707     25859016 :   unsigned char c;
    8708              : 
    8709     25859016 :   fputs (STRING_ASM_OP "\"", f);
    8710    798865066 :   while (*s != '\0')
    8711              :     {
    8712    747147034 :       c = *s;
    8713    747147034 :       escape = ELF_ASCII_ESCAPES[c];
    8714    747147034 :       switch (escape)
    8715              :         {
    8716    746947284 :         case 0:
    8717    746947284 :           putc (c, f);
    8718    746947284 :           break;
    8719        89406 :         case 1:
    8720        89406 :           putc ('\\', f);
    8721        89406 :           putc ('0'+((c>>6)&7), f);
    8722        89406 :           putc ('0'+((c>>3)&7), f);
    8723        89406 :           putc ('0'+(c&7), f);
    8724        89406 :           break;
    8725       110344 :         default:
    8726       110344 :           putc ('\\', f);
    8727       110344 :           putc (escape, f);
    8728       110344 :           break;
    8729              :         }
    8730    747147034 :       s++;
    8731              :     }
    8732     25859016 :   putc ('\"', f);
    8733     25859016 :   putc ('\n', f);
    8734     25859016 : }
    8735              : 
    8736              : /* Default ASM_OUTPUT_ASCII for ELF targets.  */
    8737              : 
    8738              : void
    8739     36084241 : default_elf_asm_output_ascii (FILE *f, const char *s, unsigned int len)
    8740              : {
    8741     36084241 :   const char *limit = s + len;
    8742     36084241 :   const char *last_null = NULL;
    8743     36084241 :   const char *last_base64 = s;
    8744     36084241 :   unsigned bytes_in_chunk = 0;
    8745     36084241 :   unsigned char c;
    8746     36084241 :   int escape;
    8747     36084241 :   bool prev_base64 = false;
    8748              : 
    8749    296587235 :   for (; s < limit; s++)
    8750              :     {
    8751    260502994 :       const char *p;
    8752              : 
    8753    260502994 :       if (bytes_in_chunk >= 60)
    8754              :         {
    8755      3283173 :           putc ('\"', f);
    8756      3283173 :           putc ('\n', f);
    8757      3283173 :           bytes_in_chunk = 0;
    8758              :         }
    8759              : 
    8760    260502994 :       if ((uintptr_t) s > (uintptr_t) last_null)
    8761              :         {
    8762   1076235651 :           for (p = s; p < limit && *p != '\0'; p++)
    8763   1039829748 :             continue;
    8764              :           last_null = p;
    8765              :         }
    8766              :       else
    8767              :         p = last_null;
    8768              : 
    8769              : #if defined(BASE64_ASM_OP) \
    8770              :     && BITS_PER_UNIT == 8 \
    8771              :     && CHAR_BIT == 8 \
    8772              :     && 'A' == 65 \
    8773              :     && 'a' == 97 \
    8774              :     && '0' == 48 \
    8775              :     && '+' == 43 \
    8776              :     && '/' == 47 \
    8777              :     && '=' == 61
    8778    260502994 :       if (s >= last_base64)
    8779              :         {
    8780              :           unsigned cnt = 0;
    8781              :           unsigned char prev_c = ' ';
    8782              :           const char *t;
    8783   1139512603 :           for (t = s; t < limit && (t - s) < (long) ELF_STRING_LIMIT - 1; t++)
    8784              :             {
    8785   1126197412 :               if (t == p && t != s)
    8786              :                 {
    8787     24987166 :                   if (cnt <= ((unsigned) (t - s) + 1 + 2) / 3 * 4
    8788     24020919 :                       && (!prev_base64 || (t - s) >= 16)
    8789     24016477 :                       && ((t - s) > 1 || cnt <= 2))
    8790              :                     {
    8791     23926478 :                       last_base64 = p;
    8792     23926478 :                       goto no_base64;
    8793              :                     }
    8794              :                 }
    8795   1102270934 :               c = *t;
    8796   1102270934 :               escape = ELF_ASCII_ESCAPES[c];
    8797   1102270934 :               switch (escape)
    8798              :                 {
    8799   1008393468 :                 case 0:
    8800   1008393468 :                   ++cnt;
    8801   1008393468 :                   break;
    8802     88487933 :                 case 1:
    8803     88487933 :                   if (c == 0)
    8804              :                     {
    8805     10872011 :                       if (prev_c == 0
    8806      5615532 :                           && t + 1 < limit
    8807      4762487 :                           && (t + 1 - s) < (long) ELF_STRING_LIMIT - 1)
    8808              :                         break;
    8809      6111548 :                       cnt += 2 + strlen (STRING_ASM_OP) + 1;
    8810              :                     }
    8811              :                   else
    8812     77615922 :                     cnt += 4;
    8813              :                   break;
    8814      5389533 :                 default:
    8815      5389533 :                   cnt += 2;
    8816      5389533 :                   break;
    8817              :                 }
    8818   1102270934 :               prev_c = c;
    8819              :             }
    8820     13315191 :           if (cnt > ((unsigned) (t - s) + 2) / 3 * 4 && (t - s) >= 3)
    8821              :             {
    8822      1784584 :               if (bytes_in_chunk > 0)
    8823              :                 {
    8824          540 :                   putc ('\"', f);
    8825          540 :                   putc ('\n', f);
    8826          540 :                   bytes_in_chunk = 0;
    8827              :                 }
    8828              : 
    8829      1784584 :               unsigned char buf[(ELF_STRING_LIMIT + 2) / 3 * 4 + 3];
    8830      1784584 :               unsigned j = 0;
    8831      1784584 :               static const char base64_enc[] =
    8832              :                 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
    8833              :                 "0123456789+/";
    8834              : 
    8835      1784584 :               fputs (BASE64_ASM_OP "\"", f);
    8836     47382476 :               while (s < t)
    8837              :                 {
    8838     45092242 :                   unsigned char a = *s;
    8839     45092242 :                   unsigned char b = 0, c = 0;
    8840     45092242 :                   if (s < t - 1)
    8841     44515801 :                     b = s[1];
    8842     45092242 :                   if (s < t - 2)
    8843     43813308 :                     c = s[2];
    8844     45092242 :                   unsigned long v = ((((unsigned long) a) << 16)
    8845     45092242 :                                      | (((unsigned long) b) << 8)
    8846     45092242 :                                      | c);
    8847     45092242 :                   buf[j++] = base64_enc[(v >> 18) & 63];
    8848     45092242 :                   buf[j++] = base64_enc[(v >> 12) & 63];
    8849     45092242 :                   buf[j++] = base64_enc[(v >> 6) & 63];
    8850     45092242 :                   buf[j++] = base64_enc[v & 63];
    8851     45092242 :                   if (s >= t - 2)
    8852              :                     {
    8853      1278934 :                       buf[j - 1] = '=';
    8854      1278934 :                       if (s >= t - 1)
    8855       576441 :                         buf[j - 2] = '=';
    8856              :                       break;
    8857              :                     }
    8858     43813308 :                   s += 3;
    8859              :                 }
    8860      1784584 :               memcpy (buf + j, "\"\n", 3);
    8861      1784584 :               fputs ((const char *) buf, f);
    8862      1784584 :               s = t - 1;
    8863      1784584 :               prev_base64 = true;
    8864      1784584 :               continue;
    8865      1784584 :             }
    8866              :           last_base64 = t;
    8867              :         no_base64:
    8868              :           prev_base64 = false;
    8869              :         }
    8870              : #else
    8871              :       (void) last_base64;
    8872              :       (void) prev_base64;
    8873              : #endif
    8874              : 
    8875    258718410 :       if (p < limit && (p - s) <= (long) ELF_STRING_LIMIT)
    8876              :         {
    8877     25860828 :           if (bytes_in_chunk > 0)
    8878              :             {
    8879       192745 :               putc ('\"', f);
    8880       192745 :               putc ('\n', f);
    8881       192745 :               bytes_in_chunk = 0;
    8882              :             }
    8883              : 
    8884     25860828 :           if (p == s && p + 1 < limit && p[1] == '\0')
    8885              :             {
    8886        34742 :               for (p = s + 2; p < limit && *p == '\0'; p++)
    8887        32930 :                 continue;
    8888         1812 :               ASM_OUTPUT_SKIP (f, (unsigned HOST_WIDE_INT) (p - s));
    8889         1812 :               s = p - 1;
    8890              :             }
    8891              :           else
    8892              :             {
    8893     25859016 :               default_elf_asm_output_limited_string (f, s);
    8894     25859016 :               s = p;
    8895              :             }
    8896              :         }
    8897              :       else
    8898              :         {
    8899    232857582 :           if (bytes_in_chunk == 0)
    8900     12360751 :             fputs (ASCII_DATA_ASM_OP "\"", f);
    8901              : 
    8902    232857582 :           c = *s;
    8903    232857582 :           escape = ELF_ASCII_ESCAPES[c];
    8904    232857582 :           switch (escape)
    8905              :             {
    8906    230091032 :             case 0:
    8907    230091032 :               putc (c, f);
    8908    230091032 :               bytes_in_chunk++;
    8909    230091032 :               break;
    8910      1064172 :             case 1:
    8911      1064172 :               putc ('\\', f);
    8912      1064172 :               putc ('0'+((c>>6)&7), f);
    8913      1064172 :               putc ('0'+((c>>3)&7), f);
    8914      1064172 :               putc ('0'+(c&7), f);
    8915      1064172 :               bytes_in_chunk += 4;
    8916      1064172 :               break;
    8917      1702378 :             default:
    8918      1702378 :               putc ('\\', f);
    8919      1702378 :               putc (escape, f);
    8920      1702378 :               bytes_in_chunk += 2;
    8921      1702378 :               break;
    8922              :             }
    8923              : 
    8924              :         }
    8925              :     }
    8926              : 
    8927     36084241 :   if (bytes_in_chunk > 0)
    8928              :     {
    8929      8884293 :       putc ('\"', f);
    8930      8884293 :       putc ('\n', f);
    8931              :     }
    8932     36084241 : }
    8933              : #endif
    8934              : 
    8935              : static GTY(()) section *elf_init_array_section;
    8936              : static GTY(()) section *elf_fini_array_section;
    8937              : 
    8938              : static section *
    8939        24333 : get_elf_initfini_array_priority_section (int priority,
    8940              :                                          bool constructor_p)
    8941              : {
    8942        24333 :   section *sec;
    8943        24333 :   if (priority != DEFAULT_INIT_PRIORITY)
    8944              :     {
    8945         4885 :       char buf[18];
    8946         4885 :       sprintf (buf, "%s.%.5u",
    8947              :                constructor_p ? ".init_array" : ".fini_array",
    8948              :                priority);
    8949         4885 :       sec = get_section (buf, SECTION_WRITE | SECTION_NOTYPE, NULL_TREE);
    8950              :     }
    8951              :   else
    8952              :     {
    8953        19448 :       if (constructor_p)
    8954              :         {
    8955        19389 :           if (elf_init_array_section == NULL)
    8956        18566 :             elf_init_array_section
    8957        18566 :               = get_section (".init_array",
    8958              :                              SECTION_WRITE | SECTION_NOTYPE, NULL_TREE);
    8959        19389 :           sec = elf_init_array_section;
    8960              :         }
    8961              :       else
    8962              :         {
    8963           59 :           if (elf_fini_array_section == NULL)
    8964           51 :             elf_fini_array_section
    8965           51 :               = get_section (".fini_array",
    8966              :                              SECTION_WRITE | SECTION_NOTYPE, NULL_TREE);
    8967           59 :           sec = elf_fini_array_section;
    8968              :         }
    8969              :     }
    8970        24333 :   return sec;
    8971              : }
    8972              : 
    8973              : /* Use .init_array section for constructors. */
    8974              : 
    8975              : void
    8976        22746 : default_elf_init_array_asm_out_constructor (rtx symbol, int priority)
    8977              : {
    8978        22746 :   section *sec = get_elf_initfini_array_priority_section (priority,
    8979              :                                                           true);
    8980        22746 :   assemble_addr_to_section (symbol, sec);
    8981        22746 : }
    8982              : 
    8983              : /* Use .fini_array section for destructors. */
    8984              : 
    8985              : void
    8986         1587 : default_elf_fini_array_asm_out_destructor (rtx symbol, int priority)
    8987              : {
    8988         1587 :   section *sec = get_elf_initfini_array_priority_section (priority,
    8989              :                                                           false);
    8990         1587 :   assemble_addr_to_section (symbol, sec);
    8991         1587 : }
    8992              : 
    8993              : /* Default TARGET_ASM_OUTPUT_IDENT hook.
    8994              : 
    8995              :    This is a bit of a cheat.  The real default is a no-op, but this
    8996              :    hook is the default for all targets with a .ident directive.  */
    8997              : 
    8998              : void
    8999       236755 : default_asm_output_ident_directive (const char *ident_str)
    9000              : {
    9001       236755 :   const char *ident_asm_op = "\t.ident\t";
    9002              : 
    9003              :   /* If we are still in the front end, do not write out the string
    9004              :      to asm_out_file.  Instead, add a fake top-level asm statement.
    9005              :      This allows the front ends to use this hook without actually
    9006              :      writing to asm_out_file, to handle #ident or Pragma Ident.  */
    9007       236755 :   if (symtab->state == PARSING)
    9008              :     {
    9009           27 :       char *buf = ACONCAT ((ident_asm_op, "\"", ident_str, "\"\n", NULL));
    9010           27 :       symtab->finalize_toplevel_asm (build_string (strlen (buf), buf));
    9011              :     }
    9012              :   else
    9013       236728 :     fprintf (asm_out_file, "%s\"%s\"\n", ident_asm_op, ident_str);
    9014       236755 : }
    9015              : 
    9016              : /* Switch to a COMDAT section with COMDAT name of decl.
    9017              : 
    9018              :    FIXME:  resolve_unique_section needs to deal better with
    9019              :    decls with both DECL_SECTION_NAME and DECL_ONE_ONLY.  Once
    9020              :    that is fixed, this if-else statement can be replaced with
    9021              :    a single call to "switch_to_section (sect)".  */
    9022              : 
    9023              : void
    9024           15 : switch_to_comdat_section (section *sect, tree decl)
    9025              : {
    9026              : #if defined (OBJECT_FORMAT_ELF)
    9027           15 :   targetm.asm_out.named_section (sect->named.name,
    9028           15 :                                  sect->named.common.flags
    9029              :                                  | SECTION_LINKONCE,
    9030              :                                  decl);
    9031           15 :   in_section = sect;
    9032              : #else
    9033              :   /* Neither OBJECT_FORMAT_PE, nor OBJECT_FORMAT_COFF is set here.
    9034              :      Therefore the following check is used.
    9035              :      In case a the target is PE or COFF a comdat group section
    9036              :      is created, e.g. .vtable_map_vars$foo. The linker places
    9037              :      everything in .vtable_map_vars at the end.
    9038              : 
    9039              :      A fix could be made in
    9040              :      gcc/config/i386/winnt.cc: mingw_pe_unique_section.  */
    9041              :   if (TARGET_PECOFF)
    9042              :     {
    9043              :       char *name;
    9044              : 
    9045              :       if (TREE_CODE (decl) == IDENTIFIER_NODE)
    9046              :         name = ACONCAT ((sect->named.name, "$",
    9047              :                          IDENTIFIER_POINTER (decl), NULL));
    9048              :       else
    9049              :         name = ACONCAT ((sect->named.name, "$",
    9050              :                          IDENTIFIER_POINTER (DECL_COMDAT_GROUP (decl)),
    9051              :                          NULL));
    9052              : 
    9053              :       targetm.asm_out.named_section (name,
    9054              :                                      sect->named.common.flags
    9055              :                                      | SECTION_LINKONCE,
    9056              :                                      decl);
    9057              :       in_section = sect;
    9058              :     }
    9059              :   else
    9060              :     switch_to_section (sect);
    9061              : #endif
    9062           15 : }
    9063              : 
    9064              : /* This function ensures that vtable_map variables are not only
    9065              :    in the comdat section, but that each variable has its own unique
    9066              :    comdat name.  Without this the variables end up in the same section
    9067              :    with a single comdat name.  */
    9068              : 
    9069              : static void
    9070            3 : handle_vtv_comdat_section (section *sect, const_tree decl ATTRIBUTE_UNUSED)
    9071              : {
    9072            3 :   switch_to_comdat_section(sect, DECL_NAME (decl));
    9073            3 : }
    9074              : 
    9075              : void
    9076       259439 : varasm_cc_finalize ()
    9077              : {
    9078       259439 :   first_global_object_name = nullptr;
    9079       259439 :   weak_global_object_name = nullptr;
    9080              : 
    9081       259439 :   const_labelno = 0;
    9082       259439 :   size_directive_output = 0;
    9083              : 
    9084       259439 :   last_assemble_variable_decl = NULL_TREE;
    9085       259439 :   first_function_block_is_cold = false;
    9086       259439 :   saw_no_split_stack = false;
    9087       259439 :   text_section = nullptr;
    9088       259439 :   data_section = nullptr;
    9089       259439 :   readonly_data_section = nullptr;
    9090       259439 :   sdata_section = nullptr;
    9091       259439 :   ctors_section = nullptr;
    9092       259439 :   dtors_section = nullptr;
    9093       259439 :   bss_section = nullptr;
    9094       259439 :   sbss_section = nullptr;
    9095       259439 :   tls_comm_section = nullptr;
    9096       259439 :   comm_section = nullptr;
    9097       259439 :   lcomm_section = nullptr;
    9098       259439 :   bss_noswitch_section = nullptr;
    9099       259439 :   exception_section = nullptr;
    9100       259439 :   eh_frame_section = nullptr;
    9101       259439 :   in_section = nullptr;
    9102       259439 :   in_cold_section_p = false;
    9103       259439 :   cold_function_name = NULL_TREE;
    9104       259439 :   unnamed_sections = nullptr;
    9105       259439 :   section_htab = nullptr;
    9106       259439 :   object_block_htab = nullptr;
    9107       259439 :   anchor_labelno = 0;
    9108       259439 :   shared_constant_pool = nullptr;
    9109       259439 :   pending_assemble_externals = NULL_TREE;
    9110       259439 :   pending_libcall_symbols = nullptr;
    9111              : 
    9112              : #ifdef ASM_OUTPUT_EXTERNAL
    9113       259439 :   pending_assemble_externals_processed = false;
    9114       279771 :   delete pending_assemble_externals_set;
    9115       259439 :   pending_assemble_externals_set = nullptr;
    9116              : #endif
    9117              : 
    9118       259439 :   weak_decls = NULL_TREE;
    9119       259439 :   initial_trampoline = nullptr;
    9120       259439 :   const_desc_htab = nullptr;
    9121       259439 :   weakref_targets = NULL_TREE;
    9122       259439 :   alias_pairs = nullptr;
    9123       259439 :   tm_clone_hash = nullptr;
    9124       259439 :   trampolines_created = 0;
    9125       259439 :   elf_init_array_section = nullptr;
    9126       259439 :   elf_fini_array_section = nullptr;
    9127       259439 : }
    9128              : 
    9129              : #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.