Cleanup global decl stream reference streaming, part 2

gcc/ChangeLog:

2020-06-01  Jan Hubicka  <hubicka@ucw.cz>

	* lto-streamer.h (enum LTO_tags): Remove LTO_field_decl_ref,
	LTO_function_decl_ref, LTO_label_decl_ref, LTO_namespace_decl_ref,
	LTO_result_decl_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 and
	LTO_namelist_decl_ref; add LTO_global_stream_ref.
	* lto-streamer-in.c (lto_input_tree_ref): Simplify.
	(lto_input_scc): Update.
	(lto_input_tree_1): Update.
	* lto-streamer-out.c (lto_indexable_tree_ref): Simlify.
	* lto-streamer.c (lto_tag_name): Update.
This commit is contained in:
Jan Hubicka 2020-06-01 19:13:58 +02:00
parent 258059d91b
commit 1746d5f3e6
4 changed files with 21 additions and 131 deletions

View File

@ -316,34 +316,17 @@ lto_input_tree_ref (class lto_input_block *ib, class data_in *data_in,
unsigned HOST_WIDE_INT ix_u; unsigned HOST_WIDE_INT ix_u;
tree result = NULL_TREE; tree result = NULL_TREE;
lto_tag_check_range (tag, LTO_field_decl_ref, LTO_namelist_decl_ref); if (tag == LTO_ssa_name_ref)
switch (tag)
{ {
case LTO_ssa_name_ref:
ix_u = streamer_read_uhwi (ib); ix_u = streamer_read_uhwi (ib);
result = (*SSANAMES (fn))[ix_u]; result = (*SSANAMES (fn))[ix_u];
break; }
else
case LTO_type_ref: {
case LTO_field_decl_ref: gcc_checking_assert (tag == LTO_global_stream_ref);
case LTO_function_decl_ref:
case LTO_type_decl_ref:
case LTO_namespace_decl_ref:
case LTO_global_decl_ref:
case LTO_result_decl_ref:
case LTO_const_decl_ref:
case LTO_imported_decl_ref:
case LTO_label_decl_ref:
case LTO_translation_unit_decl_ref:
case LTO_namelist_decl_ref:
ix_u = streamer_read_uhwi (ib); ix_u = streamer_read_uhwi (ib);
result = (*data_in->file_data->current_decl_state result = (*data_in->file_data->current_decl_state
->streams[LTO_DECL_STREAM])[ix_u]; ->streams[LTO_DECL_STREAM])[ix_u];
break;
default:
gcc_unreachable ();
} }
gcc_assert (result); gcc_assert (result);
@ -1485,7 +1468,7 @@ lto_input_scc (class lto_input_block *ib, class data_in *data_in,
{ {
enum LTO_tags tag = streamer_read_record_start (ib); enum LTO_tags tag = streamer_read_record_start (ib);
if (tag == LTO_null if (tag == LTO_null
|| (tag >= LTO_field_decl_ref && tag <= LTO_global_decl_ref) || tag == LTO_global_stream_ref
|| tag == LTO_tree_pickle_reference || tag == LTO_tree_pickle_reference
|| tag == LTO_integer_cst || tag == LTO_integer_cst
|| tag == LTO_tree_scc || tag == LTO_tree_scc
@ -1549,7 +1532,7 @@ lto_input_tree_1 (class lto_input_block *ib, class data_in *data_in,
if (tag == LTO_null) if (tag == LTO_null)
result = NULL_TREE; result = NULL_TREE;
else if (tag >= LTO_field_decl_ref && tag <= LTO_namelist_decl_ref) else if (tag == LTO_global_stream_ref || tag == LTO_ssa_name_ref)
{ {
/* If TAG is a reference to an indexable tree, the next value /* 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 in IB is the index into the table where we expect to find

View File

@ -252,85 +252,19 @@ static void
lto_indexable_tree_ref (struct output_block *ob, tree expr, lto_indexable_tree_ref (struct output_block *ob, tree expr,
enum LTO_tags *tag, unsigned *index) enum LTO_tags *tag, unsigned *index)
{ {
enum tree_code code;
enum lto_decl_stream_e_t encoder;
gcc_checking_assert (tree_is_indexable (expr)); gcc_checking_assert (tree_is_indexable (expr));
if (TYPE_P (expr)) if (TREE_CODE (expr) == SSA_NAME)
{ {
*tag = LTO_type_ref; *tag = LTO_ssa_name_ref;
encoder = LTO_DECL_STREAM; *index = SSA_NAME_VERSION (expr);
} }
else else
{ {
code = TREE_CODE (expr); *tag = LTO_global_stream_ref;
switch (code) *index = lto_get_index (&ob->decl_state->streams[LTO_DECL_STREAM], expr);
{
case SSA_NAME:
*tag = LTO_ssa_name_ref;
*index = SSA_NAME_VERSION (expr);
return;
break;
case FIELD_DECL:
*tag = LTO_field_decl_ref;
encoder = LTO_DECL_STREAM;
break;
case FUNCTION_DECL:
*tag = LTO_function_decl_ref;
encoder = LTO_DECL_STREAM;
break;
case VAR_DECL:
case DEBUG_EXPR_DECL:
gcc_checking_assert (decl_function_context (expr) == NULL
|| TREE_STATIC (expr));
/* FALLTHRU */
case PARM_DECL:
*tag = LTO_global_decl_ref;
encoder = LTO_DECL_STREAM;
break;
case CONST_DECL:
*tag = LTO_const_decl_ref;
encoder = LTO_DECL_STREAM;
break;
case TYPE_DECL:
*tag = LTO_type_decl_ref;
encoder = LTO_DECL_STREAM;
break;
case NAMESPACE_DECL:
*tag = LTO_namespace_decl_ref;
encoder = LTO_DECL_STREAM;
break;
case LABEL_DECL:
*tag = LTO_label_decl_ref;
encoder = LTO_DECL_STREAM;
break;
case RESULT_DECL:
*tag = LTO_result_decl_ref;
encoder = LTO_DECL_STREAM;
break;
case TRANSLATION_UNIT_DECL:
*tag = LTO_translation_unit_decl_ref;
encoder = LTO_DECL_STREAM;
break;
default:
/* No other node is indexable, so it should have been handled by
lto_output_tree. */
gcc_unreachable ();
} }
} }
*index = lto_get_index (&ob->decl_state->streams[encoder], expr);
}
/* Output a static or extern var DECL to OBS. */ /* Output a static or extern var DECL to OBS. */

View File

@ -84,24 +84,10 @@ lto_tag_name (enum LTO_tags tag)
return "LTO_ert_must_not_throw"; return "LTO_ert_must_not_throw";
case LTO_tree_pickle_reference: case LTO_tree_pickle_reference:
return "LTO_tree_pickle_reference"; return "LTO_tree_pickle_reference";
case LTO_field_decl_ref: case LTO_global_stream_ref:
return "LTO_field_decl_ref"; return "LTO_global_sream_ref";
case LTO_function_decl_ref:
return "LTO_function_decl_ref";
case LTO_label_decl_ref:
return "LTO_label_decl_ref";
case LTO_namespace_decl_ref:
return "LTO_namespace_decl_ref";
case LTO_result_decl_ref:
return "LTO_result_decl_ref";
case LTO_ssa_name_ref: case LTO_ssa_name_ref:
return "LTO_ssa_name_ref"; return "LTO_ssa_name_ref";
case LTO_type_decl_ref:
return "LTO_type_decl_ref";
case LTO_type_ref:
return "LTO_type_ref";
case LTO_global_decl_ref:
return "LTO_global_decl_ref";
default: default:
return "LTO_UNKNOWN"; return "LTO_UNKNOWN";
} }

View File

@ -185,28 +185,15 @@ enum LTO_tags
LTO_trees, LTO_trees,
/* References to indexable tree nodes. These objects are stored in /* References to indexable tree nodes. These objects are stored in
tables that are written separately from the function bodies that tables that are written separately from the function bodies
reference them. This way they can be instantiated even when the and variable constructors that reference them. This way they can be
referencing functions aren't (e.g., during WPA) and it also allows instantiated even when the referencing functions aren't (e.g., during WPA)
functions to be copied from one file to another without having and it also allows functions to be copied from one file to another without
to unpickle the body first (the references are location having to unpickle the body first (the references are location
independent). independent). */
LTO_global_stream_ref,
NOTE, do not regroup these values as the grouping is exposed
in the range checks done in lto_input_tree. */
LTO_field_decl_ref, /* Do not change. */
LTO_function_decl_ref,
LTO_label_decl_ref,
LTO_namespace_decl_ref,
LTO_result_decl_ref,
LTO_ssa_name_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_namelist_decl_ref, /* Do not change. */
/* This tag must always be last. */ /* This tag must always be last. */
LTO_NUM_TAGS LTO_NUM_TAGS