Bug 113636 - [14 Regression] internal compiler error: in dead_debug_global_find, at valtrack.cc:275 since r14-6290-g9f0f7d802482a8
Summary: [14 Regression] internal compiler error: in dead_debug_global_find, at valtra...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 14.0
: P3 normal
Target Milestone: 14.0
Assignee: Richard Sandiford
URL:
Keywords: ice-on-valid-code, needs-reduction
Depends on:
Blocks:
 
Reported: 2024-01-28 14:10 UTC by Toon Moene
Modified: 2024-01-30 09:37 UTC (History)
4 users (show)

See Also:
Host:
Target: aarch64-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2024-01-29 00:00:00


Attachments
Reduced so far (576 bytes, text/plain)
2024-01-29 05:16 UTC, Andrew Pinski
Details
Further reduction (375 bytes, text/plain)
2024-01-29 12:20 UTC, Claudio Bantaloukas
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Toon Moene 2024-01-28 14:10:15 UTC
A build + test run [r14-8465] on aarch64-linux-gnu draws the following ICE while compiling math/cmplx:

during RTL pass: sched1
cmath_test.go: In function 'math/cmplx.BenchmarkCos':
cmath_test.go:1520:1: internal compiler error: in dead_debug_global_find, at valtrack.cc:275
 1520 | func BenchmarkCos(b *testing.B) {
      | ^
0x131ce17 dead_debug_global_find
        /home/toon/compilers/gcc/gcc/valtrack.cc:275
0x131ce17 dead_debug_global_find
        /home/toon/compilers/gcc/gcc/valtrack.cc:269
0x131cef3 dead_debug_global_replace_temp
        /home/toon/compilers/gcc/gcc/valtrack.cc:321
0x131df33 dead_debug_promote_uses
        /home/toon/compilers/gcc/gcc/valtrack.cc:450
0x131df33 dead_debug_local_finish(dead_debug_local*, bitmap_head*)
        /home/toon/compilers/gcc/gcc/valtrack.cc:487
0x1d777eb dce_process_block
        /home/toon/compilers/gcc/gcc/dce.cc:1060
0x1d777eb fast_dce
        /home/toon/compilers/gcc/gcc/dce.cc:1128
0x1d77d17 rest_of_handle_fast_dce
        /home/toon/compilers/gcc/gcc/dce.cc:1194
0x1d77d17 run_fast_df_dce()
        /home/toon/compilers/gcc/gcc/dce.cc:1242
0xa6c8e7 df_lr_finalize
        /home/toon/compilers/gcc/gcc/df-problems.cc:1065
0xa6585f df_analyze_problem(dataflow*, bitmap_head*, int*, int)
        /home/toon/compilers/gcc/gcc/df-core.cc:1190
0xa658ff df_analyze_1
        /home/toon/compilers/gcc/gcc/df-core.cc:1235
0x1e5574b sched_init()
        /home/toon/compilers/gcc/gcc/haifa-sched.cc:7348
0x1e570e7 haifa_sched_init()
        /home/toon/compilers/gcc/gcc/haifa-sched.cc:7372
0xf38a4f schedule_insns()
        /home/toon/compilers/gcc/gcc/sched-rgn.cc:3517
0xf39157 schedule_insns()
        /home/toon/compilers/gcc/gcc/sched-rgn.cc:3511
0xf39157 rest_of_handle_sched
        /home/toon/compilers/gcc/gcc/sched-rgn.cc:3729
0xf39157 execute
        /home/toon/compilers/gcc/gcc/sched-rgn.cc:3839
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
FAIL: math/cmplx

The build was started with the following system compiler:

$ echo | gcc -### -E - -march=native -mtune=native
Using built-in specs.
COLLECT_GCC=gcc
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: aarch64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 13.2.0-9' --with-bugurl=file:///usr/share/doc/gcc-13/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-13 --program-prefix=aarch64-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-gnu-unique-object --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --enable-fix-cortex-a53-843419 --disable-werror --enable-offload-targets=nvptx-none=/build/reproducible-path/gcc-13-13.2.0/debian/tmp-nvptx/usr --enable-offload-defaulted --without-cuda-driver --enable-checking=release --build=aarch64-linux-gnu --host=aarch64-linux-gnu --target=aarch64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=4
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.2.0 (Debian 13.2.0-9) 
COLLECT_GCC_OPTIONS='-E'   '-mlittle-endian' '-mabi=lp64' '-mtune=thunderxt88'
 /usr/libexec/gcc/aarch64-linux-gnu/13/cc1 -E -quiet -imultiarch aarch64-linux-gnu - -mlittle-endian "-mabi=lp64" "-mtune=thunderxt88" -fasynchronous-unwind-tables -dumpbase -
COMPILER_PATH=/usr/libexec/gcc/aarch64-linux-gnu/13/:/usr/libexec/gcc/aarch64-linux-gnu/13/:/usr/libexec/gcc/aarch64-linux-gnu/:/usr/lib/gcc/aarch64-linux-gnu/13/:/usr/lib/gcc/aarch64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/aarch64-linux-gnu/13/:/usr/lib/gcc/aarch64-linux-gnu/13/../../../aarch64-linux-gnu/:/usr/lib/gcc/aarch64-linux-gnu/13/../../../../lib/:/lib/aarch64-linux-gnu/:/lib/../lib/:/usr/lib/aarch64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/aarch64-linux-gnu/13/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-E'   '-mlittle-endian' '-mabi=lp64' '-mtune=thunderxt88'

using these configure flags:

Compiler version: 14.0.1 20240127 (experimental) [master r14-8465-g5200ef26ac1] (GCC) 
Platform: aarch64-unknown-linux-gnu
configure flags: --prefix=/home/toon/compilers/install/gcc --with-gnu-as --with-gnu-ld --enable-languages=all --disable-multilib --disable-nls

CPU information:

$ cat /proc/cpuinfo
processor       : 0
BogoMIPS        : 200.00
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
CPU implementer : 0x43
CPU architecture: 8
CPU variant     : 0x1
CPU part        : 0x0a1
CPU revision    : 1
....
processor       : 47
BogoMIPS        : 200.00
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
CPU implementer : 0x43
CPU architecture: 8
CPU variant     : 0x1
CPU part        : 0x0a1
CPU revision    : 1

Link to the test summary:

https://gcc.gnu.org/pipermail/gcc-testresults/2024-January/806431.html
Comment 1 Andrew Pinski 2024-01-29 03:51:38 UTC
I can reproduce this with a cross to aarch64-linux-gnu too.
Comment 2 Andrew Pinski 2024-01-29 03:53:20 UTC
It has been failing since at least `Wed Dec 13 06:06:19 UTC 2023` for me.
Comment 3 Andrew Pinski 2024-01-29 03:56:10 UTC
Started between r14-5889-c9d691a7daa162d6d2092 and r14-6443-g3e93a3f09dc I think.
Comment 4 Andrew Pinski 2024-01-29 04:26:58 UTC
Just FYI (just recording on how to reproduce it once the build is finished, needed to modify some scripts to get the command line out in the first place):

cd /home/apinski/src/upstream-full-cross/gcc/libgo/go/math/cmplx

/home/apinski/src/upstream-full-cross/gcc/objdir-stage2/./gcc/gccgo -B/home/apinski/src/upstream-full-cross/gcc/objdir-stage2/./gcc/ -B/home/apinski/src/upstream-full-cross/install/aarch64-linux-gnu/bin/ -B/home/apinski/src/upstream-full-cross/install/aarch64-linux-gnu/lib/ -isystem /home/apinski/src/upstream-full-cross/install/aarch64-linux-gnu/include -isystem /home/apinski/src/upstream-full-cross/install/aarch64-linux-gnu/sys-include -g -O2 -L /home/apinski/src/upstream-full-cross/gcc/objdir-stage2/aarch64-linux-gnu/libgo -L /home/apinski/src/upstream-full-cross/gcc/objdir-stage2/aarch64-linux-gnu/libgo/.libs -g -fgo-pkgpath=math/cmplx -c -I . -fno-toplevel-reorder -o _gotest_.o cmath_test.go huge_test.go abs.go asin.go conj.go exp.go isinf.go isnan.go log.go phase.go polar.go pow.go rect.go sin.go sqrt.go tan.go
Comment 5 Andrew Pinski 2024-01-29 04:48:43 UTC
Trying to reduce this slightly.
Comment 6 Andrew Pinski 2024-01-29 05:16:58 UTC
Created attachment 57248 [details]
Reduced so far

But this might still need some external modules, need to understand that ...
Comment 7 Andrew Pinski 2024-01-29 05:59:13 UTC
Looks like it is early RA which exposing/causing this.

Adding `-mearly-ra=none` to the command line causes the ICE to go away.

I tried to create a C testcase but I am unable to so far. Plus it requires debugging info so it is harder to recreate with inlining and such.
Comment 8 Claudio Bantaloukas 2024-01-29 12:20:29 UTC
Created attachment 57250 [details]
Further reduction

Further reduced test case
Comment 9 Claudio Bantaloukas 2024-01-29 13:50:05 UTC
git bisect "gccgo -g -O3 -mtune=thunderxt88 -c -o __case.o case.go" starting with $(git merge-base origin/releases/gcc-13 origin/trunk) as a first good commit points at [9f0f7d802482a8958d6cdc72f1fe0c8549db2182] aarch64: Add an early RA for strided registers
Comment 10 Richard Sandiford 2024-01-29 14:10:56 UTC
Mine.
Comment 11 GCC Commits 2024-01-30 09:30:50 UTC
The trunk branch has been updated by Richard Sandiford <rsandifo@gcc.gnu.org>:

https://gcc.gnu.org/g:aeec7d87a28ac80c64ebfa88cef3dccee3ba8efc

commit r14-8518-gaeec7d87a28ac80c64ebfa88cef3dccee3ba8efc
Author: Richard Sandiford <richard.sandiford@arm.com>
Date:   Tue Jan 30 09:30:35 2024 +0000

    aarch64: Handle debug references to removed registers [PR113636]
    
    In this PR, we entered early-ra with quite a bit of dead code.
    The code was duly removed (to avoid wasting registers), but there
    was a dangling reference in debug instructions, which caused an
    ICE later.
    
    Fixed by resetting a debug instruction if it references a register
    that is no longer needed by non-debug instructions.
    
    gcc/
            PR target/113636
            * config/aarch64/aarch64-early-ra.cc (early_ra::replace_regs): Take
            the containing insn as an extra parameter.  Reset debug instructions
            if they reference a register that is no longer used by real insns.
            (early_ra::apply_allocation): Update calls accordingly.
    
    gcc/testsuite/
            PR target/113636
            * go.dg/pr113636.go: New test.
Comment 12 Richard Sandiford 2024-01-30 09:37:00 UTC
Fixed.  Thanks for the report and help with reproducing.