From afb0d51359158a213e4919a8d46da6497724d26c Mon Sep 17 00:00:00 2001 From: hubicka Date: Fri, 11 Jul 2014 17:43:44 +0000 Subject: * vapool.c: Include tree-ssa-alias.h, gimple.h and lto-streamer.h (varpool_get_constructor): New function. (varpool_ctor_useable_for_folding_p): Break out from ... (ctor_for_folding): ... here; use varpool_get_constructor. (varpool_assemble_decl): Likewise. * lto-streamer.h (struct output_block): Turn cgraph_node to symbol filed. (lto_input_variable_constructor): Declare. * ipa-visibility.c (function_and_variable_visibility): Use varpool_get_constructor. * cgraph.h (varpool_get_constructor): Declare. (varpool_ctor_useable_for_folding_p): New function. * lto-streamer-out.c (get_symbol_initial_value): Take encoder parameter; return error_mark_node for non-trivial constructors. (lto_write_tree_1, DFS_write_tree): UPdate use of get_symbol_initial_value. (output_function): Update initialization of symbol. (output_constructor): New function. (copy_function): Rename to .. (copy_function_or_variable): ... this one; handle vars too. (lto_output): Output variable sections. * lto-streamer-in.c (input_constructor): New function. (lto_read_body): Rename from ... (lto_read_body_or_constructor): ... this one; handle vars too. (lto_input_variable_constructor): New function. * ipa-prop.c (ipa_prop_write_jump_functions, ipa_prop_write_all_agg_replacement): Update. * lto-cgraph.c (compute_ltrans_boundary): Use it. (output_cgraph_opt_summary): Set symbol to NULL. * lto-partition.c (add_references_to_partition): Use varpool_ctor_useable_for_folding_p. * lto.c (lto_read_in_decl_state): Update sanity check. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@212467 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/lto-streamer-in.c | 67 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 51 insertions(+), 16 deletions(-) (limited to 'gcc/lto-streamer-in.c') diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c index 5d7989353fe..7c22183b519 100644 --- a/gcc/lto-streamer-in.c +++ b/gcc/lto-streamer-in.c @@ -1029,6 +1029,15 @@ input_function (tree fn_decl, struct data_in *data_in, pop_cfun (); } +/* Read the body of function FN_DECL from DATA_IN using input block IB. */ + +static void +input_constructor (tree var, struct data_in *data_in, + struct lto_input_block *ib) +{ + DECL_INITIAL (var) = stream_read_tree (ib, data_in); +} + /* Read the body from DATA for function NODE and fill it in. FILE_DATA are the global decls and types. SECTION_TYPE is either @@ -1037,8 +1046,8 @@ input_function (tree fn_decl, struct data_in *data_in, that function. */ static void -lto_read_body (struct lto_file_decl_data *file_data, struct cgraph_node *node, - const char *data, enum lto_section_type section_type) +lto_read_body_or_constructor (struct lto_file_decl_data *file_data, struct symtab_node *node, + const char *data, enum lto_section_type section_type) { const struct lto_function_header *header; struct data_in *data_in; @@ -1050,19 +1059,32 @@ lto_read_body (struct lto_file_decl_data *file_data, struct cgraph_node *node, tree fn_decl = node->decl; header = (const struct lto_function_header *) data; - cfg_offset = sizeof (struct lto_function_header); - main_offset = cfg_offset + header->cfg_size; - string_offset = main_offset + header->main_size; - - LTO_INIT_INPUT_BLOCK (ib_cfg, - data + cfg_offset, - 0, - header->cfg_size); + if (TREE_CODE (node->decl) == FUNCTION_DECL) + { + cfg_offset = sizeof (struct lto_function_header); + main_offset = cfg_offset + header->cfg_size; + string_offset = main_offset + header->main_size; + + LTO_INIT_INPUT_BLOCK (ib_cfg, + data + cfg_offset, + 0, + header->cfg_size); + + LTO_INIT_INPUT_BLOCK (ib_main, + data + main_offset, + 0, + header->main_size); + } + else + { + main_offset = sizeof (struct lto_function_header); + string_offset = main_offset + header->main_size; - LTO_INIT_INPUT_BLOCK (ib_main, - data + main_offset, - 0, - header->main_size); + LTO_INIT_INPUT_BLOCK (ib_main, + data + main_offset, + 0, + header->main_size); + } data_in = lto_data_in_create (file_data, data + string_offset, header->string_size, vNULL); @@ -1082,7 +1104,10 @@ lto_read_body (struct lto_file_decl_data *file_data, struct cgraph_node *node, /* Set up the struct function. */ from = data_in->reader_cache->nodes.length (); - input_function (fn_decl, data_in, &ib_main, &ib_cfg); + if (TREE_CODE (node->decl) == FUNCTION_DECL) + input_function (fn_decl, data_in, &ib_main, &ib_cfg); + else + input_constructor (fn_decl, data_in, &ib_main); /* And fixup types we streamed locally. */ { struct streamer_tree_cache_d *cache = data_in->reader_cache; @@ -1124,7 +1149,17 @@ void lto_input_function_body (struct lto_file_decl_data *file_data, struct cgraph_node *node, const char *data) { - lto_read_body (file_data, node, data, LTO_section_function_body); + lto_read_body_or_constructor (file_data, node, data, LTO_section_function_body); +} + +/* Read the body of NODE using DATA. FILE_DATA holds the global + decls and types. */ + +void +lto_input_variable_constructor (struct lto_file_decl_data *file_data, + struct varpool_node *node, const char *data) +{ + lto_read_body_or_constructor (file_data, node, data, LTO_section_function_body); } -- cgit v1.2.1