GCC Middle and Back End API Reference
lto-streamer-in.c File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "toplev.h"
#include "tree.h"
#include "expr.h"
#include "flags.h"
#include "params.h"
#include "input.h"
#include "hashtab.h"
#include "basic-block.h"
#include "gimple.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-ssanames.h"
#include "tree-into-ssa.h"
#include "tree-dfa.h"
#include "tree-ssa.h"
#include "tree-pass.h"
#include "function.h"
#include "ggc.h"
#include "diagnostic.h"
#include "except.h"
#include "debug.h"
#include "vec.h"
#include "ipa-utils.h"
#include "data-streamer.h"
#include "gimple-streamer.h"
#include "lto-streamer.h"
#include "tree-streamer.h"
#include "streamer-hooks.h"
#include "cfgloop.h"
Include dependency graph for lto-streamer-in.c:

Data Structures

struct  freeing_string_slot_hasher

Macros

#define FIXUP_EH_REGION(r)   (r) = (*eh_array)[(HOST_WIDE_INT) (intptr_t) (r)]
#define FIXUP_EH_LP(p)   (p) = (*lp_array)[(HOST_WIDE_INT) (intptr_t) (p)]

Functions

void lto_tag_check_set ()
void lto_input_data_block ()
static const char * canon_file_name ()
location_t lto_input_location ()
tree lto_input_tree_ref (struct lto_input_block *ib, struct data_in *data_in, struct function *fn, enum LTO_tags tag)
static struct eh_catch_dlto_input_eh_catch_list (struct lto_input_block *ib, struct data_in *data_in, eh_catch *last_p)
static eh_region input_eh_region ()
static eh_landing_pad input_eh_lp ()
static void fixup_eh_region_pointers ()
void lto_init_eh ()
static void input_eh_regions (struct lto_input_block *ib, struct data_in *data_in, struct function *fn)
static basic_block make_new_block ()
static void input_cfg (struct lto_input_block *ib, struct function *fn, int count_materialization_scale)
static void input_ssa_names (struct lto_input_block *ib, struct data_in *data_in, struct function *fn)
static void fixup_call_stmt_edges_1 (struct cgraph_node *node, gimple *stmts, struct function *fn)
static void fixup_call_stmt_edges ()
static void input_struct_function_base (struct function *fn, struct data_in *data_in, struct lto_input_block *ib)
static void input_function (tree fn_decl, struct data_in *data_in, struct lto_input_block *ib, struct lto_input_block *ib_cfg)
static void lto_read_body (struct lto_file_decl_data *file_data, struct cgraph_node *node, const char *data, enum lto_section_type section_type)
void lto_input_function_body (struct lto_file_decl_data *file_data, struct cgraph_node *node, const char *data)
static void lto_read_tree_1 ()
static tree lto_read_tree (struct lto_input_block *ib, struct data_in *data_in, enum LTO_tags tag, hashval_t hash)
hashval_t lto_input_scc (struct lto_input_block *ib, struct data_in *data_in, unsigned *len, unsigned *entry_len)
tree lto_input_tree_1 (struct lto_input_block *ib, struct data_in *data_in, enum LTO_tags tag, hashval_t hash)
tree lto_input_tree ()
void lto_input_toplevel_asms ()
void lto_reader_init ()
struct data_inlto_data_in_create (struct lto_file_decl_data *file_data, const char *strings, unsigned len, vec< ld_plugin_symbol_resolution_t > resolutions)
void lto_data_in_delete ()

Variables

static hash_table
< freeing_string_slot_hasher
file_name_hash_table

Macro Definition Documentation

#define FIXUP_EH_LP (   p)    (p) = (*lp_array)[(HOST_WIDE_INT) (intptr_t) (p)]
#define FIXUP_EH_REGION (   r)    (r) = (*eh_array)[(HOST_WIDE_INT) (intptr_t) (r)]

Function Documentation

static const char* canon_file_name ( )
static

Lookup STRING in file_name_hash_table. If found, return the existing string, otherwise insert STRING as the canonical version.

References string_slot::len, and string_slot::s.

static void fixup_call_stmt_edges ( )
static

Fixup call_stmt pointers in NODE and all clones.

static void fixup_call_stmt_edges_1 ( struct cgraph_node node,
gimple stmts,
struct function fn 
)
static

Go through all NODE edges and fixup call_stmt pointers so they point to STMTS.

static void fixup_eh_region_pointers ( )
static

After reading the EH regions, pointers to peer and children regions are region numbers. This converts all these region numbers into real pointers into the rematerialized regions for FN. ROOT_REGION is the region number for the root EH region in FN.

 Convert all the index numbers stored in pointer fields into
 pointers to the corresponding slots in the EH region array.   
     The array may contain NULL regions.   
 Convert all the index numbers stored in pointer fields into
 pointers to the corresponding slots in the EH landing pad array.   
     The array may contain NULL landing pads.   

References FIXUP_EH_LP, FIXUP_EH_REGION, gcc_assert, eh_region_d::index, eh_region_d::inner, eh_region_d::landing_pads, eh_region_d::next_peer, NULL, and eh_region_d::outer.

static void input_cfg ( struct lto_input_block ib,
struct function fn,
int  count_materialization_scale 
)
static

Read the CFG for function FN from input block IB.

Connect up the CFG.   
 ???  The cfgloop interface is tied to cfun.   


 Input the loop tree.   
 Input each loop and associate it with its loop header so
 flow_loops_find can rebuild the loop tree.   
     Read everything copy_loop_info copies.   
     flow_loops_find doesn't like loops not in the tree, hook them
     all as siblings of the tree root temporarily.   
 Rebuild the loop tree.   

References apply_scale(), BASIC_BLOCK_FOR_FUNCTION, count, edge_def::count, make_edge(), make_new_block(), NULL, edge_def::probability, streamer_read_gcov_count(), streamer_read_hwi(), and streamer_read_uhwi().

static eh_landing_pad input_eh_lp ( )
static

Read and return EH landing pad IX from input block IB, using descriptors in DATA_IN.

Read the landing pad header.

static eh_region input_eh_region ( )
static

Read and return EH region IX from input block IB, using descriptors in DATA_IN.

Read the region header.

 Read all the region pointers as region numbers.  We'll fix up
 the pointers once the whole array has been read.   

Referenced by input_eh_regions().

static void input_eh_regions ( struct lto_input_block ib,
struct data_in data_in,
struct function fn 
)
static

Read the exception table for FN from IB using the data descriptors in DATA_IN.

 If the file contains EH regions, then it was compiled with
 -fexceptions.  In that case, initialize the backend EH
 machinery.   
 Read the EH region array.   
 Read the landing pads.   
 Read the runtime type data.   
 Read the table of action chains.   
 Reconstruct the EH region tree by fixing up the peer/children
 pointers.   

References input_eh_region(), and vec_safe_grow_cleared().

static void input_function ( tree  fn_decl,
struct data_in data_in,
struct lto_input_block ib,
struct lto_input_block ib_cfg 
)
static

Read the body of function FN_DECL from DATA_IN using input block IB.

 Read decls for parameters and args.   
 Read the tree of lexical scopes for the function.   
 We input IL in SSA form.   
 Read all the SSA names.   
 Read the exception handling regions in the function.   
 Read all the basic blocks.   
 Fix up the call statements that are mentioned in the callgraph
 edges.   
         If we're recompiling LTO objects with debug stmts but
         we're not supposed to have debug stmts, remove them now.
         We can't remove them earlier because this would cause uid
         mismatches in fixups, but we can do it at this point, as
         long as debug stmts don't require fixups.   
 Set the gimple body to the statement sequence in the entry
 basic block.  FIXME lto, this is fairly hacky.  The existence
 of a gimple body is used by the cgraph routines, but we should
 really use the presence of the CFG.   
static void input_ssa_names ( struct lto_input_block ib,
struct data_in data_in,
struct function fn 
)
static

Read the SSA names array for function FN from DATA_IN using input block IB.

Skip over the elements that had been freed.

References cgraph_edge::call_stmt, fatal_error(), gimple_stmt_max_uid(), and cgraph_edge::lto_stmt_uid.

static void input_struct_function_base ( struct function fn,
struct data_in data_in,
struct lto_input_block ib 
)
static

Input the base body of struct function FN from DATA_IN using input block IB.

 Read the static chain and non-local goto save area.   
 Read all the local symbols.   
 Input the current IL state of the function.   
 Read all the attributes for FN.   
 Input the function start and end loci.   
struct data_in* lto_data_in_create ( struct lto_file_decl_data file_data,
const char *  strings,
unsigned  len,
vec< ld_plugin_symbol_resolution_t resolutions 
)
read

Create a new data_in object for FILE_DATA. STRINGS is the string table to use with LEN strings. RESOLUTIONS is the vector of linker resolutions (NULL if not using a linker plugin).

void lto_data_in_delete ( )

Remove DATA_IN.

void lto_init_eh ( void  )

Initialize EH support.

Contrary to most other FEs, we only initialize EH support when at least one of the files in the set contains exception regions in it. Since this happens much later than the call to init_eh in lang_dependent_init, we have to set flag_exceptions and call init_eh again to initialize the EH tables.

References gcc_assert, HOST_WIDE_INT, LTO_eh_table, lto_init_eh(), LTO_null, lto_tag_check_range(), streamer_read_hwi(), and streamer_read_record_start().

Referenced by lto_init_eh().

void lto_input_data_block ( )

Read LENGTH bytes from STREAM to ADDR.

static struct eh_catch_d* lto_input_eh_catch_list ( struct lto_input_block ib,
struct data_in data_in,
eh_catch last_p 
)
staticread

Read and return a double-linked list of catch handlers from input block IB, using descriptors in DATA_IN.

     Read the catch node.   
     Register all the types in N->FILTER_LIST.   
     Chain N to the end of the list.   
     Set the head of the list the first time through the loop.   

References add_type_for_runtime(), eh_catch_d::filter_list, eh_catch_d::label, LTO_eh_catch, lto_tag_check_range(), NULL, eh_catch_d::prev_catch, stream_read_tree, streamer_read_record_start(), TREE_CHAIN, TREE_VALUE, and eh_catch_d::type_list.

void lto_input_function_body ( struct lto_file_decl_data file_data,
struct cgraph_node node,
const char *  data 
)

Read the body of NODE using DATA. FILE_DATA holds the global decls and types.

References lto_input_tree_1(), streamer_read_record_start(), and streamer_read_uhwi().

location_t lto_input_location ( )

Read a location bitpack from input block IB.

hashval_t lto_input_scc ( struct lto_input_block ib,
struct data_in data_in,
unsigned *  len,
unsigned *  entry_len 
)

Populate the reader cache with trees materialized from the SCC following in the IB, DATA_IN stream.

 A blob of unnamed tree nodes, fill the cache from it and
 recurse.   
     Materialize size trees by reading their headers.   
     Read the tree bitpacks and references.   
         end_marker =  
void lto_input_toplevel_asms ( )

Input toplevel asms.

Make sure the file was generated by the exact same compiler.

tree lto_input_tree ( )
tree lto_input_tree_1 ( struct lto_input_block ib,
struct data_in data_in,
enum LTO_tags  tag,
hashval_t  hash 
)

Read a tree from input block IB using the per-file context in DATA_IN. This context is used, for example, to resolve references to previously read nodes.

     If TAG is a reference to an indexable tree, the next value
     in IB is the index into the table where we expect to find
     that tree.   
     If TAG is a reference to a previously read tree, look it up in
     the reader cache.   
     If we are going to read a built-in function, all we need is
     the code and class.   
     For shared integer constants in singletons we can use the existing
     tree integer constant merging code.   
     Input and skip the SCC.   
     Recurse.   
     Otherwise, materialize a new node from IB.   

Referenced by lto_input_function_body().

tree lto_input_tree_ref ( struct lto_input_block ib,
struct data_in data_in,
struct function fn,
enum LTO_tags  tag 
)

Read a reference to a tree node from DATA_IN using input block IB. TAG is the expected node that should be found in IB, if TAG belongs to one of the indexable trees, expect to read a reference index to be looked up in one of the symbol tables, otherwise read the pysical representation of the tree using stream_read_tree. FN is the function scope for the read tree.

References data_in::file_data, gcc_unreachable, LTO_const_decl_ref, LTO_field_decl_ref, LTO_function_decl_ref, LTO_global_decl_ref, LTO_imported_decl_ref, LTO_label_decl_ref, LTO_namespace_decl_ref, LTO_result_decl_ref, LTO_ssa_name_ref, LTO_translation_unit_decl_ref, LTO_type_decl_ref, LTO_type_ref, SSANAMES, and streamer_read_uhwi().

Referenced by lto_read_tree().

static void lto_read_body ( struct lto_file_decl_data file_data,
struct cgraph_node node,
const char *  data,
enum lto_section_type  section_type 
)
static

Read the body from DATA for function NODE and fill it in. FILE_DATA are the global decls and types. SECTION_TYPE is either LTO_section_function_body or LTO_section_static_initializer. If section type is LTO_section_function_body, FN must be the decl for that function.

 Make sure the file was generated by the exact same compiler.   
     Use the function's decl state.  
     Set up the struct function.   
     And fixup types we streamed locally.   
     Restore decl state  

References gcc_assert, NULL_TREE, TYPE_CANONICAL, TYPE_MAIN_VARIANT, and TYPE_NEXT_VARIANT.

static tree lto_read_tree ( struct lto_input_block ib,
struct data_in data_in,
enum LTO_tags  tag,
hashval_t  hash 
)
static

Read the physical representation of a tree node with tag TAG from input block IB using the per-file context in DATA_IN.

 Instantiate a new tree node.   
 Enter RESULT in the reader cache.  This will make RESULT
 available so that circular references in the rest of the tree
 structure can be resolved in subsequent calls to stream_read_tree.   
 end_marker =  

References cfun, gcc_assert, LTO_field_decl_ref, LTO_global_decl_ref, lto_input_tree_ref(), LTO_null, LTO_NUM_TAGS, LTO_tree_pickle_reference, and NULL_TREE.

static void lto_read_tree_1 ( )
static

Read the physical representation of a tree node EXPR from input block IB using the per-file context in DATA_IN.

 Read all the bitfield values in EXPR.  Note that for LTO, we
 only write language-independent bitfields, so no more unpacking is
 needed.   
 Read all the pointer fields in EXPR.   
 Read any LTO-specific data not read by the tree streamer.   
 We should never try to instantiate an MD or NORMAL builtin here.   

References gcc_unreachable, LTO_builtin_decl, LTO_field_decl_ref, LTO_global_decl_ref, LTO_integer_cst, LTO_null, LTO_tree_pickle_reference, LTO_tree_scc, streamer_tree_cache_d::nodes, data_in::reader_cache, streamer_alloc_tree(), streamer_read_record_start(), streamer_read_uchar(), streamer_read_uhwi(), streamer_tree_cache_append(), and streamer_tree_cache_get_tree().

void lto_reader_init ( void  )

Initialization for the LTO reader.

void lto_tag_check_set ( )

Check that tag ACTUAL has one of the given values. NUM_TAGS is the number of valid tag values to check.

static basic_block make_new_block ( )
static

Make a new basic block with index INDEX in function FN.

Referenced by input_cfg().


Variable Documentation

hash_table<freeing_string_slot_hasher> file_name_hash_table
static

The table to hold the file names.