LCOV - code coverage report
Current view: top level - gcc - lto-streamer.h (source / functions) Coverage Total Hit
Test: gcc.info Lines: 97.8 % 135 132
Test Date: 2026-06-20 15:32:29 Functions: 100.0 % 19 19
Legend: Lines:     hit not hit

            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-2026 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 tuples 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 succeed; mark all changes in the cache as
     272              :      accepted.  */
     273              :   void accept_location_cache ();
     274              :   /* Tree merging did succeed; throw away recent changes.  */
     275              :   void revert_location_cache ();
     276              :   void input_location (location_t *loc, struct bitpack_d *bp,
     277              :                        class data_in *data_in);
     278              :   void input_location_and_block (location_t *loc, struct bitpack_d *bp,
     279              :                                  class lto_input_block *ib,
     280              :                                  class data_in *data_in);
     281       212212 :   lto_location_cache ()
     282       212212 :      : loc_cache (), accepted_length (0), current_file (NULL), current_line (0),
     283       212212 :        current_col (0), current_sysp (false), current_loc (UNKNOWN_LOCATION),
     284       212212 :        current_block (NULL_TREE)
     285              :   {
     286       212212 :     gcc_assert (!current_cache);
     287       212212 :     current_cache = this;
     288       212212 :   }
     289       212212 :   ~lto_location_cache ()
     290              :   {
     291       212212 :     apply_location_cache ();
     292       212212 :     gcc_assert (current_cache == this);
     293       212212 :     current_cache = NULL;
     294       212212 :   }
     295              : 
     296              :   /* There can be at most one instance of location cache (combining multiple
     297              :      would bring it out of sync with libcpp linemap); point to current
     298              :      one.  */
     299              :   static lto_location_cache *current_cache;
     300              : 
     301              : private:
     302              :   static int cmp_loc (const void *pa, const void *pb);
     303              : 
     304              :   struct cached_location
     305              :   {
     306              :     const char *file;
     307              :     location_t *loc;
     308              :     int line, col;
     309              :     bool sysp;
     310              :     tree block;
     311              :     unsigned discr;
     312              :   };
     313              : 
     314              :   /* The location cache.  */
     315              : 
     316              :   auto_vec<cached_location> loc_cache;
     317              : 
     318              :   /* Accepted entries are ones used by trees that are known to be not unified
     319              :      by tree merging.  */
     320              : 
     321              :   int accepted_length;
     322              : 
     323              :   /* Bookkeeping to remember state in between calls to lto_apply_location_cache
     324              :      When streaming gimple, the location cache is not used and thus
     325              :      lto_apply_location_cache happens per location basis.  It is then
     326              :      useful to avoid redundant calls of linemap API.  */
     327              : 
     328              :   const char *current_file;
     329              :   int current_line;
     330              :   int current_col;
     331              :   bool current_sysp;
     332              :   location_t current_loc;
     333              :   tree current_block;
     334              :   unsigned current_discr;
     335              : };
     336              : 
     337              : /* Structure used as buffer for reading an LTO file.  */
     338              : class lto_input_block
     339              : {
     340              : public:
     341              :   /* Special constructor for the string table, it abuses this to
     342              :      do random access but use the uhwi decoder.  */
     343      1367483 :   lto_input_block (const char *data_, unsigned int p_, unsigned int len_,
     344              :                    const lto_file_decl_data *file_data_)
     345      1367483 :       : data (data_), file_data (file_data_), p (p_), len (len_) {}
     346       366853 :   lto_input_block (const char *data_, unsigned int len_,
     347              :                    const lto_file_decl_data *file_data_)
     348       281639 :       : data (data_), file_data (file_data_), p (0), len (len_) {}
     349              : 
     350              :   const char *data;
     351              :   const lto_file_decl_data *file_data;
     352              :   unsigned int p;
     353              :   unsigned int len;
     354              : };
     355              : 
     356              : /* Compression algorithm used for compression of LTO bytecode.  */
     357              : 
     358              : enum lto_compression
     359              : {
     360              :   ZLIB,
     361              :   ZSTD
     362              : };
     363              : 
     364              : /* Structure that represents LTO ELF section with information
     365              :    about the format.  */
     366              : 
     367              : struct lto_section
     368              : {
     369              :   int16_t major_version;
     370              :   int16_t minor_version;
     371              :   unsigned char slim_object;
     372              :   unsigned char _padding;
     373              : 
     374              :   /* Flags is a private field that is not defined publicly.  */
     375              :   uint16_t flags;
     376              : 
     377              :   /* Set compression to FLAGS.  */
     378        34795 :   inline void set_compression (lto_compression c)
     379              :   {
     380        34795 :     flags = c;
     381              :   }
     382              : 
     383              :   /* Get compression from FLAGS.  */
     384       219619 :   inline lto_compression get_compression ()
     385              :   {
     386       219619 :     return (lto_compression) flags;
     387              :   }
     388              : };
     389              : 
     390              : STATIC_ASSERT (sizeof (lto_section) == 8);
     391              : 
     392              : /* The is the first part of the record in an LTO file for many of the
     393              :    IPA passes.  */
     394              : struct lto_simple_header
     395              : {
     396              :   /* Size of main gimple body of function.  */
     397              :   int32_t main_size;
     398              : };
     399              : 
     400              : struct lto_simple_header_with_strings : lto_simple_header
     401              : {
     402              :   /* Size of the string table.  */
     403              :   int32_t string_size;
     404              : };
     405              : 
     406              : /* The header for a function body.  */
     407              : struct lto_function_header : lto_simple_header_with_strings
     408              : {
     409              :   /* Size of the cfg.  */
     410              :   int32_t cfg_size;
     411              : };
     412              : 
     413              : 
     414              : /* Structure describing a symbol section.  */
     415              : struct lto_decl_header : lto_simple_header_with_strings
     416              : {
     417              :   /* Size of region for decl state. */
     418              :   int32_t decl_state_size;
     419              : 
     420              :   /* Number of nodes in globals stream.  */
     421              :   int32_t num_nodes;
     422              : };
     423              : 
     424              : 
     425              : /* Statistics gathered during LTO, WPA and LTRANS.  */
     426              : struct lto_stats_d
     427              : {
     428              :   unsigned HOST_WIDE_INT num_input_cgraph_nodes;
     429              :   unsigned HOST_WIDE_INT num_output_symtab_nodes;
     430              :   unsigned HOST_WIDE_INT num_input_files;
     431              :   unsigned HOST_WIDE_INT num_output_files;
     432              :   unsigned HOST_WIDE_INT num_cgraph_partitions;
     433              :   unsigned HOST_WIDE_INT section_size[LTO_N_SECTION_TYPES];
     434              :   unsigned HOST_WIDE_INT num_function_bodies;
     435              :   unsigned HOST_WIDE_INT num_trees[NUM_TREE_CODES];
     436              :   unsigned HOST_WIDE_INT num_output_il_bytes;
     437              :   unsigned HOST_WIDE_INT num_compressed_il_bytes;
     438              :   unsigned HOST_WIDE_INT num_input_il_bytes;
     439              :   unsigned HOST_WIDE_INT num_uncompressed_il_bytes;
     440              :   unsigned HOST_WIDE_INT num_tree_bodies_output;
     441              :   unsigned HOST_WIDE_INT num_pickle_refs_output;
     442              : };
     443              : 
     444              : /* Entry of LTO symtab encoder.  */
     445              : struct lto_encoder_entry
     446              : {
     447              :   /* Constructor.  */
     448      1433821 :   lto_encoder_entry (toplevel_node* n)
     449      1433821 :     : node (n), in_partition (false), body (false), only_for_inlining (true),
     450      1433821 :       initializer (false)
     451              :   {}
     452              : 
     453              :   toplevel_node *node;
     454              :   /* Is the node in this partition (i.e. ltrans of this partition will
     455              :      be responsible for outputting it)? */
     456              :   unsigned int in_partition:1;
     457              :   /* Do we encode body in this partition?  */
     458              :   unsigned int body:1;
     459              :   /* Do we stream this node only for inlining?  */
     460              :   unsigned int only_for_inlining:1;
     461              :   /* Do we encode initializer in this partition?
     462              :      For example the readonly variable initializers are encoded to aid
     463              :      constant folding even if they are not in the partition.  */
     464              :   unsigned int initializer:1;
     465              : };
     466              : 
     467              : 
     468              : /* Encoder data structure used to stream callgraph nodes.  */
     469              : struct lto_symtab_encoder_d
     470              : {
     471              :   vec<lto_encoder_entry> nodes;
     472              :   hash_map<toplevel_node *, size_t> *map;
     473              : 
     474              :   /* Mapping of input order of nodes onto output order.  */
     475              :   hash_map<int_hash<int, -1, -2>, int> *order_remap;
     476              : };
     477              : 
     478              : typedef struct lto_symtab_encoder_d *lto_symtab_encoder_t;
     479              : 
     480              : /* Iterator structure for cgraph node sets.  */
     481              : struct lto_symtab_encoder_iterator
     482              : {
     483              :   lto_symtab_encoder_t encoder;
     484              :   unsigned index;
     485              : };
     486              : 
     487              : 
     488              : 
     489              : /* The lto_tree_ref_encoder struct is used to encode trees into indices. */
     490              : 
     491              : struct lto_tree_ref_encoder
     492              : {
     493              :   hash_map<tree, unsigned> *tree_hash_table;      /* Maps pointers to indices. */
     494              :   vec<tree> trees;                        /* Maps indices to pointers. */
     495              : };
     496              : 
     497              : 
     498              : /* Structure to hold states of input scope.  */
     499              : struct GTY((for_user)) lto_in_decl_state
     500              : {
     501              :   /* Array of lto_in_decl_buffers to store type and decls streams. */
     502              :   vec<tree, va_gc> *streams[LTO_N_DECL_STREAMS];
     503              : 
     504              :   /* If this in-decl state is associated with a function. FN_DECL
     505              :      point to the FUNCTION_DECL. */
     506              :   tree fn_decl;
     507              : 
     508              :   /* True if decl state is compressed.  */
     509              :   bool compressed;
     510              : };
     511              : 
     512              : typedef struct lto_in_decl_state *lto_in_decl_state_ptr;
     513              : 
     514              : struct decl_state_hasher : ggc_ptr_hash<lto_in_decl_state>
     515              : {
     516              :   static hashval_t
     517      2013977 :   hash (lto_in_decl_state *s)
     518              :   {
     519      2013977 :     return htab_hash_pointer (s->fn_decl);
     520              :   }
     521              : 
     522              :   static bool
     523      1672694 :   equal (lto_in_decl_state *a, lto_in_decl_state *b)
     524              :   {
     525      1672694 :     return a->fn_decl == b->fn_decl;
     526              :   }
     527              : };
     528              : 
     529              : /* The structure that holds all of the vectors of global types,
     530              :    decls and cgraph nodes used in the serialization of this file.  */
     531              : struct lto_out_decl_state
     532              : {
     533              :   /* The buffers contain the sets of decls of various kinds and types we have
     534              :      seen so far and the indexes assigned to them.  */
     535              :   struct lto_tree_ref_encoder streams[LTO_N_DECL_STREAMS];
     536              : 
     537              :   /* Encoder for cgraph nodes.  */
     538              :   lto_symtab_encoder_t symtab_node_encoder;
     539              : 
     540              :   /* If this out-decl state belongs to a function, fn_decl points to that
     541              :      function.  Otherwise, it is NULL. */
     542              :   tree fn_decl;
     543              : 
     544              :   /* True if decl state is compressed.  */
     545              :   bool compressed;
     546              : 
     547              :   /* True if offload tables should be output. */
     548              :   bool output_offload_tables_p;
     549              : };
     550              : 
     551              : typedef struct lto_out_decl_state *lto_out_decl_state_ptr;
     552              : 
     553              : 
     554              : /* Compact representation of a index <-> resolution pair. Unpacked to an
     555              :    vector later. */
     556              : struct res_pair
     557              : {
     558              :   ld_plugin_symbol_resolution_t res;
     559              :   unsigned index;
     560              : };
     561              : 
     562              : 
     563              : /* One of these is allocated for each object file that being compiled
     564              :    by lto.  This structure contains the tables that are needed by the
     565              :    serialized functions and ipa passes to connect themselves to the
     566              :    global types and decls as they are reconstituted.  */
     567              : struct GTY(()) lto_file_decl_data
     568              : {
     569              :   /* Decl state currently used. */
     570              :   struct lto_in_decl_state *current_decl_state;
     571              : 
     572              :   /* Decl state corresponding to regions outside of any functions
     573              :      in the compilation unit. */
     574              :   struct lto_in_decl_state *global_decl_state;
     575              : 
     576              :   /* Table of cgraph nodes present in this file.  */
     577              :   lto_symtab_encoder_t GTY((skip)) symtab_node_encoder;
     578              : 
     579              :   /* Hash table maps lto-related section names to location in file.  */
     580              :   hash_table<decl_state_hasher> *function_decl_states;
     581              : 
     582              :   /* The .o file that these offsets relate to.  */
     583              :   const char *GTY((skip)) file_name;
     584              : 
     585              :   /* Hash table maps lto-related section names to location in file.  */
     586              :   htab_t GTY((skip)) section_hash_table;
     587              : 
     588              :   /* Hash new name of renamed global declaration to its original name.  */
     589              :   htab_t GTY((skip)) renaming_hash_table;
     590              : 
     591              :   /* Linked list used temporarily in reader */
     592              :   struct lto_file_decl_data *next;
     593              : 
     594              :   /* Order in which the file appears on the command line.  */
     595              :   int order;
     596              : 
     597              :   /* Sub ID for merged objects. */
     598              :   unsigned HOST_WIDE_INT id;
     599              : 
     600              :   /* Symbol resolutions for this file */
     601              :   vec<res_pair>  GTY((skip)) respairs;
     602              :   unsigned max_index;
     603              : 
     604              :   gcov_summary GTY((skip)) profile_info;
     605              : 
     606              :   /* Map assigning declarations their resolutions.  */
     607              :   hash_map<tree, ld_plugin_symbol_resolution> * GTY((skip)) resolution_map;
     608              : 
     609              :   /* Mode translation table.  */
     610              :   const unsigned char *mode_table;
     611              : 
     612              :   /* Read LTO section.  */
     613              :   lto_section lto_section_header;
     614              : 
     615              :   int order_base;
     616              : 
     617              :   int unit_base;
     618              : 
     619              :   unsigned mode_bits;
     620              : };
     621              : 
     622              : typedef struct lto_file_decl_data *lto_file_decl_data_ptr;
     623              : 
     624              : struct lto_char_ptr_base
     625              : {
     626              :   char *ptr;
     627              : };
     628              : 
     629              : /* An incore byte stream to buffer the various parts of the function.
     630              :    The entire structure should be zeroed when created.  The record
     631              :    consists of a set of blocks.  The first sizeof (ptr) bytes are used
     632              :    as a chain, and the rest store the bytes to be written.  */
     633              : struct lto_output_stream
     634              : {
     635              :   /* The pointer to the first block in the stream.  */
     636              :   struct lto_char_ptr_base * first_block;
     637              : 
     638              :   /* The pointer to the last and current block in the stream.  */
     639              :   struct lto_char_ptr_base * current_block;
     640              : 
     641              :   /* The pointer to where the next char should be written.  */
     642              :   char * current_pointer;
     643              : 
     644              :   /* The number of characters left in the current block.  */
     645              :   unsigned int left_in_block;
     646              : 
     647              :   /* The block size of the last block allocated.  */
     648              :   unsigned int block_size;
     649              : 
     650              :   /* The total number of characters written.  */
     651              :   unsigned int total_size;
     652              : };
     653              : 
     654              : /* A simple output block.  This can be used for simple IPA passes that
     655              :    do not need more than one stream.  */
     656              : struct lto_simple_output_block
     657              : {
     658              :   enum lto_section_type section_type;
     659              :   struct lto_out_decl_state *decl_state;
     660              : 
     661              :   /* The stream that the main tree codes are written to.  */
     662              :   struct lto_output_stream *main_stream;
     663              : };
     664              : 
     665              : /* String hashing.  */
     666              : 
     667              : struct string_slot
     668              : {
     669              :   const char *s;
     670              :   int len;
     671              :   unsigned int slot_num;
     672              : };
     673              : 
     674              : /* Hashtable helpers.  */
     675              : 
     676              : struct string_slot_hasher : nofree_ptr_hash <string_slot>
     677              : {
     678              :   static inline hashval_t hash (const string_slot *);
     679              :   static inline bool equal (const string_slot *, const string_slot *);
     680              : };
     681              : 
     682              : /* Returns a hash code for DS.  Adapted from libiberty's htab_hash_string
     683              :    to support strings that may not end in '\0'.  */
     684              : 
     685              : inline hashval_t
     686     11265739 : string_slot_hasher::hash (const string_slot *ds)
     687              : {
     688     11265739 :   hashval_t r = ds->len;
     689     11265739 :   int i;
     690              : 
     691    285865174 :   for (i = 0; i < ds->len; i++)
     692    274599435 :      r = r * 67 + (unsigned)ds->s[i] - 113;
     693     11265739 :   return r;
     694              : }
     695              : 
     696              : /* Returns nonzero if DS1 and DS2 are equal.  */
     697              : 
     698              : inline bool
     699      8952272 : string_slot_hasher::equal (const string_slot *ds1, const string_slot *ds2)
     700              : {
     701      8952272 :   if (ds1->len == ds2->len)
     702      4947321 :     return memcmp (ds1->s, ds2->s, ds1->len) == 0;
     703              : 
     704              :   return 0;
     705              : }
     706              : 
     707              : /* Data structure holding all the data and descriptors used when writing
     708              :    an LTO file.  */
     709              : struct output_block
     710              : {
     711              :   enum lto_section_type section_type;
     712              :   struct lto_out_decl_state *decl_state;
     713              : 
     714              :   /* The stream that the main tree codes are written to.  */
     715              :   struct lto_output_stream *main_stream;
     716              : 
     717              :   /* The stream that contains the string table.  */
     718              :   struct lto_output_stream *string_stream;
     719              : 
     720              :   /* The stream that contains the cfg.  */
     721              :   struct lto_output_stream *cfg_stream;
     722              : 
     723              :   /* The hash table that contains the set of strings we have seen so
     724              :      far and the indexes assigned to them.  */
     725              :   hash_table<string_slot_hasher> *string_hash_table;
     726              : 
     727              :   /* The current symbol that we are currently serializing.  Null
     728              :      if we are serializing something else.  */
     729              :   symtab_node *symbol;
     730              : 
     731              :   /* These are the last file and line that were seen in the stream.
     732              :      If the current node differs from these, it needs to insert
     733              :      something into the stream and fix these up.  */
     734              :   const char *current_file;
     735              :   int current_line;
     736              :   int current_col;
     737              :   bool current_sysp;
     738              :   bool reset_locus;
     739              :   bool emit_pwd;
     740              :   tree current_block;
     741              :   unsigned current_discr;
     742              : 
     743              :   /* Cache of nodes written in this section.  */
     744              :   struct streamer_tree_cache_d *writer_cache;
     745              : 
     746              :   /* All trees identified as local to the unit streamed.  */
     747              :   hash_set<tree> *local_trees;
     748              : 
     749              :   /* All data persistent across whole duration of output block
     750              :      can go here.  */
     751              :   struct obstack obstack;
     752              : };
     753              : 
     754              : 
     755              : /* Data and descriptors used when reading from an LTO file.  */
     756       424424 : class data_in
     757              : {
     758              : public:
     759              :   /* The global decls and types.  */
     760              :   struct lto_file_decl_data *file_data;
     761              : 
     762              :   /* The string table.  */
     763              :   const char *strings;
     764              : 
     765              :   /* The length of the string table.  */
     766              :   unsigned int strings_len;
     767              : 
     768              :   /* Maps each reference number to the resolution done by the linker. */
     769              :   vec<ld_plugin_symbol_resolution_t> globals_resolution;
     770              : 
     771              :   /* Cache of pickled nodes.  */
     772              :   struct streamer_tree_cache_d *reader_cache;
     773              : 
     774              :   /* Cache of source code location.  */
     775              :   lto_location_cache location_cache;
     776              : };
     777              : 
     778              : 
     779              : /* In lto-section-in.cc  */
     780              : extern class lto_input_block * lto_create_simple_input_block (
     781              :                                struct lto_file_decl_data *,
     782              :                                enum lto_section_type, const char **, size_t *);
     783              : extern void
     784              : lto_destroy_simple_input_block (struct lto_file_decl_data *,
     785              :                                 enum lto_section_type,
     786              :                                 class lto_input_block *, const char *, size_t);
     787              : extern void lto_set_in_hooks (struct lto_file_decl_data **,
     788              :                               lto_get_section_data_f *,
     789              :                               lto_free_section_data_f *);
     790              : extern struct lto_file_decl_data **lto_get_file_decl_data (void);
     791              : extern const char *lto_get_section_data (struct lto_file_decl_data *,
     792              :                                          enum lto_section_type,
     793              :                                          const char *, int, size_t *,
     794              :                                          bool decompress = false);
     795              : extern const char *lto_get_summary_section_data (struct lto_file_decl_data *,
     796              :                                                  enum lto_section_type,
     797              :                                                  size_t *);
     798              : extern const char *lto_get_raw_section_data (struct lto_file_decl_data *,
     799              :                                              enum lto_section_type,
     800              :                                              const char *, int, size_t *);
     801              : extern void lto_free_section_data (struct lto_file_decl_data *,
     802              :                                    enum lto_section_type,
     803              :                                    const char *, const char *, size_t,
     804              :                                    bool decompress = false);
     805              : extern void lto_free_raw_section_data (struct lto_file_decl_data *,
     806              :                                        enum lto_section_type,
     807              :                                        const char *, const char *, size_t);
     808              : extern htab_t lto_create_renaming_table (void);
     809              : extern void lto_record_renamed_decl (struct lto_file_decl_data *,
     810              :                                      const char *, const char *);
     811              : extern const char *lto_get_decl_name_mapping (struct lto_file_decl_data *,
     812              :                                               const char *);
     813              : extern struct lto_in_decl_state *lto_new_in_decl_state (void);
     814              : extern void lto_delete_in_decl_state (struct lto_in_decl_state *);
     815              : extern struct lto_in_decl_state *lto_get_function_in_decl_state (
     816              :                                       struct lto_file_decl_data *, tree);
     817              : extern void lto_free_function_in_decl_state (struct lto_in_decl_state *);
     818              : extern void lto_free_function_in_decl_state_for_node (symtab_node *);
     819              : extern void lto_section_overrun (class lto_input_block *) ATTRIBUTE_NORETURN;
     820              : extern void lto_value_range_error (const char *,
     821              :                                    HOST_WIDE_INT, HOST_WIDE_INT,
     822              :                                    HOST_WIDE_INT) ATTRIBUTE_NORETURN;
     823              : 
     824              : /* In lto-section-out.cc  */
     825              : extern void lto_begin_section (const char *, bool);
     826              : extern void lto_end_section (void);
     827              : extern void lto_write_data (const void *, unsigned int);
     828              : extern void lto_write_raw_data (const void *, unsigned int);
     829              : extern void lto_write_stream (struct lto_output_stream *);
     830              : extern struct lto_simple_output_block *lto_create_simple_output_block (
     831              :                                 enum lto_section_type);
     832              : extern void lto_destroy_simple_output_block (struct lto_simple_output_block *);
     833              : extern struct lto_out_decl_state *lto_new_out_decl_state (void);
     834              : extern void lto_delete_out_decl_state (struct lto_out_decl_state *);
     835              : extern struct lto_out_decl_state *lto_get_out_decl_state (void);
     836              : extern void lto_push_out_decl_state (struct lto_out_decl_state *);
     837              : extern struct lto_out_decl_state *lto_pop_out_decl_state (void);
     838              : extern void lto_record_function_out_decl_state (tree,
     839              :                                                 struct lto_out_decl_state *);
     840              : extern void lto_append_block (struct lto_output_stream *);
     841              : 
     842              : 
     843              : /* In lto-streamer.cc.  */
     844              : 
     845              : /* Set when streaming LTO for offloading compiler.  */
     846              : extern bool lto_stream_offload_p;
     847              : 
     848              : extern const char *lto_tag_name (enum LTO_tags);
     849              : extern char *lto_get_section_name (int, const char *, int,
     850              :                                    struct lto_file_decl_data *);
     851              : extern void print_lto_report (const char *);
     852              : extern void lto_streamer_init (void);
     853              : extern bool gate_lto_out (void);
     854              : extern void lto_check_version (int, int, const char *);
     855              : extern void lto_streamer_hooks_init (void);
     856              : 
     857              : /* In lto-streamer-in.cc */
     858              : extern void lto_input_cgraph (struct lto_file_decl_data *, const char *);
     859              : extern void lto_reader_init (void);
     860              : extern void lto_free_file_name_hash (void);
     861              : extern void lto_input_function_body (struct lto_file_decl_data *,
     862              :                                      struct cgraph_node *,
     863              :                                      const char *);
     864              : extern void lto_input_variable_constructor (struct lto_file_decl_data *,
     865              :                                             struct varpool_node *,
     866              :                                             const char *);
     867              : extern void lto_input_constructors_and_inits (struct lto_file_decl_data *,
     868              :                                               const char *);
     869              : extern void lto_input_toplevel_asms (struct lto_file_decl_data *, int);
     870              : extern void lto_input_mode_table (struct lto_file_decl_data *);
     871              : extern class data_in *lto_data_in_create (struct lto_file_decl_data *,
     872              :                                     const char *, unsigned,
     873              :                                     vec<ld_plugin_symbol_resolution_t> );
     874              : extern void lto_data_in_delete (class data_in *);
     875              : extern void lto_input_data_block (class lto_input_block *, void *, size_t);
     876              : void lto_input_location (location_t *, struct bitpack_d *, class data_in *);
     877              : tree lto_input_tree_ref (class lto_input_block *, class data_in *,
     878              :                          struct function *, enum LTO_tags);
     879              : void lto_tag_check_set (enum LTO_tags, int, ...);
     880              : void lto_init_eh (void);
     881              : hashval_t lto_input_scc (class lto_input_block *, class data_in *,
     882              :                          unsigned *, unsigned *, bool);
     883              : tree lto_input_tree_1 (class lto_input_block *, class data_in *,
     884              :                        enum LTO_tags, hashval_t hash);
     885              : tree lto_input_tree (class lto_input_block *, class data_in *);
     886              : tree stream_read_tree_ref (class lto_input_block *, class data_in *);
     887              : 
     888              : 
     889              : /* In lto-streamer-out.cc  */
     890              : extern void lto_register_decl_definition (tree, struct lto_file_decl_data *);
     891              : extern struct output_block *create_output_block (enum lto_section_type);
     892              : extern void destroy_output_block (struct output_block *);
     893              : extern void lto_output_tree (struct output_block *, tree, bool, bool);
     894              : extern void stream_write_tree_ref (struct output_block *, tree);
     895              : extern void lto_output_var_decl_ref (struct lto_out_decl_state *,
     896              :                                      struct lto_output_stream *, tree);
     897              : extern void lto_output_fn_decl_ref (struct lto_out_decl_state *,
     898              :                                     struct lto_output_stream *, tree);
     899              : extern tree lto_input_var_decl_ref (lto_input_block *, lto_file_decl_data *);
     900              : extern tree lto_input_fn_decl_ref (lto_input_block *, lto_file_decl_data *);
     901              : extern void lto_output_toplevel_asms (lto_symtab_encoder_t);
     902              : extern void produce_asm (struct output_block *ob);
     903              : extern void lto_output ();
     904              : extern void produce_asm_for_decls ();
     905              : void lto_output_decl_state_streams (struct output_block *,
     906              :                                     struct lto_out_decl_state *);
     907              : void lto_output_decl_state_refs (struct output_block *,
     908              :                                  struct lto_output_stream *,
     909              :                                  struct lto_out_decl_state *);
     910              : bool lto_variably_modified_type_p (tree);
     911              : void lto_output_location (struct output_block *, struct bitpack_d *,
     912              :                           location_t);
     913              : void lto_output_location_and_block (struct output_block *, struct bitpack_d *,
     914              :                                     location_t);
     915              : void lto_output_init_mode_table (void);
     916              : void lto_prepare_function_for_streaming (cgraph_node *);
     917              : 
     918              : 
     919              : /* In lto-cgraph.cc  */
     920              : lto_symtab_encoder_t lto_symtab_encoder_new (bool);
     921              : int lto_symtab_encoder_encode (lto_symtab_encoder_t, toplevel_node *);
     922              : void lto_symtab_encoder_delete (lto_symtab_encoder_t);
     923              : bool lto_symtab_encoder_delete_node (lto_symtab_encoder_t, toplevel_node *);
     924              : bool lto_symtab_encoder_encode_body_p (lto_symtab_encoder_t,
     925              :                                        struct cgraph_node *);
     926              : bool lto_symtab_encoder_only_for_inlining_p (lto_symtab_encoder_t,
     927              :                                              struct cgraph_node *);
     928              : bool lto_symtab_encoder_in_partition_p (lto_symtab_encoder_t,
     929              :                                         toplevel_node *);
     930              : void lto_set_symtab_encoder_in_partition (lto_symtab_encoder_t,
     931              :                                           toplevel_node *);
     932              : 
     933              : bool lto_symtab_encoder_encode_initializer_p (lto_symtab_encoder_t,
     934              :                                               varpool_node *);
     935              : void output_symtab (void);
     936              : void input_symtab (void);
     937              : void input_toplevel_asms (void);
     938              : void output_offload_tables (void);
     939              : void input_offload_tables (bool);
     940              : bool referenced_from_other_partition_p (struct ipa_ref_list *,
     941              :                                         lto_symtab_encoder_t);
     942              : bool reachable_from_other_partition_p (struct cgraph_node *,
     943              :                                        lto_symtab_encoder_t);
     944              : bool referenced_from_this_partition_p (symtab_node *,
     945              :                                         lto_symtab_encoder_t);
     946              : bool reachable_from_this_partition_p (struct cgraph_node *,
     947              :                                       lto_symtab_encoder_t);
     948              : lto_symtab_encoder_t compute_ltrans_boundary (lto_symtab_encoder_t encoder);
     949              : void select_what_to_stream (void);
     950              : 
     951              : /* In options-save.cc.  */
     952              : void cl_target_option_stream_out (struct output_block *, struct bitpack_d *,
     953              :                                   struct cl_target_option *);
     954              : 
     955              : void cl_target_option_stream_in (class data_in *,
     956              :                                  struct bitpack_d *,
     957              :                                  struct cl_target_option *);
     958              : 
     959              : void cl_optimization_stream_out (struct output_block *,
     960              :                                  struct bitpack_d *, struct cl_optimization *);
     961              : 
     962              : void cl_optimization_stream_in (class data_in *,
     963              :                                 struct bitpack_d *, struct cl_optimization *);
     964              : 
     965              : 
     966              : 
     967              : /* In lto-opts.cc.  */
     968              : extern void lto_write_options (void);
     969              : 
     970              : 
     971              : /* Statistics gathered during LTO, WPA and LTRANS.  */
     972              : extern struct lto_stats_d lto_stats;
     973              : 
     974              : /* Section names corresponding to the values of enum lto_section_type.  */
     975              : extern const char *lto_section_name[];
     976              : 
     977              : /* Holds all the out decl states of functions output so far in the
     978              :    current output file.  */
     979              : extern vec<lto_out_decl_state_ptr> lto_function_decl_states;
     980              : 
     981              : /* Return true if LTO tag TAG corresponds to a tree code.  */
     982              : inline bool
     983      4397334 : lto_tag_is_tree_code_p (enum LTO_tags tag)
     984              : {
     985      4397334 :   return tag > LTO_first_tree_tag && (unsigned) tag <= MAX_TREE_CODES;
     986              : }
     987              : 
     988              : 
     989              : /* Return true if LTO tag TAG corresponds to a gimple code.  */
     990              : inline bool
     991      1408737 : lto_tag_is_gimple_code_p (enum LTO_tags tag)
     992              : {
     993      1408737 :   return (unsigned) tag >= LTO_first_gimple_tag
     994      1408737 :          && (unsigned) tag
     995              :             < (unsigned) LTO_first_gimple_tag + LAST_AND_UNUSED_GIMPLE_CODE;
     996              : }
     997              : 
     998              : 
     999              : /* Return the LTO tag corresponding to gimple code CODE.  See enum
    1000              :    LTO_tags for details on the conversion.  */
    1001              : inline enum LTO_tags
    1002      1694305 : lto_gimple_code_to_tag (enum gimple_code code)
    1003              : {
    1004      1694305 :   return (enum LTO_tags) ((unsigned) code + LTO_first_gimple_tag);
    1005              : }
    1006              : 
    1007              : 
    1008              : /* Return the GIMPLE code corresponding to TAG.  See enum LTO_tags for
    1009              :    details on the conversion.  */
    1010              : inline enum gimple_code
    1011      1408737 : lto_tag_to_gimple_code (enum LTO_tags tag)
    1012              : {
    1013      1408737 :   gcc_assert (lto_tag_is_gimple_code_p (tag));
    1014      1408737 :   return (enum gimple_code) ((unsigned) tag - LTO_first_gimple_tag);
    1015              : }
    1016              : 
    1017              : 
    1018              : /* Return the LTO tag corresponding to tree code CODE.  See enum
    1019              :    LTO_tags for details on the conversion.  */
    1020              : inline enum LTO_tags
    1021      7125447 : lto_tree_code_to_tag (enum tree_code code)
    1022              : {
    1023      7125447 :   return (enum LTO_tags) ((unsigned) code + LTO_first_tree_tag);
    1024              : }
    1025              : 
    1026              : 
    1027              : /* Return the tree code corresponding to TAG.  See enum LTO_tags for
    1028              :    details on the conversion.  */
    1029              : inline enum tree_code
    1030      4397334 : lto_tag_to_tree_code (enum LTO_tags tag)
    1031              : {
    1032      4397334 :   gcc_assert (lto_tag_is_tree_code_p (tag));
    1033      4397334 :   return (enum tree_code) ((unsigned) tag - LTO_first_tree_tag);
    1034              : }
    1035              : 
    1036              : /* Check that tag ACTUAL == EXPECTED.  */
    1037              : inline void
    1038        85214 : lto_tag_check (enum LTO_tags actual, enum LTO_tags expected)
    1039              : {
    1040        85214 :   if (actual != expected)
    1041            0 :     internal_error ("bytecode stream: expected tag %s instead of %s",
    1042              :                     lto_tag_name (expected), lto_tag_name (actual));
    1043        85214 : }
    1044              : 
    1045              : /* Check that tag ACTUAL is in the range [TAG1, TAG2].  */
    1046              : inline void
    1047        10149 : lto_tag_check_range (enum LTO_tags actual, enum LTO_tags tag1,
    1048              :                      enum LTO_tags tag2)
    1049              : {
    1050        10149 :   if (actual < tag1 || actual > tag2)
    1051            0 :     internal_error ("bytecode stream: tag %s is not in the expected range "
    1052              :                     "[%s, %s]",
    1053              :                     lto_tag_name (actual),
    1054              :                     lto_tag_name (tag1),
    1055              :                     lto_tag_name (tag2));
    1056        10149 : }
    1057              : 
    1058              : /* Initialize an lto_out_decl_buffer ENCODER.  */
    1059              : inline void
    1060       191304 : lto_init_tree_ref_encoder (struct lto_tree_ref_encoder *encoder)
    1061              : {
    1062       191304 :   encoder->tree_hash_table = new hash_map<tree, unsigned> (251);
    1063       191304 :   encoder->trees.create (0);
    1064       191304 : }
    1065              : 
    1066              : 
    1067              : /* Destroy an lto_tree_ref_encoder ENCODER by freeing its contents.  The
    1068              :    memory used by ENCODER is not freed by this function.  */
    1069              : inline void
    1070       191304 : lto_destroy_tree_ref_encoder (struct lto_tree_ref_encoder *encoder)
    1071              : {
    1072              :   /* Hash table may be delete already.  */
    1073       191304 :   delete encoder->tree_hash_table;
    1074       191304 :   encoder->tree_hash_table = NULL;
    1075       191304 :   encoder->trees.release ();
    1076       191304 : }
    1077              : 
    1078              : /* Return the number of trees encoded in ENCODER. */
    1079              : inline unsigned int
    1080       609490 : lto_tree_ref_encoder_size (struct lto_tree_ref_encoder *encoder)
    1081              : {
    1082      1180660 :   return encoder->trees.length ();
    1083              : }
    1084              : 
    1085              : /* Return the IDX-th tree in ENCODER. */
    1086              : inline tree
    1087      5326322 : lto_tree_ref_encoder_get_tree (struct lto_tree_ref_encoder *encoder,
    1088              :                                unsigned int idx)
    1089              : {
    1090      5326322 :   return encoder->trees[idx];
    1091              : }
    1092              : 
    1093              : /* Return number of encoded nodes in ENCODER.  */
    1094              : inline int
    1095     20334408 : lto_symtab_encoder_size (lto_symtab_encoder_t encoder)
    1096              : {
    1097     32343916 :   return encoder->nodes.length ();
    1098              : }
    1099              : 
    1100              : /* Value used to represent failure of lto_symtab_encoder_lookup.  */
    1101              : #define LCC_NOT_FOUND   (-1)
    1102              : 
    1103              : /* Look up NODE in encoder.  Return NODE's reference if it has been encoded
    1104              :    or LCC_NOT_FOUND if it is not there.  */
    1105              : 
    1106              : inline int
    1107     12669585 : lto_symtab_encoder_lookup (lto_symtab_encoder_t encoder,
    1108              :                            toplevel_node *node)
    1109              : {
    1110     12669585 :   size_t *slot = encoder->map->get (node);
    1111     12669585 :   return (slot && *slot ? *(slot) - 1 : LCC_NOT_FOUND);
    1112              : }
    1113              : 
    1114              : /* Return true if iterator LSE points to nothing.  */
    1115              : inline bool
    1116     14953164 : lsei_end_p (lto_symtab_encoder_iterator lsei)
    1117              : {
    1118      6798605 :   return lsei.index >= (unsigned)lto_symtab_encoder_size (lsei.encoder);
    1119              : }
    1120              : 
    1121              : /* Advance iterator LSE.  */
    1122              : inline void
    1123     11936613 : lsei_next (lto_symtab_encoder_iterator *lsei)
    1124              : {
    1125     11936613 :   lsei->index++;
    1126     11173177 : }
    1127              : 
    1128              : /* Return the node pointed to by LSI.  */
    1129              : inline toplevel_node *
    1130     16741837 : lsei_node (lto_symtab_encoder_iterator lsei)
    1131              : {
    1132     12289767 :   return lsei.encoder->nodes[lsei.index].node;
    1133              : }
    1134              : 
    1135              : /* Return the node pointed to by LSI.  */
    1136              : inline struct cgraph_node *
    1137      1251716 : lsei_cgraph_node (lto_symtab_encoder_iterator lsei)
    1138              : {
    1139      1251716 :   return dyn_cast<cgraph_node *> (lsei.encoder->nodes[lsei.index].node);
    1140              : }
    1141              : 
    1142              : /* Return the node pointed to by LSI.  */
    1143              : inline varpool_node *
    1144       281380 : lsei_varpool_node (lto_symtab_encoder_iterator lsei)
    1145              : {
    1146       281380 :   return dyn_cast<varpool_node *> (lsei.encoder->nodes[lsei.index].node);
    1147              : }
    1148              : 
    1149              : /* Return the cgraph node corresponding to REF using ENCODER.  */
    1150              : 
    1151              : inline toplevel_node *
    1152      7876095 : lto_symtab_encoder_deref (lto_symtab_encoder_t encoder, int ref)
    1153              : {
    1154      7874299 :   if (ref == LCC_NOT_FOUND)
    1155              :     return NULL;
    1156              : 
    1157      7876095 :   return encoder->nodes[ref].node;
    1158              : }
    1159              : 
    1160              : /* Return an iterator to the first node in LSI.  */
    1161              : inline lto_symtab_encoder_iterator
    1162              : lsei_start (lto_symtab_encoder_t encoder)
    1163              : {
    1164              :   lto_symtab_encoder_iterator lsei;
    1165              : 
    1166              :   lsei.encoder = encoder;
    1167              :   lsei.index = 0;
    1168              :   return lsei;
    1169              : }
    1170              : 
    1171              : /* Advance iterator LSE.  */
    1172              : inline void
    1173       696737 : lsei_next_in_partition (lto_symtab_encoder_iterator *lsei)
    1174              : {
    1175       696737 :   lsei_next (lsei);
    1176       696737 :   while (!lsei_end_p (*lsei)
    1177      2283191 :          && !lto_symtab_encoder_in_partition_p (lsei->encoder, lsei_node (*lsei)))
    1178       464620 :     lsei_next (lsei);
    1179       696737 : }
    1180              : 
    1181              : /* Return an iterator to the first node in LSI.  */
    1182              : inline lto_symtab_encoder_iterator
    1183        39911 : lsei_start_in_partition (lto_symtab_encoder_t encoder)
    1184              : {
    1185        39911 :   lto_symtab_encoder_iterator lsei = lsei_start (encoder);
    1186              : 
    1187        39911 :   if (lsei_end_p (lsei))
    1188          388 :     return lsei;
    1189        39523 :   if (!lto_symtab_encoder_in_partition_p (encoder, lsei_node (lsei)))
    1190            0 :     lsei_next_in_partition (&lsei);
    1191              : 
    1192        39523 :   return lsei;
    1193              : }
    1194              : 
    1195              : /* Advance iterator LSE.  */
    1196              : inline void
    1197      1255823 : lsei_next_function_in_partition (lto_symtab_encoder_iterator *lsei)
    1198              : {
    1199      1255823 :   lsei_next (lsei);
    1200      1255823 :   while (!lsei_end_p (*lsei)
    1201     17039675 :          && (!is_a <cgraph_node *> (lsei_node (*lsei))
    1202      3523345 :              || !lto_symtab_encoder_in_partition_p (lsei->encoder, lsei_node (*lsei))))
    1203      5637093 :     lsei_next (lsei);
    1204      1255823 : }
    1205              : 
    1206              : /* Return an iterator to the first node in LSI.  */
    1207              : inline lto_symtab_encoder_iterator
    1208       290962 : lsei_start_function_in_partition (lto_symtab_encoder_t encoder)
    1209              : {
    1210       290962 :   lto_symtab_encoder_iterator lsei = lsei_start (encoder);
    1211              : 
    1212       290962 :   if (lsei_end_p (lsei))
    1213         2556 :     return lsei;
    1214       573264 :   if (!is_a <cgraph_node *> (lsei_node (lsei))
    1215       284858 :       || !lto_symtab_encoder_in_partition_p (encoder, lsei_node (lsei)))
    1216         4107 :     lsei_next_function_in_partition (&lsei);
    1217              : 
    1218       288406 :   return lsei;
    1219              : }
    1220              : 
    1221              : /* Advance iterator LSE.  */
    1222              : inline void
    1223       315273 : lsei_next_variable_in_partition (lto_symtab_encoder_iterator *lsei)
    1224              : {
    1225       315273 :   lsei_next (lsei);
    1226       315273 :   while (!lsei_end_p (*lsei)
    1227      1154699 :          && (!is_a <varpool_node *> (lsei_node (*lsei))
    1228       280715 :              || !lto_symtab_encoder_in_partition_p (lsei->encoder, lsei_node (*lsei))))
    1229       138998 :     lsei_next (lsei);
    1230       315273 : }
    1231              : 
    1232              : /* Return an iterator to the first node in LSI.  */
    1233              : inline lto_symtab_encoder_iterator
    1234        34795 : lsei_start_variable_in_partition (lto_symtab_encoder_t encoder)
    1235              : {
    1236        34795 :   lto_symtab_encoder_iterator lsei = lsei_start (encoder);
    1237              : 
    1238        34795 :   if (lsei_end_p (lsei))
    1239          237 :     return lsei;
    1240        35223 :   if (!is_a <varpool_node *> (lsei_node (lsei))
    1241          665 :       || !lto_symtab_encoder_in_partition_p (encoder, lsei_node (lsei)))
    1242        33893 :     lsei_next_variable_in_partition (&lsei);
    1243              : 
    1244        34558 :   return lsei;
    1245              : }
    1246              : 
    1247              : /* Entry for the delayed registering of decl -> DIE references.  */
    1248              : struct dref_entry {
    1249              :     tree decl;
    1250              :     const char *sym;
    1251              :     unsigned HOST_WIDE_INT off;
    1252              : };
    1253              : 
    1254              : extern vec<dref_entry> dref_queue;
    1255              : 
    1256              : extern FILE *streamer_dump_file;
    1257              : 
    1258              : #endif /* GCC_LTO_STREAMER_H  */
        

Generated by: LCOV version 2.4-beta

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