LCOV - code coverage report
Current view: top level - gcc - lto-streamer.h (source / functions) Coverage Total Hit
Test: gcc.info Lines: 97.8 % 137 134
Test Date: 2024-12-21 13:15:12 Functions: 100.0 % 19 19
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* Data structures and declarations used for reading and writing
       2                 :             :    GIMPLE to a file stream.
       3                 :             : 
       4                 :             :    Copyright (C) 2009-2024 Free Software Foundation, Inc.
       5                 :             :    Contributed by Doug Kwan <dougkwan@google.com>
       6                 :             : 
       7                 :             : This file is part of GCC.
       8                 :             : 
       9                 :             : GCC is free software; you can redistribute it and/or modify it under
      10                 :             : the terms of the GNU General Public License as published by the Free
      11                 :             : Software Foundation; either version 3, or (at your option) any later
      12                 :             : version.
      13                 :             : 
      14                 :             : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      15                 :             : WARRANTY; without even the implied warranty of MERCHANTABILITY or
      16                 :             : FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      17                 :             : for more details.
      18                 :             : 
      19                 :             : You should have received a copy of the GNU General Public License
      20                 :             : along with GCC; see the file COPYING3.  If not see
      21                 :             : <http://www.gnu.org/licenses/>.  */
      22                 :             : 
      23                 :             : #ifndef GCC_LTO_STREAMER_H
      24                 :             : #define GCC_LTO_STREAMER_H
      25                 :             : 
      26                 :             : #include "plugin-api.h"
      27                 :             : #include "gcov-io.h"
      28                 :             : #include "diagnostic.h"
      29                 :             : #include "version.h"
      30                 :             : 
      31                 :             : /* The encoding for a function consists of the following sections:
      32                 :             : 
      33                 :             :    1)    The header.
      34                 :             :    2)    FIELD_DECLS.
      35                 :             :    3)    FUNCTION_DECLS.
      36                 :             :    4)    global VAR_DECLS.
      37                 :             :    5)    type_decls
      38                 :             :    6)    types.
      39                 :             :    7)    Names for the labels that have names
      40                 :             :    8)    The SSA names.
      41                 :             :    9)    The control flow graph.
      42                 :             :    10-11)Gimple for local decls.
      43                 :             :    12)   Gimple for the function.
      44                 :             :    13)   Strings.
      45                 :             : 
      46                 :             :    1) THE HEADER.
      47                 :             :    2-6) THE GLOBAL DECLS AND TYPES.
      48                 :             : 
      49                 :             :       The global decls and types are encoded in the same way.  For each
      50                 :             :       entry, there is word with the offset within the section to the
      51                 :             :       entry.
      52                 :             : 
      53                 :             :    7) THE LABEL NAMES.
      54                 :             : 
      55                 :             :       Since most labels do not have names, this section my be of zero
      56                 :             :       length.  It consists of an array of string table references, one
      57                 :             :       per label.  In the lto code, the labels are given either
      58                 :             :       positive or negative indexes.  the positive ones have names and
      59                 :             :       the negative ones do not.  The positive index can be used to
      60                 :             :       find the name in this array.
      61                 :             : 
      62                 :             :    9) THE CFG.
      63                 :             : 
      64                 :             :    10) Index into the local decls.  Since local decls can have local
      65                 :             :       decls inside them, they must be read in randomly in order to
      66                 :             :       properly restore them.
      67                 :             : 
      68                 :             :    11-12) GIMPLE FOR THE LOCAL DECLS AND THE FUNCTION BODY.
      69                 :             : 
      70                 :             :      The gimple consists of a set of records.
      71                 :             : 
      72                 :             :      THE FUNCTION
      73                 :             : 
      74                 :             :      At the top level of (8) is the function. It consists of five
      75                 :             :      pieces:
      76                 :             : 
      77                 :             :      LTO_function     - The tag.
      78                 :             :      eh tree          - This is all of the exception handling regions
      79                 :             :                         put out in a post order traversial of the
      80                 :             :                         tree.  Siblings are output as lists terminated
      81                 :             :                         by a 0.  The set of fields matches the fields
      82                 :             :                         defined in except.cc.
      83                 :             : 
      84                 :             :      last_basic_block - in uleb128 form.
      85                 :             : 
      86                 :             :      basic blocks     - This is the set of basic blocks.
      87                 :             : 
      88                 :             :      zero             - The termination of the basic blocks.
      89                 :             : 
      90                 :             :      BASIC BLOCKS
      91                 :             : 
      92                 :             :      There are two forms of basic blocks depending on if they are
      93                 :             :      empty or not.
      94                 :             : 
      95                 :             :      The basic block consists of:
      96                 :             : 
      97                 :             :      LTO_bb1 or LTO_bb0 - The tag.
      98                 :             : 
      99                 :             :      bb->index          - the index in uleb128 form.
     100                 :             : 
     101                 :             :      #succs             - The number of successors un uleb128 form.
     102                 :             : 
     103                 :             :      the successors     - For each edge, a pair.  The first of the
     104                 :             :                           pair is the index of the successor in
     105                 :             :                           uleb128 form and the second are the flags in
     106                 :             :                           uleb128 form.
     107                 :             : 
     108                 :             :      the statements     - A gimple tree, as described above.
     109                 :             :                           These are only present for LTO_BB1.
     110                 :             :                           Following each statement is an optional
     111                 :             :                           exception handling record LTO_eh_region
     112                 :             :                           which contains the region number (for
     113                 :             :                           regions >= 0).
     114                 :             : 
     115                 :             :      zero               - This is only present for LTO_BB1 and is used
     116                 :             :                           to terminate the statements and exception
     117                 :             :                           regions within this block.
     118                 :             : 
     119                 :             :    12) STRINGS
     120                 :             : 
     121                 :             :      String are represented in the table as pairs, a length in ULEB128
     122                 :             :      form followed by the data for the string.  */
     123                 :             : 
     124                 :             : #define LTO_major_version GCC_major_version
     125                 :             : #define LTO_minor_version 0
     126                 :             : 
     127                 :             : typedef unsigned char   lto_decl_flags_t;
     128                 :             : 
     129                 :             : /* Tags representing the various IL objects written to the bytecode file
     130                 :             :    (GIMPLE statements, basic blocks, EH regions, tree nodes, etc).
     131                 :             : 
     132                 :             :    NOTE, when adding new LTO tags, also update lto_tag_name.  */
     133                 :             : enum LTO_tags
     134                 :             : {
     135                 :             :   LTO_null = 0,
     136                 :             : 
     137                 :             :   /* Reference to previously-streamed node.  */
     138                 :             :   LTO_tree_pickle_reference,
     139                 :             : 
     140                 :             :   /* References to indexable tree nodes.  These objects are stored in
     141                 :             :      tables that are written separately from the function bodies
     142                 :             :      and variable constructors that reference them.  This way they can be
     143                 :             :      instantiated even when the referencing functions aren't (e.g., during WPA)
     144                 :             :      and it also allows functions to be copied from one file to another without
     145                 :             :      having to unpickle the body first (the references are location
     146                 :             :      independent).  */
     147                 :             :   LTO_global_stream_ref,
     148                 :             : 
     149                 :             :   LTO_ssa_name_ref,
     150                 :             : 
     151                 :             :   /* Special for global streamer.  A blob of unnamed tree nodes.  */
     152                 :             :   LTO_tree_scc,
     153                 :             : 
     154                 :             :   /* Sequence of trees.  */
     155                 :             :   LTO_trees,
     156                 :             : 
     157                 :             :   /* Shared INTEGER_CST node.  */
     158                 :             :   LTO_integer_cst,
     159                 :             : 
     160                 :             :   /* Tags of trees are encoded as
     161                 :             :      LTO_first_tree_tag + TREE_CODE.  */
     162                 :             :   LTO_first_tree_tag,
     163                 :             :   /* Tags of gimple typles are encoded as
     164                 :             :      LTO_first_gimple_tag + gimple_code.  */
     165                 :             :   LTO_first_gimple_tag = LTO_first_tree_tag + MAX_TREE_CODES,
     166                 :             : 
     167                 :             :   /* Entry and exit basic blocks.  */
     168                 :             :   LTO_bb0 = LTO_first_gimple_tag + LAST_AND_UNUSED_GIMPLE_CODE,
     169                 :             :   LTO_bb1,
     170                 :             : 
     171                 :             :   /* EH region holding the previous statement.  */
     172                 :             :   LTO_eh_region,
     173                 :             : 
     174                 :             :   /* Function body.  */
     175                 :             :   LTO_function,
     176                 :             : 
     177                 :             :   /* EH table.  */
     178                 :             :   LTO_eh_table,
     179                 :             : 
     180                 :             :   /* EH region types.  These mirror enum eh_region_type.  */
     181                 :             :   LTO_ert_cleanup,
     182                 :             :   LTO_ert_try,
     183                 :             :   LTO_ert_allowed_exceptions,
     184                 :             :   LTO_ert_must_not_throw,
     185                 :             : 
     186                 :             :   /* EH landing pad.  */
     187                 :             :   LTO_eh_landing_pad,
     188                 :             : 
     189                 :             :   /* EH try/catch node.  */
     190                 :             :   LTO_eh_catch,
     191                 :             : 
     192                 :             :   /* This tag must always be last.  */
     193                 :             :   LTO_NUM_TAGS
     194                 :             : };
     195                 :             : 
     196                 :             : 
     197                 :             : /* Set of section types that are in an LTO file.  This list will grow
     198                 :             :    as the number of IPA passes grows since each IPA pass will need its
     199                 :             :    own section type to store its summary information.
     200                 :             : 
     201                 :             :    When adding a new section type, you must also extend the
     202                 :             :    LTO_SECTION_NAME array in lto-section-in.cc.  */
     203                 :             : enum lto_section_type
     204                 :             : {
     205                 :             :   LTO_section_decls = 0,
     206                 :             :   LTO_section_function_body,
     207                 :             :   LTO_section_static_initializer,
     208                 :             :   LTO_section_symtab,
     209                 :             :   LTO_section_symtab_extension,
     210                 :             :   LTO_section_refs,
     211                 :             :   LTO_section_asm,
     212                 :             :   LTO_section_jump_functions,
     213                 :             :   LTO_section_ipa_pure_const,
     214                 :             :   LTO_section_ipa_reference,
     215                 :             :   LTO_section_ipa_profile,
     216                 :             :   LTO_section_symtab_nodes,
     217                 :             :   LTO_section_opts,
     218                 :             :   LTO_section_cgraph_opt_sum,
     219                 :             :   LTO_section_ipa_fn_summary,
     220                 :             :   LTO_section_ipcp_transform,
     221                 :             :   LTO_section_ipa_icf,
     222                 :             :   LTO_section_offload_table,
     223                 :             :   LTO_section_mode_table,
     224                 :             :   LTO_section_lto,
     225                 :             :   LTO_section_ipa_sra,
     226                 :             :   LTO_section_odr_types,
     227                 :             :   LTO_section_ipa_modref,
     228                 :             :   LTO_N_SECTION_TYPES           /* Must be last.  */
     229                 :             : };
     230                 :             : 
     231                 :             : /* Indices to the various function, type and symbol streams. */
     232                 :             : enum lto_decl_stream_e_t
     233                 :             : {
     234                 :             :   LTO_DECL_STREAM = 0,          /* Must be first.  */
     235                 :             :   LTO_N_DECL_STREAMS
     236                 :             : };
     237                 :             : 
     238                 :             : typedef enum ld_plugin_symbol_resolution ld_plugin_symbol_resolution_t;
     239                 :             : 
     240                 :             : /* Return a char pointer to the start of a data stream for an lto pass
     241                 :             :    or function.  The first parameter is the file data that contains
     242                 :             :    the information.  The second parameter is the type of information
     243                 :             :    to be obtained.  The third parameter is the name of the function
     244                 :             :    and is only used when finding a function body; otherwise it is
     245                 :             :    NULL.  The fourth parameter is the length of the data returned.  */
     246                 :             : typedef const char* (lto_get_section_data_f) (struct lto_file_decl_data *,
     247                 :             :                                               enum lto_section_type,
     248                 :             :                                               const char *,
     249                 :             :                                               int,
     250                 :             :                                               size_t *);
     251                 :             : 
     252                 :             : /* Return the data found from the above call.  The first three
     253                 :             :    parameters are the same as above.  The fourth parameter is the data
     254                 :             :    itself and the fifth is the length of the data. */
     255                 :             : typedef void (lto_free_section_data_f) (struct lto_file_decl_data *,
     256                 :             :                                         enum lto_section_type,
     257                 :             :                                         const char *,
     258                 :             :                                         const char *,
     259                 :             :                                         size_t);
     260                 :             : 
     261                 :             : /* The location cache holds expanded locations for streamed in trees.
     262                 :             :    This is done to reduce memory usage of libcpp linemap that strongly prefers
     263                 :             :    locations to be inserted in the source order.  */
     264                 :             : 
     265                 :             : class lto_location_cache
     266                 :             : {
     267                 :             : public:
     268                 :             :   /* Apply all changes in location cache.  Add locations into linemap and patch
     269                 :             :      trees.  */
     270                 :             :   bool apply_location_cache ();
     271                 :             :   /* Tree merging did not suceed; mark all changes in the cache as accepted.  */
     272                 :             :   void accept_location_cache ();
     273                 :             :   /* Tree merging did suceed; throw away recent changes.  */
     274                 :             :   void revert_location_cache ();
     275                 :             :   void input_location (location_t *loc, struct bitpack_d *bp,
     276                 :             :                        class data_in *data_in);
     277                 :             :   void input_location_and_block (location_t *loc, struct bitpack_d *bp,
     278                 :             :                                  class lto_input_block *ib,
     279                 :             :                                  class data_in *data_in);
     280                 :      204029 :   lto_location_cache ()
     281                 :      204029 :      : loc_cache (), accepted_length (0), current_file (NULL), current_line (0),
     282                 :      204029 :        current_col (0), current_sysp (false), current_loc (UNKNOWN_LOCATION),
     283                 :      204029 :        current_block (NULL_TREE)
     284                 :             :   {
     285                 :      204029 :     gcc_assert (!current_cache);
     286                 :      204029 :     current_cache = this;
     287                 :      204029 :   }
     288                 :      204029 :   ~lto_location_cache ()
     289                 :             :   {
     290                 :      204029 :     apply_location_cache ();
     291                 :      204029 :     gcc_assert (current_cache == this);
     292                 :      204029 :     current_cache = NULL;
     293                 :      204029 :   }
     294                 :             : 
     295                 :             :   /* There can be at most one instance of location cache (combining multiple
     296                 :             :      would bring it out of sync with libcpp linemap); point to current
     297                 :             :      one.  */
     298                 :             :   static lto_location_cache *current_cache;
     299                 :             : 
     300                 :             : private:
     301                 :             :   static int cmp_loc (const void *pa, const void *pb);
     302                 :             : 
     303                 :             :   struct cached_location
     304                 :             :   {
     305                 :             :     const char *file;
     306                 :             :     location_t *loc;
     307                 :             :     int line, col;
     308                 :             :     bool sysp;
     309                 :             :     tree block;
     310                 :             :     unsigned discr;
     311                 :             :   };
     312                 :             : 
     313                 :             :   /* The location cache.  */
     314                 :             : 
     315                 :             :   auto_vec<cached_location> loc_cache;
     316                 :             : 
     317                 :             :   /* Accepted entries are ones used by trees that are known to be not unified
     318                 :             :      by tree merging.  */
     319                 :             : 
     320                 :             :   int accepted_length;
     321                 :             : 
     322                 :             :   /* Bookkeeping to remember state in between calls to lto_apply_location_cache
     323                 :             :      When streaming gimple, the location cache is not used and thus
     324                 :             :      lto_apply_location_cache happens per location basis.  It is then
     325                 :             :      useful to avoid redundant calls of linemap API.  */
     326                 :             : 
     327                 :             :   const char *current_file;
     328                 :             :   int current_line;
     329                 :             :   int current_col;
     330                 :             :   bool current_sysp;
     331                 :             :   location_t current_loc;
     332                 :             :   tree current_block;
     333                 :             :   unsigned current_discr;
     334                 :             : };
     335                 :             : 
     336                 :             : /* Structure used as buffer for reading an LTO file.  */
     337                 :             : class lto_input_block
     338                 :             : {
     339                 :             : public:
     340                 :             :   /* Special constructor for the string table, it abuses this to
     341                 :             :      do random access but use the uhwi decoder.  */
     342                 :     1299664 :   lto_input_block (const char *data_, unsigned int p_, unsigned int len_,
     343                 :             :                    const lto_file_decl_data *file_data_)
     344                 :     1299664 :       : data (data_), file_data (file_data_), p (p_), len (len_) {}
     345                 :      353374 :   lto_input_block (const char *data_, unsigned int len_,
     346                 :             :                    const lto_file_decl_data *file_data_)
     347                 :      270162 :       : data (data_), file_data (file_data_), p (0), len (len_) {}
     348                 :             : 
     349                 :             :   const char *data;
     350                 :             :   const lto_file_decl_data *file_data;
     351                 :             :   unsigned int p;
     352                 :             :   unsigned int len;
     353                 :             : };
     354                 :             : 
     355                 :             : /* Compression algorithm used for compression of LTO bytecode.  */
     356                 :             : 
     357                 :             : enum lto_compression
     358                 :             : {
     359                 :             :   ZLIB,
     360                 :             :   ZSTD
     361                 :             : };
     362                 :             : 
     363                 :             : /* Structure that represents LTO ELF section with information
     364                 :             :    about the format.  */
     365                 :             : 
     366                 :             : struct lto_section
     367                 :             : {
     368                 :             :   int16_t major_version;
     369                 :             :   int16_t minor_version;
     370                 :             :   unsigned char slim_object;
     371                 :             :   unsigned char _padding;
     372                 :             : 
     373                 :             :   /* Flags is a private field that is not defined publicly.  */
     374                 :             :   uint16_t flags;
     375                 :             : 
     376                 :             :   /* Set compression to FLAGS.  */
     377                 :       33181 :   inline void set_compression (lto_compression c)
     378                 :             :   {
     379                 :       33181 :     flags = c;
     380                 :             :   }
     381                 :             : 
     382                 :             :   /* Get compression from FLAGS.  */
     383                 :      210544 :   inline lto_compression get_compression ()
     384                 :             :   {
     385                 :      210544 :     return (lto_compression) flags;
     386                 :             :   }
     387                 :             : };
     388                 :             : 
     389                 :             : STATIC_ASSERT (sizeof (lto_section) == 8);
     390                 :             : 
     391                 :             : /* The is the first part of the record in an LTO file for many of the
     392                 :             :    IPA passes.  */
     393                 :             : struct lto_simple_header
     394                 :             : {
     395                 :             :   /* Size of main gimple body of function.  */
     396                 :             :   int32_t main_size;
     397                 :             : };
     398                 :             : 
     399                 :             : struct lto_simple_header_with_strings : lto_simple_header
     400                 :             : {
     401                 :             :   /* Size of the string table.  */
     402                 :             :   int32_t string_size;
     403                 :             : };
     404                 :             : 
     405                 :             : /* The header for a function body.  */
     406                 :             : struct lto_function_header : lto_simple_header_with_strings
     407                 :             : {
     408                 :             :   /* Size of the cfg.  */
     409                 :             :   int32_t cfg_size;
     410                 :             : };
     411                 :             : 
     412                 :             : 
     413                 :             : /* Structure describing a symbol section.  */
     414                 :             : struct lto_decl_header : lto_simple_header_with_strings
     415                 :             : {
     416                 :             :   /* Size of region for decl state. */
     417                 :             :   int32_t decl_state_size;
     418                 :             : 
     419                 :             :   /* Number of nodes in globals stream.  */
     420                 :             :   int32_t num_nodes;
     421                 :             : };
     422                 :             : 
     423                 :             : 
     424                 :             : /* Statistics gathered during LTO, WPA and LTRANS.  */
     425                 :             : struct lto_stats_d
     426                 :             : {
     427                 :             :   unsigned HOST_WIDE_INT num_input_cgraph_nodes;
     428                 :             :   unsigned HOST_WIDE_INT num_output_symtab_nodes;
     429                 :             :   unsigned HOST_WIDE_INT num_input_files;
     430                 :             :   unsigned HOST_WIDE_INT num_output_files;
     431                 :             :   unsigned HOST_WIDE_INT num_cgraph_partitions;
     432                 :             :   unsigned HOST_WIDE_INT section_size[LTO_N_SECTION_TYPES];
     433                 :             :   unsigned HOST_WIDE_INT num_function_bodies;
     434                 :             :   unsigned HOST_WIDE_INT num_trees[NUM_TREE_CODES];
     435                 :             :   unsigned HOST_WIDE_INT num_output_il_bytes;
     436                 :             :   unsigned HOST_WIDE_INT num_compressed_il_bytes;
     437                 :             :   unsigned HOST_WIDE_INT num_input_il_bytes;
     438                 :             :   unsigned HOST_WIDE_INT num_uncompressed_il_bytes;
     439                 :             :   unsigned HOST_WIDE_INT num_tree_bodies_output;
     440                 :             :   unsigned HOST_WIDE_INT num_pickle_refs_output;
     441                 :             : };
     442                 :             : 
     443                 :             : /* Entry of LTO symtab encoder.  */
     444                 :             : struct lto_encoder_entry
     445                 :             : {
     446                 :             :   /* Constructor.  */
     447                 :     1406800 :   lto_encoder_entry (symtab_node* n)
     448                 :     1406800 :     : node (n), in_partition (false), body (false), only_for_inlining (true),
     449                 :     1406800 :       initializer (false)
     450                 :             :   {}
     451                 :             : 
     452                 :             :   symtab_node *node;
     453                 :             :   /* Is the node in this partition (i.e. ltrans of this partition will
     454                 :             :      be responsible for outputting it)? */
     455                 :             :   unsigned int in_partition:1;
     456                 :             :   /* Do we encode body in this partition?  */
     457                 :             :   unsigned int body:1;
     458                 :             :   /* Do we stream this node only for inlining?  */
     459                 :             :   unsigned int only_for_inlining:1;
     460                 :             :   /* Do we encode initializer in this partition?
     461                 :             :      For example the readonly variable initializers are encoded to aid
     462                 :             :      constant folding even if they are not in the partition.  */
     463                 :             :   unsigned int initializer:1;
     464                 :             : };
     465                 :             : 
     466                 :             : 
     467                 :             : /* Encoder data structure used to stream callgraph nodes.  */
     468                 :             : struct lto_symtab_encoder_d
     469                 :             : {
     470                 :             :   vec<lto_encoder_entry> nodes;
     471                 :             :   hash_map<symtab_node *, size_t> *map;
     472                 :             : 
     473                 :             :   /* Mapping of input order of nodes onto output order.  */
     474                 :             :   hash_map<int_hash<int, -1, -2>, int> *order_remap;
     475                 :             : };
     476                 :             : 
     477                 :             : typedef struct lto_symtab_encoder_d *lto_symtab_encoder_t;
     478                 :             : 
     479                 :             : /* Iterator structure for cgraph node sets.  */
     480                 :             : struct lto_symtab_encoder_iterator
     481                 :             : {
     482                 :             :   lto_symtab_encoder_t encoder;
     483                 :             :   unsigned index;
     484                 :             : };
     485                 :             : 
     486                 :             : 
     487                 :             : 
     488                 :             : /* The lto_tree_ref_encoder struct is used to encode trees into indices. */
     489                 :             : 
     490                 :             : struct lto_tree_ref_encoder
     491                 :             : {
     492                 :             :   hash_map<tree, unsigned> *tree_hash_table;      /* Maps pointers to indices. */
     493                 :             :   vec<tree> trees;                        /* Maps indices to pointers. */
     494                 :             : };
     495                 :             : 
     496                 :             : 
     497                 :             : /* Structure to hold states of input scope.  */
     498                 :             : struct GTY((for_user)) lto_in_decl_state
     499                 :             : {
     500                 :             :   /* Array of lto_in_decl_buffers to store type and decls streams. */
     501                 :             :   vec<tree, va_gc> *streams[LTO_N_DECL_STREAMS];
     502                 :             : 
     503                 :             :   /* If this in-decl state is associated with a function. FN_DECL
     504                 :             :      point to the FUNCTION_DECL. */
     505                 :             :   tree fn_decl;
     506                 :             : 
     507                 :             :   /* True if decl state is compressed.  */
     508                 :             :   bool compressed;
     509                 :             : };
     510                 :             : 
     511                 :             : typedef struct lto_in_decl_state *lto_in_decl_state_ptr;
     512                 :             : 
     513                 :             : struct decl_state_hasher : ggc_ptr_hash<lto_in_decl_state>
     514                 :             : {
     515                 :             :   static hashval_t
     516                 :     1553734 :   hash (lto_in_decl_state *s)
     517                 :             :   {
     518                 :     1553734 :     return htab_hash_pointer (s->fn_decl);
     519                 :             :   }
     520                 :             : 
     521                 :             :   static bool
     522                 :     1380048 :   equal (lto_in_decl_state *a, lto_in_decl_state *b)
     523                 :             :   {
     524                 :     1380048 :     return a->fn_decl == b->fn_decl;
     525                 :             :   }
     526                 :             : };
     527                 :             : 
     528                 :             : /* The structure that holds all of the vectors of global types,
     529                 :             :    decls and cgraph nodes used in the serialization of this file.  */
     530                 :             : struct lto_out_decl_state
     531                 :             : {
     532                 :             :   /* The buffers contain the sets of decls of various kinds and types we have
     533                 :             :      seen so far and the indexes assigned to them.  */
     534                 :             :   struct lto_tree_ref_encoder streams[LTO_N_DECL_STREAMS];
     535                 :             : 
     536                 :             :   /* Encoder for cgraph nodes.  */
     537                 :             :   lto_symtab_encoder_t symtab_node_encoder;
     538                 :             : 
     539                 :             :   /* If this out-decl state belongs to a function, fn_decl points to that
     540                 :             :      function.  Otherwise, it is NULL. */
     541                 :             :   tree fn_decl;
     542                 :             : 
     543                 :             :   /* True if decl state is compressed.  */
     544                 :             :   bool compressed;
     545                 :             : 
     546                 :             :   /* True if offload tables should be output. */
     547                 :             :   bool output_offload_tables_p;
     548                 :             : };
     549                 :             : 
     550                 :             : typedef struct lto_out_decl_state *lto_out_decl_state_ptr;
     551                 :             : 
     552                 :             : 
     553                 :             : /* Compact representation of a index <-> resolution pair. Unpacked to an
     554                 :             :    vector later. */
     555                 :             : struct res_pair
     556                 :             : {
     557                 :             :   ld_plugin_symbol_resolution_t res;
     558                 :             :   unsigned index;
     559                 :             : };
     560                 :             : 
     561                 :             : 
     562                 :             : /* One of these is allocated for each object file that being compiled
     563                 :             :    by lto.  This structure contains the tables that are needed by the
     564                 :             :    serialized functions and ipa passes to connect themselves to the
     565                 :             :    global types and decls as they are reconstituted.  */
     566                 :             : struct GTY(()) lto_file_decl_data
     567                 :             : {
     568                 :             :   /* Decl state currently used. */
     569                 :             :   struct lto_in_decl_state *current_decl_state;
     570                 :             : 
     571                 :             :   /* Decl state corresponding to regions outside of any functions
     572                 :             :      in the compilation unit. */
     573                 :             :   struct lto_in_decl_state *global_decl_state;
     574                 :             : 
     575                 :             :   /* Table of cgraph nodes present in this file.  */
     576                 :             :   lto_symtab_encoder_t GTY((skip)) symtab_node_encoder;
     577                 :             : 
     578                 :             :   /* Hash table maps lto-related section names to location in file.  */
     579                 :             :   hash_table<decl_state_hasher> *function_decl_states;
     580                 :             : 
     581                 :             :   /* The .o file that these offsets relate to.  */
     582                 :             :   const char *GTY((skip)) file_name;
     583                 :             : 
     584                 :             :   /* Hash table maps lto-related section names to location in file.  */
     585                 :             :   htab_t GTY((skip)) section_hash_table;
     586                 :             : 
     587                 :             :   /* Hash new name of renamed global declaration to its original name.  */
     588                 :             :   htab_t GTY((skip)) renaming_hash_table;
     589                 :             : 
     590                 :             :   /* Linked list used temporarily in reader */
     591                 :             :   struct lto_file_decl_data *next;
     592                 :             : 
     593                 :             :   /* Order in which the file appears on the command line.  */
     594                 :             :   int order;
     595                 :             : 
     596                 :             :   /* Sub ID for merged objects. */
     597                 :             :   unsigned HOST_WIDE_INT id;
     598                 :             : 
     599                 :             :   /* Symbol resolutions for this file */
     600                 :             :   vec<res_pair>  GTY((skip)) respairs;
     601                 :             :   unsigned max_index;
     602                 :             : 
     603                 :             :   gcov_summary GTY((skip)) profile_info;
     604                 :             : 
     605                 :             :   /* Map assigning declarations their resolutions.  */
     606                 :             :   hash_map<tree, ld_plugin_symbol_resolution> * GTY((skip)) resolution_map;
     607                 :             : 
     608                 :             :   /* Mode translation table.  */
     609                 :             :   const unsigned char *mode_table;
     610                 :             : 
     611                 :             :   /* Read LTO section.  */
     612                 :             :   lto_section lto_section_header;
     613                 :             : 
     614                 :             :   int order_base;
     615                 :             : 
     616                 :             :   int unit_base;
     617                 :             : 
     618                 :             :   unsigned mode_bits;
     619                 :             : };
     620                 :             : 
     621                 :             : typedef struct lto_file_decl_data *lto_file_decl_data_ptr;
     622                 :             : 
     623                 :             : struct lto_char_ptr_base
     624                 :             : {
     625                 :             :   char *ptr;
     626                 :             : };
     627                 :             : 
     628                 :             : /* An incore byte stream to buffer the various parts of the function.
     629                 :             :    The entire structure should be zeroed when created.  The record
     630                 :             :    consists of a set of blocks.  The first sizeof (ptr) bytes are used
     631                 :             :    as a chain, and the rest store the bytes to be written.  */
     632                 :             : struct lto_output_stream
     633                 :             : {
     634                 :             :   /* The pointer to the first block in the stream.  */
     635                 :             :   struct lto_char_ptr_base * first_block;
     636                 :             : 
     637                 :             :   /* The pointer to the last and current block in the stream.  */
     638                 :             :   struct lto_char_ptr_base * current_block;
     639                 :             : 
     640                 :             :   /* The pointer to where the next char should be written.  */
     641                 :             :   char * current_pointer;
     642                 :             : 
     643                 :             :   /* The number of characters left in the current block.  */
     644                 :             :   unsigned int left_in_block;
     645                 :             : 
     646                 :             :   /* The block size of the last block allocated.  */
     647                 :             :   unsigned int block_size;
     648                 :             : 
     649                 :             :   /* The total number of characters written.  */
     650                 :             :   unsigned int total_size;
     651                 :             : };
     652                 :             : 
     653                 :             : /* A simple output block.  This can be used for simple IPA passes that
     654                 :             :    do not need more than one stream.  */
     655                 :             : struct lto_simple_output_block
     656                 :             : {
     657                 :             :   enum lto_section_type section_type;
     658                 :             :   struct lto_out_decl_state *decl_state;
     659                 :             : 
     660                 :             :   /* The stream that the main tree codes are written to.  */
     661                 :             :   struct lto_output_stream *main_stream;
     662                 :             : };
     663                 :             : 
     664                 :             : /* String hashing.  */
     665                 :             : 
     666                 :             : struct string_slot
     667                 :             : {
     668                 :             :   const char *s;
     669                 :             :   int len;
     670                 :             :   unsigned int slot_num;
     671                 :             : };
     672                 :             : 
     673                 :             : /* Hashtable helpers.  */
     674                 :             : 
     675                 :             : struct string_slot_hasher : nofree_ptr_hash <string_slot>
     676                 :             : {
     677                 :             :   static inline hashval_t hash (const string_slot *);
     678                 :             :   static inline bool equal (const string_slot *, const string_slot *);
     679                 :             : };
     680                 :             : 
     681                 :             : /* Returns a hash code for DS.  Adapted from libiberty's htab_hash_string
     682                 :             :    to support strings that may not end in '\0'.  */
     683                 :             : 
     684                 :             : inline hashval_t
     685                 :    10903577 : string_slot_hasher::hash (const string_slot *ds)
     686                 :             : {
     687                 :    10903577 :   hashval_t r = ds->len;
     688                 :    10903577 :   int i;
     689                 :             : 
     690                 :   275077667 :   for (i = 0; i < ds->len; i++)
     691                 :   264174090 :      r = r * 67 + (unsigned)ds->s[i] - 113;
     692                 :    10903577 :   return r;
     693                 :             : }
     694                 :             : 
     695                 :             : /* Returns nonzero if DS1 and DS2 are equal.  */
     696                 :             : 
     697                 :             : inline bool
     698                 :     8649150 : string_slot_hasher::equal (const string_slot *ds1, const string_slot *ds2)
     699                 :             : {
     700                 :     8649150 :   if (ds1->len == ds2->len)
     701                 :     4902162 :     return memcmp (ds1->s, ds2->s, ds1->len) == 0;
     702                 :             : 
     703                 :             :   return 0;
     704                 :             : }
     705                 :             : 
     706                 :             : /* Data structure holding all the data and descriptors used when writing
     707                 :             :    an LTO file.  */
     708                 :             : struct output_block
     709                 :             : {
     710                 :             :   enum lto_section_type section_type;
     711                 :             :   struct lto_out_decl_state *decl_state;
     712                 :             : 
     713                 :             :   /* The stream that the main tree codes are written to.  */
     714                 :             :   struct lto_output_stream *main_stream;
     715                 :             : 
     716                 :             :   /* The stream that contains the string table.  */
     717                 :             :   struct lto_output_stream *string_stream;
     718                 :             : 
     719                 :             :   /* The stream that contains the cfg.  */
     720                 :             :   struct lto_output_stream *cfg_stream;
     721                 :             : 
     722                 :             :   /* The hash table that contains the set of strings we have seen so
     723                 :             :      far and the indexes assigned to them.  */
     724                 :             :   hash_table<string_slot_hasher> *string_hash_table;
     725                 :             : 
     726                 :             :   /* The current symbol that we are currently serializing.  Null
     727                 :             :      if we are serializing something else.  */
     728                 :             :   symtab_node *symbol;
     729                 :             : 
     730                 :             :   /* These are the last file and line that were seen in the stream.
     731                 :             :      If the current node differs from these, it needs to insert
     732                 :             :      something into the stream and fix these up.  */
     733                 :             :   const char *current_file;
     734                 :             :   int current_line;
     735                 :             :   int current_col;
     736                 :             :   bool current_sysp;
     737                 :             :   bool reset_locus;
     738                 :             :   bool emit_pwd;
     739                 :             :   tree current_block;
     740                 :             :   unsigned current_discr;
     741                 :             : 
     742                 :             :   /* Cache of nodes written in this section.  */
     743                 :             :   struct streamer_tree_cache_d *writer_cache;
     744                 :             : 
     745                 :             :   /* All trees identified as local to the unit streamed.  */
     746                 :             :   hash_set<tree> *local_trees;
     747                 :             : 
     748                 :             :   /* All data persistent across whole duration of output block
     749                 :             :      can go here.  */
     750                 :             :   struct obstack obstack;
     751                 :             : };
     752                 :             : 
     753                 :             : 
     754                 :             : /* Data and descriptors used when reading from an LTO file.  */
     755                 :      408058 : class data_in
     756                 :             : {
     757                 :             : public:
     758                 :             :   /* The global decls and types.  */
     759                 :             :   struct lto_file_decl_data *file_data;
     760                 :             : 
     761                 :             :   /* The string table.  */
     762                 :             :   const char *strings;
     763                 :             : 
     764                 :             :   /* The length of the string table.  */
     765                 :             :   unsigned int strings_len;
     766                 :             : 
     767                 :             :   /* Maps each reference number to the resolution done by the linker. */
     768                 :             :   vec<ld_plugin_symbol_resolution_t> globals_resolution;
     769                 :             : 
     770                 :             :   /* Cache of pickled nodes.  */
     771                 :             :   struct streamer_tree_cache_d *reader_cache;
     772                 :             : 
     773                 :             :   /* Cache of source code location.  */
     774                 :             :   lto_location_cache location_cache;
     775                 :             : };
     776                 :             : 
     777                 :             : 
     778                 :             : /* In lto-section-in.cc  */
     779                 :             : extern class lto_input_block * lto_create_simple_input_block (
     780                 :             :                                struct lto_file_decl_data *,
     781                 :             :                                enum lto_section_type, const char **, size_t *);
     782                 :             : extern void
     783                 :             : lto_destroy_simple_input_block (struct lto_file_decl_data *,
     784                 :             :                                 enum lto_section_type,
     785                 :             :                                 class lto_input_block *, const char *, size_t);
     786                 :             : extern void lto_set_in_hooks (struct lto_file_decl_data **,
     787                 :             :                               lto_get_section_data_f *,
     788                 :             :                               lto_free_section_data_f *);
     789                 :             : extern struct lto_file_decl_data **lto_get_file_decl_data (void);
     790                 :             : extern const char *lto_get_section_data (struct lto_file_decl_data *,
     791                 :             :                                          enum lto_section_type,
     792                 :             :                                          const char *, int, size_t *,
     793                 :             :                                          bool decompress = false);
     794                 :             : extern const char *lto_get_summary_section_data (struct lto_file_decl_data *,
     795                 :             :                                                  enum lto_section_type,
     796                 :             :                                                  size_t *);
     797                 :             : extern const char *lto_get_raw_section_data (struct lto_file_decl_data *,
     798                 :             :                                              enum lto_section_type,
     799                 :             :                                              const char *, int, size_t *);
     800                 :             : extern void lto_free_section_data (struct lto_file_decl_data *,
     801                 :             :                                    enum lto_section_type,
     802                 :             :                                    const char *, const char *, size_t,
     803                 :             :                                    bool decompress = false);
     804                 :             : extern void lto_free_raw_section_data (struct lto_file_decl_data *,
     805                 :             :                                        enum lto_section_type,
     806                 :             :                                        const char *, const char *, size_t);
     807                 :             : extern htab_t lto_create_renaming_table (void);
     808                 :             : extern void lto_record_renamed_decl (struct lto_file_decl_data *,
     809                 :             :                                      const char *, const char *);
     810                 :             : extern const char *lto_get_decl_name_mapping (struct lto_file_decl_data *,
     811                 :             :                                               const char *);
     812                 :             : extern struct lto_in_decl_state *lto_new_in_decl_state (void);
     813                 :             : extern void lto_delete_in_decl_state (struct lto_in_decl_state *);
     814                 :             : extern struct lto_in_decl_state *lto_get_function_in_decl_state (
     815                 :             :                                       struct lto_file_decl_data *, tree);
     816                 :             : extern void lto_free_function_in_decl_state (struct lto_in_decl_state *);
     817                 :             : extern void lto_free_function_in_decl_state_for_node (symtab_node *);
     818                 :             : extern void lto_section_overrun (class lto_input_block *) ATTRIBUTE_NORETURN;
     819                 :             : extern void lto_value_range_error (const char *,
     820                 :             :                                    HOST_WIDE_INT, HOST_WIDE_INT,
     821                 :             :                                    HOST_WIDE_INT) ATTRIBUTE_NORETURN;
     822                 :             : 
     823                 :             : /* In lto-section-out.cc  */
     824                 :             : extern void lto_begin_section (const char *, bool);
     825                 :             : extern void lto_end_section (void);
     826                 :             : extern void lto_write_data (const void *, unsigned int);
     827                 :             : extern void lto_write_raw_data (const void *, unsigned int);
     828                 :             : extern void lto_write_stream (struct lto_output_stream *);
     829                 :             : extern struct lto_simple_output_block *lto_create_simple_output_block (
     830                 :             :                                 enum lto_section_type);
     831                 :             : extern void lto_destroy_simple_output_block (struct lto_simple_output_block *);
     832                 :             : extern struct lto_out_decl_state *lto_new_out_decl_state (void);
     833                 :             : extern void lto_delete_out_decl_state (struct lto_out_decl_state *);
     834                 :             : extern struct lto_out_decl_state *lto_get_out_decl_state (void);
     835                 :             : extern void lto_push_out_decl_state (struct lto_out_decl_state *);
     836                 :             : extern struct lto_out_decl_state *lto_pop_out_decl_state (void);
     837                 :             : extern void lto_record_function_out_decl_state (tree,
     838                 :             :                                                 struct lto_out_decl_state *);
     839                 :             : extern void lto_append_block (struct lto_output_stream *);
     840                 :             : 
     841                 :             : 
     842                 :             : /* In lto-streamer.cc.  */
     843                 :             : 
     844                 :             : /* Set when streaming LTO for offloading compiler.  */
     845                 :             : extern bool lto_stream_offload_p;
     846                 :             : 
     847                 :             : extern const char *lto_tag_name (enum LTO_tags);
     848                 :             : extern char *lto_get_section_name (int, const char *, int,
     849                 :             :                                    struct lto_file_decl_data *);
     850                 :             : extern void print_lto_report (const char *);
     851                 :             : extern void lto_streamer_init (void);
     852                 :             : extern bool gate_lto_out (void);
     853                 :             : extern void lto_check_version (int, int, const char *);
     854                 :             : extern void lto_streamer_hooks_init (void);
     855                 :             : 
     856                 :             : /* In lto-streamer-in.cc */
     857                 :             : extern void lto_input_cgraph (struct lto_file_decl_data *, const char *);
     858                 :             : extern void lto_reader_init (void);
     859                 :             : extern void lto_free_file_name_hash (void);
     860                 :             : extern void lto_input_function_body (struct lto_file_decl_data *,
     861                 :             :                                      struct cgraph_node *,
     862                 :             :                                      const char *);
     863                 :             : extern void lto_input_variable_constructor (struct lto_file_decl_data *,
     864                 :             :                                             struct varpool_node *,
     865                 :             :                                             const char *);
     866                 :             : extern void lto_input_constructors_and_inits (struct lto_file_decl_data *,
     867                 :             :                                               const char *);
     868                 :             : extern void lto_input_toplevel_asms (struct lto_file_decl_data *, int);
     869                 :             : extern void lto_input_mode_table (struct lto_file_decl_data *);
     870                 :             : extern class data_in *lto_data_in_create (struct lto_file_decl_data *,
     871                 :             :                                     const char *, unsigned,
     872                 :             :                                     vec<ld_plugin_symbol_resolution_t> );
     873                 :             : extern void lto_data_in_delete (class data_in *);
     874                 :             : extern void lto_input_data_block (class lto_input_block *, void *, size_t);
     875                 :             : void lto_input_location (location_t *, struct bitpack_d *, class data_in *);
     876                 :             : tree lto_input_tree_ref (class lto_input_block *, class data_in *,
     877                 :             :                          struct function *, enum LTO_tags);
     878                 :             : void lto_tag_check_set (enum LTO_tags, int, ...);
     879                 :             : void lto_init_eh (void);
     880                 :             : hashval_t lto_input_scc (class lto_input_block *, class data_in *,
     881                 :             :                          unsigned *, unsigned *, bool);
     882                 :             : tree lto_input_tree_1 (class lto_input_block *, class data_in *,
     883                 :             :                        enum LTO_tags, hashval_t hash);
     884                 :             : tree lto_input_tree (class lto_input_block *, class data_in *);
     885                 :             : tree stream_read_tree_ref (class lto_input_block *, class data_in *);
     886                 :             : 
     887                 :             : 
     888                 :             : /* In lto-streamer-out.cc  */
     889                 :             : extern void lto_register_decl_definition (tree, struct lto_file_decl_data *);
     890                 :             : extern struct output_block *create_output_block (enum lto_section_type);
     891                 :             : extern void destroy_output_block (struct output_block *);
     892                 :             : extern void lto_output_tree (struct output_block *, tree, bool, bool);
     893                 :             : extern void stream_write_tree_ref (struct output_block *, tree);
     894                 :             : extern void lto_output_var_decl_ref (struct lto_out_decl_state *,
     895                 :             :                                      struct lto_output_stream *, tree);
     896                 :             : extern void lto_output_fn_decl_ref (struct lto_out_decl_state *,
     897                 :             :                                     struct lto_output_stream *, tree);
     898                 :             : extern tree lto_input_var_decl_ref (lto_input_block *, lto_file_decl_data *);
     899                 :             : extern tree lto_input_fn_decl_ref (lto_input_block *, lto_file_decl_data *);
     900                 :             : extern void lto_output_toplevel_asms (void);
     901                 :             : extern void produce_asm (struct output_block *ob);
     902                 :             : extern void lto_output ();
     903                 :             : extern void produce_asm_for_decls ();
     904                 :             : void lto_output_decl_state_streams (struct output_block *,
     905                 :             :                                     struct lto_out_decl_state *);
     906                 :             : void lto_output_decl_state_refs (struct output_block *,
     907                 :             :                                  struct lto_output_stream *,
     908                 :             :                                  struct lto_out_decl_state *);
     909                 :             : void lto_output_location (struct output_block *, struct bitpack_d *,
     910                 :             :                           location_t);
     911                 :             : void lto_output_location_and_block (struct output_block *, struct bitpack_d *,
     912                 :             :                                     location_t);
     913                 :             : void lto_output_init_mode_table (void);
     914                 :             : void lto_prepare_function_for_streaming (cgraph_node *);
     915                 :             : 
     916                 :             : 
     917                 :             : /* In lto-cgraph.cc  */
     918                 :             : extern bool asm_nodes_output;
     919                 :             : lto_symtab_encoder_t lto_symtab_encoder_new (bool);
     920                 :             : int lto_symtab_encoder_encode (lto_symtab_encoder_t, symtab_node *);
     921                 :             : void lto_symtab_encoder_delete (lto_symtab_encoder_t);
     922                 :             : bool lto_symtab_encoder_delete_node (lto_symtab_encoder_t, symtab_node *);
     923                 :             : bool lto_symtab_encoder_encode_body_p (lto_symtab_encoder_t,
     924                 :             :                                        struct cgraph_node *);
     925                 :             : bool lto_symtab_encoder_only_for_inlining_p (lto_symtab_encoder_t,
     926                 :             :                                              struct cgraph_node *);
     927                 :             : bool lto_symtab_encoder_in_partition_p (lto_symtab_encoder_t,
     928                 :             :                                         symtab_node *);
     929                 :             : void lto_set_symtab_encoder_in_partition (lto_symtab_encoder_t,
     930                 :             :                                           symtab_node *);
     931                 :             : 
     932                 :             : bool lto_symtab_encoder_encode_initializer_p (lto_symtab_encoder_t,
     933                 :             :                                               varpool_node *);
     934                 :             : void output_symtab (void);
     935                 :             : void input_symtab (void);
     936                 :             : void output_offload_tables (void);
     937                 :             : void input_offload_tables (bool);
     938                 :             : bool referenced_from_other_partition_p (struct ipa_ref_list *,
     939                 :             :                                         lto_symtab_encoder_t);
     940                 :             : bool reachable_from_other_partition_p (struct cgraph_node *,
     941                 :             :                                        lto_symtab_encoder_t);
     942                 :             : bool referenced_from_this_partition_p (symtab_node *,
     943                 :             :                                         lto_symtab_encoder_t);
     944                 :             : bool reachable_from_this_partition_p (struct cgraph_node *,
     945                 :             :                                       lto_symtab_encoder_t);
     946                 :             : lto_symtab_encoder_t compute_ltrans_boundary (lto_symtab_encoder_t encoder);
     947                 :             : void select_what_to_stream (void);
     948                 :             : 
     949                 :             : /* In omp-general.cc.  */
     950                 :             : void omp_lto_output_declare_variant_alt (lto_simple_output_block *,
     951                 :             :                                          cgraph_node *, lto_symtab_encoder_t);
     952                 :             : void omp_lto_input_declare_variant_alt (lto_input_block *, cgraph_node *,
     953                 :             :                                         vec<symtab_node *>);
     954                 :             : 
     955                 :             : /* In options-save.cc.  */
     956                 :             : void cl_target_option_stream_out (struct output_block *, struct bitpack_d *,
     957                 :             :                                   struct cl_target_option *);
     958                 :             : 
     959                 :             : void cl_target_option_stream_in (class data_in *,
     960                 :             :                                  struct bitpack_d *,
     961                 :             :                                  struct cl_target_option *);
     962                 :             : 
     963                 :             : void cl_optimization_stream_out (struct output_block *,
     964                 :             :                                  struct bitpack_d *, struct cl_optimization *);
     965                 :             : 
     966                 :             : void cl_optimization_stream_in (class data_in *,
     967                 :             :                                 struct bitpack_d *, struct cl_optimization *);
     968                 :             : 
     969                 :             : 
     970                 :             : 
     971                 :             : /* In lto-opts.cc.  */
     972                 :             : extern void lto_write_options (void);
     973                 :             : 
     974                 :             : 
     975                 :             : /* Statistics gathered during LTO, WPA and LTRANS.  */
     976                 :             : extern struct lto_stats_d lto_stats;
     977                 :             : 
     978                 :             : /* Section names corresponding to the values of enum lto_section_type.  */
     979                 :             : extern const char *lto_section_name[];
     980                 :             : 
     981                 :             : /* Holds all the out decl states of functions output so far in the
     982                 :             :    current output file.  */
     983                 :             : extern vec<lto_out_decl_state_ptr> lto_function_decl_states;
     984                 :             : 
     985                 :             : /* Return true if LTO tag TAG corresponds to a tree code.  */
     986                 :             : inline bool
     987                 :     4211398 : lto_tag_is_tree_code_p (enum LTO_tags tag)
     988                 :             : {
     989                 :     4211398 :   return tag > LTO_first_tree_tag && (unsigned) tag <= MAX_TREE_CODES;
     990                 :             : }
     991                 :             : 
     992                 :             : 
     993                 :             : /* Return true if LTO tag TAG corresponds to a gimple code.  */
     994                 :             : inline bool
     995                 :     1378706 : lto_tag_is_gimple_code_p (enum LTO_tags tag)
     996                 :             : {
     997                 :     1378706 :   return (unsigned) tag >= LTO_first_gimple_tag
     998                 :     1378706 :          && (unsigned) tag
     999                 :             :             < LTO_first_gimple_tag + LAST_AND_UNUSED_GIMPLE_CODE;
    1000                 :             : }
    1001                 :             : 
    1002                 :             : 
    1003                 :             : /* Return the LTO tag corresponding to gimple code CODE.  See enum
    1004                 :             :    LTO_tags for details on the conversion.  */
    1005                 :             : inline enum LTO_tags
    1006                 :     1647526 : lto_gimple_code_to_tag (enum gimple_code code)
    1007                 :             : {
    1008                 :     1647526 :   return (enum LTO_tags) ((unsigned) code + LTO_first_gimple_tag);
    1009                 :             : }
    1010                 :             : 
    1011                 :             : 
    1012                 :             : /* Return the GIMPLE code corresponding to TAG.  See enum LTO_tags for
    1013                 :             :    details on the conversion.  */
    1014                 :             : inline enum gimple_code
    1015                 :     1378706 : lto_tag_to_gimple_code (enum LTO_tags tag)
    1016                 :             : {
    1017                 :     1378706 :   gcc_assert (lto_tag_is_gimple_code_p (tag));
    1018                 :     1378706 :   return (enum gimple_code) ((unsigned) tag - LTO_first_gimple_tag);
    1019                 :             : }
    1020                 :             : 
    1021                 :             : 
    1022                 :             : /* Return the LTO tag corresponding to tree code CODE.  See enum
    1023                 :             :    LTO_tags for details on the conversion.  */
    1024                 :             : inline enum LTO_tags
    1025                 :     6892687 : lto_tree_code_to_tag (enum tree_code code)
    1026                 :             : {
    1027                 :     6892687 :   return (enum LTO_tags) ((unsigned) code + LTO_first_tree_tag);
    1028                 :             : }
    1029                 :             : 
    1030                 :             : 
    1031                 :             : /* Return the tree code corresponding to TAG.  See enum LTO_tags for
    1032                 :             :    details on the conversion.  */
    1033                 :             : inline enum tree_code
    1034                 :     4211398 : lto_tag_to_tree_code (enum LTO_tags tag)
    1035                 :             : {
    1036                 :     4211398 :   gcc_assert (lto_tag_is_tree_code_p (tag));
    1037                 :     4211398 :   return (enum tree_code) ((unsigned) tag - LTO_first_tree_tag);
    1038                 :             : }
    1039                 :             : 
    1040                 :             : /* Check that tag ACTUAL == EXPECTED.  */
    1041                 :             : inline void
    1042                 :       83212 : lto_tag_check (enum LTO_tags actual, enum LTO_tags expected)
    1043                 :             : {
    1044                 :       83212 :   if (actual != expected)
    1045                 :           0 :     internal_error ("bytecode stream: expected tag %s instead of %s",
    1046                 :             :                     lto_tag_name (expected), lto_tag_name (actual));
    1047                 :       83212 : }
    1048                 :             : 
    1049                 :             : /* Check that tag ACTUAL is in the range [TAG1, TAG2].  */
    1050                 :             : inline void
    1051                 :       10020 : lto_tag_check_range (enum LTO_tags actual, enum LTO_tags tag1,
    1052                 :             :                      enum LTO_tags tag2)
    1053                 :             : {
    1054                 :       10020 :   if (actual < tag1 || actual > tag2)
    1055                 :           0 :     internal_error ("bytecode stream: tag %s is not in the expected range "
    1056                 :             :                     "[%s, %s]",
    1057                 :             :                     lto_tag_name (actual),
    1058                 :             :                     lto_tag_name (tag1),
    1059                 :             :                     lto_tag_name (tag2));
    1060                 :       10020 : }
    1061                 :             : 
    1062                 :             : /* Initialize an lto_out_decl_buffer ENCODER.  */
    1063                 :             : inline void
    1064                 :      184524 : lto_init_tree_ref_encoder (struct lto_tree_ref_encoder *encoder)
    1065                 :             : {
    1066                 :      184524 :   encoder->tree_hash_table = new hash_map<tree, unsigned> (251);
    1067                 :      184524 :   encoder->trees.create (0);
    1068                 :      184524 : }
    1069                 :             : 
    1070                 :             : 
    1071                 :             : /* Destroy an lto_tree_ref_encoder ENCODER by freeing its contents.  The
    1072                 :             :    memory used by ENCODER is not freed by this function.  */
    1073                 :             : inline void
    1074                 :      184524 : lto_destroy_tree_ref_encoder (struct lto_tree_ref_encoder *encoder)
    1075                 :             : {
    1076                 :             :   /* Hash table may be delete already.  */
    1077                 :      184524 :   delete encoder->tree_hash_table;
    1078                 :      184524 :   encoder->tree_hash_table = NULL;
    1079                 :      184524 :   encoder->trees.release ();
    1080                 :      184524 : }
    1081                 :             : 
    1082                 :             : /* Return the number of trees encoded in ENCODER. */
    1083                 :             : inline unsigned int
    1084                 :      587933 : lto_tree_ref_encoder_size (struct lto_tree_ref_encoder *encoder)
    1085                 :             : {
    1086                 :     1138754 :   return encoder->trees.length ();
    1087                 :             : }
    1088                 :             : 
    1089                 :             : /* Return the IDX-th tree in ENCODER. */
    1090                 :             : inline tree
    1091                 :     5136818 : lto_tree_ref_encoder_get_tree (struct lto_tree_ref_encoder *encoder,
    1092                 :             :                                unsigned int idx)
    1093                 :             : {
    1094                 :     5136818 :   return encoder->trees[idx];
    1095                 :             : }
    1096                 :             : 
    1097                 :             : /* Return number of encoded nodes in ENCODER.  */
    1098                 :             : inline int
    1099                 :    17828021 : lto_symtab_encoder_size (lto_symtab_encoder_t encoder)
    1100                 :             : {
    1101                 :    29382303 :   return encoder->nodes.length ();
    1102                 :             : }
    1103                 :             : 
    1104                 :             : /* Value used to represent failure of lto_symtab_encoder_lookup.  */
    1105                 :             : #define LCC_NOT_FOUND   (-1)
    1106                 :             : 
    1107                 :             : /* Look up NODE in encoder.  Return NODE's reference if it has been encoded
    1108                 :             :    or LCC_NOT_FOUND if it is not there.  */
    1109                 :             : 
    1110                 :             : inline int
    1111                 :    12469409 : lto_symtab_encoder_lookup (lto_symtab_encoder_t encoder,
    1112                 :             :                            symtab_node *node)
    1113                 :             : {
    1114                 :    12469409 :   size_t *slot = encoder->map->get (node);
    1115                 :    12469409 :   return (slot && *slot ? *(slot) - 1 : LCC_NOT_FOUND);
    1116                 :             : }
    1117                 :             : 
    1118                 :             : /* Return true if iterator LSE points to nothing.  */
    1119                 :             : inline bool
    1120                 :    13851827 : lsei_end_p (lto_symtab_encoder_iterator lsei)
    1121                 :             : {
    1122                 :     5555985 :   return lsei.index >= (unsigned)lto_symtab_encoder_size (lsei.encoder);
    1123                 :             : }
    1124                 :             : 
    1125                 :             : /* Advance iterator LSE.  */
    1126                 :             : inline void
    1127                 :    10879444 : lsei_next (lto_symtab_encoder_iterator *lsei)
    1128                 :             : {
    1129                 :    10879444 :   lsei->index++;
    1130                 :    10879437 : }
    1131                 :             : 
    1132                 :             : /* Return the node pointed to by LSI.  */
    1133                 :             : inline symtab_node *
    1134                 :    15606975 : lsei_node (lto_symtab_encoder_iterator lsei)
    1135                 :             : {
    1136                 :    11239022 :   return lsei.encoder->nodes[lsei.index].node;
    1137                 :             : }
    1138                 :             : 
    1139                 :             : /* Return the node pointed to by LSI.  */
    1140                 :             : inline struct cgraph_node *
    1141                 :     1210225 : lsei_cgraph_node (lto_symtab_encoder_iterator lsei)
    1142                 :             : {
    1143                 :     1210225 :   return dyn_cast<cgraph_node *> (lsei.encoder->nodes[lsei.index].node);
    1144                 :             : }
    1145                 :             : 
    1146                 :             : /* Return the node pointed to by LSI.  */
    1147                 :             : inline varpool_node *
    1148                 :      278648 : lsei_varpool_node (lto_symtab_encoder_iterator lsei)
    1149                 :             : {
    1150                 :      278648 :   return dyn_cast<varpool_node *> (lsei.encoder->nodes[lsei.index].node);
    1151                 :             : }
    1152                 :             : 
    1153                 :             : /* Return the cgraph node corresponding to REF using ENCODER.  */
    1154                 :             : 
    1155                 :             : inline symtab_node *
    1156                 :     6589717 : lto_symtab_encoder_deref (lto_symtab_encoder_t encoder, int ref)
    1157                 :             : {
    1158                 :     6588051 :   if (ref == LCC_NOT_FOUND)
    1159                 :             :     return NULL;
    1160                 :             : 
    1161                 :     6589717 :   return encoder->nodes[ref].node;
    1162                 :             : }
    1163                 :             : 
    1164                 :             : /* Return an iterator to the first node in LSI.  */
    1165                 :             : inline lto_symtab_encoder_iterator
    1166                 :             : lsei_start (lto_symtab_encoder_t encoder)
    1167                 :             : {
    1168                 :             :   lto_symtab_encoder_iterator lsei;
    1169                 :             : 
    1170                 :      403745 :   lsei.encoder = encoder;
    1171                 :      403744 :   lsei.index = 0;
    1172                 :             :   return lsei;
    1173                 :             : }
    1174                 :             : 
    1175                 :             : /* Advance iterator LSE.  */
    1176                 :             : inline void
    1177                 :      685211 : lsei_next_in_partition (lto_symtab_encoder_iterator *lsei)
    1178                 :             : {
    1179                 :      685211 :   lsei_next (lsei);
    1180                 :      685211 :   while (!lsei_end_p (*lsei)
    1181                 :     2255103 :          && !lto_symtab_encoder_in_partition_p (lsei->encoder, lsei_node (*lsei)))
    1182                 :      460924 :     lsei_next (lsei);
    1183                 :      685211 : }
    1184                 :             : 
    1185                 :             : /* Return an iterator to the first node in LSI.  */
    1186                 :             : inline lto_symtab_encoder_iterator
    1187                 :       37555 : lsei_start_in_partition (lto_symtab_encoder_t encoder)
    1188                 :             : {
    1189                 :       37555 :   lto_symtab_encoder_iterator lsei = lsei_start (encoder);
    1190                 :             : 
    1191                 :       37555 :   if (lsei_end_p (lsei))
    1192                 :         388 :     return lsei;
    1193                 :       37167 :   if (!lto_symtab_encoder_in_partition_p (encoder, lsei_node (lsei)))
    1194                 :           0 :     lsei_next_in_partition (&lsei);
    1195                 :             : 
    1196                 :       37167 :   return lsei;
    1197                 :             : }
    1198                 :             : 
    1199                 :             : /* Advance iterator LSE.  */
    1200                 :             : inline void
    1201                 :     1214057 : lsei_next_function_in_partition (lto_symtab_encoder_iterator *lsei)
    1202                 :             : {
    1203                 :     1214057 :   lsei_next (lsei);
    1204                 :     1214057 :   while (!lsei_end_p (*lsei)
    1205                 :    16831783 :          && (!is_a <cgraph_node *> (lsei_node (*lsei))
    1206                 :     3476076 :              || !lto_symtab_encoder_in_partition_p (lsei->encoder, lsei_node (*lsei))))
    1207                 :     5591558 :     lsei_next (lsei);
    1208                 :     1214057 : }
    1209                 :             : 
    1210                 :             : /* Return an iterator to the first node in LSI.  */
    1211                 :             : inline lto_symtab_encoder_iterator
    1212                 :      275836 : lsei_start_function_in_partition (lto_symtab_encoder_t encoder)
    1213                 :             : {
    1214                 :      275836 :   lto_symtab_encoder_iterator lsei = lsei_start (encoder);
    1215                 :             : 
    1216                 :      275836 :   if (lsei_end_p (lsei))
    1217                 :        2556 :     return lsei;
    1218                 :      543119 :   if (!is_a <cgraph_node *> (lsei_node (lsei))
    1219                 :      269839 :       || !lto_symtab_encoder_in_partition_p (encoder, lsei_node (lsei)))
    1220                 :        3832 :     lsei_next_function_in_partition (&lsei);
    1221                 :             : 
    1222                 :      273280 :   return lsei;
    1223                 :             : }
    1224                 :             : 
    1225                 :             : /* Advance iterator LSE.  */
    1226                 :             : inline void
    1227                 :      310998 : lsei_next_variable_in_partition (lto_symtab_encoder_iterator *lsei)
    1228                 :             : {
    1229                 :      310998 :   lsei_next (lsei);
    1230                 :      310998 :   while (!lsei_end_p (*lsei)
    1231                 :     1138896 :          && (!is_a <varpool_node *> (lsei_node (*lsei))
    1232                 :      278055 :              || !lto_symtab_encoder_in_partition_p (lsei->encoder, lsei_node (*lsei))))
    1233                 :      135894 :     lsei_next (lsei);
    1234                 :      310998 : }
    1235                 :             : 
    1236                 :             : /* Return an iterator to the first node in LSI.  */
    1237                 :             : inline lto_symtab_encoder_iterator
    1238                 :       33181 : lsei_start_variable_in_partition (lto_symtab_encoder_t encoder)
    1239                 :             : {
    1240                 :       33181 :   lto_symtab_encoder_iterator lsei = lsei_start (encoder);
    1241                 :             : 
    1242                 :       33181 :   if (lsei_end_p (lsei))
    1243                 :         238 :     return lsei;
    1244                 :       33536 :   if (!is_a <varpool_node *> (lsei_node (lsei))
    1245                 :         593 :       || !lto_symtab_encoder_in_partition_p (encoder, lsei_node (lsei)))
    1246                 :       32350 :     lsei_next_variable_in_partition (&lsei);
    1247                 :             : 
    1248                 :       32943 :   return lsei;
    1249                 :             : }
    1250                 :             : 
    1251                 :             : /* Entry for the delayed registering of decl -> DIE references.  */
    1252                 :             : struct dref_entry {
    1253                 :             :     tree decl;
    1254                 :             :     const char *sym;
    1255                 :             :     unsigned HOST_WIDE_INT off;
    1256                 :             : };
    1257                 :             : 
    1258                 :             : extern vec<dref_entry> dref_queue;
    1259                 :             : 
    1260                 :             : extern FILE *streamer_dump_file;
    1261                 :             : 
    1262                 :             : #endif /* GCC_LTO_STREAMER_H  */
        

Generated by: LCOV version 2.1-beta

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