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

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