Commit 207c68cd by Richard Biener Committed by Richard Biener

lto-streamer.h (struct lto_input_block): Make it a class with a constructor.

2014-08-08  Richard Biener  <rguenther@suse.de>

	* lto-streamer.h (struct lto_input_block): Make it a class
	with a constructor.
	(LTO_INIT_INPUT_BLOCK, LTO_INIT_INPUT_BLOCK_PTR): Remove.
	(struct lto_function_header, struct lto_simple_header,
	struct lto_simple_header_with_strings,
	struct lto_decl_header, struct lto_function_header): Make
	a simple inheritance hieararchy.  Remove unused fields.
	(struct lto_asm_header): Remove.
	* lto-streamer-out.c (produce_asm): Adjust.
	(lto_output_toplevel_asms): Likewise.
	(produce_asm_for_decls): Likewise.
	* lto-section-out.c (lto_destroy_simple_output_block): Likewise.
	* data-streamer-in.c (string_for_index): Likewise.
	* ipa-inline-analysis.c (inline_read_section): Likewise.
	* ipa-prop.c (ipa_prop_read_section): Likewise.
	(read_replacements_section): Likewise.
	* lto-cgraph.c (input_cgraph_opt_section): Likewise.
	* lto-section-in.c (lto_create_simple_input_block): Likewise.
	(lto_destroy_simple_input_block): Likewise.
	* lto-streamer-in.c (lto_read_body_or_constructor): Likewise.
	(lto_input_toplevel_asms): Likewise.

	lto/
	* lto.c (lto_read_decls): Adjust for lto_input_block changes.

From-SVN: r213759
parent 07165dd7
2014-08-08 Richard Biener <rguenther@suse.de>
* lto-streamer.h (struct lto_input_block): Make it a class
with a constructor.
(LTO_INIT_INPUT_BLOCK, LTO_INIT_INPUT_BLOCK_PTR): Remove.
(struct lto_function_header, struct lto_simple_header,
struct lto_simple_header_with_strings,
struct lto_decl_header, struct lto_function_header): Make
a simple inheritance hieararchy. Remove unused fields.
(struct lto_asm_header): Remove.
* lto-streamer-out.c (produce_asm): Adjust.
(lto_output_toplevel_asms): Likewise.
(produce_asm_for_decls): Likewise.
* lto-section-out.c (lto_destroy_simple_output_block): Likewise.
* data-streamer-in.c (string_for_index): Likewise.
* ipa-inline-analysis.c (inline_read_section): Likewise.
* ipa-prop.c (ipa_prop_read_section): Likewise.
(read_replacements_section): Likewise.
* lto-cgraph.c (input_cgraph_opt_section): Likewise.
* lto-section-in.c (lto_create_simple_input_block): Likewise.
(lto_destroy_simple_input_block): Likewise.
* lto-streamer-in.c (lto_read_body_or_constructor): Likewise.
(lto_input_toplevel_asms): Likewise.
2014-08-08 Alexander Ivchenko <alexander.ivchenko@intel.com> 2014-08-08 Alexander Ivchenko <alexander.ivchenko@intel.com>
Maxim Kuznetsov <maxim.kuznetsov@intel.com> Maxim Kuznetsov <maxim.kuznetsov@intel.com>
Anna Tikhonova <anna.tikhonova@intel.com> Anna Tikhonova <anna.tikhonova@intel.com>
......
...@@ -39,7 +39,6 @@ along with GCC; see the file COPYING3. If not see ...@@ -39,7 +39,6 @@ along with GCC; see the file COPYING3. If not see
const char * const char *
string_for_index (struct data_in *data_in, unsigned int loc, unsigned int *rlen) string_for_index (struct data_in *data_in, unsigned int loc, unsigned int *rlen)
{ {
struct lto_input_block str_tab;
unsigned int len; unsigned int len;
const char *result; const char *result;
...@@ -50,8 +49,7 @@ string_for_index (struct data_in *data_in, unsigned int loc, unsigned int *rlen) ...@@ -50,8 +49,7 @@ string_for_index (struct data_in *data_in, unsigned int loc, unsigned int *rlen)
} }
/* Get the string stored at location LOC in DATA_IN->STRINGS. */ /* Get the string stored at location LOC in DATA_IN->STRINGS. */
LTO_INIT_INPUT_BLOCK (str_tab, data_in->strings, loc - 1, lto_input_block str_tab (data_in->strings, loc - 1, data_in->strings_len);
data_in->strings_len);
len = streamer_read_uhwi (&str_tab); len = streamer_read_uhwi (&str_tab);
*rlen = len; *rlen = len;
......
...@@ -4086,12 +4086,10 @@ inline_read_section (struct lto_file_decl_data *file_data, const char *data, ...@@ -4086,12 +4086,10 @@ inline_read_section (struct lto_file_decl_data *file_data, const char *data,
const int main_offset = cfg_offset + header->cfg_size; const int main_offset = cfg_offset + header->cfg_size;
const int string_offset = main_offset + header->main_size; const int string_offset = main_offset + header->main_size;
struct data_in *data_in; struct data_in *data_in;
struct lto_input_block ib;
unsigned int i, count2, j; unsigned int i, count2, j;
unsigned int f_count; unsigned int f_count;
LTO_INIT_INPUT_BLOCK (ib, (const char *) data + main_offset, 0, lto_input_block ib ((const char *) data + main_offset, header->main_size);
header->main_size);
data_in = data_in =
lto_data_in_create (file_data, (const char *) data + string_offset, lto_data_in_create (file_data, (const char *) data + string_offset,
......
...@@ -4930,12 +4930,11 @@ ipa_prop_read_section (struct lto_file_decl_data *file_data, const char *data, ...@@ -4930,12 +4930,11 @@ ipa_prop_read_section (struct lto_file_decl_data *file_data, const char *data,
const int main_offset = cfg_offset + header->cfg_size; const int main_offset = cfg_offset + header->cfg_size;
const int string_offset = main_offset + header->main_size; const int string_offset = main_offset + header->main_size;
struct data_in *data_in; struct data_in *data_in;
struct lto_input_block ib_main;
unsigned int i; unsigned int i;
unsigned int count; unsigned int count;
LTO_INIT_INPUT_BLOCK (ib_main, (const char *) data + main_offset, 0, lto_input_block ib_main ((const char *) data + main_offset,
header->main_size); header->main_size);
data_in = data_in =
lto_data_in_create (file_data, (const char *) data + string_offset, lto_data_in_create (file_data, (const char *) data + string_offset,
...@@ -5108,12 +5107,11 @@ read_replacements_section (struct lto_file_decl_data *file_data, ...@@ -5108,12 +5107,11 @@ read_replacements_section (struct lto_file_decl_data *file_data,
const int main_offset = cfg_offset + header->cfg_size; const int main_offset = cfg_offset + header->cfg_size;
const int string_offset = main_offset + header->main_size; const int string_offset = main_offset + header->main_size;
struct data_in *data_in; struct data_in *data_in;
struct lto_input_block ib_main;
unsigned int i; unsigned int i;
unsigned int count; unsigned int count;
LTO_INIT_INPUT_BLOCK (ib_main, (const char *) data + main_offset, 0, lto_input_block ib_main ((const char *) data + main_offset,
header->main_size); header->main_size);
data_in = lto_data_in_create (file_data, (const char *) data + string_offset, data_in = lto_data_in_create (file_data, (const char *) data + string_offset,
header->string_size, vNULL); header->string_size, vNULL);
......
...@@ -1896,12 +1896,11 @@ input_cgraph_opt_section (struct lto_file_decl_data *file_data, ...@@ -1896,12 +1896,11 @@ input_cgraph_opt_section (struct lto_file_decl_data *file_data,
const int main_offset = cfg_offset + header->cfg_size; const int main_offset = cfg_offset + header->cfg_size;
const int string_offset = main_offset + header->main_size; const int string_offset = main_offset + header->main_size;
struct data_in *data_in; struct data_in *data_in;
struct lto_input_block ib_main;
unsigned int i; unsigned int i;
unsigned int count; unsigned int count;
LTO_INIT_INPUT_BLOCK (ib_main, (const char *) data + main_offset, 0, lto_input_block ib_main ((const char *) data + main_offset,
header->main_size); header->main_size);
data_in = data_in =
lto_data_in_create (file_data, (const char *) data + string_offset, lto_data_in_create (file_data, (const char *) data + string_offset,
......
...@@ -227,19 +227,13 @@ lto_create_simple_input_block (struct lto_file_decl_data *file_data, ...@@ -227,19 +227,13 @@ lto_create_simple_input_block (struct lto_file_decl_data *file_data,
const struct lto_simple_header * header const struct lto_simple_header * header
= (const struct lto_simple_header *) data; = (const struct lto_simple_header *) data;
struct lto_input_block* ib_main;
int main_offset = sizeof (struct lto_simple_header); int main_offset = sizeof (struct lto_simple_header);
if (!data) if (!data)
return NULL; return NULL;
ib_main = XNEW (struct lto_input_block);
*datar = data; *datar = data;
LTO_INIT_INPUT_BLOCK_PTR (ib_main, data + main_offset, return new lto_input_block (data + main_offset, header->main_size);
0, header->main_size);
return ib_main;
} }
...@@ -255,7 +249,7 @@ lto_destroy_simple_input_block (struct lto_file_decl_data *file_data, ...@@ -255,7 +249,7 @@ lto_destroy_simple_input_block (struct lto_file_decl_data *file_data,
struct lto_input_block *ib, struct lto_input_block *ib,
const char *data, size_t len) const char *data, size_t len)
{ {
free (ib); delete ib;
lto_free_section_data (file_data, section_type, NULL, data, len); lto_free_section_data (file_data, section_type, NULL, data, len);
} }
......
...@@ -278,9 +278,8 @@ lto_destroy_simple_output_block (struct lto_simple_output_block *ob) ...@@ -278,9 +278,8 @@ lto_destroy_simple_output_block (struct lto_simple_output_block *ob)
/* Write the header which says how to decode the pieces of the /* Write the header which says how to decode the pieces of the
t. */ t. */
memset (&header, 0, sizeof (struct lto_simple_header)); memset (&header, 0, sizeof (struct lto_simple_header));
header.lto_header.major_version = LTO_major_version; header.major_version = LTO_major_version;
header.lto_header.minor_version = LTO_minor_version; header.minor_version = LTO_minor_version;
header.compressed_size = 0;
header.main_size = ob->main_stream->total_size; header.main_size = ob->main_stream->total_size;
lto_write_data (&header, sizeof header); lto_write_data (&header, sizeof header);
......
...@@ -1054,8 +1054,6 @@ lto_read_body_or_constructor (struct lto_file_decl_data *file_data, struct symta ...@@ -1054,8 +1054,6 @@ lto_read_body_or_constructor (struct lto_file_decl_data *file_data, struct symta
int cfg_offset; int cfg_offset;
int main_offset; int main_offset;
int string_offset; int string_offset;
struct lto_input_block ib_cfg;
struct lto_input_block ib_main;
tree fn_decl = node->decl; tree fn_decl = node->decl;
header = (const struct lto_function_header *) data; header = (const struct lto_function_header *) data;
...@@ -1064,26 +1062,11 @@ lto_read_body_or_constructor (struct lto_file_decl_data *file_data, struct symta ...@@ -1064,26 +1062,11 @@ lto_read_body_or_constructor (struct lto_file_decl_data *file_data, struct symta
cfg_offset = sizeof (struct lto_function_header); cfg_offset = sizeof (struct lto_function_header);
main_offset = cfg_offset + header->cfg_size; main_offset = cfg_offset + header->cfg_size;
string_offset = main_offset + header->main_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 else
{ {
main_offset = sizeof (struct lto_function_header); main_offset = sizeof (struct lto_function_header);
string_offset = main_offset + header->main_size; string_offset = main_offset + 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, data_in = lto_data_in_create (file_data, data + string_offset,
...@@ -1104,8 +1087,12 @@ lto_read_body_or_constructor (struct lto_file_decl_data *file_data, struct symta ...@@ -1104,8 +1087,12 @@ lto_read_body_or_constructor (struct lto_file_decl_data *file_data, struct symta
/* Set up the struct function. */ /* Set up the struct function. */
from = data_in->reader_cache->nodes.length (); from = data_in->reader_cache->nodes.length ();
lto_input_block ib_main (data + main_offset, header->main_size);
if (TREE_CODE (node->decl) == FUNCTION_DECL) if (TREE_CODE (node->decl) == FUNCTION_DECL)
input_function (fn_decl, data_in, &ib_main, &ib_cfg); {
lto_input_block ib_cfg (data + cfg_offset, header->cfg_size);
input_function (fn_decl, data_in, &ib_main, &ib_cfg);
}
else else
input_constructor (fn_decl, data_in, &ib_main); input_constructor (fn_decl, data_in, &ib_main);
/* And fixup types we streamed locally. */ /* And fixup types we streamed locally. */
...@@ -1357,10 +1344,10 @@ lto_input_toplevel_asms (struct lto_file_decl_data *file_data, int order_base) ...@@ -1357,10 +1344,10 @@ lto_input_toplevel_asms (struct lto_file_decl_data *file_data, int order_base)
size_t len; size_t len;
const char *data = lto_get_section_data (file_data, LTO_section_asm, const char *data = lto_get_section_data (file_data, LTO_section_asm,
NULL, &len); NULL, &len);
const struct lto_asm_header *header = (const struct lto_asm_header *) data; const struct lto_simple_header_with_strings *header
= (const struct lto_simple_header_with_strings *) data;
int string_offset; int string_offset;
struct data_in *data_in; struct data_in *data_in;
struct lto_input_block ib;
tree str; tree str;
if (! data) if (! data)
...@@ -1368,10 +1355,7 @@ lto_input_toplevel_asms (struct lto_file_decl_data *file_data, int order_base) ...@@ -1368,10 +1355,7 @@ lto_input_toplevel_asms (struct lto_file_decl_data *file_data, int order_base)
string_offset = sizeof (*header) + header->main_size; string_offset = sizeof (*header) + header->main_size;
LTO_INIT_INPUT_BLOCK (ib, lto_input_block ib (data + sizeof (*header), header->main_size);
data + sizeof (*header),
0,
header->main_size);
data_in = lto_data_in_create (file_data, data + string_offset, data_in = lto_data_in_create (file_data, data + string_offset,
header->string_size, vNULL); header->string_size, vNULL);
......
...@@ -1886,10 +1886,8 @@ produce_asm (struct output_block *ob, tree fn) ...@@ -1886,10 +1886,8 @@ produce_asm (struct output_block *ob, tree fn)
memset (&header, 0, sizeof (struct lto_function_header)); memset (&header, 0, sizeof (struct lto_function_header));
/* Write the header. */ /* Write the header. */
header.lto_header.major_version = LTO_major_version; header.major_version = LTO_major_version;
header.lto_header.minor_version = LTO_minor_version; header.minor_version = LTO_minor_version;
header.compressed_size = 0;
if (section_type == LTO_section_function_body) if (section_type == LTO_section_function_body)
header.cfg_size = ob->cfg_stream->total_size; header.cfg_size = ob->cfg_stream->total_size;
...@@ -2097,7 +2095,7 @@ lto_output_toplevel_asms (void) ...@@ -2097,7 +2095,7 @@ lto_output_toplevel_asms (void)
struct output_block *ob; struct output_block *ob;
struct asm_node *can; struct asm_node *can;
char *section_name; char *section_name;
struct lto_asm_header header; struct lto_simple_header_with_strings header;
if (! asm_nodes) if (! asm_nodes)
return; return;
...@@ -2123,8 +2121,8 @@ lto_output_toplevel_asms (void) ...@@ -2123,8 +2121,8 @@ lto_output_toplevel_asms (void)
memset (&header, 0, sizeof (header)); memset (&header, 0, sizeof (header));
/* Write the header. */ /* Write the header. */
header.lto_header.major_version = LTO_major_version; header.major_version = LTO_major_version;
header.lto_header.minor_version = LTO_minor_version; header.minor_version = LTO_minor_version;
header.main_size = ob->main_stream->total_size; header.main_size = ob->main_stream->total_size;
header.string_size = ob->string_stream->total_size; header.string_size = ob->string_stream->total_size;
...@@ -2657,8 +2655,8 @@ produce_asm_for_decls (void) ...@@ -2657,8 +2655,8 @@ produce_asm_for_decls (void)
lto_output_decl_state_streams (ob, fn_out_state); lto_output_decl_state_streams (ob, fn_out_state);
} }
header.lto_header.major_version = LTO_major_version; header.major_version = LTO_major_version;
header.lto_header.minor_version = LTO_minor_version; header.minor_version = LTO_minor_version;
/* Currently not used. This field would allow us to preallocate /* Currently not used. This field would allow us to preallocate
the globals vector, so that it need not be resized as it is extended. */ the globals vector, so that it need not be resized as it is extended. */
......
...@@ -307,27 +307,21 @@ typedef void (lto_free_section_data_f) (struct lto_file_decl_data *, ...@@ -307,27 +307,21 @@ typedef void (lto_free_section_data_f) (struct lto_file_decl_data *,
size_t); size_t);
/* Structure used as buffer for reading an LTO file. */ /* Structure used as buffer for reading an LTO file. */
struct lto_input_block class lto_input_block
{ {
public:
/* Special constructor for the string table, it abuses this to
do random access but use the uhwi decoder. */
lto_input_block (const char *data_, unsigned int p_, unsigned int len_)
: data (data_), p (p_), len (len_) {}
lto_input_block (const char *data_, unsigned int len_)
: data (data_), p (0), len (len_) {}
const char *data; const char *data;
unsigned int p; unsigned int p;
unsigned int len; unsigned int len;
}; };
#define LTO_INIT_INPUT_BLOCK(BASE,D,P,L) \
do { \
BASE.data = D; \
BASE.p = P; \
BASE.len = L; \
} while (0)
#define LTO_INIT_INPUT_BLOCK_PTR(BASE,D,P,L) \
do { \
BASE->data = D; \
BASE->p = P; \
BASE->len = L; \
} while (0)
/* The is the first part of the record for a function or constructor /* The is the first part of the record for a function or constructor
in the .o file. */ in the .o file. */
...@@ -337,27 +331,16 @@ struct lto_header ...@@ -337,27 +331,16 @@ struct lto_header
int16_t minor_version; int16_t minor_version;
}; };
/* The header for a function body. */ /* The is the first part of the record in an LTO file for many of the
struct lto_function_header IPA passes. */
struct lto_simple_header : lto_header
{ {
/* The header for all types of sections. */ /* Size of main gimple body of function. */
struct lto_header lto_header; int32_t main_size;
};
/* Number of labels with names. */
int32_t num_named_labels;
/* Number of labels without names. */
int32_t num_unnamed_labels;
/* Size compressed or 0 if not compressed. */
int32_t compressed_size;
/* Size of names for named labels. */
int32_t named_label_size;
/* Size of the cfg. */
int32_t cfg_size;
struct lto_simple_header_with_strings : lto_simple_header
{
/* Size of main gimple body of function. */ /* Size of main gimple body of function. */
int32_t main_size; int32_t main_size;
...@@ -365,41 +348,22 @@ struct lto_function_header ...@@ -365,41 +348,22 @@ struct lto_function_header
int32_t string_size; int32_t string_size;
}; };
/* The header for a function body. */
struct lto_function_header : lto_simple_header_with_strings
{
/* Size of the cfg. */
int32_t cfg_size;
};
/* Structure describing a symbol section. */ /* Structure describing a symbol section. */
struct lto_decl_header struct lto_decl_header : lto_simple_header_with_strings
{ {
/* The header for all types of sections. */
struct lto_header lto_header;
/* Size of region for decl state. */ /* Size of region for decl state. */
int32_t decl_state_size; int32_t decl_state_size;
/* Number of nodes in globals stream. */ /* Number of nodes in globals stream. */
int32_t num_nodes; int32_t num_nodes;
/* Size of region for expressions, decls, types, etc. */
int32_t main_size;
/* Size of the string table. */
int32_t string_size;
};
/* Structure describing top level asm()s. */
struct lto_asm_header
{
/* The header for all types of sections. */
struct lto_header lto_header;
/* Size compressed or 0 if not compressed. */
int32_t compressed_size;
/* Size of region for expressions, decls, types, etc. */
int32_t main_size;
/* Size of the string table. */
int32_t string_size;
}; };
...@@ -595,20 +559,6 @@ struct lto_output_stream ...@@ -595,20 +559,6 @@ struct lto_output_stream
unsigned int total_size; unsigned int total_size;
}; };
/* The is the first part of the record in an LTO file for many of the
IPA passes. */
struct lto_simple_header
{
/* The header for all types of sections. */
struct lto_header lto_header;
/* Size of main gimple body of function. */
int32_t main_size;
/* Size of main stream when compressed. */
int32_t compressed_size;
};
/* A simple output block. This can be used for simple IPA passes that /* A simple output block. This can be used for simple IPA passes that
do not need more than one stream. */ do not need more than one stream. */
struct lto_simple_output_block struct lto_simple_output_block
......
2014-08-08 Richard Biener <rguenther@suse.de>
* lto.c (lto_read_decls): Adjust for lto_input_block changes.
2014-08-08 Bin Cheng <bin.cheng@arm.com> 2014-08-08 Bin Cheng <bin.cheng@arm.com>
PR lto/62032 PR lto/62032
......
...@@ -1844,14 +1844,13 @@ lto_read_decls (struct lto_file_decl_data *decl_data, const void *data, ...@@ -1844,14 +1844,13 @@ lto_read_decls (struct lto_file_decl_data *decl_data, const void *data,
const int decl_offset = sizeof (struct lto_decl_header); const int decl_offset = sizeof (struct lto_decl_header);
const int main_offset = decl_offset + header->decl_state_size; const int main_offset = decl_offset + header->decl_state_size;
const int string_offset = main_offset + header->main_size; const int string_offset = main_offset + header->main_size;
struct lto_input_block ib_main;
struct data_in *data_in; struct data_in *data_in;
unsigned int i; unsigned int i;
const uint32_t *data_ptr, *data_end; const uint32_t *data_ptr, *data_end;
uint32_t num_decl_states; uint32_t num_decl_states;
LTO_INIT_INPUT_BLOCK (ib_main, (const char *) data + main_offset, 0, lto_input_block ib_main ((const char *) data + main_offset,
header->main_size); header->main_size);
data_in = lto_data_in_create (decl_data, (const char *) data + string_offset, data_in = lto_data_in_create (decl_data, (const char *) data + string_offset,
header->string_size, resolutions); header->string_size, resolutions);
......
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