> From 33c58cab6bc0d779b11e7ffb36bfb485d73d6816 Mon Sep 17 00:00:00 2001 > From: Martin Liska <mli...@suse.cz> > Date: Wed, 21 Oct 2020 11:11:03 +0200 > Subject: [PATCH] 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.
OK with ... > diff --git a/gcc/varasm.c b/gcc/varasm.c > index ea0b59cf44a..207c9b077d1 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,12 @@ get_section (const char *name, unsigned int flags, tree > decl) > } > else > { > + if (not_existing) > + { > + error ("Section already exists: %qs", name); > + gcc_unreachable (); > + } internal_error here? OK, I see that you do checking in the get_section that is not lto streaming only. I guess in that case you also want to do same checking in the place we produce .o file directly (during WPA->ltrans streaming). Honza > + > 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 > -- > 2.28.0 >