On 10/29/20 1:51 PM, Jan Hubicka wrote:

 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?

Yep! Thanks for review.

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).

You are right, it's the following call stack:

#0  simple_object_write_create_section (sobj=0x305e930, name=0x305c200 
".gnu.lto_.ipa_modref.38127cbcd9999426", align=3, errmsg=0x7fffffffd928, 
err=0x7fffffffd924) at /home/marxin/Programming/gcc/libiberty/simple-object.c:462
#1  0x000000000096e044 in lto_obj_begin_section (name=0x305c200 
".gnu.lto_.ipa_modref.38127cbcd9999426") at 
/home/marxin/Programming/gcc/gcc/lto/lto-object.c:333
#2  0x0000000000dbc70e in lto_begin_section (name=0x305c200 
".gnu.lto_.ipa_modref.38127cbcd9999426", compress=false) at 
/home/marxin/Programming/gcc/gcc/lto-section-out.c:68
#3  0x0000000000db153d in produce_asm (ob=0x307a3d0, fn=0x0) at 
/home/marxin/Programming/gcc/gcc/lto-streamer-out.c:2206
#4  0x0000000000c78275 in (anonymous namespace)::modref_write () at 
/home/marxin/Programming/gcc/gcc/ipa-modref.c:1372
#5  0x0000000000ea4ae0 in ipa_write_optimization_summaries_1 (pass=0x30715d0, 
state=0x305ed40) at /home/marxin/Programming/gcc/gcc/passes.c:2785
#6  0x0000000000ea4be8 in ipa_write_optimization_summaries (encoder=0x305bce0) 
at /home/marxin/Programming/gcc/gcc/passes.c:2818
#7  0x000000000096996f in stream_out (temp_filename=0x305b280 "./a.ltrans0.o", 
encoder=0x305bce0, part=0) at /home/marxin/Programming/gcc/gcc/lto/lto.c:172
#8  0x0000000000969af0 in stream_out_partitions_1 (temp_filename=0x305b280 
"./a.ltrans0.o", blen=10, min=0, max=1) at 
/home/marxin/Programming/gcc/gcc/lto/lto.c:218
#9  0x0000000000969b4d in stream_out_partitions (temp_filename=0x305b280 
"./a.ltrans0.o", blen=10, min=0, max=1, last=true) at 
/home/marxin/Programming/gcc/gcc/lto/lto.c:235
#10 0x000000000096a274 in lto_wpa_write_files () at 
/home/marxin/Programming/gcc/gcc/lto/lto.c:394
#11 0x000000000096a75d in do_whole_program_analysis () at 
/home/marxin/Programming/gcc/gcc/lto/lto.c:537
#12 0x000000000096a86b in lto_main () at 
/home/marxin/Programming/gcc/gcc/lto/lto.c:637
#13 0x000000000102bc6c in compile_file () at 
/home/marxin/Programming/gcc/gcc/toplev.c:460
#14 0x000000000102eff4 in do_compile () at 
/home/marxin/Programming/gcc/gcc/toplev.c:2321
#15 0x000000000102f2eb in toplev::main (this=0x7fffffffdd3e, argc=17, 
argv=0x30496d0) at /home/marxin/Programming/gcc/gcc/toplev.c:2460
#16 0x000000000216ff50 in main (argc=17, argv=0x7fffffffde48) at 
/home/marxin/Programming/gcc/gcc/main.c:39

I'm going to prepare one another patch for it and I'm going to install
this patch.

Martin


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



Reply via email to