https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96291

            Bug ID: 96291
           Summary: -flto fails as "internal compiler error: Segmentation
                    fault" during IPA pass: cp
                    incall_for_symbol_thunks_and_aliases()
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: slyfox at inbox dot ru
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

Originally reported by Gabriel Marcano as https://bugs.gentoo.org/733482 where
radare-4.5.0 ICEs gcc if that is built with -flto.

ICE is reproducible on both gcc-10 and gcc-11. Here is the minimal(ish)
reproducer:

// cat sdb.c
  int b;
  void a();
  void sdb_ns_free();
  void c(int d) {
    sdb_ns_free();
    a(b, 0);
  }
  void sdb_free() { c(0); }

// cat ns.c
  void sdb_free();
  void sdb_ns_free() { sdb_free(); }

// cat main.c
  void sdb_free();
  void a() { sdb_free(); }

$ x86_64-pc-linux-gnu-gcc -c -O2 -flto -o sdb.o sdb.c
$ x86_64-pc-linux-gnu-gcc -c -O2 -flto -o ns.o ns.c
$ x86_64-pc-linux-gnu-gcc -c -O2 -flto -O0 -o main.o main.c
$+ x86_64-pc-linux-gnu-gcc -O2 -flto -o sdb main.o sdb.o ns.o
during IPA pass: cp
lto1: internal compiler error: Segmentation fault
0xa6d3df crash_signal
       
/usr/src/debug/sys-devel/gcc-11.0.0_pre9999/gcc-11.0.0_pre9999/gcc/toplev.c:328
0x7f1656e35c3f ???
       
/usr/src/debug/sys-libs/glibc-2.31-r6/glibc-2.31/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0x5d4751 has_undead_caller_from_outside_scc_p
       
/usr/src/debug/sys-devel/gcc-11.0.0_pre9999/gcc-11.0.0_pre9999/gcc/ipa-cp.c:5670
0x680054 cgraph_node::call_for_symbol_thunks_and_aliases(bool (*)(cgraph_node*,
void*), void*, bool, bool)
       
/usr/src/debug/sys-devel/gcc-11.0.0_pre9999/gcc-11.0.0_pre9999/gcc/cgraph.c:2450
0x12fe86d identify_dead_nodes
       
/usr/src/debug/sys-devel/gcc-11.0.0_pre9999/gcc-11.0.0_pre9999/gcc/ipa-cp.c:5687
0x12fe86d ipcp_decision_stage
       
/usr/src/debug/sys-devel/gcc-11.0.0_pre9999/gcc-11.0.0_pre9999/gcc/ipa-cp.c:5730
0x12fe86d ipcp_driver
       
/usr/src/debug/sys-devel/gcc-11.0.0_pre9999/gcc-11.0.0_pre9999/gcc/ipa-cp.c:5908
0x12fe86d execute
       
/usr/src/debug/sys-devel/gcc-11.0.0_pre9999/gcc-11.0.0_pre9999/gcc/ipa-cp.c:5999
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://bugs.gentoo.org/> for instructions.
lto-wrapper: fatal error: /usr/bin/x86_64-pc-linux-gnu-gcc returned 1 exit
status
compilation terminated.
/usr/lib/gcc/x86_64-pc-linux-gnu/11.0.0/../../../../x86_64-pc-linux-gnu/bin/ld:
error: lto-wrapper failed
collect2: error: ld returned 1 exit status

Reply via email to