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

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


Attachments

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;
  writew(s);
}

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
        ../../source/gcc/toplev.cc:316
0xbd5d7b mark_label_nuses
        ../../source/gcc/emit-rtl.cc:3755
0xbd5dcc mark_label_nuses
        ../../source/gcc/emit-rtl.cc:3763
0xbd5dcc mark_label_nuses
        ../../source/gcc/emit-rtl.cc:3763
0xbd5ded mark_label_nuses
        ../../source/gcc/emit-rtl.cc:3766
0xbda6e6 try_split(rtx_def*, rtx_insn*, int)
        ../../source/gcc/emit-rtl.cc:3952
0xf929d7 split_insn
        ../../source/gcc/recog.cc:3383
0xf981c7 split_all_insns()
        ../../source/gcc/recog.cc:3487
0xf98278 execute
        ../../source/gcc/recog.cc:4411

$ gcc/xgcc -Bgcc -v
Reading specs from gcc/specs
COLLECT_GCC=gcc/xgcc
COLLECT_LTO_WRAPPER=gcc/lto-wrapper
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)
	../../trunk.year/gcc/toplev.cc:316
0xcc7899 mark_label_nuses(rtx_def*)
	../../trunk.year/gcc/emit-rtl.cc:3750
Comment 3 GCC Commits 2023-11-16 15:59:35 UTC
The master branch has been updated by Uros Bizjak <uros@gcc.gnu.org>:

https://gcc.gnu.org/g:06ff410e0dea135d41bc5f7a9a007d7ba6822dbf

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
    
    gcc/ChangeLog:
    
            * 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
Fixed.
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!