From: Martin Liska Date: Wed, 21 Oct 2020 09:11:03 +0000 (+0200) Subject: LTO: get_section: add new argument X-Git-Tag: releases/gcc-10.3.0~710 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32d16af0c4ede8d008d4360cca7c805db518166f;p=thirdparty%2Fgcc.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. (cherry picked from commit 568de14d2e74cfdd600b8995ff6ac08c98ddef48) --- diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index c7867dbed9b1..b1f0881bd706 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -5946,22 +5946,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 = @@ -5983,8 +5967,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 55a0b272a96a..e07c9b3bba01 100644 --- a/gcc/ipa-fnsummary.c +++ b/gcc/ipa-fnsummary.c @@ -4346,6 +4346,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++])) @@ -4364,8 +4365,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 (); @@ -4500,8 +4499,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 5e3216da6312..70a554c44479 100644 --- a/gcc/langhooks.c +++ b/gcc/langhooks.c @@ -777,7 +777,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 eb253c503299..2f2f1697fd89 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 5bf4e96a7739..0e7531926f8c 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -276,10 +276,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; @@ -296,6 +298,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