From: Martin Liska Date: Wed, 21 Oct 2020 09:11:03 +0000 (+0200) Subject: LTO: get_section: add new argument X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=568de14d2e74cfdd600b8995ff6ac08c98ddef48;p=gcc.git LTO: get_section: add new argument gcc/ChangeLog: PR lto/97508 * langhooks.c (lhd_begin_section): Call get_section with not_existing = true. * output.h (get_section): Add new argument. * varasm.c (get_section): Fail when NOT_EXISTING is true and a section already exists. * ipa-cp.c (ipcp_write_summary): Remove. (ipcp_read_summary): Likewise. * ipa-fnsummary.c (ipa_fn_summary_read): Always read jump functions summary. (ipa_fn_summary_write): Always stream it. --- diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index f981366a345..028480f6ce4 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -5943,22 +5943,6 @@ ipcp_generate_summary (void) ipa_analyze_node (node); } -/* Write ipcp summary for nodes in SET. */ - -static void -ipcp_write_summary (void) -{ - ipa_prop_write_jump_functions (); -} - -/* Read ipcp summary. */ - -static void -ipcp_read_summary (void) -{ - ipa_prop_read_jump_functions (); -} - namespace { const pass_data pass_data_ipa_cp = @@ -5980,8 +5964,8 @@ public: pass_ipa_cp (gcc::context *ctxt) : ipa_opt_pass_d (pass_data_ipa_cp, ctxt, ipcp_generate_summary, /* generate_summary */ - ipcp_write_summary, /* write_summary */ - ipcp_read_summary, /* read_summary */ + NULL, /* write_summary */ + NULL, /* read_summary */ ipcp_write_transformation_summaries, /* write_optimization_summary */ ipcp_read_transformation_summaries, /* diff --git a/gcc/ipa-fnsummary.c b/gcc/ipa-fnsummary.c index f27c5f07fa7..ff05ab67238 100644 --- a/gcc/ipa-fnsummary.c +++ b/gcc/ipa-fnsummary.c @@ -4526,6 +4526,7 @@ ipa_fn_summary_read (void) struct lto_file_decl_data *file_data; unsigned int j = 0; + ipa_prop_read_jump_functions (); ipa_fn_summary_alloc (); while ((file_data = file_data_vec[j++])) @@ -4544,8 +4545,6 @@ ipa_fn_summary_read (void) "ipa inline summary is missing in input file"); } ipa_register_cgraph_hooks (); - if (!flag_ipa_cp) - ipa_prop_read_jump_functions (); gcc_assert (ipa_fn_summaries); ipa_fn_summaries->enable_insertion_hook (); @@ -4693,8 +4692,7 @@ ipa_fn_summary_write (void) produce_asm (ob, NULL); destroy_output_block (ob); - if (!flag_ipa_cp) - ipa_prop_write_jump_functions (); + ipa_prop_write_jump_functions (); } diff --git a/gcc/langhooks.c b/gcc/langhooks.c index 8819a8859d4..d82f54251fd 100644 --- a/gcc/langhooks.c +++ b/gcc/langhooks.c @@ -790,7 +790,7 @@ lhd_begin_section (const char *name) saved_section = text_section; /* Create a new section and switch to it. */ - section = get_section (name, SECTION_DEBUG | SECTION_EXCLUDE, NULL); + section = get_section (name, SECTION_DEBUG | SECTION_EXCLUDE, NULL, true); switch_to_section (section); } diff --git a/gcc/output.h b/gcc/output.h index eb253c50329..2f2f1697fd8 100644 --- a/gcc/output.h +++ b/gcc/output.h @@ -523,7 +523,8 @@ extern GTY(()) bool in_cold_section_p; extern section *get_unnamed_section (unsigned int, void (*) (const void *), const void *); -extern section *get_section (const char *, unsigned int, tree); +extern section *get_section (const char *, unsigned int, tree, + bool not_existing = false); extern section *get_named_section (tree, const char *, int); extern section *get_variable_section (tree, bool); extern void place_block_symbol (rtx); diff --git a/gcc/varasm.c b/gcc/varasm.c index ea0b59cf44a..435c7b348a5 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -277,10 +277,12 @@ get_noswitch_section (unsigned int flags, noswitch_section_callback callback) } /* Return the named section structure associated with NAME. Create - a new section with the given fields if no such structure exists. */ + a new section with the given fields if no such structure exists. + When NOT_EXISTING, then fail if the section already exists. */ section * -get_section (const char *name, unsigned int flags, tree decl) +get_section (const char *name, unsigned int flags, tree decl, + bool not_existing) { section *sect, **slot; @@ -297,6 +299,9 @@ get_section (const char *name, unsigned int flags, tree decl) } else { + if (not_existing) + internal_error ("Section already exists: %qs", name); + sect = *slot; /* It is fine if one of the sections has SECTION_NOTYPE as long as the other has none of the contrary flags (see the logic at the end