+2019-10-30 Martin Liska <mliska@suse.cz>
+
+ PR lto/91393
+ PR lto/88220
+ * cgraph.c (cgraph_node::get_create): Overwrite node->order
+ from a first_clone in order to get proper LTO section
+ in LTO stream.
+ (cgraph_node::get_untransformed_body):
+ Use lto_get_section_data where symtab_node::order
+ must be provided.
+ * cgraphclones.c (cgraph_node::find_replacement):
+ Update also symbol order.
+ * ipa-fnsummary.c (ipa_fn_summary_read):
+ Use new function lto_get_summary_section_data.
+ * ipa-hsa.c (ipa_hsa_read_summary): Likewise.
+ * ipa-icf.c (sem_item_optimizer::read_summary):
+ Likewise.
+ * ipa-prop.c (ipa_prop_read_jump_functions):
+ Likewise.
+ (ipcp_read_transformation_summaries): Likewise.
+ * ipa-sra.c (ipa_sra_read_summary): Likewise.
+ * lto-cgraph.c (input_node): Add also order_base.
+ (input_varpool_node): Likewise.
+ (input_cgraph_1): Assign the order_base.
+ (input_cgraph_opt_summary): Use new lto_get_summary_section_data.
+ * lto-opts.c (lto_write_options): Pass new argument.
+ * lto-section-in.c (lto_get_section_data): Add new argumente order.
+ (lto_get_summary_section_data): New.
+ (lto_get_raw_section_data): Add order argument.
+ (lto_create_simple_input_block): Likewise.
+ * lto-section-out.c (lto_destroy_simple_output_block):
+ Likewise.
+ * lto-streamer-in.c (lto_input_toplevel_asms):
+ Use lto_get_summary_section_data.
+ (lto_input_mode_table): Likewise.
+ * lto-streamer-out.c (produce_asm): Pass symtab_node::order.
+ (lto_output_toplevel_asms): Pass new argument.
+ (copy_function_or_variable): Likewise.
+ (produce_lto_section):Likewise.
+ (produce_symtab): Likewise.
+ (lto_write_mode_table): Likewise.
+ (produce_asm_for_decls): Likewise.
+ * lto-streamer.c (lto_get_section_name): Concat symbol name
+ and symbol order.
+ * lto-streamer.h (lto_get_section_data): Add order argument.
+ (lto_get_summary_section_data): New.
+ (lto_get_raw_section_data): Add order argument.
+ (lto_get_section_name): Likewise.
+ * varpool.c (varpool_node::get_constructor): Pass order argument.
+
2019-10-30 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/92262
{
first_clone->clone_of = node;
node->clones = first_clone;
+ node->order = first_clone->order;
symtab->symtab_prevail_in_asm_name_hash (node);
node->decl->decl_with_vis.symtab_node = node;
if (dump_file)
struct lto_in_decl_state *decl_state
= lto_get_function_in_decl_state (file_data, decl);
+ cgraph_node *origin = this;
+ while (origin->clone_of)
+ origin = origin->clone_of;
+
+ int stream_order = origin->order - file_data->order_base;
data = lto_get_section_data (file_data, LTO_section_function_body,
- name, &len, decl_state->compressed);
+ name, stream_order, &len,
+ decl_state->compressed);
if (!data)
- fatal_error (input_location, "%s: section %s is missing",
- file_data->file_name,
- name);
+ fatal_error (input_location, "%s: section %s.%d is missing",
+ file_data->file_name, name, stream_order);
gcc_assert (DECL_STRUCT_FUNCTION (decl) == NULL);
n->clone_of = next_inline_clone;
n = n->next_sibling_clone;
}
+
+ /* Update order in order to be able to find a LTO section
+ with function body. */
+ replacement->order = order;
+
return replacement;
}
else
while ((file_data = file_data_vec[j++]))
{
size_t len;
- const char *data = lto_get_section_data (file_data,
- LTO_section_ipa_fn_summary,
- NULL, &len);
+ const char *data
+ = lto_get_summary_section_data (file_data, LTO_section_ipa_fn_summary,
+ &len);
if (data)
inline_read_section (file_data, data, len);
else
while ((file_data = file_data_vec[j++]))
{
size_t len;
- const char *data = lto_get_section_data (file_data, LTO_section_ipa_hsa,
- NULL, &len);
-
+ const char *data
+ = lto_get_summary_section_data (file_data, LTO_section_ipa_hsa, &len);
if (data)
ipa_hsa_read_section (file_data, data, len);
}
while ((file_data = file_data_vec[j++]))
{
size_t len;
- const char *data = lto_get_section_data (file_data,
- LTO_section_ipa_icf, NULL, &len);
-
+ const char *data
+ = lto_get_summary_section_data (file_data, LTO_section_ipa_icf, &len);
if (data)
read_section (file_data, data, len);
}
while ((file_data = file_data_vec[j++]))
{
size_t len;
- const char *data = lto_get_section_data (file_data, LTO_section_jump_functions, NULL, &len);
-
+ const char *data
+ = lto_get_summary_section_data (file_data, LTO_section_jump_functions,
+ &len);
if (data)
ipa_prop_read_section (file_data, data, len);
}
while ((file_data = file_data_vec[j++]))
{
size_t len;
- const char *data = lto_get_section_data (file_data,
- LTO_section_ipcp_transform,
- NULL, &len);
+ const char *data
+ = lto_get_summary_section_data (file_data, LTO_section_ipcp_transform,
+ &len);
if (data)
read_replacements_section (file_data, data, len);
}
while ((file_data = file_data_vec[j++]))
{
size_t len;
- const char *data = lto_get_section_data (file_data, LTO_section_ipa_sra,
- NULL, &len);
+ const char *data
+ = lto_get_summary_section_data (file_data, LTO_section_ipa_sra, &len);
if (data)
isra_read_summary_section (file_data, data, len);
}
/* Number of LDPR values known to GCC. */
#define LDPR_NUM_KNOWN (LDPR_PREVAILING_DEF_IRONLY_EXP + 1)
-/* All node orders are ofsetted by ORDER_BASE. */
-static int order_base;
-
/* Cgraph streaming is organized as set of record whose type
is indicated by a tag. */
enum LTO_symtab_tags
int i, count;
tree group;
const char *section;
- order = streamer_read_hwi (ib) + order_base;
+ order = streamer_read_hwi (ib) + file_data->order_base;
clone_ref = streamer_read_hwi (ib);
decl_index = streamer_read_uhwi (ib);
tree group;
const char *section;
- order = streamer_read_hwi (ib) + order_base;
+ order = streamer_read_hwi (ib) + file_data->order_base;
decl_index = streamer_read_uhwi (ib);
var_decl = lto_file_decl_data_get_var_decl (file_data, decl_index);
unsigned i;
tag = streamer_read_enum (ib, LTO_symtab_tags, LTO_symtab_last_tag);
- order_base = symtab->order;
+ file_data->order_base = symtab->order;
while (tag)
{
if (tag == LTO_symtab_edge)
tag = streamer_read_enum (ib, LTO_symtab_tags, LTO_symtab_last_tag);
}
- lto_input_toplevel_asms (file_data, order_base);
+ lto_input_toplevel_asms (file_data, file_data->order_base);
/* AUX pointers should be all non-zero for function nodes read from the stream. */
if (flag_checking)
while ((file_data = file_data_vec[j++]))
{
size_t len;
- const char *data =
- lto_get_section_data (file_data, LTO_section_cgraph_opt_sum, NULL,
- &len);
-
+ const char *data
+ = lto_get_summary_section_data (file_data, LTO_section_cgraph_opt_sum,
+ &len);
if (data)
input_cgraph_opt_section (file_data, data, len, nodes);
}
char *args;
bool first_p = true;
- section_name = lto_get_section_name (LTO_section_opts, NULL, NULL);
+ section_name = lto_get_section_name (LTO_section_opts, NULL, 0, NULL);
lto_begin_section (section_name, false);
obstack_init (&temporary_obstack);
const char *
lto_get_section_data (struct lto_file_decl_data *file_data,
enum lto_section_type section_type,
- const char *name,
+ const char *name, int order,
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, order,
+ len);
const size_t header_length = sizeof (struct lto_data_header);
struct lto_data_header *header;
struct lto_buffer buffer;
return data;
}
+/* Return a char pointer to the start of a data stream for an LTO pass.
+ FILE_DATA indicates where to obtain the data.
+ SECTION_TYPE is the type of information to be obtained.
+ LEN is the size of the data returned. */
+
+const char *
+lto_get_summary_section_data (struct lto_file_decl_data *file_data,
+ enum lto_section_type section_type, size_t *len)
+{
+ return lto_get_section_data (file_data, section_type, NULL, 0, len);
+}
+
/* 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,
+ const char *name, int order,
size_t *len)
{
- return (get_section_f) (file_data, section_type, name, len);
+ return (get_section_f) (file_data, section_type, name, order, len);
}
/* Free the data found from the above call. The first three
enum lto_section_type section_type,
const char **datar, size_t *len)
{
- const char *data = lto_get_section_data (file_data, section_type, NULL, len);
+ const char *data = lto_get_section_data (file_data, section_type, NULL, 0,
+ len);
const struct lto_simple_header * header
= (const struct lto_simple_header *) data;
char *section_name;
struct lto_simple_header header;
- section_name = lto_get_section_name (ob->section_type, NULL, NULL);
+ section_name = lto_get_section_name (ob->section_type, NULL, 0, NULL);
lto_begin_section (section_name, !flag_wpa);
free (section_name);
lto_input_toplevel_asms (struct lto_file_decl_data *file_data, int order_base)
{
size_t len;
- const char *data = lto_get_section_data (file_data, LTO_section_asm,
- NULL, &len);
+ const char *data
+ = lto_get_summary_section_data (file_data, LTO_section_asm, &len);
const struct lto_simple_header_with_strings *header
= (const struct lto_simple_header_with_strings *) data;
int string_offset;
lto_input_mode_table (struct lto_file_decl_data *file_data)
{
size_t len;
- const char *data = lto_get_section_data (file_data, LTO_section_mode_table,
- NULL, &len);
+ const char *data
+ = lto_get_summary_section_data (file_data, LTO_section_mode_table, &len);
if (! data)
{
internal_error ("cannot read LTO mode table from %s",
if (section_type == LTO_section_function_body)
{
const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fn));
- section_name = lto_get_section_name (section_type, name, NULL);
+ section_name = lto_get_section_name (section_type, name,
+ symtab_node::get (fn)->order,
+ NULL);
}
else
- section_name = lto_get_section_name (section_type, NULL, NULL);
+ section_name = lto_get_section_name (section_type, NULL, 0, NULL);
lto_begin_section (section_name, !flag_wpa);
free (section_name);
streamer_write_string_cst (ob, ob->main_stream, NULL_TREE);
- section_name = lto_get_section_name (LTO_section_asm, NULL, NULL);
+ section_name = lto_get_section_name (LTO_section_asm, NULL, 0, NULL);
lto_begin_section (section_name, !flag_wpa);
free (section_name);
size_t len;
const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (function));
char *section_name =
- lto_get_section_name (LTO_section_function_body, name, NULL);
+ lto_get_section_name (LTO_section_function_body, name, node->order, NULL);
size_t i, j;
struct lto_in_decl_state *in_state;
struct lto_out_decl_state *out_state = lto_get_out_decl_state ();
name = lto_get_decl_name_mapping (file_data, name);
data = lto_get_raw_section_data (file_data, LTO_section_function_body,
- name, &len);
+ name, node->order - file_data->order_base,
+ &len);
gcc_assert (data);
/* Do a bit copy of the function body. */
/* Stream LTO meta section. */
output_block *ob = create_output_block (LTO_section_lto);
- char * section_name = lto_get_section_name (LTO_section_lto, NULL, NULL);
+ char * section_name = lto_get_section_name (LTO_section_lto, NULL, 0, NULL);
lto_begin_section (section_name, false);
free (section_name);
produce_symtab (struct output_block *ob)
{
struct streamer_tree_cache_d *cache = ob->writer_cache;
- char *section_name = lto_get_section_name (LTO_section_symtab, NULL, NULL);
+ char *section_name = lto_get_section_name (LTO_section_symtab, NULL, 0, NULL);
lto_symtab_encoder_t encoder = ob->decl_state->symtab_node_encoder;
lto_symtab_encoder_iterator lsei;
streamer_write_bitpack (&bp);
char *section_name
- = lto_get_section_name (LTO_section_mode_table, NULL, NULL);
+ = lto_get_section_name (LTO_section_mode_table, NULL, 0, NULL);
lto_begin_section (section_name, !flag_wpa);
free (section_name);
memset (&header, 0, sizeof (struct lto_decl_header));
- section_name = lto_get_section_name (LTO_section_decls, NULL, NULL);
+ section_name = lto_get_section_name (LTO_section_decls, NULL, 0, NULL);
lto_begin_section (section_name, !flag_wpa);
free (section_name);
to free the returned name. */
char *
-lto_get_section_name (int section_type, const char *name, struct lto_file_decl_data *f)
+lto_get_section_name (int section_type, const char *name,
+ int node_order, struct lto_file_decl_data *f)
{
const char *add;
char post[32];
gcc_assert (name != NULL);
if (name[0] == '*')
name++;
- add = name;
+
+ char *buffer = (char *)xmalloc (strlen (name) + 32);
+ sprintf (buffer, "%s.%d", name, node_order);
+
+ add = buffer;
sep = "";
}
else if (section_type < LTO_N_SECTION_TYPES)
typedef const char* (lto_get_section_data_f) (struct lto_file_decl_data *,
enum lto_section_type,
const char *,
+ int,
size_t *);
/* Return the data found from the above call. The first three
/* Read LTO section. */
lto_section lto_section_header;
+
+ int order_base;
};
typedef struct lto_file_decl_data *lto_file_decl_data_ptr;
extern struct lto_file_decl_data **lto_get_file_decl_data (void);
extern const char *lto_get_section_data (struct lto_file_decl_data *,
enum lto_section_type,
- const char *, size_t *,
+ const char *, int, size_t *,
bool decompress = false);
+extern const char *lto_get_summary_section_data (struct lto_file_decl_data *,
+ enum lto_section_type,
+ size_t *);
extern const char *lto_get_raw_section_data (struct lto_file_decl_data *,
enum lto_section_type,
- const char *, size_t *);
+ const char *, int, size_t *);
extern void lto_free_section_data (struct lto_file_decl_data *,
enum lto_section_type,
const char *, const char *, size_t,
extern bool lto_stream_offload_p;
extern const char *lto_tag_name (enum LTO_tags);
-extern char *lto_get_section_name (int, const char *, struct lto_file_decl_data *);
+extern char *lto_get_section_name (int, const char *, int,
+ struct lto_file_decl_data *);
extern void print_lto_report (const char *);
extern void lto_streamer_init (void);
extern bool gate_lto_out (void);
+2019-10-30 Martin Liska <mliska@suse.cz>
+
+ PR lto/91393
+ PR lto/88220
+ * lto-common.c (lto_file_finalize): Use lto_get_summary_section_data.
+ (get_section_data): Add order argument.
+
2019-10-29 Martin Liska <mliska@suse.cz>
* lto.c (do_whole_program_analysis): Pass
#endif
/* Read and verify LTO section. */
- data = lto_get_section_data (file_data, LTO_section_lto, NULL, &len, false);
+ data = lto_get_summary_section_data (file_data, LTO_section_lto, &len);
if (data == NULL)
{
fatal_error (input_location, "bytecode stream in file %qs generated "
file_data->lto_section_header.minor_version,
file_data->file_name);
- data = lto_get_section_data (file_data, LTO_section_decls, NULL, &len);
+ data = lto_get_summary_section_data (file_data, LTO_section_decls, &len);
if (data == NULL)
{
internal_error ("cannot read %<LTO_section_decls%> from %s",
static const char *
get_section_data (struct lto_file_decl_data *file_data,
- enum lto_section_type section_type,
- const char *name,
- size_t *len)
+ enum lto_section_type section_type,
+ const char *name, int order,
+ size_t *len)
{
htab_t section_hash_table = file_data->section_hash_table;
struct lto_section_slot *f_slot;
struct lto_section_slot s_slot;
const char *section_name = lto_get_section_name (section_type, name,
- file_data);
+ order, file_data);
char *data = NULL;
*len = 0;
+2019-10-30 Martin Liska <mliska@suse.cz>
+
+ PR lto/91393
+ PR lto/88220
+ * gcc.dg/lto/pr91393_0.c: New test.
+
2019-10-30 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/92262
--- /dev/null
+void __open_alias(int, ...) __asm__("open");
+void __open_alias(int flags, ...) {}
+extern __inline __attribute__((__gnu_inline__)) int open() {}
+struct {
+ void *func;
+} a = {open};
+
+int main()
+{
+ return 0;
+}
= lto_get_function_in_decl_state (file_data, decl);
data = lto_get_section_data (file_data, LTO_section_function_body,
- name, &len, decl_state->compressed);
+ name, order - file_data->order_base,
+ &len, decl_state->compressed);
if (!data)
- fatal_error (input_location, "%s: section %s is missing",
+ fatal_error (input_location, "%s: section %s.%d is missing",
file_data->file_name,
- name);
+ name, order - file_data->order_base);
if (!quiet_flag)
fprintf (stderr, " in:%s", IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));