Bug 112567 - [14 regression] ICE in RTL pass: split2: Segmentation fault
Summary: [14 regression] ICE in RTL pass: split2: Segmentation fault
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 14.0
: P3 normal
Target Milestone: 14.0
Assignee: Uroš Bizjak
Keywords: ice-on-valid-code
Depends on:
Reported: 2023-11-16 12:39 UTC by Sergei Trofimovich
Modified: 2023-11-16 19:15 UTC (History)
1 user (show)

See Also:
Target: x86_64-*-*
Known to work:
Known to fail:
Last reconfirmed: 2023-11-16 00:00:00


Note You need to log in before you can comment on or make changes to this bug.
Description Sergei Trofimovich 2023-11-16 12:39:55 UTC
Noticed ICE when was building linux-6.6.1 with gcc-master at r14-5529-g7a496b7ce10518

cvise came up with the following trigger:

// $ cat ast_mode.c.c
union { char b[4]; void (*ul)(void); } gu;
int gv;

void writew(...);

void bug(void) {
  struct { char b[2]; } s;

  gu.ul = bug;
  s.b[0] = gu.b[1] | gv;

Crashes as:

$ gcc -O1  -c ast_mode.c.c -o a.o
during RTL pass: split2
ast_mode.c.c: In function 'bug':
ast_mode.c.c:12:1: internal compiler error: Segmentation fault
   12 | }
      | ^
0x103e83f crash_signal
0xbd5d7b mark_label_nuses
0xbd5dcc mark_label_nuses
0xbd5dcc mark_label_nuses
0xbd5ded mark_label_nuses
0xbda6e6 try_split(rtx_def*, rtx_insn*, int)
0xf929d7 split_insn
0xf981c7 split_all_insns()
0xf98278 execute

$ gcc/xgcc -Bgcc -v
Reading specs from gcc/specs
Target: x86_64-pc-linux-gnu
Configured with: /home/slyfox/dev/git/gcc/configure --disable-multilib --disable-bootstrap --disable-lto --disable-libsanitizer --enable-languages=c CFLAGS='-O1 -g0' CXXFLAGS='-O1 -g0' LDFLAGS='-O1 -g0' : (reconfigured) /home/slyfox/dev/git/gcc/configure --disable-multilib --disable-bootstrap --disable-lto --disable-libsanitizer --enable-languages=c CFLAGS='-O1 -g0' CXXFLAGS='-O1 -g0' LDFLAGS='-O1 -g0'
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20231116 (experimental) (GCC)
Comment 1 Uroš Bizjak 2023-11-16 13:10:05 UTC
Mine, due to [1], this time I managed to split to invalid RTX...

I have a patch.

[1] https://gcc.gnu.org/pipermail/gcc-cvs/2023-November/393104.html
Comment 2 David Binderman 2023-11-16 14:05:46 UTC
I get the same for this C++ code:

struct {
  long length();
} fromBase32Hex_input;
int set_bits_start, set_bits_length;
char fromBase32Hex_block[1];
char fromBase32Hex_cr;
void fromBase32Hex() {
  for (; fromBase32Hex_input.length();) {
    char *s = fromBase32Hex_block;
    char cc = set_bits_length >> 8;
    if (set_bits_length) {
      s[set_bits_start / 8] |= cc;
      s[set_bits_start / 8 + 1] |= fromBase32Hex_cr;
    s[set_bits_start / 8] |= fromBase32Hex_cr;

cvise $ ~/gcc/results/bin/gcc -c -w -O2  bug982.cc
cvise $ ~/gcc/results/bin/gcc -c -w -O2 -march=znver1 bug982.cc
during RTL pass: split2
bug982.cc: In function ‘void fromBase32Hex()’:
bug982.cc:17:1: internal compiler error: Segmentation fault
   17 | }
      | ^
0x11b6759 crash_signal(int)
0xcc7899 mark_label_nuses(rtx_def*)
Comment 3 GCC Commits 2023-11-16 15:59:35 UTC
The master branch has been updated by Uros Bizjak <uros@gcc.gnu.org>:


commit r14-5533-g06ff410e0dea135d41bc5f7a9a007d7ba6822dbf
Author: Uros Bizjak <ubizjak@gmail.com>
Date:   Thu Nov 16 16:48:07 2023 +0100

    i386: Fix invalid RTX in split2 pass [PR112567]
    Also fix some indentitation inconsistencies.
            PR target/112567
            * config/i386/i386.md (*<any_logic:code>qi_ext<mode>_1_slp):
            Fix generation of invalid RTX in split pattern.
Comment 4 Uroš Bizjak 2023-11-16 16:03:18 UTC
Comment 5 Sergei Trofimovich 2023-11-16 19:15:02 UTC
The fix allowed me to build linux-6.6.1 successfully with current gcc-master. Thank you!