From 533c07c594cef102741325e09a6580094fa32cba Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Tue, 31 May 2011 16:58:49 +0200 Subject: [PATCH] cgraph.h (cgraph_inline_failed_t): Give enum a name * cgraph.h (cgraph_inline_failed_t): Give enum a name * lto-cgraph.c (LDPR_NUM_KNOWN): New macro. (LTO_cgraph_tags): Add LTO_cgraph_last_tag. (lto_output_edge): Use output_enum and var_len_unsigned. (lto_output_varpool_node): Likewise. (input_overwrite_node): Do not take resolution parameter; extract it from a bitpack. (input_node): Do not read resolution; use input_enum and var_len_unsigned. (input_varpool_node): Likewise. (input_edge): Likewise. (input_cgraph_1): Likewise. From-SVN: r174487 --- gcc/ChangeLog | 15 ++++++++++++ gcc/cgraph.h | 2 +- gcc/lto-cgraph.c | 62 ++++++++++++++++++++++++++++-------------------- 3 files changed, 52 insertions(+), 27 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 84a37572384..0057740d7e0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,18 @@ +2011-05-31 Jan Hubicka + + * cgraph.h (cgraph_inline_failed_t): Give enum a name + * lto-cgraph.c (LDPR_NUM_KNOWN): New macro. + (LTO_cgraph_tags): Add LTO_cgraph_last_tag. + (lto_output_edge): Use output_enum and var_len_unsigned. + (lto_output_varpool_node): Likewise. + (input_overwrite_node): Do not take resolution parameter; + extract it from a bitpack. + (input_node): Do not read resolution; use input_enum and + var_len_unsigned. + (input_varpool_node): Likewise. + (input_edge): Likewise. + (input_cgraph_1): Likewise. + 2011-05-31 Richard Guenther * gimple.c (gimple_register_canonical_type): Do not register diff --git a/gcc/cgraph.h b/gcc/cgraph.h index 8be0354c2e2..ded3aedbb0f 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -304,7 +304,7 @@ typedef struct #define DEFCIFCODE(code, string) CIF_ ## code, /* Reasons for inlining failures. */ -typedef enum { +typedef enum cgraph_inline_failed_enum { #include "cif-code.def" CIF_N_REASONS } cgraph_inline_failed_t; diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c index 22f44ad9783..1d2f92e9d1e 100644 --- a/gcc/lto-cgraph.c +++ b/gcc/lto-cgraph.c @@ -49,6 +49,8 @@ static void output_varpool (cgraph_node_set, varpool_node_set); static void output_cgraph_opt_summary (cgraph_node_set set); static void input_cgraph_opt_summary (VEC (cgraph_node_ptr, heap) * nodes); +/* Number of LDPR values known to GCC. */ +#define LDPR_NUM_KNOWN (LDPR_RESOLVED_DYN + 1) /* Cgraph streaming is organized as set of record whose type is indicated by a tag. */ @@ -62,7 +64,8 @@ enum LTO_cgraph_tags LTO_cgraph_analyzed_node, /* Cgraph edges. */ LTO_cgraph_edge, - LTO_cgraph_indirect_edge + LTO_cgraph_indirect_edge, + LTO_cgraph_last_tag }; /* Create a new cgraph encoder. */ @@ -262,9 +265,11 @@ lto_output_edge (struct lto_simple_output_block *ob, struct cgraph_edge *edge, struct bitpack_d bp; if (edge->indirect_unknown_callee) - lto_output_uleb128_stream (ob->main_stream, LTO_cgraph_indirect_edge); + lto_output_enum (ob->main_stream, LTO_cgraph_tags, LTO_cgraph_last_tag, + LTO_cgraph_indirect_edge); else - lto_output_uleb128_stream (ob->main_stream, LTO_cgraph_edge); + lto_output_enum (ob->main_stream, LTO_cgraph_tags, LTO_cgraph_last_tag, + LTO_cgraph_edge); ref = lto_cgraph_encoder_lookup (encoder, edge->caller); gcc_assert (ref != LCC_NOT_FOUND); @@ -282,9 +287,10 @@ lto_output_edge (struct lto_simple_output_block *ob, struct cgraph_edge *edge, bp = bitpack_create (ob->main_stream); uid = (!gimple_has_body_p (edge->caller->decl) ? edge->lto_stmt_uid : gimple_uid (edge->call_stmt)); - bp_pack_value (&bp, uid, HOST_BITS_PER_INT); - bp_pack_value (&bp, edge->inline_failed, HOST_BITS_PER_INT); - bp_pack_value (&bp, edge->frequency, HOST_BITS_PER_INT); + bp_pack_enum (&bp, cgraph_inline_failed_enum, + CIF_N_REASONS, edge->inline_failed); + bp_pack_var_len_unsigned (&bp, uid); + bp_pack_var_len_unsigned (&bp, edge->frequency); bp_pack_value (&bp, edge->indirect_inlining_edge, 1); bp_pack_value (&bp, edge->call_stmt_cannot_inline_p, 1); bp_pack_value (&bp, edge->can_throw_external, 1); @@ -415,7 +421,7 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node, else tag = LTO_cgraph_unavail_node; - lto_output_uleb128_stream (ob->main_stream, tag); + lto_output_enum (ob->main_stream, LTO_cgraph_tags, LTO_cgraph_last_tag, tag); /* In WPA mode, we only output part of the call-graph. Also, we fake cgraph node attributes. There are two cases that we care. @@ -503,8 +509,9 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node, bp_pack_value (&bp, node->only_called_at_startup, 1); bp_pack_value (&bp, node->only_called_at_exit, 1); bp_pack_value (&bp, node->thunk.thunk_p && !boundary_p, 1); + bp_pack_enum (&bp, ld_plugin_symbol_resolution, + LDPR_NUM_KNOWN, node->resolution); lto_output_bitpack (&bp); - lto_output_uleb128_stream (ob->main_stream, node->resolution); if (node->thunk.thunk_p && !boundary_p) { @@ -534,7 +541,8 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node, lto_output_fn_decl_index (ob->decl_state, ob->main_stream, alias->thunk.alias); gcc_assert (cgraph_get_node (alias->thunk.alias) == node); - lto_output_uleb128_stream (ob->main_stream, alias->resolution); + lto_output_enum (ob->main_stream, ld_plugin_symbol_resolution, + LDPR_NUM_KNOWN, alias->resolution); alias = alias->previous; } while (alias); @@ -595,7 +603,8 @@ lto_output_varpool_node (struct lto_simple_output_block *ob, struct varpool_node else ref = LCC_NOT_FOUND; lto_output_sleb128_stream (ob->main_stream, ref); - lto_output_uleb128_stream (ob->main_stream, node->resolution); + lto_output_enum (ob->main_stream, ld_plugin_symbol_resolution, + LDPR_NUM_KNOWN, node->resolution); if (count) { @@ -603,7 +612,8 @@ lto_output_varpool_node (struct lto_simple_output_block *ob, struct varpool_node for (alias = node->extra_name; alias; alias = alias->next) { lto_output_var_decl_index (ob->decl_state, ob->main_stream, alias->decl); - lto_output_uleb128_stream (ob->main_stream, alias->resolution); + lto_output_enum (ob->main_stream, ld_plugin_symbol_resolution, + LDPR_NUM_KNOWN, alias->resolution); } } } @@ -909,8 +919,7 @@ static void input_overwrite_node (struct lto_file_decl_data *file_data, struct cgraph_node *node, enum LTO_cgraph_tags tag, - struct bitpack_d *bp, - enum ld_plugin_symbol_resolution resolution) + struct bitpack_d *bp) { node->aux = (void *) tag; node->local.lto_file_data = file_data; @@ -946,7 +955,8 @@ input_overwrite_node (struct lto_file_decl_data *file_data, node->only_called_at_startup = bp_unpack_value (bp, 1); node->only_called_at_exit = bp_unpack_value (bp, 1); node->thunk.thunk_p = bp_unpack_value (bp, 1); - node->resolution = resolution; + node->resolution = bp_unpack_enum (bp, ld_plugin_symbol_resolution, + LDPR_NUM_KNOWN); } /* Output the part of the cgraph in SET. */ @@ -989,7 +999,6 @@ input_node (struct lto_file_decl_data *file_data, int ref = LCC_NOT_FOUND, ref2 = LCC_NOT_FOUND; unsigned long same_body_count = 0; int clone_ref; - enum ld_plugin_symbol_resolution resolution; clone_ref = lto_input_sleb128 (ib); @@ -1021,8 +1030,7 @@ input_node (struct lto_file_decl_data *file_data, "node %d", node->uid); bp = lto_input_bitpack (ib); - resolution = (enum ld_plugin_symbol_resolution)lto_input_uleb128 (ib); - input_overwrite_node (file_data, node, tag, &bp, resolution); + input_overwrite_node (file_data, node, tag, &bp); /* Store a reference for now, and fix up later to be a pointer. */ node->global.inlined_to = (cgraph_node_ptr) (intptr_t) ref; @@ -1058,7 +1066,8 @@ input_node (struct lto_file_decl_data *file_data, real_alias = lto_file_decl_data_get_fn_decl (file_data, decl_index); alias = cgraph_same_body_alias (node, alias_decl, real_alias); gcc_assert (alias); - alias->resolution = (enum ld_plugin_symbol_resolution)lto_input_uleb128 (ib); + alias->resolution = lto_input_enum (ib, ld_plugin_symbol_resolution, + LDPR_NUM_KNOWN); } return node; } @@ -1102,7 +1111,8 @@ input_varpool_node (struct lto_file_decl_data *file_data, ref = lto_input_sleb128 (ib); /* Store a reference for now, and fix up later to be a pointer. */ node->same_comdat_group = (struct varpool_node *) (intptr_t) ref; - node->resolution = (enum ld_plugin_symbol_resolution)lto_input_uleb128 (ib); + node->resolution = lto_input_enum (ib, ld_plugin_symbol_resolution, + LDPR_NUM_KNOWN); if (aliases_p) { count = lto_input_uleb128 (ib); @@ -1112,7 +1122,8 @@ input_varpool_node (struct lto_file_decl_data *file_data, lto_input_uleb128 (ib)); struct varpool_node *alias; alias = varpool_extra_name_alias (decl, var_decl); - alias->resolution = (enum ld_plugin_symbol_resolution)lto_input_uleb128 (ib); + alias->resolution = lto_input_enum (ib, ld_plugin_symbol_resolution, + LDPR_NUM_KNOWN); } } return node; @@ -1179,10 +1190,9 @@ input_edge (struct lto_input_block *ib, VEC(cgraph_node_ptr, heap) *nodes, count = (gcov_type) lto_input_sleb128 (ib); bp = lto_input_bitpack (ib); - stmt_id = (unsigned int) bp_unpack_value (&bp, HOST_BITS_PER_INT); - inline_failed = (cgraph_inline_failed_t) bp_unpack_value (&bp, - HOST_BITS_PER_INT); - freq = (int) bp_unpack_value (&bp, HOST_BITS_PER_INT); + inline_failed = bp_unpack_enum (&bp, cgraph_inline_failed_enum, CIF_N_REASONS); + stmt_id = bp_unpack_var_len_unsigned (&bp); + freq = (int) bp_unpack_var_len_unsigned (&bp); if (indirect) edge = cgraph_create_indirect_edge (caller, NULL, 0, count, freq); @@ -1225,7 +1235,7 @@ input_cgraph_1 (struct lto_file_decl_data *file_data, unsigned i; unsigned HOST_WIDE_INT len; - tag = (enum LTO_cgraph_tags) lto_input_uleb128 (ib); + tag = lto_input_enum (ib, LTO_cgraph_tags, LTO_cgraph_last_tag); while (tag) { if (tag == LTO_cgraph_edge) @@ -1241,7 +1251,7 @@ input_cgraph_1 (struct lto_file_decl_data *file_data, lto_cgraph_encoder_encode (file_data->cgraph_node_encoder, node); } - tag = (enum LTO_cgraph_tags) lto_input_uleb128 (ib); + tag = lto_input_enum (ib, LTO_cgraph_tags, LTO_cgraph_last_tag); } /* Input toplevel asms. */ -- 2.30.2