Commit 533c07c5 by Jan Hubicka Committed by Jan Hubicka

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
parent 2611db71
2011-05-31 Jan Hubicka <jh@suse.cz>
* 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 <rguenther@suse.de> 2011-05-31 Richard Guenther <rguenther@suse.de>
* gimple.c (gimple_register_canonical_type): Do not register * gimple.c (gimple_register_canonical_type): Do not register
......
...@@ -304,7 +304,7 @@ typedef struct ...@@ -304,7 +304,7 @@ typedef struct
#define DEFCIFCODE(code, string) CIF_ ## code, #define DEFCIFCODE(code, string) CIF_ ## code,
/* Reasons for inlining failures. */ /* Reasons for inlining failures. */
typedef enum { typedef enum cgraph_inline_failed_enum {
#include "cif-code.def" #include "cif-code.def"
CIF_N_REASONS CIF_N_REASONS
} cgraph_inline_failed_t; } cgraph_inline_failed_t;
......
...@@ -49,6 +49,8 @@ static void output_varpool (cgraph_node_set, varpool_node_set); ...@@ -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 output_cgraph_opt_summary (cgraph_node_set set);
static void input_cgraph_opt_summary (VEC (cgraph_node_ptr, heap) * nodes); 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 /* Cgraph streaming is organized as set of record whose type
is indicated by a tag. */ is indicated by a tag. */
...@@ -62,7 +64,8 @@ enum LTO_cgraph_tags ...@@ -62,7 +64,8 @@ enum LTO_cgraph_tags
LTO_cgraph_analyzed_node, LTO_cgraph_analyzed_node,
/* Cgraph edges. */ /* Cgraph edges. */
LTO_cgraph_edge, LTO_cgraph_edge,
LTO_cgraph_indirect_edge LTO_cgraph_indirect_edge,
LTO_cgraph_last_tag
}; };
/* Create a new cgraph encoder. */ /* Create a new cgraph encoder. */
...@@ -262,9 +265,11 @@ lto_output_edge (struct lto_simple_output_block *ob, struct cgraph_edge *edge, ...@@ -262,9 +265,11 @@ lto_output_edge (struct lto_simple_output_block *ob, struct cgraph_edge *edge,
struct bitpack_d bp; struct bitpack_d bp;
if (edge->indirect_unknown_callee) 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 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); ref = lto_cgraph_encoder_lookup (encoder, edge->caller);
gcc_assert (ref != LCC_NOT_FOUND); gcc_assert (ref != LCC_NOT_FOUND);
...@@ -282,9 +287,10 @@ lto_output_edge (struct lto_simple_output_block *ob, struct cgraph_edge *edge, ...@@ -282,9 +287,10 @@ lto_output_edge (struct lto_simple_output_block *ob, struct cgraph_edge *edge,
bp = bitpack_create (ob->main_stream); bp = bitpack_create (ob->main_stream);
uid = (!gimple_has_body_p (edge->caller->decl) uid = (!gimple_has_body_p (edge->caller->decl)
? edge->lto_stmt_uid : gimple_uid (edge->call_stmt)); ? edge->lto_stmt_uid : gimple_uid (edge->call_stmt));
bp_pack_value (&bp, uid, HOST_BITS_PER_INT); bp_pack_enum (&bp, cgraph_inline_failed_enum,
bp_pack_value (&bp, edge->inline_failed, HOST_BITS_PER_INT); CIF_N_REASONS, edge->inline_failed);
bp_pack_value (&bp, edge->frequency, HOST_BITS_PER_INT); 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->indirect_inlining_edge, 1);
bp_pack_value (&bp, edge->call_stmt_cannot_inline_p, 1); bp_pack_value (&bp, edge->call_stmt_cannot_inline_p, 1);
bp_pack_value (&bp, edge->can_throw_external, 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, ...@@ -415,7 +421,7 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node,
else else
tag = LTO_cgraph_unavail_node; 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 /* In WPA mode, we only output part of the call-graph. Also, we
fake cgraph node attributes. There are two cases that we care. 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, ...@@ -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_startup, 1);
bp_pack_value (&bp, node->only_called_at_exit, 1); bp_pack_value (&bp, node->only_called_at_exit, 1);
bp_pack_value (&bp, node->thunk.thunk_p && !boundary_p, 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_bitpack (&bp);
lto_output_uleb128_stream (ob->main_stream, node->resolution);
if (node->thunk.thunk_p && !boundary_p) if (node->thunk.thunk_p && !boundary_p)
{ {
...@@ -534,7 +541,8 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node, ...@@ -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, lto_output_fn_decl_index (ob->decl_state, ob->main_stream,
alias->thunk.alias); alias->thunk.alias);
gcc_assert (cgraph_get_node (alias->thunk.alias) == node); 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; alias = alias->previous;
} }
while (alias); while (alias);
...@@ -595,7 +603,8 @@ lto_output_varpool_node (struct lto_simple_output_block *ob, struct varpool_node ...@@ -595,7 +603,8 @@ lto_output_varpool_node (struct lto_simple_output_block *ob, struct varpool_node
else else
ref = LCC_NOT_FOUND; ref = LCC_NOT_FOUND;
lto_output_sleb128_stream (ob->main_stream, ref); 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) if (count)
{ {
...@@ -603,7 +612,8 @@ lto_output_varpool_node (struct lto_simple_output_block *ob, struct varpool_node ...@@ -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) for (alias = node->extra_name; alias; alias = alias->next)
{ {
lto_output_var_decl_index (ob->decl_state, ob->main_stream, alias->decl); 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 ...@@ -909,8 +919,7 @@ static void
input_overwrite_node (struct lto_file_decl_data *file_data, input_overwrite_node (struct lto_file_decl_data *file_data,
struct cgraph_node *node, struct cgraph_node *node,
enum LTO_cgraph_tags tag, enum LTO_cgraph_tags tag,
struct bitpack_d *bp, struct bitpack_d *bp)
enum ld_plugin_symbol_resolution resolution)
{ {
node->aux = (void *) tag; node->aux = (void *) tag;
node->local.lto_file_data = file_data; node->local.lto_file_data = file_data;
...@@ -946,7 +955,8 @@ input_overwrite_node (struct lto_file_decl_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_startup = bp_unpack_value (bp, 1);
node->only_called_at_exit = 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->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. */ /* Output the part of the cgraph in SET. */
...@@ -989,7 +999,6 @@ input_node (struct lto_file_decl_data *file_data, ...@@ -989,7 +999,6 @@ input_node (struct lto_file_decl_data *file_data,
int ref = LCC_NOT_FOUND, ref2 = LCC_NOT_FOUND; int ref = LCC_NOT_FOUND, ref2 = LCC_NOT_FOUND;
unsigned long same_body_count = 0; unsigned long same_body_count = 0;
int clone_ref; int clone_ref;
enum ld_plugin_symbol_resolution resolution;
clone_ref = lto_input_sleb128 (ib); clone_ref = lto_input_sleb128 (ib);
...@@ -1021,8 +1030,7 @@ input_node (struct lto_file_decl_data *file_data, ...@@ -1021,8 +1030,7 @@ input_node (struct lto_file_decl_data *file_data,
"node %d", node->uid); "node %d", node->uid);
bp = lto_input_bitpack (ib); bp = lto_input_bitpack (ib);
resolution = (enum ld_plugin_symbol_resolution)lto_input_uleb128 (ib); input_overwrite_node (file_data, node, tag, &bp);
input_overwrite_node (file_data, node, tag, &bp, resolution);
/* Store a reference for now, and fix up later to be a pointer. */ /* Store a reference for now, and fix up later to be a pointer. */
node->global.inlined_to = (cgraph_node_ptr) (intptr_t) ref; node->global.inlined_to = (cgraph_node_ptr) (intptr_t) ref;
...@@ -1058,7 +1066,8 @@ input_node (struct lto_file_decl_data *file_data, ...@@ -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); real_alias = lto_file_decl_data_get_fn_decl (file_data, decl_index);
alias = cgraph_same_body_alias (node, alias_decl, real_alias); alias = cgraph_same_body_alias (node, alias_decl, real_alias);
gcc_assert (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; return node;
} }
...@@ -1102,7 +1111,8 @@ input_varpool_node (struct lto_file_decl_data *file_data, ...@@ -1102,7 +1111,8 @@ input_varpool_node (struct lto_file_decl_data *file_data,
ref = lto_input_sleb128 (ib); ref = lto_input_sleb128 (ib);
/* Store a reference for now, and fix up later to be a pointer. */ /* Store a reference for now, and fix up later to be a pointer. */
node->same_comdat_group = (struct varpool_node *) (intptr_t) ref; 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) if (aliases_p)
{ {
count = lto_input_uleb128 (ib); count = lto_input_uleb128 (ib);
...@@ -1112,7 +1122,8 @@ input_varpool_node (struct lto_file_decl_data *file_data, ...@@ -1112,7 +1122,8 @@ input_varpool_node (struct lto_file_decl_data *file_data,
lto_input_uleb128 (ib)); lto_input_uleb128 (ib));
struct varpool_node *alias; struct varpool_node *alias;
alias = varpool_extra_name_alias (decl, var_decl); 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; return node;
...@@ -1179,10 +1190,9 @@ input_edge (struct lto_input_block *ib, VEC(cgraph_node_ptr, heap) *nodes, ...@@ -1179,10 +1190,9 @@ input_edge (struct lto_input_block *ib, VEC(cgraph_node_ptr, heap) *nodes,
count = (gcov_type) lto_input_sleb128 (ib); count = (gcov_type) lto_input_sleb128 (ib);
bp = lto_input_bitpack (ib); bp = lto_input_bitpack (ib);
stmt_id = (unsigned int) bp_unpack_value (&bp, HOST_BITS_PER_INT); inline_failed = bp_unpack_enum (&bp, cgraph_inline_failed_enum, CIF_N_REASONS);
inline_failed = (cgraph_inline_failed_t) bp_unpack_value (&bp, stmt_id = bp_unpack_var_len_unsigned (&bp);
HOST_BITS_PER_INT); freq = (int) bp_unpack_var_len_unsigned (&bp);
freq = (int) bp_unpack_value (&bp, HOST_BITS_PER_INT);
if (indirect) if (indirect)
edge = cgraph_create_indirect_edge (caller, NULL, 0, count, freq); edge = cgraph_create_indirect_edge (caller, NULL, 0, count, freq);
...@@ -1225,7 +1235,7 @@ input_cgraph_1 (struct lto_file_decl_data *file_data, ...@@ -1225,7 +1235,7 @@ input_cgraph_1 (struct lto_file_decl_data *file_data,
unsigned i; unsigned i;
unsigned HOST_WIDE_INT len; 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) while (tag)
{ {
if (tag == LTO_cgraph_edge) if (tag == LTO_cgraph_edge)
...@@ -1241,7 +1251,7 @@ input_cgraph_1 (struct lto_file_decl_data *file_data, ...@@ -1241,7 +1251,7 @@ input_cgraph_1 (struct lto_file_decl_data *file_data,
lto_cgraph_encoder_encode (file_data->cgraph_node_encoder, node); 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. */ /* Input toplevel asms. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment