@@ -249,38 +249,12 @@ enum lto_section_type
/* Indices to the various function, type and symbol streams. */
enum lto_decl_stream_e_t
{
- LTO_DECL_STREAM_TYPE = 0, /* Must be first. */
- 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_DECL_STREAM = 0, /* Must be first. */
LTO_N_DECL_STREAMS
};
typedef enum ld_plugin_symbol_resolution ld_plugin_symbol_resolution_t;
-
-/* Macro to define convenience functions for type and decl streams
- in lto_file_decl_data. */
-#define DEFINE_DECL_STREAM_FUNCS(UPPER_NAME, name) \
-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; \
- return (*state->streams[LTO_DECL_STREAM_## UPPER_NAME])[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 vec_safe_length (state->streams[LTO_DECL_STREAM_## UPPER_NAME]); \
-}
-
-
/* 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
@@ -908,10 +882,12 @@ extern struct output_block *create_output_block (enum lto_section_type);
extern void destroy_output_block (struct output_block *);
extern void lto_output_tree (struct output_block *, tree, bool, bool);
extern void stream_write_tree_ref (struct output_block *, tree);
-extern void lto_output_var_decl_index (struct lto_out_decl_state *,
- struct lto_output_stream *, tree);
-extern void lto_output_fn_decl_index (struct lto_out_decl_state *,
- struct lto_output_stream *, tree);
+extern void lto_output_var_decl_ref (struct lto_out_decl_state *,
+ struct lto_output_stream *, tree);
+extern void lto_output_fn_decl_ref (struct lto_out_decl_state *,
+ struct lto_output_stream *, tree);
+extern tree lto_input_var_decl_ref (lto_input_block *, lto_file_decl_data *);
+extern tree lto_input_fn_decl_ref (lto_input_block *, lto_file_decl_data *);
extern void lto_output_toplevel_asms (void);
extern void produce_asm (struct output_block *ob, tree fn);
extern void lto_output ();
@@ -1251,14 +1227,6 @@ lsei_start_variable_in_partition (lto_symtab_encoder_t encoder)
return lsei;
}
-DEFINE_DECL_STREAM_FUNCS (TYPE, type)
-DEFINE_DECL_STREAM_FUNCS (FIELD_DECL, field_decl)
-DEFINE_DECL_STREAM_FUNCS (FN_DECL, fn_decl)
-DEFINE_DECL_STREAM_FUNCS (VAR_DECL, var_decl)
-DEFINE_DECL_STREAM_FUNCS (TYPE_DECL, type_decl)
-DEFINE_DECL_STREAM_FUNCS (NAMESPACE_DECL, namespace_decl)
-DEFINE_DECL_STREAM_FUNCS (LABEL_DECL, label_decl)
-
/* Entry for the delayed registering of decl -> DIE references. */
struct dref_entry {
tree decl;
@@ -1039,7 +1039,7 @@ stream_out_bitmap (struct lto_simple_output_block *ob,
EXECUTE_IF_AND_IN_BITMAP (bits, ltrans_statics, 0, index, bi)
{
tree decl = (*reference_vars_to_consider) [index];
- lto_output_var_decl_index (ob->decl_state, ob->main_stream, decl);
+ lto_output_var_decl_ref (ob->decl_state, ob->main_stream, decl);
}
}
@@ -1158,9 +1158,7 @@ ipa_reference_read_optimization_summary (void)
fprintf (dump_file, "all module statics:");
for (i = 0; i < (unsigned int)b_count; i++)
{
- unsigned int var_index = streamer_read_uhwi (ib);
- tree v_decl = lto_file_decl_data_get_var_decl (file_data,
- var_index);
+ tree v_decl = lto_input_var_decl_ref (ib, file_data);
bool existed;
bitmap_set_bit (all_module_statics,
ipa_reference_var_get_or_insert_uid
@@ -1206,9 +1204,7 @@ ipa_reference_read_optimization_summary (void)
(&optimization_summary_obstack);
for (j = 0; j < (unsigned int)v_count; j++)
{
- unsigned int var_index = streamer_read_uhwi (ib);
- tree v_decl = lto_file_decl_data_get_var_decl (file_data,
- var_index);
+ tree v_decl = lto_input_var_decl_ref (ib, file_data);
bitmap_set_bit (info->statics_read,
ipa_reference_var_uid (v_decl));
if (dump_file)
@@ -1235,9 +1231,7 @@ ipa_reference_read_optimization_summary (void)
(&optimization_summary_obstack);
for (j = 0; j < (unsigned int)v_count; j++)
{
- unsigned int var_index = streamer_read_uhwi (ib);
- tree v_decl = lto_file_decl_data_get_var_decl (file_data,
- var_index);
+ tree v_decl = lto_input_var_decl_ref (ib, file_data);
bitmap_set_bit (info->statics_written,
ipa_reference_var_uid (v_decl));
if (dump_file)
@@ -451,7 +451,7 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node,
streamer_write_hwi_stream (ob->main_stream, ref);
- lto_output_fn_decl_index (ob->decl_state, ob->main_stream, node->decl);
+ lto_output_fn_decl_ref (ob->decl_state, ob->main_stream, node->decl);
node->count.stream_out (ob->main_stream);
streamer_write_hwi_stream (ob->main_stream, node->count_materialization_scale);
@@ -591,7 +591,7 @@ lto_output_varpool_node (struct lto_simple_output_block *ob, varpool_node *node,
streamer_write_enum (ob->main_stream, LTO_symtab_tags, LTO_symtab_last_tag,
LTO_symtab_variable);
streamer_write_hwi_stream (ob->main_stream, node->order);
- lto_output_var_decl_index (ob->decl_state, ob->main_stream, node->decl);
+ lto_output_var_decl_ref (ob->decl_state, ob->main_stream, node->decl);
bp = bitpack_create (ob->main_stream);
bp_pack_value (&bp, node->externally_visible, 1);
bp_pack_value (&bp, node->no_reorder, 1);
@@ -1071,16 +1071,16 @@ output_offload_tables (void)
{
streamer_write_enum (ob->main_stream, LTO_symtab_tags,
LTO_symtab_last_tag, LTO_symtab_unavail_node);
- lto_output_fn_decl_index (ob->decl_state, ob->main_stream,
- (*offload_funcs)[i]);
+ lto_output_fn_decl_ref (ob->decl_state, ob->main_stream,
+ (*offload_funcs)[i]);
}
for (unsigned i = 0; i < vec_safe_length (offload_vars); i++)
{
streamer_write_enum (ob->main_stream, LTO_symtab_tags,
LTO_symtab_last_tag, LTO_symtab_variable);
- lto_output_var_decl_index (ob->decl_state, ob->main_stream,
- (*offload_vars)[i]);
+ lto_output_var_decl_ref (ob->decl_state, ob->main_stream,
+ (*offload_vars)[i]);
}
streamer_write_uhwi_stream (ob->main_stream, 0);
@@ -1219,7 +1219,6 @@ input_node (struct lto_file_decl_data *file_data,
tree fn_decl;
struct cgraph_node *node;
struct bitpack_d bp;
- unsigned decl_index;
int ref = LCC_NOT_FOUND, ref2 = LCC_NOT_FOUND;
int clone_ref;
int order;
@@ -1229,8 +1228,7 @@ input_node (struct lto_file_decl_data *file_data,
order = streamer_read_hwi (ib) + file_data->order_base;
clone_ref = streamer_read_hwi (ib);
- decl_index = streamer_read_uhwi (ib);
- fn_decl = lto_file_decl_data_get_fn_decl (file_data, decl_index);
+ fn_decl = lto_input_fn_decl_ref (ib, file_data);
if (clone_ref != LCC_NOT_FOUND)
{
@@ -1339,7 +1337,6 @@ static varpool_node *
input_varpool_node (struct lto_file_decl_data *file_data,
class lto_input_block *ib)
{
- int decl_index;
tree var_decl;
varpool_node *node;
struct bitpack_d bp;
@@ -1349,8 +1346,7 @@ input_varpool_node (struct lto_file_decl_data *file_data,
const char *section;
order = streamer_read_hwi (ib) + file_data->order_base;
- decl_index = streamer_read_uhwi (ib);
- var_decl = lto_file_decl_data_get_var_decl (file_data, decl_index);
+ var_decl = lto_input_var_decl_ref (ib, file_data);
/* Declaration of functions can be already merged with a declaration
from other input file. We keep cgraph unmerged until after streaming
@@ -1781,9 +1777,8 @@ input_offload_tables (bool do_force_output)
{
if (tag == LTO_symtab_unavail_node)
{
- int decl_index = streamer_read_uhwi (ib);
tree fn_decl
- = lto_file_decl_data_get_fn_decl (file_data, decl_index);
+ = lto_input_fn_decl_ref (ib, file_data);
vec_safe_push (offload_funcs, fn_decl);
/* Prevent IPA from removing fn_decl as unreachable, since there
@@ -1794,9 +1789,8 @@ input_offload_tables (bool do_force_output)
}
else if (tag == LTO_symtab_variable)
{
- int decl_index = streamer_read_uhwi (ib);
tree var_decl
- = lto_file_decl_data_get_var_decl (file_data, decl_index);
+ = lto_input_var_decl_ref (ib, file_data);
vec_safe_push (offload_vars, var_decl);
/* Prevent IPA from removing var_decl as unused, since there
@@ -320,36 +320,16 @@ lto_input_tree_ref (class lto_input_block *ib, class data_in *data_in,
switch (tag)
{
- case LTO_type_ref:
- ix_u = streamer_read_uhwi (ib);
- result = lto_file_decl_data_get_type (data_in->file_data, ix_u);
- break;
-
case LTO_ssa_name_ref:
ix_u = streamer_read_uhwi (ib);
result = (*SSANAMES (fn))[ix_u];
break;
+ case LTO_type_ref:
case LTO_field_decl_ref:
- ix_u = streamer_read_uhwi (ib);
- result = lto_file_decl_data_get_field_decl (data_in->file_data, ix_u);
- break;
-
case LTO_function_decl_ref:
- ix_u = streamer_read_uhwi (ib);
- result = lto_file_decl_data_get_fn_decl (data_in->file_data, ix_u);
- break;
-
case LTO_type_decl_ref:
- ix_u = streamer_read_uhwi (ib);
- result = lto_file_decl_data_get_type_decl (data_in->file_data, ix_u);
- break;
-
case LTO_namespace_decl_ref:
- ix_u = streamer_read_uhwi (ib);
- result = lto_file_decl_data_get_namespace_decl (data_in->file_data, ix_u);
- break;
-
case LTO_global_decl_ref:
case LTO_result_decl_ref:
case LTO_const_decl_ref:
@@ -358,7 +338,8 @@ lto_input_tree_ref (class lto_input_block *ib, class data_in *data_in,
case LTO_translation_unit_decl_ref:
case LTO_namelist_decl_ref:
ix_u = streamer_read_uhwi (ib);
- result = lto_file_decl_data_get_var_decl (data_in->file_data, ix_u);
+ result = (*data_in->file_data->current_decl_state
+ ->streams[LTO_DECL_STREAM])[ix_u];
break;
default:
@@ -370,6 +351,30 @@ lto_input_tree_ref (class lto_input_block *ib, class data_in *data_in,
return result;
}
+/* Read VAR_DECL reference to DATA from IB. */
+
+tree
+lto_input_var_decl_ref (lto_input_block *ib, lto_file_decl_data *file_data)
+{
+ unsigned int ix_u = streamer_read_uhwi (ib);
+ tree result = (*file_data->current_decl_state
+ ->streams[LTO_DECL_STREAM])[ix_u];
+ gcc_assert (TREE_CODE (result) == VAR_DECL);
+ return result;
+}
+
+/* Read VAR_DECL reference to DATA from IB. */
+
+tree
+lto_input_fn_decl_ref (lto_input_block *ib, lto_file_decl_data *file_data)
+{
+ unsigned int ix_u = streamer_read_uhwi (ib);
+ tree result = (*file_data->current_decl_state
+ ->streams[LTO_DECL_STREAM])[ix_u];
+ gcc_assert (TREE_CODE (result) == FUNCTION_DECL);
+ return result;
+}
+
/* Read and return a double-linked list of catch handlers from input
block IB, using descriptors in DATA_IN. */
@@ -260,7 +260,7 @@ lto_indexable_tree_ref (struct output_block *ob, tree expr,
if (TYPE_P (expr))
{
*tag = LTO_type_ref;
- encoder = LTO_DECL_STREAM_TYPE;
+ encoder = LTO_DECL_STREAM;
}
else
{
@@ -275,12 +275,12 @@ lto_indexable_tree_ref (struct output_block *ob, tree expr,
case FIELD_DECL:
*tag = LTO_field_decl_ref;
- encoder = LTO_DECL_STREAM_FIELD_DECL;
+ encoder = LTO_DECL_STREAM;
break;
case FUNCTION_DECL:
*tag = LTO_function_decl_ref;
- encoder = LTO_DECL_STREAM_FN_DECL;
+ encoder = LTO_DECL_STREAM;
break;
case VAR_DECL:
@@ -290,37 +290,37 @@ lto_indexable_tree_ref (struct output_block *ob, tree expr,
/* FALLTHRU */
case PARM_DECL:
*tag = LTO_global_decl_ref;
- encoder = LTO_DECL_STREAM_VAR_DECL;
+ encoder = LTO_DECL_STREAM;
break;
case CONST_DECL:
*tag = LTO_const_decl_ref;
- encoder = LTO_DECL_STREAM_VAR_DECL;
+ encoder = LTO_DECL_STREAM;
break;
case TYPE_DECL:
*tag = LTO_type_decl_ref;
- encoder = LTO_DECL_STREAM_TYPE_DECL;
+ encoder = LTO_DECL_STREAM;
break;
case NAMESPACE_DECL:
*tag = LTO_namespace_decl_ref;
- encoder = LTO_DECL_STREAM_NAMESPACE_DECL;
+ encoder = LTO_DECL_STREAM;
break;
case LABEL_DECL:
*tag = LTO_label_decl_ref;
- encoder = LTO_DECL_STREAM_VAR_DECL;
+ encoder = LTO_DECL_STREAM;
break;
case RESULT_DECL:
*tag = LTO_result_decl_ref;
- encoder = LTO_DECL_STREAM_VAR_DECL;
+ encoder = LTO_DECL_STREAM;
break;
case TRANSLATION_UNIT_DECL:
*tag = LTO_translation_unit_decl_ref;
- encoder = LTO_DECL_STREAM_VAR_DECL;
+ encoder = LTO_DECL_STREAM;
break;
default:
@@ -336,12 +336,12 @@ lto_indexable_tree_ref (struct output_block *ob, tree expr,
/* Output a static or extern var DECL to OBS. */
void
-lto_output_var_decl_index (struct lto_out_decl_state *decl_state,
- struct lto_output_stream * obs, tree decl)
+lto_output_var_decl_ref (struct lto_out_decl_state *decl_state,
+ struct lto_output_stream * obs, tree decl)
{
gcc_checking_assert (TREE_CODE (decl) == VAR_DECL);
streamer_write_uhwi_stream
- (obs, lto_get_index (&decl_state->streams[LTO_DECL_STREAM_VAR_DECL],
+ (obs, lto_get_index (&decl_state->streams[LTO_DECL_STREAM],
decl));
}
@@ -349,12 +349,12 @@ lto_output_var_decl_index (struct lto_out_decl_state *decl_state,
/* Output a static or extern var DECL to OBS. */
void
-lto_output_fn_decl_index (struct lto_out_decl_state *decl_state,
- struct lto_output_stream * obs, tree decl)
+lto_output_fn_decl_ref (struct lto_out_decl_state *decl_state,
+ struct lto_output_stream * obs, tree decl)
{
gcc_checking_assert (TREE_CODE (decl) == FUNCTION_DECL);
streamer_write_uhwi_stream
- (obs, lto_get_index (&decl_state->streams[LTO_DECL_STREAM_FN_DECL], decl));
+ (obs, lto_get_index (&decl_state->streams[LTO_DECL_STREAM], decl));
}
/* Return true if EXPR is a tree node that can be written to disk. */