GCC Middle and Back End API Reference
lto-streamer.h File Reference
#include "plugin-api.h"
#include "hash-table.h"
#include "target.h"
#include "cgraph.h"
#include "vec.h"
#include "alloc-pool.h"
#include "gcov-io.h"
#include "diagnostic.h"
#include "pointer-set.h"
Include dependency graph for lto-streamer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  lto_input_block
struct  lto_header
struct  lto_function_header
struct  lto_decl_header
struct  lto_asm_header
struct  lto_stats_d
struct  lto_encoder_entry
struct  lto_symtab_encoder_d
struct  lto_symtab_encoder_iterator
struct  lto_tree_ref_table
struct  lto_tree_ref_encoder
struct  lto_in_decl_state
struct  lto_out_decl_state
struct  res_pair
struct  lto_file_decl_data
struct  lto_char_ptr_base
struct  lto_output_stream
struct  lto_simple_header
struct  lto_simple_output_block
struct  string_slot
struct  string_slot_hasher
struct  output_block
struct  data_in

Macros

#define LTO_SECTION_NAME_PREFIX   ".gnu.lto_"
#define LTO_major_version   2
#define LTO_minor_version   2
#define DEFINE_DECL_STREAM_FUNCS(UPPER_NAME, name)
#define LTO_INIT_INPUT_BLOCK(BASE, D, P, L)
#define LTO_INIT_INPUT_BLOCK_PTR(BASE, D, P, L)
#define LCC_NOT_FOUND   (-1)

Typedefs

typedef unsigned char lto_decl_flags_t
typedef enum
ld_plugin_symbol_resolution 
ld_plugin_symbol_resolution_t
typedef const char *( lto_get_section_data_f )(struct lto_file_decl_data *, enum lto_section_type, const char *, size_t *)
typedef void( lto_free_section_data_f )(struct lto_file_decl_data *, enum lto_section_type, const char *, const char *, size_t)
typedef struct
lto_symtab_encoder_d
lto_symtab_encoder_t
typedef struct lto_in_decl_statelto_in_decl_state_ptr
typedef struct lto_out_decl_statelto_out_decl_state_ptr
typedef struct res_pair res_pair
typedef struct lto_file_decl_datalto_file_decl_data_ptr

Enumerations

enum  LTO_tags {
  LTO_null = 0, LTO_tree_pickle_reference, LTO_bb0 = 1 + MAX_TREE_CODES + LAST_AND_UNUSED_GIMPLE_CODE, LTO_bb1,
  LTO_eh_region, LTO_builtin_decl, LTO_integer_cst, LTO_function,
  LTO_eh_table, LTO_ert_cleanup, LTO_ert_try, LTO_ert_allowed_exceptions,
  LTO_ert_must_not_throw, LTO_eh_landing_pad, LTO_eh_catch, LTO_tree_scc,
  LTO_field_decl_ref, LTO_function_decl_ref, LTO_label_decl_ref, LTO_namespace_decl_ref,
  LTO_result_decl_ref, LTO_ssa_name_ref, LTO_type_decl_ref, LTO_type_ref,
  LTO_const_decl_ref, LTO_imported_decl_ref, LTO_translation_unit_decl_ref, LTO_global_decl_ref,
  LTO_NUM_TAGS
}
enum  lto_section_type {
  LTO_section_decls = 0, LTO_section_function_body, LTO_section_static_initializer, LTO_section_symtab,
  LTO_section_refs, LTO_section_asm, LTO_section_jump_functions, LTO_section_ipa_pure_const,
  LTO_section_ipa_reference, LTO_section_ipa_profile, LTO_section_symtab_nodes, LTO_section_opts,
  LTO_section_cgraph_opt_sum, LTO_section_inline_summary, LTO_section_ipcp_transform, LTO_N_SECTION_TYPES
}
enum  lto_decl_stream_e_t {
  LTO_DECL_STREAM_TYPE = 0, LTO_DECL_STREAM_FIELD_DECL, LTO_DECL_STREAM_FN_DECL, LTO_DECL_STREAM_VAR_DECL,
  LTO_DECL_STREAM_TYPE_DECL, LTO_DECL_STREAM_NAMESPACE_DECL, LTO_DECL_STREAM_LABEL_DECL, LTO_N_DECL_STREAMS
}

Functions

struct lto_input_blocklto_create_simple_input_block (struct lto_file_decl_data *, enum lto_section_type, const char **, size_t *)
void lto_destroy_simple_input_block (struct lto_file_decl_data *, enum lto_section_type, struct lto_input_block *, const char *, size_t)
void lto_set_in_hooks (struct lto_file_decl_data **, lto_get_section_data_f *, lto_free_section_data_f *)
struct lto_file_decl_data ** lto_get_file_decl_data (void)
const char * lto_get_section_data (struct lto_file_decl_data *, enum lto_section_type, const char *, size_t *)
void lto_free_section_data (struct lto_file_decl_data *, enum lto_section_type, const char *, const char *, size_t)
htab_t lto_create_renaming_table (void)
void lto_record_renamed_decl (struct lto_file_decl_data *, const char *, const char *)
const char * lto_get_decl_name_mapping (struct lto_file_decl_data *, const char *)
struct lto_in_decl_statelto_new_in_decl_state (void)
void lto_delete_in_decl_state (struct lto_in_decl_state *)
hashval_t lto_hash_in_decl_state (const void *)
int lto_eq_in_decl_state (const void *, const void *)
struct lto_in_decl_statelto_get_function_in_decl_state (struct lto_file_decl_data *, tree)
void lto_free_function_in_decl_state (struct lto_in_decl_state *)
void lto_free_function_in_decl_state_for_node (symtab_node)
void lto_section_overrun (struct lto_input_block *) ATTRIBUTE_NORETURN
void lto_value_range_error (const char *, HOST_WIDE_INT, HOST_WIDE_INT, HOST_WIDE_INT) ATTRIBUTE_NORETURN
void lto_begin_section (const char *, bool)
void lto_end_section (void)
void lto_write_stream (struct lto_output_stream *)
void lto_output_data_stream (struct lto_output_stream *, const void *, size_t)
bool lto_output_decl_index (struct lto_output_stream *, struct lto_tree_ref_encoder *, tree, unsigned int *)
void lto_output_field_decl_index (struct lto_out_decl_state *, struct lto_output_stream *, tree)
void lto_output_fn_decl_index (struct lto_out_decl_state *, struct lto_output_stream *, tree)
void lto_output_namespace_decl_index (struct lto_out_decl_state *, struct lto_output_stream *, tree)
void lto_output_var_decl_index (struct lto_out_decl_state *, struct lto_output_stream *, tree)
void lto_output_type_decl_index (struct lto_out_decl_state *, struct lto_output_stream *, tree)
void lto_output_type_ref_index (struct lto_out_decl_state *, struct lto_output_stream *, tree)
struct lto_simple_output_blocklto_create_simple_output_block (enum lto_section_type)
void lto_destroy_simple_output_block (struct lto_simple_output_block *)
struct lto_out_decl_statelto_new_out_decl_state (void)
void lto_delete_out_decl_state (struct lto_out_decl_state *)
struct lto_out_decl_statelto_get_out_decl_state (void)
void lto_push_out_decl_state (struct lto_out_decl_state *)
struct lto_out_decl_statelto_pop_out_decl_state (void)
void lto_record_function_out_decl_state (tree, struct lto_out_decl_state *)
void lto_append_block (struct lto_output_stream *)
const char * lto_tag_name (enum LTO_tags)
bitmap lto_bitmap_alloc (void)
void lto_bitmap_free (bitmap)
char * lto_get_section_name (int, const char *, struct lto_file_decl_data *)
void print_lto_report (const char *)
void lto_streamer_init (void)
bool gate_lto_out (void)
void lto_check_version (int, int)
void lto_streamer_hooks_init (void)
void lto_input_cgraph (struct lto_file_decl_data *, const char *)
void lto_reader_init (void)
void lto_input_function_body (struct lto_file_decl_data *, struct cgraph_node *, const char *)
void lto_input_constructors_and_inits (struct lto_file_decl_data *, const char *)
void lto_input_toplevel_asms (struct lto_file_decl_data *, int)
struct data_inlto_data_in_create (struct lto_file_decl_data *, const char *, unsigned, vec< ld_plugin_symbol_resolution_t >)
void lto_data_in_delete (struct data_in *)
void lto_input_data_block (struct lto_input_block *, void *, size_t)
location_t lto_input_location (struct bitpack_d *, struct data_in *)
tree lto_input_tree_ref (struct lto_input_block *, struct data_in *, struct function *, enum LTO_tags)
void lto_tag_check_set (enum LTO_tags, int,...)
void lto_init_eh (void)
hashval_t lto_input_scc (struct lto_input_block *, struct data_in *, unsigned *, unsigned *)
tree lto_input_tree_1 (struct lto_input_block *, struct data_in *, enum LTO_tags, hashval_t hash)
tree lto_input_tree (struct lto_input_block *, struct data_in *)
void lto_register_decl_definition (tree, struct lto_file_decl_data *)
struct output_blockcreate_output_block (enum lto_section_type)
void destroy_output_block (struct output_block *)
void lto_output_tree (struct output_block *, tree, bool, bool)
void lto_output_toplevel_asms (void)
void produce_asm (struct output_block *ob, tree fn)
void lto_output_decl_state_streams (struct output_block *, struct lto_out_decl_state *)
void lto_output_decl_state_refs (struct output_block *, struct lto_output_stream *, struct lto_out_decl_state *)
void lto_output_location (struct output_block *, struct bitpack_d *, location_t)
lto_symtab_encoder_t lto_symtab_encoder_new (bool)
int lto_symtab_encoder_encode (lto_symtab_encoder_t, symtab_node)
void lto_symtab_encoder_delete (lto_symtab_encoder_t)
bool lto_symtab_encoder_delete_node (lto_symtab_encoder_t, symtab_node)
bool lto_symtab_encoder_encode_body_p (lto_symtab_encoder_t, struct cgraph_node *)
bool lto_symtab_encoder_in_partition_p (lto_symtab_encoder_t, symtab_node)
void lto_set_symtab_encoder_in_partition (lto_symtab_encoder_t, symtab_node)
bool lto_symtab_encoder_encode_initializer_p (lto_symtab_encoder_t, struct varpool_node *)
void output_symtab (void)
void input_symtab (void)
bool referenced_from_other_partition_p (struct ipa_ref_list *, lto_symtab_encoder_t)
bool reachable_from_other_partition_p (struct cgraph_node *, lto_symtab_encoder_t)
bool referenced_from_this_partition_p (struct ipa_ref_list *, lto_symtab_encoder_t)
bool reachable_from_this_partition_p (struct cgraph_node *, lto_symtab_encoder_t)
lto_symtab_encoder_t compute_ltrans_boundary (lto_symtab_encoder_t encoder)
void lto_symtab_merge_decls (void)
void lto_symtab_merge_symbols (void)
tree lto_symtab_prevailing_decl (tree decl)
void lto_write_options (void)
static bool lto_tag_is_tree_code_p ()
static bool lto_tag_is_gimple_code_p ()
static enum LTO_tags lto_gimple_code_to_tag ()
static enum gimple_code lto_tag_to_gimple_code ()
static enum LTO_tags lto_tree_code_to_tag ()
static enum tree_code lto_tag_to_tree_code ()
static void lto_tag_check ()
static void lto_tag_check_range (enum LTO_tags actual, enum LTO_tags tag1, enum LTO_tags tag2)
static void lto_init_tree_ref_encoder ()
static void lto_destroy_tree_ref_encoder ()
static unsigned int lto_tree_ref_encoder_size ()
static tree lto_tree_ref_encoder_get_tree (struct lto_tree_ref_encoder *encoder, unsigned int idx)
static int lto_symtab_encoder_size ()
static int lto_symtab_encoder_lookup (lto_symtab_encoder_t encoder, symtab_node node)
static bool lsei_end_p ()
static void lsei_next ()
static symtab_node lsei_node ()
static struct cgraph_nodelsei_cgraph_node ()
static struct varpool_nodelsei_varpool_node ()
static symtab_node lto_symtab_encoder_deref ()
static lto_symtab_encoder_iterator lsei_start ()
static void lsei_next_in_partition ()
static lto_symtab_encoder_iterator lsei_start_in_partition ()
static void lsei_next_function_in_partition ()
static lto_symtab_encoder_iterator lsei_start_function_in_partition ()
static void lsei_next_variable_in_partition ()
static lto_symtab_encoder_iterator lsei_start_variable_in_partition ()

Variables

struct lto_stats_d lto_stats
const char * lto_section_name []
vec< lto_out_decl_state_ptrlto_function_decl_states

Macro Definition Documentation

#define DEFINE_DECL_STREAM_FUNCS (   UPPER_NAME,
  name 
)
Value:
static inline tree \
lto_file_decl_data_get_ ## name (struct lto_file_decl_data *data, \
unsigned int idx) \
{ \
struct lto_in_decl_state *state = data->current_decl_state; \
gcc_assert (idx < state->streams[LTO_DECL_STREAM_## UPPER_NAME].size); \
return state->streams[LTO_DECL_STREAM_## UPPER_NAME].trees[idx]; \
} \
\
static inline unsigned int \
lto_file_decl_data_num_ ## name ## s (struct lto_file_decl_data *data) \
{ \
struct lto_in_decl_state *state = data->current_decl_state; \
return state->streams[LTO_DECL_STREAM_## UPPER_NAME].size; \
}

Macro to define convenience functions for type and decl streams in lto_file_decl_data.

#define LCC_NOT_FOUND   (-1)

Value used to represent failure of lto_symtab_encoder_lookup.

Referenced by input_overwrite_node(), lto_symtab_encoder_encode_initializer_p(), lto_tag_is_tree_code_p(), and lto_tree_code_to_tag().

#define LTO_INIT_INPUT_BLOCK (   BASE,
  D,
  P,
 
)
Value:
do { \
BASE.data = D; \
BASE.p = P; \
BASE.len = L; \
} while (0)
#define LTO_INIT_INPUT_BLOCK_PTR (   BASE,
  D,
  P,
 
)
Value:
do { \
BASE->data = D; \
BASE->p = P; \
BASE->len = L; \
} while (0)
#define LTO_major_version   2
#define LTO_minor_version   2
#define LTO_SECTION_NAME_PREFIX   ".gnu.lto_"

Data structures and declarations used for reading and writing GIMPLE to a file stream.

Copyright (C) 2009-2013 Free Software Foundation, Inc. Contributed by Doug Kwan dougk.nosp@m.wan@.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/. Define when debugging the LTO streamer. This causes the writer to output the numeric value for the memory address of the tree node being emitted. When debugging a problem in the reader, check the original address that the writer was emitting using lto_orig_address_get. With this value, set a breakpoint in the writer (e.g., lto_output_tree) to trace how the faulty node is being emitted. #define LTO_STREAMER_DEBUG 1 The encoding for a function consists of the following sections:

1) The header. 2) FIELD_DECLS. 3) FUNCTION_DECLS. 4) global VAR_DECLS. 5) type_decls 6) types. 7) Names for the labels that have names 8) The SSA names. 9) The control flow graph. 10-11)Gimple for local decls. 12) Gimple for the function. 13) Strings.

1) THE HEADER. 2-6) THE GLOBAL DECLS AND TYPES.

The global decls and types are encoded in the same way. For each entry, there is word with the offset within the section to the entry.

7) THE LABEL NAMES.

Since most labels do not have names, this section my be of zero length. It consists of an array of string table references, one per label. In the lto code, the labels are given either positive or negative indexes. the positive ones have names and the negative ones do not. The positive index can be used to find the name in this array.

9) THE CFG.

10) Index into the local decls. Since local decls can have local decls inside them, they must be read in randomly in order to properly restore them.

11-12) GIMPLE FOR THE LOCAL DECLS AND THE FUNCTION BODY.

The gimple consists of a set of records.

THE FUNCTION

At the top level of (8) is the function. It consists of five pieces:

LTO_function - The tag. eh tree - This is all of the exception handling regions put out in a post order traversial of the tree. Siblings are output as lists terminated by a 0. The set of fields matches the fields defined in except.c.

last_basic_block - in uleb128 form.

basic blocks - This is the set of basic blocks.

zero - The termination of the basic blocks.

BASIC BLOCKS

There are two forms of basic blocks depending on if they are empty or not.

The basic block consists of:

LTO_bb1 or LTO_bb0 - The tag.

bb->index - the index in uleb128 form.

#succs - The number of successors un uleb128 form.

the successors - For each edge, a pair. The first of the pair is the index of the successor in uleb128 form and the second are the flags in uleb128 form.

the statements - A gimple tree, as described above. These are only present for LTO_BB1. Following each statement is an optional exception handling record LTO_eh_region which contains the region number (for regions >= 0).

zero - This is only present for LTO_BB1 and is used to terminate the statements and exception regions within this block.

12) STRINGS

String are represented in the table as pairs, a length in ULEB128 form followed by the data for the string. The string that is the prefix on the section names we make for lto. For decls the DECL_ASSEMBLER_NAME is appended to make the section name for the functions and static_initializers. For other types of sections a '.' and the section type are appended.


Typedef Documentation

typedef enum ld_plugin_symbol_resolution ld_plugin_symbol_resolution_t
typedef unsigned char lto_decl_flags_t
typedef void( lto_free_section_data_f)(struct lto_file_decl_data *, enum lto_section_type, const char *, const char *, size_t)

Return the data found from the above call. The first three parameters are the same as above. The fourth parameter is the data itself and the fifth is the length of the data.

typedef const char*( lto_get_section_data_f)(struct lto_file_decl_data *, enum lto_section_type, const char *, size_t *)

Return a char pointer to the start of a data stream for an lto pass or function. The first parameter is the file data that contains the information. The second parameter is the type of information to be obtained. The third parameter is the name of the function and is only used when finding a function body; otherwise it is NULL. The fourth parameter is the length of the data returned.

typedef struct res_pair res_pair

Enumeration Type Documentation

Indices to the various function, type and symbol streams.

Enumerator:
LTO_DECL_STREAM_TYPE 
LTO_DECL_STREAM_FIELD_DECL 
LTO_DECL_STREAM_FN_DECL 
LTO_DECL_STREAM_VAR_DECL 
LTO_DECL_STREAM_TYPE_DECL 
LTO_DECL_STREAM_NAMESPACE_DECL 
LTO_DECL_STREAM_LABEL_DECL 
LTO_N_DECL_STREAMS 

Set of section types that are in an LTO file. This list will grow as the number of IPA passes grows since each IPA pass will need its own section type to store its summary information.

When adding a new section type, you must also extend the LTO_SECTION_NAME array in lto-section-in.c.

Enumerator:
LTO_section_decls 
LTO_section_function_body 
LTO_section_static_initializer 
LTO_section_symtab 
LTO_section_refs 
LTO_section_asm 
LTO_section_jump_functions 
LTO_section_ipa_pure_const 
LTO_section_ipa_reference 
LTO_section_ipa_profile 
LTO_section_symtab_nodes 
LTO_section_opts 
LTO_section_cgraph_opt_sum 
LTO_section_inline_summary 
LTO_section_ipcp_transform 
LTO_N_SECTION_TYPES 
enum LTO_tags

Tags representing the various IL objects written to the bytecode file (GIMPLE statements, basic blocks, EH regions, tree nodes, etc).

NOTE, when adding new LTO tags, also update lto_tag_name.

Enumerator:
LTO_null 
LTO_tree_pickle_reference 

Special for streamer. Reference to previously-streamed node.

LTO_bb0 

Reserve enough entries to fit all the tree and gimple codes handled by the streamer. This guarantees that:

1- Given a tree code C: enum LTO_tags tag == C + 1

2- Given a gimple code C: enum LTO_tags tag == C + NUM_TREE_CODES + 1

Conversely, to map between LTO tags and tree/gimple codes, the reverse operation must be applied.

LTO_bb1 
LTO_eh_region 

EH region holding the previous statement.

LTO_builtin_decl 

An MD or NORMAL builtin. Only the code and class are streamed out.

LTO_integer_cst 

Shared INTEGER_CST node.

LTO_function 

Function body.

LTO_eh_table 

EH table.

LTO_ert_cleanup 

EH region types. These mirror enum eh_region_type.

LTO_ert_try 
LTO_ert_allowed_exceptions 
LTO_ert_must_not_throw 
LTO_eh_landing_pad 

EH landing pad.

LTO_eh_catch 

EH try/catch node.

LTO_tree_scc 

Special for global streamer. A blob of unnamed tree nodes.

LTO_field_decl_ref 

References to indexable tree nodes. These objects are stored in tables that are written separately from the function bodies that reference them. This way they can be instantiated even when the referencing functions aren't (e.g., during WPA) and it also allows functions to be copied from one file to another without having to unpickle the body first (the references are location independent).

NOTE, do not regroup these values as the grouping is exposed in the range checks done in lto_input_tree.

LTO_function_decl_ref 
LTO_label_decl_ref 
LTO_namespace_decl_ref 
LTO_result_decl_ref 
LTO_ssa_name_ref 
LTO_type_decl_ref 
LTO_type_ref 
LTO_const_decl_ref 
LTO_imported_decl_ref 
LTO_translation_unit_decl_ref 
LTO_global_decl_ref 
LTO_NUM_TAGS 

This tag must always be last.


Function Documentation

lto_symtab_encoder_t compute_ltrans_boundary ( lto_symtab_encoder_t  encoder)
struct output_block* create_output_block ( enum  lto_section_type)
read
void destroy_output_block ( struct output_block )
bool gate_lto_out ( void  )

Gate function for all LTO streaming passes.

Don't bother doing anything if the program has errors.

References hash_table< Descriptor, Allocator >::find_slot(), and gcc_assert.

void input_symtab ( void  )

Input and merge the symtab from each of the .o files passed to lto1.

Clear out the aux field that was used to store enough state to tell which nodes should be overwritten.

     Some nodes may have been created by cgraph_node.  This
     happens when the callgraph contains nested functions.  If the
     node for the parent function was never emitted to the gimple
     file, cgraph_node will create a node for it when setting the
     context of the nested function.   
static struct cgraph_node* lsei_cgraph_node ( )
staticread

Return the node pointed to by LSI.

static bool lsei_end_p ( )
inlinestatic

Return true if iterator LSE points to nothing.

Referenced by lto_symtab_encoder_size(), lto_tree_ref_encoder_get_tree(), and write_symbol().

static void lsei_next ( )
inlinestatic

Advance iterator LSE.

Referenced by lto_tree_ref_encoder_get_tree(), and write_symbol().

static void lsei_next_function_in_partition ( )
inlinestatic

Advance iterator LSE.

static void lsei_next_in_partition ( )
inlinestatic

Advance iterator LSE.

static void lsei_next_variable_in_partition ( )
inlinestatic

Advance iterator LSE.

static symtab_node lsei_node ( )
inlinestatic

Return the node pointed to by LSI.

Referenced by lto_tree_ref_encoder_get_tree(), and write_symbol().

static lto_symtab_encoder_iterator lsei_start ( )
inlinestatic

Return an iterator to the first node in LSI.

Referenced by lto_symtab_encoder_size(), and write_symbol().

static lto_symtab_encoder_iterator lsei_start_function_in_partition ( )
inlinestatic

Return an iterator to the first node in LSI.

static lto_symtab_encoder_iterator lsei_start_in_partition ( )
inlinestatic

Return an iterator to the first node in LSI.

static lto_symtab_encoder_iterator lsei_start_variable_in_partition ( )
inlinestatic

Return an iterator to the first node in LSI.

static struct varpool_node* lsei_varpool_node ( )
staticread

Return the node pointed to by LSI.

void lto_append_block ( struct lto_output_stream )
void lto_begin_section ( const char *  ,
bool   
)
bitmap lto_bitmap_alloc ( void  )

Allocate a bitmap from heap. Initializes the LTO obstack if necessary.

void lto_bitmap_free ( bitmap  )
void lto_check_version ( int  ,
int   
)
htab_t lto_create_renaming_table ( void  )

Create an empty hash table for recording declaration renamings.

struct lto_input_block* lto_create_simple_input_block ( struct lto_file_decl_data file_data,
enum lto_section_type  section_type,
const char **  datar,
size_t *  len 
)
read

In lto-section-in.c

Load a section of type SECTION_TYPE from FILE_DATA, parse the header and then return an input block pointing to the section. The raw pointer to the section is returned in DATAR and LEN. These are used to free the section. Return NULL if the section is not present.

Referenced by ipa_profile_read_summary().

struct lto_simple_output_block* lto_create_simple_output_block ( enum  lto_section_type)
read
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 ( struct data_in )
void lto_delete_in_decl_state ( struct lto_in_decl_state )
void lto_delete_out_decl_state ( struct lto_out_decl_state )
void lto_destroy_simple_input_block ( struct lto_file_decl_data file_data,
enum lto_section_type  section_type,
struct lto_input_block ib,
const char *  data,
size_t  len 
)

Close the section returned from a call to LTO_CREATE_SIMPLE_INPUT_BLOCK. IB is the input block returned from that call. The FILE_DATA and SECTION_TYPE are the same as what was passed to that call and the DATA and LEN are what was returned from that call.

Referenced by ipa_profile_read_summary().

void lto_destroy_simple_output_block ( struct lto_simple_output_block )
static void lto_destroy_tree_ref_encoder ( )
inlinestatic

Destroy an lto_tree_ref_encoder ENCODER by freeing its contents. The memory used by ENCODER is not freed by this function.

Hash table may be delete already.

void lto_end_section ( void  )

End the current output section.

Referenced by write_symbol().

int lto_eq_in_decl_state ( const void *  ,
const void *   
)
void lto_free_function_in_decl_state ( struct lto_in_decl_state )
void lto_free_function_in_decl_state_for_node ( symtab_node  )
void lto_free_section_data ( struct lto_file_decl_data file_data,
enum lto_section_type  section_type,
const char *  name,
const char *  data,
size_t  len 
)

Free the data found from the above call. The first three parameters are the same as above. DATA is the data to be freed and LEN is the length of that data.

FIXME lto: WPA mode does not write compressed sections, so for now suppress uncompression mapping if flag_ltrans.

 The underlying data address has been extracted from the mapping header.
 Free that, then free the allocated uncompression buffer.   

References free_section_f.

const char* lto_get_decl_name_mapping ( struct lto_file_decl_data decl_data,
const char *  name 
)

Given a string NAME, return the string that it has been mapped to by lto_record_renamed_decl. If NAME was not renamed, it is returned unchanged. DECL_DATA holds the renaming hash table to use.

struct lto_file_decl_data** lto_get_file_decl_data ( void  )
read

Return an array of file decl datas for all of the files passed to this compilation.

References lto_buffer::data, and lto_buffer::length.

struct lto_in_decl_state* lto_get_function_in_decl_state ( struct lto_file_decl_data file_data,
tree  func 
)
read

Search the in-decl state of a function FUNC contained in the file associated with FILE_DATA. Return NULL if not found.

struct lto_out_decl_state* lto_get_out_decl_state ( void  )
read
const char* lto_get_section_data ( struct lto_file_decl_data file_data,
enum lto_section_type  section_type,
const char *  name,
size_t *  len 
)

Return a char pointer to the start of a data stream for an LTO pass or function. FILE_DATA indicates where to obtain the data. SECTION_TYPE is the type of information to be obtained. NAME is the name of the function and is only used when finding a function body; otherwise it is NULL. LEN is the size of the data returned.

FIXME lto: WPA mode does not write compressed sections, so for now suppress uncompression if flag_ltrans.

 Create a mapping header containing the underlying data and length,
 and prepend this to the uncompression buffer.  The uncompressed data
 then follows, and a pointer to the start of the uncompressed data is
 returned.   
char* lto_get_section_name ( int  ,
const char *  ,
struct lto_file_decl_data  
)
static enum LTO_tags lto_gimple_code_to_tag ( )
inlinestatic

Return the LTO tag corresponding to gimple code CODE. See enum LTO_tags for details on the conversion.

References lto_symtab_encoder_iterator::encoder, lto_symtab_encoder_iterator::index, and lto_symtab_encoder_d::nodes.

hashval_t lto_hash_in_decl_state ( const void *  )
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().

static void lto_init_tree_ref_encoder ( )
inlinestatic

Initialize an lto_out_decl_buffer ENCODER.

void lto_input_cgraph ( struct lto_file_decl_data ,
const char *   
)
void lto_input_constructors_and_inits ( struct lto_file_decl_data ,
const char *   
)
void lto_input_data_block ( struct lto_input_block ,
void *  ,
size_t   
)
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 ( struct bitpack_d ,
struct data_in  
)
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 ( struct lto_file_decl_data ,
int   
)
tree lto_input_tree ( struct lto_input_block ,
struct data_in  
)
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().

struct lto_in_decl_state* lto_new_in_decl_state ( void  )
read
struct lto_out_decl_state* lto_new_out_decl_state ( void  )
read

Return a new lto_out_decl_state.

void lto_output_data_stream ( struct lto_output_stream obs,
const void *  data,
size_t  len 
)

Write raw DATA of length LEN to the output block OB.

     No space left.   
     Determine how many bytes to copy in this loop.   
     Copy the data and do bookkeeping.   

Referenced by lto_output(), and streamer_string_index().

bool lto_output_decl_index ( struct lto_output_stream obs,
struct lto_tree_ref_encoder encoder,
tree  name,
unsigned int *  this_index 
)

Lookup NAME in ENCODER. If NAME is not found, create a new entry in ENCODER for NAME with the next available index of ENCODER, then print the index to OBS. True is returned if NAME was added to ENCODER. The resulting index is stored in THIS_INDEX.

If OBS is NULL, the only action is to add NAME to the encoder.

Referenced by lto_output_field_decl_index(), lto_output_fn_decl_index(), and lto_output_namespace_decl_index().

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_field_decl_index ( struct lto_out_decl_state decl_state,
struct lto_output_stream obs,
tree  decl 
)
void lto_output_fn_decl_index ( struct lto_out_decl_state decl_state,
struct lto_output_stream obs,
tree  decl 
)

Output a function DECL to OBS.

References LTO_DECL_STREAM_VAR_DECL, lto_output_decl_index(), and lto_out_decl_state::streams.

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_namespace_decl_index ( struct lto_out_decl_state decl_state,
struct lto_output_stream obs,
tree  decl 
)

Output a namespace DECL to OBS.

References LTO_DECL_STREAM_TYPE_DECL, lto_output_decl_index(), and lto_out_decl_state::streams.

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, stream_write_tree, streamer_write_record_start(), and eh_catch_d::type_list.

void lto_output_type_decl_index ( struct lto_out_decl_state decl_state,
struct lto_output_stream obs,
tree  decl 
)

Output a type DECL to OBS.

void lto_output_type_ref_index ( struct lto_out_decl_state decl_state,
struct lto_output_stream obs,
tree  ref 
)
void lto_output_var_decl_index ( struct lto_out_decl_state decl_state,
struct lto_output_stream obs,
tree  decl 
)

Output a static or extern var DECL to OBS.

Referenced by write_node_summary_p().

struct lto_out_decl_state* lto_pop_out_decl_state ( void  )
read

Pop the currently used out-decl state from top of stack.

void lto_push_out_decl_state ( struct lto_out_decl_state )
void lto_reader_init ( void  )

Initialization for the LTO reader.

void lto_record_function_out_decl_state ( tree  fn_decl,
struct lto_out_decl_state state 
)

Record STATE after it has been used in serializing the body of FN_DECL. STATE should no longer be used by the caller. The ownership of it is taken over from this point.

Strip all hash tables to save some memory.

void lto_record_renamed_decl ( struct lto_file_decl_data decl_data,
const char *  old_name,
const char *  new_name 
)

Record a declaration name mapping OLD_NAME -> NEW_NAME. DECL_DATA holds the renaming hash table to use.

References lto_file_decl_data::renaming_hash_table.

void lto_register_decl_definition ( tree  ,
struct lto_file_decl_data  
)
void lto_section_overrun ( struct lto_input_block )
void lto_set_in_hooks ( struct lto_file_decl_data **  data,
lto_get_section_data_f get_f,
lto_free_section_data_f free_f 
)

This is called from the lto front end to set up the hooks that are used by the ipa passes to get the data that they will deserialize.

void lto_set_symtab_encoder_in_partition ( lto_symtab_encoder_t  encoder,
symtab_node  node 
)

Return TRUE if we should encode body of NODE (if any).

void lto_streamer_hooks_init ( void  )

Initialize all the streamer hooks used for streaming GIMPLE.

void lto_streamer_init ( void  )

Initialization common to the LTO reader and writer.

Check that all the TS_* handled by the reader and writer routines match exactly the structures defined in treestruct.def. When a new TS_* astructure is added, the streamer should be updated to handle it.

References seen_error().

void lto_symtab_encoder_delete ( lto_symtab_encoder_t  )
bool lto_symtab_encoder_delete_node ( lto_symtab_encoder_t  encoder,
symtab_node  node 
)

Remove NODE from encoder.

 Remove from vector. We do this by swapping node with the last element
 of the vector.   
     Move the last element to the original spot of NODE.   
 Remove element from hash table.   
static symtab_node lto_symtab_encoder_deref ( )
inlinestatic

Return the cgraph node corresponding to REF using ENCODER.

Referenced by read_inline_edge_summary().

int lto_symtab_encoder_encode ( lto_symtab_encoder_t  encoder,
symtab_node  node 
)

Return the existing reference number of NODE in the symtab encoder in output block OB. Assign a new reference if this is the first time NODE is encoded.

Referenced by lto_set_symtab_encoder_encode_initializer(), and output_refs().

bool lto_symtab_encoder_encode_body_p ( lto_symtab_encoder_t  encoder,
struct cgraph_node node 
)

Return TRUE if we should encode initializer of NODE (if any).

bool lto_symtab_encoder_encode_initializer_p ( lto_symtab_encoder_t  encoder,
struct varpool_node node 
)

Return TRUE if we should encode initializer of NODE (if any).

References LCC_NOT_FOUND, lto_symtab_encoder_lookup(), and lto_symtab_encoder_d::nodes.

bool lto_symtab_encoder_in_partition_p ( lto_symtab_encoder_t  encoder,
symtab_node  node 
)
static int lto_symtab_encoder_lookup ( lto_symtab_encoder_t  encoder,
symtab_node  node 
)
inlinestatic

Look up NODE in encoder. Return NODE's reference if it has been encoded or LCC_NOT_FOUND if it is not there.

Referenced by lto_symtab_encoder_encode_initializer_p().

lto_symtab_encoder_t lto_symtab_encoder_new ( bool  )
static int lto_symtab_encoder_size ( )
inlinestatic

Return number of encoded nodes in ENCODER.

References lsei_end_p(), and lsei_start().

Referenced by read_inline_edge_summary().

void lto_symtab_merge_decls ( void  )

In lto-symtab.c.

void lto_symtab_merge_symbols ( void  )
tree lto_symtab_prevailing_decl ( tree  decl)
static void lto_tag_check ( )
inlinestatic

Check that tag ACTUAL == EXPECTED.

static void lto_tag_check_range ( enum LTO_tags  actual,
enum LTO_tags  tag1,
enum LTO_tags  tag2 
)
inlinestatic

Check that tag ACTUAL is in the range [TAG1, TAG2].

Referenced by lto_init_eh(), and lto_input_eh_catch_list().

void lto_tag_check_set ( enum  LTO_tags,
int  ,
  ... 
)
static bool lto_tag_is_gimple_code_p ( )
inlinestatic

Return true if LTO tag TAG corresponds to a gimple code.

static bool lto_tag_is_tree_code_p ( )
inlinestatic

Return true if LTO tag TAG corresponds to a tree code.

References LCC_NOT_FOUND, lto_symtab_encoder_d::map, and pointer_map_contains().

const char* lto_tag_name ( enum  LTO_tags)
static enum gimple_code lto_tag_to_gimple_code ( )
inlinestatic

Return the GIMPLE code corresponding to TAG. See enum LTO_tags for details on the conversion.

static enum tree_code lto_tag_to_tree_code ( )
inlinestatic

Return the tree code corresponding to TAG. See enum LTO_tags for details on the conversion.

References lto_symtab_encoder_iterator::encoder, and lto_symtab_encoder_iterator::index.

Referenced by streamer_read_tree_bitfields().

static enum LTO_tags lto_tree_code_to_tag ( )
inlinestatic

Return the LTO tag corresponding to tree code CODE. See enum LTO_tags for details on the conversion.

References LCC_NOT_FOUND, lto_symtab_encoder_d::nodes, and NULL.

static tree lto_tree_ref_encoder_get_tree ( struct lto_tree_ref_encoder encoder,
unsigned int  idx 
)
inlinestatic
static unsigned int lto_tree_ref_encoder_size ( )
inlinestatic

Return the number of trees encoded in ENCODER.

void lto_value_range_error ( const char *  purpose,
HOST_WIDE_INT  val,
HOST_WIDE_INT  min,
HOST_WIDE_INT  max 
)

Report out of range value.

Referenced by bp_pack_int_in_range(), and streamer_write_hwi_in_range().

void lto_write_options ( void  )

In lto-opts.c.

Write currently held options to an LTO IL section.

 Output options that affect GIMPLE IL semantics and are implicitely
 enabled by the frontend.
 This for now includes an explicit set of options that we also handle
 explicitly in lto-wrapper.c.  In the end the effects on GIMPLE IL
 semantics should be explicitely encoded in the IL or saved per
 function rather than per compilation unit.   
 -fexceptions causes the EH machinery to be initialized, enabling
 generation of unwind data so that explicit throw() calls work.   
 Output explicitely passed options.   
     Skip explicitly some common options that we do not need.   
     Skip frontend and driver specific options here.   
     Drop options created from the gcc driver that will be rejected
     when passed on to the driver again.   
     Also drop all options that are handled by the driver as well,
     which includes things like -o and -v or -fhelp for example.
     We do not need those.  Also drop all diagnostic options.   

References save_decoded_options, and save_decoded_options_count.

void lto_write_stream ( struct lto_output_stream )
void output_symtab ( void  )

Output the part of the symtab in SET and VSET.

 An encoder for cgraph nodes should have been created by
 ipa_write_summaries_1.   
 Write out the nodes.  We must first output a node and then its clones,
 otherwise at a time reading back the node there would be nothing to clone
 from.   
 Go over the nodes in SET again to write edges.   
 Emit toplevel asms.
 When doing WPA we must output every asm just once.  Since we do not partition asm
 nodes at all, output them to first output.  This is kind of hack, but should work
 well.   
void print_lto_report ( const char *  )
void produce_asm ( struct output_block ob,
tree  fn 
)
bool reachable_from_other_partition_p ( struct cgraph_node ,
lto_symtab_encoder_t   
)
bool reachable_from_this_partition_p ( struct cgraph_node ,
lto_symtab_encoder_t   
)
bool referenced_from_other_partition_p ( struct ipa_ref_list ,
lto_symtab_encoder_t   
)
bool referenced_from_this_partition_p ( struct ipa_ref_list list,
lto_symtab_encoder_t  encoder 
)

Return if LIST contain references from other partitions.

References cgraph_node::clone_of.


Variable Documentation

vec<lto_out_decl_state_ptr> lto_function_decl_states

Holds all the out decl states of functions output so far in the current output file.

List of out decl states used by functions. We use this to generate the decl directory later.

const char* lto_section_name[]

Section names corresponding to the values of enum lto_section_type.

Input functions for reading LTO sections.

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

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/. Section names. These must correspond to the values of enum lto_section_type.

struct lto_stats_d lto_stats

Statistics gathered during LTO, WPA and LTRANS.

Miscellaneous utilities for GIMPLE streaming. Things that are used in both input and output are here.

Copyright (C) 2009-2013 Free Software Foundation, Inc. Contributed by Doug Kwan dougk.nosp@m.wan@.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/. Statistics gathered during LTO, WPA and LTRANS.

Referenced by lto_start_compression().