Commit ca834876 by Jan Hubicka Committed by Jan Hubicka

cgraph.c (cgraph_node::get_untransformed_body): Pass compressed flag to lto_get_section_data.


	* cgraph.c (cgraph_node::get_untransformed_body): Pass compressed
	flag to lto_get_section_data.
	* varpool.c (varpool_node::get_constructor): Likewise.
	* lto-section-in.c (lto_get_section_data): Add new flag decompress.
	(lto_free_section_data): Likewise.
	(lto_get_raw_section_data): New function.
	(lto_free_raw_section_data): New function.
	(copy_function_or_variable): Copy sections w/o decompressing.
	(lto_output_decl_state_refs): Picke compressed bit.
	* lto-streamer.h (lto_in_decl_state): New flag compressed.
	(lto_out_decl_state): Likewise.
	(lto_get_section_data, lto_free_section_data): Update prototypes
	(lto_get_raw_section_data, lto_free_raw_section_data): Declare.
	(lto_write_raw_data): Declare.
	(lto_begin_section): Remove FIXME.
	(lto_write_raw_data): New function.
	(lto_write_stream): Remove FIXME.
	(lto_new_out_decl_state): Set compressed flag.

	* lto.c (lto_read_in_decl_state): Unpickle compressed bit.

From-SVN: r231593
parent b44c0c0c
2015-12-10 Jan Hubicka <hubicka@ucw.cz> 2015-12-10 Jan Hubicka <hubicka@ucw.cz>
* cgraph.c (cgraph_node::get_untransformed_body): Pass compressed
flag to lto_get_section_data.
* varpool.c (varpool_node::get_constructor): Likewise.
* lto-section-in.c (lto_get_section_data): Add new flag decompress.
(lto_free_section_data): Likewise.
(lto_get_raw_section_data): New function.
(lto_free_raw_section_data): New function.
(copy_function_or_variable): Copy sections w/o decompressing.
(lto_output_decl_state_refs): Picke compressed bit.
* lto-streamer.h (lto_in_decl_state): New flag compressed.
(lto_out_decl_state): Likewise.
(lto_get_section_data, lto_free_section_data): Update prototypes
(lto_get_raw_section_data, lto_free_raw_section_data): Declare.
(lto_write_raw_data): Declare.
(lto_begin_section): Remove FIXME.
(lto_write_raw_data): New function.
(lto_write_stream): Remove FIXME.
(lto_new_out_decl_state): Set compressed flag.
2015-12-10 Jan Hubicka <hubicka@ucw.cz>
* tree.c (free_lang_data_in_type, find_decls_types_r): Also free * tree.c (free_lang_data_in_type, find_decls_types_r): Also free
unnecesary type decls. unnecesary type decls.
* tree.h (is_redundant_typedef): Declare. * tree.h (is_redundant_typedef): Declare.
...@@ -3251,9 +3251,11 @@ cgraph_node::get_untransformed_body (void) ...@@ -3251,9 +3251,11 @@ cgraph_node::get_untransformed_body (void)
/* We may have renamed the declaration, e.g., a static function. */ /* We may have renamed the declaration, e.g., a static function. */
name = lto_get_decl_name_mapping (file_data, name); name = lto_get_decl_name_mapping (file_data, name);
struct lto_in_decl_state *decl_state
= lto_get_function_in_decl_state (file_data, decl);
data = lto_get_section_data (file_data, LTO_section_function_body, data = lto_get_section_data (file_data, LTO_section_function_body,
name, &len); name, &len, decl_state->compressed);
if (!data) if (!data)
fatal_error (input_location, "%s: section %s is missing", fatal_error (input_location, "%s: section %s is missing",
file_data->file_name, file_data->file_name,
...@@ -3264,7 +3266,7 @@ cgraph_node::get_untransformed_body (void) ...@@ -3264,7 +3266,7 @@ cgraph_node::get_untransformed_body (void)
lto_input_function_body (file_data, this, data); lto_input_function_body (file_data, this, data);
lto_stats.num_function_bodies++; lto_stats.num_function_bodies++;
lto_free_section_data (file_data, LTO_section_function_body, name, lto_free_section_data (file_data, LTO_section_function_body, name,
data, len); data, len, decl_state->compressed);
lto_free_function_in_decl_state_for_node (this); lto_free_function_in_decl_state_for_node (this);
/* Keep lto file data so ipa-inline-analysis knows about cross module /* Keep lto file data so ipa-inline-analysis knows about cross module
inlining. */ inlining. */
......
...@@ -130,7 +130,7 @@ const char * ...@@ -130,7 +130,7 @@ const char *
lto_get_section_data (struct lto_file_decl_data *file_data, lto_get_section_data (struct lto_file_decl_data *file_data,
enum lto_section_type section_type, enum lto_section_type section_type,
const char *name, const char *name,
size_t *len) size_t *len, bool decompress)
{ {
const char *data = (get_section_f) (file_data, section_type, name, len); const char *data = (get_section_f) (file_data, section_type, name, len);
const size_t header_length = sizeof (struct lto_data_header); const size_t header_length = sizeof (struct lto_data_header);
...@@ -142,9 +142,10 @@ lto_get_section_data (struct lto_file_decl_data *file_data, ...@@ -142,9 +142,10 @@ lto_get_section_data (struct lto_file_decl_data *file_data,
if (data == NULL) if (data == NULL)
return NULL; return NULL;
/* FIXME lto: WPA mode does not write compressed sections, so for now /* WPA->ltrans streams are not compressed with exception of function bodies
suppress uncompression if flag_ltrans. */ and variable initializers that has been verbatim copied from earlier
if (!flag_ltrans) compilations. */
if (!flag_ltrans || decompress)
{ {
/* Create a mapping header containing the underlying data and length, /* Create a mapping header containing the underlying data and length,
and prepend this to the uncompression buffer. The uncompressed data and prepend this to the uncompression buffer. The uncompressed data
...@@ -170,6 +171,16 @@ lto_get_section_data (struct lto_file_decl_data *file_data, ...@@ -170,6 +171,16 @@ lto_get_section_data (struct lto_file_decl_data *file_data,
return data; return data;
} }
/* Get the section data without any header parsing or uncompression. */
const char *
lto_get_raw_section_data (struct lto_file_decl_data *file_data,
enum lto_section_type section_type,
const char *name,
size_t *len)
{
return (get_section_f) (file_data, section_type, name, len);
}
/* Free the data found from the above call. The first three /* Free the data found from the above call. The first three
parameters are the same as above. DATA is the data to be freed and parameters are the same as above. DATA is the data to be freed and
...@@ -180,7 +191,7 @@ lto_free_section_data (struct lto_file_decl_data *file_data, ...@@ -180,7 +191,7 @@ lto_free_section_data (struct lto_file_decl_data *file_data,
enum lto_section_type section_type, enum lto_section_type section_type,
const char *name, const char *name,
const char *data, const char *data,
size_t len) size_t len, bool decompress)
{ {
const size_t header_length = sizeof (struct lto_data_header); const size_t header_length = sizeof (struct lto_data_header);
const char *real_data = data - header_length; const char *real_data = data - header_length;
...@@ -189,9 +200,7 @@ lto_free_section_data (struct lto_file_decl_data *file_data, ...@@ -189,9 +200,7 @@ lto_free_section_data (struct lto_file_decl_data *file_data,
gcc_assert (free_section_f); gcc_assert (free_section_f);
/* FIXME lto: WPA mode does not write compressed sections, so for now if (flag_ltrans && !decompress)
suppress uncompression mapping if flag_ltrans. */
if (flag_ltrans)
{ {
(free_section_f) (file_data, section_type, name, data, len); (free_section_f) (file_data, section_type, name, data, len);
return; return;
...@@ -203,6 +212,17 @@ lto_free_section_data (struct lto_file_decl_data *file_data, ...@@ -203,6 +212,17 @@ lto_free_section_data (struct lto_file_decl_data *file_data,
free (CONST_CAST (char *, real_data)); free (CONST_CAST (char *, real_data));
} }
/* Free data allocated by lto_get_raw_section_data. */
void
lto_free_raw_section_data (struct lto_file_decl_data *file_data,
enum lto_section_type section_type,
const char *name,
const char *data,
size_t len)
{
(free_section_f) (file_data, section_type, name, data, len);
}
/* Load a section of type SECTION_TYPE from FILE_DATA, parse the /* Load a section of type SECTION_TYPE from FILE_DATA, parse the
header and then return an input block pointing to the section. The header and then return an input block pointing to the section. The
......
...@@ -501,6 +501,9 @@ struct GTY((for_user)) lto_in_decl_state ...@@ -501,6 +501,9 @@ struct GTY((for_user)) lto_in_decl_state
/* If this in-decl state is associated with a function. FN_DECL /* If this in-decl state is associated with a function. FN_DECL
point to the FUNCTION_DECL. */ point to the FUNCTION_DECL. */
tree fn_decl; tree fn_decl;
/* True if decl state is compressed. */
bool compressed;
}; };
typedef struct lto_in_decl_state *lto_in_decl_state_ptr; typedef struct lto_in_decl_state *lto_in_decl_state_ptr;
...@@ -534,6 +537,9 @@ struct lto_out_decl_state ...@@ -534,6 +537,9 @@ struct lto_out_decl_state
/* If this out-decl state belongs to a function, fn_decl points to that /* If this out-decl state belongs to a function, fn_decl points to that
function. Otherwise, it is NULL. */ function. Otherwise, it is NULL. */
tree fn_decl; tree fn_decl;
/* True if decl state is compressed. */
bool compressed;
}; };
typedef struct lto_out_decl_state *lto_out_decl_state_ptr; typedef struct lto_out_decl_state *lto_out_decl_state_ptr;
...@@ -758,9 +764,17 @@ extern void lto_set_in_hooks (struct lto_file_decl_data **, ...@@ -758,9 +764,17 @@ extern void lto_set_in_hooks (struct lto_file_decl_data **,
extern struct lto_file_decl_data **lto_get_file_decl_data (void); extern struct lto_file_decl_data **lto_get_file_decl_data (void);
extern const char *lto_get_section_data (struct lto_file_decl_data *, extern const char *lto_get_section_data (struct lto_file_decl_data *,
enum lto_section_type, enum lto_section_type,
const char *, size_t *,
bool decompress = false);
extern const char *lto_get_raw_section_data (struct lto_file_decl_data *,
enum lto_section_type,
const char *, size_t *); const char *, size_t *);
extern void lto_free_section_data (struct lto_file_decl_data *, extern void lto_free_section_data (struct lto_file_decl_data *,
enum lto_section_type, enum lto_section_type,
const char *, const char *, size_t,
bool decompress = false);
extern void lto_free_raw_section_data (struct lto_file_decl_data *,
enum lto_section_type,
const char *, const char *, size_t); const char *, const char *, size_t);
extern htab_t lto_create_renaming_table (void); extern htab_t lto_create_renaming_table (void);
extern void lto_record_renamed_decl (struct lto_file_decl_data *, extern void lto_record_renamed_decl (struct lto_file_decl_data *,
...@@ -782,6 +796,7 @@ extern void lto_value_range_error (const char *, ...@@ -782,6 +796,7 @@ extern void lto_value_range_error (const char *,
extern void lto_begin_section (const char *, bool); extern void lto_begin_section (const char *, bool);
extern void lto_end_section (void); extern void lto_end_section (void);
extern void lto_write_data (const void *, unsigned int); extern void lto_write_data (const void *, unsigned int);
extern void lto_write_raw_data (const void *, unsigned int);
extern void lto_write_stream (struct lto_output_stream *); extern void lto_write_stream (struct lto_output_stream *);
extern bool lto_output_decl_index (struct lto_output_stream *, extern bool lto_output_decl_index (struct lto_output_stream *,
struct lto_tree_ref_encoder *, struct lto_tree_ref_encoder *,
......
2015-12-10 Jan Hubicka <hubicka@ucw.cz>
* lto.c (lto_read_in_decl_state): Unpickle compressed bit.
2015-12-11 Jan Hubicka <hubicka@ucw.cz> 2015-12-11 Jan Hubicka <hubicka@ucw.cz>
PR ipa/61886 PR ipa/61886
......
...@@ -234,6 +234,8 @@ lto_read_in_decl_state (struct data_in *data_in, const uint32_t *data, ...@@ -234,6 +234,8 @@ lto_read_in_decl_state (struct data_in *data_in, const uint32_t *data,
uint32_t i, j; uint32_t i, j;
ix = *data++; ix = *data++;
state->compressed = ix & 1;
ix /= 2;
decl = streamer_tree_cache_get_tree (data_in->reader_cache, ix); decl = streamer_tree_cache_get_tree (data_in->reader_cache, ix);
if (!VAR_OR_FUNCTION_DECL_P (decl)) if (!VAR_OR_FUNCTION_DECL_P (decl))
{ {
......
...@@ -296,9 +296,11 @@ varpool_node::get_constructor (void) ...@@ -296,9 +296,11 @@ varpool_node::get_constructor (void)
/* We may have renamed the declaration, e.g., a static function. */ /* We may have renamed the declaration, e.g., a static function. */
name = lto_get_decl_name_mapping (file_data, name); name = lto_get_decl_name_mapping (file_data, name);
struct lto_in_decl_state *decl_state
= lto_get_function_in_decl_state (file_data, decl);
data = lto_get_section_data (file_data, LTO_section_function_body, data = lto_get_section_data (file_data, LTO_section_function_body,
name, &len); name, &len, decl_state->compressed);
if (!data) if (!data)
fatal_error (input_location, "%s: section %s is missing", fatal_error (input_location, "%s: section %s is missing",
file_data->file_name, file_data->file_name,
...@@ -308,7 +310,7 @@ varpool_node::get_constructor (void) ...@@ -308,7 +310,7 @@ varpool_node::get_constructor (void)
gcc_assert (DECL_INITIAL (decl) != error_mark_node); gcc_assert (DECL_INITIAL (decl) != error_mark_node);
lto_stats.num_function_bodies++; lto_stats.num_function_bodies++;
lto_free_section_data (file_data, LTO_section_function_body, name, lto_free_section_data (file_data, LTO_section_function_body, name,
data, len); data, len, decl_state->compressed);
lto_free_function_in_decl_state_for_node (this); lto_free_function_in_decl_state_for_node (this);
timevar_pop (TV_IPA_LTO_CTORS_IN); timevar_pop (TV_IPA_LTO_CTORS_IN);
return DECL_INITIAL (decl); return DECL_INITIAL (decl);
......
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