GCC Middle and Back End API Reference
lto-streamer-out.c File Reference

Data Structures

struct  sccs
struct  scc_entry

Functions

static void clear_line_info ()
struct output_blockcreate_output_block ()
void destroy_output_block ()
static void output_type_ref ()
static bool tree_is_indexable ()
void lto_output_location (struct output_block *ob, struct bitpack_d *bp, location_t loc)
static void lto_output_tree_ref ()
static bool lto_is_streamable ()
static tree get_symbol_initial_value ()
static void lto_write_tree_1 ()
static void lto_write_tree ()
static void lto_output_tree_1 (struct output_block *ob, tree expr, hashval_t hash, bool ref_p, bool this_ref_p)
static void DFS_write_tree (struct output_block *ob, sccs *from_state, tree expr, bool ref_p, bool this_ref_p)
static void DFS_write_tree_body (struct output_block *ob, tree expr, sccs *expr_state, bool ref_p)
static hashval_t hash_tree ()
static int scc_entry_compare ()
static hashval_t hash_scc ()
void lto_output_tree (struct output_block *ob, tree expr, bool ref_p, bool this_ref_p)
static void output_eh_try_list ()
static void output_eh_region ()
static void output_eh_lp ()
static void output_eh_regions ()
static void output_ssa_names ()
static void output_cfg ()
void produce_asm ()
static void output_struct_function_base ()
static void output_function ()
void lto_output_toplevel_asms ()
static void copy_function ()
static void lto_output ()
ipa_opt_pass_dmake_pass_ipa_lto_gimple_out ()
static void write_global_stream (struct output_block *ob, struct lto_tree_ref_encoder *encoder)
static void write_global_references (struct output_block *ob, struct lto_output_stream *ref_stream, struct lto_tree_ref_encoder *encoder)
void lto_output_decl_state_streams (struct output_block *ob, struct lto_out_decl_state *state)
void lto_output_decl_state_refs (struct output_block *ob, struct lto_output_stream *out_stream, struct lto_out_decl_state *state)
static size_t lto_out_decl_state_written_size ()
static void write_symbol (struct streamer_tree_cache_d *cache, struct lto_output_stream *stream, tree t, struct pointer_set_t *seen, bool alias)
bool output_symbol_p ()
static void produce_symtab ()
static void produce_asm_for_decls ()
ipa_opt_pass_dmake_pass_ipa_lto_finish_out ()

Variables

static unsigned int next_dfs_num
static vec< scc_entrysccstack
static struct pointer_map_tsccstate
static struct obstack sccstate_obstack

Function Documentation

static void clear_line_info ( )
static
@verbatim 

Write the GIMPLE representation to a file stream.

Copyright (C) 2009-2013 Free Software Foundation, Inc. Contributed by Kenneth Zadeck zadec.nosp@m.k@na.nosp@m.tural.nosp@m.brid.nosp@m.ge.co.nosp@m.m Re-implemented by Diego Novillo dnovi.nosp@m.llo@.nosp@m.googl.nosp@m.e.co.nosp@m.m

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/.

   Clear the line info stored in DATA_IN.  
static void copy_function ( )
static
   Copy the function body of NODE without deserializing. 
     We may have renamed the declaration, e.g., a static function.  
     Do a bit copy of the function body.  
     Copy decls. 
         The out state must have the same indices and the in state.
         So just copy the vector.  All the encoders in the in state
         must be empty where we reach here. 
struct output_block* create_output_block ( )
read
   Create the output block and return it.  SECTION_TYPE is
   LTO_section_function_body or LTO_static_initializer.  

Referenced by read_inline_edge_summary().

void destroy_output_block ( )
   Destroy the output block OB.  
static void DFS_write_tree ( struct output_block ob,
sccs from_state,
tree  expr,
bool  ref_p,
bool  this_ref_p 
)
static
   DFS walk EXPR and stream SCCs of tree bodies if they are not
   already in the streamer cache.  Main routine called for
   each visit of EXPR.  
     Handle special cases.  
     Do not DFS walk into indexable trees.  
     Check if we already streamed EXPR.  
         Not yet visited.  DFS recurse and push it onto the stack.  
             Walk any LTO-specific edges.  
                 Handle DECL_INITIAL for symbols.  
         See if we found an SCC.  
             Pop the SCC and compute its size.  
             No need to compute hashes for LTRANS units, we don't perform
             any merging there.  
                 Put the entries with the least number of collisions first.  
             Write LTO_tree_scc.  
             Write size-1 SCCs without wrapping them inside SCC bundles.
             All INTEGER_CSTs need to be handled this way as we need
             their type to materialize them.  Also builtins are handled
             this way.
             ???  We still wrap these in LTO_tree_scc so at the
             input side we can properly identify the tree we want
             to ultimatively return.  
                 Write the size of the SCC entry candidates.  
                 Write all headers and populate the streamer cache.  
                     Write the header, containing everything needed to
                     materialize EXPR on the reading side.  
                 Write the bitpacks and tree references.  
                     Mark the end of the tree.  
             Finally truncate the vector.  

References first.

Referenced by hash_scc().

static void DFS_write_tree_body ( struct output_block ob,
tree  expr,
sccs expr_state,
bool  ref_p 
)
static
   Handle the tree EXPR in the DFS walk with SCC state EXPR_STATE and
   DFS recurse for all tree edges originating from it.  
         Drop names that were created for anonymous entities.  
         Note, DECL_INITIAL is not handled here.  Since DECL_INITIAL needs
         special handling in LTO, it must be handled by streamer hooks.  
         Do not follow DECL_ABSTRACT_ORIGIN.  We cannot handle debug information
         for early inlining so drop it on the floor instead of ICEing in
         dwarf2out.c.  
         Make sure we don't inadvertently set the assembler name.  
         Do not follow TYPE_POINTER_TO or TYPE_REFERENCE_TO.  They will be
         reconstructed during fixup.  
         Do not follow TYPE_NEXT_VARIANT, we reconstruct the variant lists
         during fixup.  
         TYPE_CANONICAL is re-computed during type merging, so no need
         to follow it here.  
           ???  FIXME.  See also streamer_write_chain.  
         Follow BLOCK_ABSTRACT_ORIGIN for the limited cases we can
         handle - those that represent inlined function scopes.
         For the drop rest them on the floor instead of ICEing
         in dwarf2out.c.  
         Do not follow BLOCK_NONLOCALIZED_VARS.  We cannot handle debug
         information for early inlined BLOCKs so drop it on the floor instead
         of ICEing in dwarf2out.c.  
         BLOCK_FRAGMENT_ORIGIN and BLOCK_FRAGMENT_CHAIN is not live at LTO
         streaming time.  
         Do not output BLOCK_SUBBLOCKS.  Instead on streaming-in this
         list is re-constructed from BLOCK_SUPERCONTEXT.  
         Note that the number of BINFO slots has already been emitted in
         EXPR's header (see streamer_write_tree_header) because this length
         is needed to build the empty BINFO node on the reader side.  
         The number of BINFO_BASE_ACCESSES has already been emitted in
         EXPR's bitfield section.  
         Do not walk BINFO_INHERITANCE_CHAIN, BINFO_SUBVTT_INDEX
         and BINFO_VPTR_INDEX; these are used by C++ FE only.  

References gdbhooks::IDENTIFIER_NODE.

Referenced by hash_scc().

static tree get_symbol_initial_value ( )
static
   For EXPR lookup and return what we want to stream to OB as DECL_INITIAL.  
     Handle DECL_INITIAL for symbols.  

Referenced by hash_scc().

static hashval_t hash_scc ( )
static
   Return a hash value for the SCC on the SCC stack from FIRST with
   size SIZE.  
     Compute hash values for the SCC members.  
     Sort the SCC of type, hash pairs so that when we mix in
     all members of the SCC the hash value becomes independent on
     the order we visited the SCC.  Disregard hashes equal to
     the hash of the tree we mix into because we cannot guarantee
     a stable sort for those across different TUs.  
         Skip same hashes.  

References DFS_write_tree(), DFS_write_tree_body(), sccs::dfsnum, first, get_symbol_initial_value(), sccs::low, sccstate_obstack, and streamer_handle_as_builtin_p().

static hashval_t hash_tree ( )
static
   Return a hash value for the tree T.  
     Hash TS_BASE.  
             DECL_IN_TEXT_SECTION is set during final asm output only.  
             For pointers factor in the pointed-to type recursively as
             we cannot recurse through only pointers.
             ???  We can generalize this by keeping track of the
             in-SCC edges for each tree (or arbitrarily the first
             such edge) and hashing that in in a second stage
             (instead of the quadratic mixing of the SCC we do now).  
         Drop names that were created for anonymous entities.  
         ???  Hash DECL_INITIAL as streamed.  Needs the output-block to
         be able to call get_symbol_initial_value.  
         Do not walk BINFO_INHERITANCE_CHAIN, BINFO_SUBVTT_INDEX
         and BINFO_VPTR_INDEX; these are used by C++ FE only.  
static bool lto_is_streamable ( )
inlinestatic
   Return true if EXPR is a tree node that can be written to disk.  
     Notice that we reject SSA_NAMEs as well.  We only emit the SSA
     name version in lto_output_tree_ref (see output_ssa_names).  
static size_t lto_out_decl_state_written_size ( )
static
   Return the written size of STATE. 

References symtab_node_base::decl, IPA_REF_ALIAS, symtab_node_base::ref_list, and ipa_ref::referring.

static void lto_output ( )
static
   Main entry point from the pass manager.  
     Initialize the streamer.  
     Process only the functions with bodies.  
     Emit the callgraph after emitting function bodies.  This needs to
     be done now to make sure that all the statements in every function
     have been renumbered so that edges can be associated with call
     statements using the statement UIDs.  

References lto_output_data_stream(), lto_tree_ref_encoder_get_tree(), streamer_tree_cache_lookup(), and output_block::writer_cache.

void lto_output_decl_state_refs ( struct output_block ob,
struct lto_output_stream out_stream,
struct lto_out_decl_state state 
)
   Write all the references in an lto_out_decl_state STATE using
   output block OB and output stream OUT_STREAM.  
     Write reference to FUNCTION_DECL.  If there is not function,
     write reference to void_type_node. 
void lto_output_decl_state_streams ( struct output_block ob,
struct lto_out_decl_state state 
)
   Write all the streams in an lto_out_decl_state STATE using
   output block OB and output stream OUT_STREAM.  
void lto_output_location ( struct output_block ob,
struct bitpack_d bp,
location_t  loc 
)
   Output info about new location into bitpack BP.
   After outputting bitpack, lto_output_location_data has
   to be done to output actual data.  
void lto_output_toplevel_asms ( void  )
   Emit toplevel asms.  
     Make string 0 be a NULL string.  
     The entire header stream is computed here.  
     Write the header.  
     Put all of the gimple and the string table out the asm file as a
     block of text.  
void lto_output_tree ( struct output_block ob,
tree  expr,
bool  ref_p,
bool  this_ref_p 
)
   Emit the physical representation of tree node EXPR to output block
   OB.  If THIS_REF_P is true, the leaves of EXPR are emitted as references
   via lto_output_tree_ref.  REF_P is used for streaming siblings of EXPR.  
         If a node has already been streamed out, make sure that
         we don't write it more than once.  Otherwise, the reader
         will instantiate two different nodes for the same object.  
         This is the first time we see EXPR, write all reachable
         trees to OB.  
         Protect against recursion which means disconnect between
         what tree edges we walk in the DFS walk and what edges
         we stream out.  
         Start the DFS walk.  
         Save ob state ... 
         let's see ... 
         Finally append a reference to the tree we were writing.
         ???  If expr ended up as a singleton we could have
         inlined it here and avoid outputting a reference.  

References eh_catch_d::filter_list, eh_catch_d::label, LTO_eh_catch, streamer_write_record_start(), and eh_catch_d::type_list.

static void lto_output_tree_1 ( struct output_block ob,
tree  expr,
hashval_t  hash,
bool  ref_p,
bool  this_ref_p 
)
static
   Emit the physical representation of tree node EXPR to output block
   OB.  If THIS_REF_P is true, the leaves of EXPR are emitted as references
   via lto_output_tree_ref.  REF_P is used for streaming siblings of EXPR.  
         MD and NORMAL builtins do not need to be written out
         completely as they are always instantiated by the
         compiler on startup.  The only builtins that need to
         be written out are BUILT_IN_FRONTEND.  For all other
         builtins, we simply write the class and code.  
         Shared INTEGER_CST nodes are special because they need their
         original type to be materialized by the reader (to implement
         TYPE_CACHED_VALUES).  
         This is the first time we see EXPR, write its fields
         to OB.  
static void lto_output_tree_ref ( )
static
   If EXPR is an indexable tree node, output a reference to it to
   output block OB.  Otherwise, output the physical representation of
   EXPR to OB.  
         No other node is indexable, so it should have been handled by
         lto_output_tree.  
static void lto_write_tree ( )
static
   Write a physical representation of tree node EXPR to output block
   OB.  If REF_P is true, the leaves of EXPR are emitted as references
   via lto_output_tree_ref.  IX is the index into the streamer cache
   where EXPR is stored.  
     Write the header, containing everything needed to materialize
     EXPR on the reading side.  
     Mark the end of EXPR.  

References streamer_handle_as_builtin_p(), streamer_tree_cache_insert(), streamer_write_builtin(), tree_is_indexable(), and output_block::writer_cache.

static void lto_write_tree_1 ( )
static
   Write a physical representation of tree node EXPR to output block
   OB.  If REF_P is true, the leaves of EXPR are emitted as references
   via lto_output_tree_ref.  IX is the index into the streamer cache
   where EXPR is stored.  
     Pack all the non-pointer fields in EXPR into a bitpack and write
     the resulting bitpack.  
     Write all the pointer fields in EXPR.  
     Write any LTO-specific data to OB.  
         Handle DECL_INITIAL for symbols.  
ipa_opt_pass_d* make_pass_ipa_lto_finish_out ( )
ipa_opt_pass_d* make_pass_ipa_lto_gimple_out ( )

References targetm.

static void output_cfg ( )
static
   Output the cfg.  
     Output the number of the highest basic block.  
         Output the successors and the edge flags.  
     ???  The cfgloop interface is tied to cfun.  
     Output the number of loops.  
     Output each loop, skipping the tree root which has number zero.  
         Write the index of the loop header.  That's enough to rebuild
         the loop tree on the reader side.  Stream -1 for an unused
         loop entry.  
         Write everything copy_loop_info copies.  

References lto_get_section_name().

static void output_eh_lp ( )
static
   Output landing pad LP to OB.  
static void output_eh_region ( )
static
   Output EH region R in function FN to OB.  CURR_RN is the slot index
   that is being emitted in FN->EH->REGION_ARRAY.  This is used to
   detect EH region sharing.  
static void output_eh_regions ( )
static
   Output the existing eh_table to OB.  
         Emit the index of the root of the EH region tree.  
         Emit all the EH regions in the region array.  
         Emit all landing pads.  
         Emit all the runtime type data.  
         Emit the table of action chains.  
     The LTO_null either terminates the record or indicates that there
     are no eh_records at all.  

References output_block::cfg_stream, cfun, edge_def::count, edge_def::dest, edge_def::flags, get_loop(), basic_block_def::index, output_block::main_stream, basic_block_def::next_bb, number_of_loops(), edge_def::probability, PROFILE_LAST, streamer_write_gcov_count(), streamer_write_hwi(), streamer_write_uhwi(), and basic_block_def::succs.

static void output_eh_try_list ( )
static
static void output_function ( )
static
   Output the body of function NODE->DECL.  
     Set current_function_decl and cfun.  
     Make string 0 be a NULL string.  
     Output decls for parameters and args.  
     Output DECL_INITIAL for the function, which contains the tree of
     lexical scopes.  
     We also stream abstract functions where we stream only stuff needed for
     debug info.  
         Output all the SSA names used in the function.  
         Output any exception handling regions.  
         We will renumber the statements.  The code that does this uses
         the same ordering that we use for serializing them so we can use
         the same code on the other end and not have to write out the
         statement numbers.  We do not assign UIDs to PHIs here because
         virtual PHIs get re-computed on-the-fly which would make numbers
         inconsistent.  
                 Virtual PHIs are not going to be streamed.  
         To avoid keeping duplicate gimple IDs in the statements, renumber
         virtual phis now.  
         Output the code for the function.  
         The terminator for this function.  
     Create a section to hold the pickled output of this function.   
static void output_ssa_names ( )
static
   Output all of the active ssa names to the ssa_names stream.  
           ???  This drops SSA_NAME_IDENTIFIER on the floor.  
static void output_struct_function_base ( )
static
   Output the base body of struct function FN using output block OB.  
     Output the static chain and non-local goto save area.  
     Output all the local variables in the function.  
     Output current IL state of the function.  
     Write all the attributes for FN.  
     Output the function start and end loci.  
bool output_symbol_p ( )
   Return true if NODE should appear in the plugin symbol table.  
     We keep external functions in symtab for sake of inlining
     and devirtualization.  We do not want to see them in symbol table as
     references unless they are really used.  
    Ignore all references from external vars initializers - they are not really
    part of the compilation unit until they are used by folding.  Some symbols,
    like references to external construction vtables can not be referred to at all.
    We decide this at can_refer_decl_in_current_unit_p.  

Referenced by write_symbol().

static void output_type_ref ( )
static
   Look up NODE in the type table and write the index for it to OB.  
void produce_asm ( )
   Create the header in the file using OB.  If the section type is for
   a function, set FN to the decl for that function.  
     The entire header is stream computed here.  
     Write the header.  
     Put all of the gimple and the string table out the asm file as a
     block of text.  
static void produce_asm_for_decls ( )
static
   This pass is run after all of the functions are serialized and all
   of the IPA passes have written their serialized forms.  This pass
   causes the vector of all of the global decls and types used from
   this file to be written in to a section that can then be read in to
   recover these on other side.  
     Make string 0 be a NULL string.  
     Write the global symbols.  
     Currently not used.  This field would allow us to preallocate
     the globals vector, so that it need not be resized as it is extended.  
     Compute the total size of all decl out states. 
     Write the main out-decl state, followed by out-decl states of
     functions. 
     Write the symbol table.  It is used by linker to determine dependencies
     and thus we can skip it for WPA.  
     Write command line opts.  
     Deallocate memory and clean up.  
static void produce_symtab ( )
static
   Write an IL symbol table to OB.
   SET and VSET are cgraph/varpool node sets we are outputting.  
     Write the symbol table.
     First write everything defined and then all declarations.
     This is necessary to handle cases where we have duplicated symbols.  

References IPA_PASS.

static int scc_entry_compare ( )
static
   Compare two SCC entries by their hash value for qsorting them.  
static bool tree_is_indexable ( )
static
   Return true if tree node T is written to various tables.  For these
   nodes, we sometimes want to write their phyiscal representation
   (via lto_output_tree), and sometimes we need to emit an index
   reference into a table (via lto_output_tree_ref).  
     Parameters and return values of functions of variably modified types
     must go to global stream, because they may be used in the type
     definition.  
     Variably modified types need to be streamed alongside function
     bodies because they can refer to local entities.  Together with
     them we have to localize their members as well.
     ???  In theory that includes non-FIELD_DECLs as well.  

Referenced by lto_write_tree().

static void write_global_references ( struct output_block ob,
struct lto_output_stream ref_stream,
struct lto_tree_ref_encoder encoder 
)
static
   Write a sequence of indices into the globals vector corresponding
   to the trees in ENCODER.  These are used by the reader to map the
   indices used to refer to global entities within function bodies to
   their referents.  
     Write size as 32-bit unsigned. 
static void write_global_stream ( struct output_block ob,
struct lto_tree_ref_encoder encoder 
)
static
   Write each node in encoded by ENCODER to OB, as well as those reachable
   from it and required for correct representation of its semantics.
   Each node in ENCODER must be a global declaration or a type.  A node
   is written only once, even if it appears multiple times in the
   vector.  Certain transitively-reachable nodes, such as those
   representing expressions, may be duplicated, but such nodes
   must not appear in ENCODER itself.  
static void write_symbol ( struct streamer_tree_cache_d cache,
struct lto_output_stream stream,
tree  t,
struct pointer_set_t seen,
bool  alias 
)
static
   Write symbol T into STREAM in CACHE. SEEN specifies symbols we wrote
   so far.  
     None of the following kinds of symbols are needed in the
     symbol table.  
     This behaves like assemble_name_raw in varasm.c, performing the
     same name manipulations that ASM_OUTPUT_LABELREF does. 
         When something is defined, it should have node attached.  
     Imitate what default_elf_asm_output_external do.
     When symbol is external, we need to output it with DEFAULT visibility
     when compiling with -fvisibility=default, while with HIDDEN visibility
     when symbol has attribute (visibility("hidden")) specified.
     targetm.binds_local_p check DECL_VISIBILITY_SPECIFIED and gets this
     right. 

References symtab_node_base::decl, output_block::decl_state, free(), lsei_end_p(), lsei_next(), lsei_node(), lsei_start(), lto_begin_section(), lto_end_section(), lto_get_section_name(), LTO_section_symtab, lto_write_stream(), memset(), output_symbol_p(), pointer_set_create(), pointer_set_destroy(), lto_out_decl_state::symtab_node_encoder, and output_block::writer_cache.


Variable Documentation

unsigned int next_dfs_num
static
vec<scc_entry> sccstack
static
struct pointer_map_t* sccstate
static
struct obstack sccstate_obstack
static

Referenced by hash_scc().