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

            Bug ID: 124627
           Summary: ICE with LTO with -O1/-O2/-O3 + -g
           Product: gcc
           Version: 15.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: resence at parsoma dot net
  Target Milestone: ---

Created attachment 64012
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64012&action=edit
1st of 4 preprocessed TU for reproduction

Build with:
# -O0 builds but doesn't link due to lacking main(); O1/O2/O3 ICE
gcc -Wall -Wextra -Werror=uninitialized -Werror=return-type
-Werror=return-local-addr -Werror=pedantic -flto -O3 -g -c a.c b.c c.c d.c
gcc -Werror=lto-type-mismatch -o /dev/null a.o b.o c.o d.o

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-linux-gnu/15/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 15.2.0-16'
--with-bugurl=file:///usr/share/doc/gcc-15/README.Bugs
--enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2,rust,cobol,algol68
--prefix=/usr --with-gcc-major-version-only --program-suffix=-15
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-libstdcxx-backtrace
--enable-gnu-unique-object --disable-vtable-verify --enable-plugin
--enable-default-pie --with-system-zlib --enable-libphobos-checking=release
--with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch
--disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none=/build/reproducible-path/gcc-15-15.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/reproducible-path/gcc-15-15.2.0/debian/tmp-gcn/usr
--enable-offload-defaulted --without-cuda-driver --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
--with-build-config=bootstrap-lto-lean --enable-link-serialization=3
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 15.2.0 (Debian 15.2.0-16)

Output (-O1):
a.c: In function ‘kh’:
a.c:8:14: warning: unused parameter ‘a’ [-Wunused-parameter]
    8 | int *kh(int *a, int *c) { return cj(0, c); }
      |         ~~~~~^
a.c: In function ‘bg’:
a.c:19:14: warning: unused parameter ‘r’ [-Wunused-parameter]
   19 | int *bg(int *r, void *ap) {
      |         ~~~~~^
a.c: In function ‘xw’:
a.c:24:14: warning: unused parameter ‘a’ [-Wunused-parameter]
   24 | int *xw(int *a, struct Duration d) {
      |         ~~~~~^
a.c:24:33: warning: unused parameter ‘d’ [-Wunused-parameter]
   24 | int *xw(int *a, struct Duration d) {
      |                 ~~~~~~~~~~~~~~~~^
a.c: In function ‘bh’:
a.c:2:31: warning: ‘noreturn’ function does return
    2 | static inline void bh(int *) {}
      |                               ^
b.c: In function ‘yg’:
b.c:17:35: warning: unused parameter ‘x’ [-Wunused-parameter]
   17 | int *yg(int *tr, int *p_raw, long x) {
      |                              ~~~~~^
d.c: In function ‘mk’:
d.c:9:14: warning: unused parameter ‘r’ [-Wunused-parameter]
    9 | int *mk(int *r, void *ctx) {
      |         ~~~~~^
d.c:9:23: warning: unused parameter ‘ctx’ [-Wunused-parameter]
    9 | int *mk(int *r, void *ctx) {
      |                 ~~~~~~^~~
d.c: In function ‘sb’:
d.c:14:33: warning: unused variable ‘fp’ [-Wunused-variable]
   14 | void sb(void) { int *(*volatile fp)(int *, void *) = mk; }
      |                                 ^~
during GIMPLE pass: dom
c.c: In function ‘cj’:
c.c:5:6: internal compiler error: Segmentation fault
    5 | int *cj(int **cy, int *g) {
      |      ^
0x155af1f diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
        ???:0
0x1529055 internal_error(char const*, ...)
        ???:0
0x16a7081 update_ssa(unsigned int)
        ???:0
0x1647a3c cleanup_tree_cfg(unsigned int)
        ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-15/README.Bugs> for instructions.
lto-wrapper: fatal error: gcc returned 1 exit status
compilation terminated.
/usr/bin/x86_64-linux-gnu-ld.bfd: error: lto-wrapper failed
collect2: error: ld returned 1 exit status

In -O2 and -O3:
a.c: In function ‘kh’:
a.c:8:14: warning: unused parameter ‘a’ [-Wunused-parameter]
    8 | int *kh(int *a, int *c) { return cj(0, c); }
      |         ~~~~~^
a.c: In function ‘bg’:
a.c:19:14: warning: unused parameter ‘r’ [-Wunused-parameter]
   19 | int *bg(int *r, void *ap) {
      |         ~~~~~^
a.c: In function ‘xw’:
a.c:24:14: warning: unused parameter ‘a’ [-Wunused-parameter]
   24 | int *xw(int *a, struct Duration d) {
      |         ~~~~~^
a.c:24:33: warning: unused parameter ‘d’ [-Wunused-parameter]
   24 | int *xw(int *a, struct Duration d) {
      |                 ~~~~~~~~~~~~~~~~^
a.c: In function ‘bh’:
a.c:2:31: warning: ‘noreturn’ function does return
    2 | static inline void bh(int *) {}
      |                               ^
b.c: In function ‘yg’:
b.c:17:35: warning: unused parameter ‘x’ [-Wunused-parameter]
   17 | int *yg(int *tr, int *p_raw, long x) {
      |                              ~~~~~^
d.c: In function ‘mk’:
d.c:9:14: warning: unused parameter ‘r’ [-Wunused-parameter]
    9 | int *mk(int *r, void *ctx) {
      |         ~~~~~^
d.c:9:23: warning: unused parameter ‘ctx’ [-Wunused-parameter]
    9 | int *mk(int *r, void *ctx) {
      |                 ~~~~~~^~~
d.c: In function ‘sb’:
d.c:14:33: warning: unused variable ‘fp’ [-Wunused-variable]
   14 | void sb(void) { int *(*volatile fp)(int *, void *) = mk; }
      |                                 ^~
during GIMPLE pass: threadfull
c.c: In function ‘cj’:
c.c:5:6: internal compiler error: Segmentation fault
    5 | int *cj(int **cy, int *g) {
      |      ^
0x155af1f diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
        ???:0
0x1529055 internal_error(char const*, ...)
        ???:0
0x16a7081 update_ssa(unsigned int)
        ???:0
0x1647a3c cleanup_tree_cfg(unsigned int)
        ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-15/README.Bugs> for instructions.
lto-wrapper: fatal error: gcc returned 1 exit status
compilation terminated.
/usr/bin/x86_64-linux-gnu-ld.bfd: error: lto-wrapper failed
collect2: error: ld returned 1 exit status

Reply via email to