https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65117
Bug ID: 65117
Summary: xtensa: With -Os, invalid parameter c1 for
reg_class_subset_p() to cause segment fault.
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: gang.chen.5i5j at gmail dot com
The related source file:
# cat r100.i
#pragma pack()
struct r100_cs_cube_info {
char a[17];
unsigned int width;
unsigned int height;
};
struct r100_cs_track_texture {
char a[96];
struct r100_cs_cube_info cube_info[5];
unsigned int tex_coord_type;
unsigned int txdepth;
char roundup_h;
};
struct r100_cs_track {
char a[89];
unsigned int num_cb;
unsigned int num_texture;
struct r100_cs_track_texture textures[2];
};
struct radeon_device;
void r100_cs_track_clear(int x, struct r100_cs_track *y)
{
int i, j;
for (i = 0; i < y->num_texture; i++) {
if (x <= 8)
y->textures[i].txdepth = 0;
else {
y->textures[i].txdepth = 9;
y->textures[i].tex_coord_type = 1;
}
y->textures[i].roundup_h = 0;
if (y->num_cb)
for (j= 0; j < 5; j++) {
y->textures[i].cube_info[j].width = 2;
y->textures[i].cube_info[j].height = 2;
}
}
}
The related issue:
# /upstream/release-xtensa/libexec/gcc/xtensa-gchen-elf32/5.0.0/cc1 -Os r100.i
r100.i: In function 'r100_cs_track_clear':
r100.i:43:1: internal compiler error: Segmentation fault
}
^
0xa4427f crash_signal
../../gcc-xtensa/gcc/toplev.c:383
0x9c79c0 reg_class_subset_p(int, int)
../../gcc-xtensa/gcc/reginfo.c:1221
0x9d7a0c find_reloads(rtx_insn*, int, int, int, short*)
../../gcc-xtensa/gcc/reload.c:3678
0x9e2cbb reload_as_needed
../../gcc-xtensa/gcc/reload1.c:4688
0x9e8460 reload(rtx_insn*, int)
../../gcc-xtensa/gcc/reload1.c:1092
0x8cdb2d do_reload
../../gcc-xtensa/gcc/ira.c:5430
0x8cdb2d execute
../../gcc-xtensa/gcc/ira.c:5589
The related version:
# /upstream/release-xtensa/bin/xtensa-gchen-elf32-gcc -v
Using built-in specs.
COLLECT_GCC=/upstream/release-xtensa/bin/xtensa-gchen-elf32-gcc
COLLECT_LTO_WRAPPER=/upstream/release-xtensa/libexec/gcc/xtensa-gchen-elf32/5.0.0/lto-wrapper
Target: xtensa-gchen-elf32
Configured with: ../gcc-xtensa/configure --target=xtensa-gchen-elf32
--prefix=/upstream/release-xtensa --disable-nls --enable-languages=c
--disable-threads --disable-shared --enable-libssp --disable-libquadmath
--disable-libgomp --disable-libatomic
Thread model: single
gcc version 5.0.0 20150219 (experimental) (GCC)
# /upstream/release-xtensa/bin/xtensa-gchen-elf32-ld -v
GNU ld (GNU Binutils) 2.25.51.20150219
I shall try to fix it within this month, at present, the direct cause is: for
reg_class_subset_p(), the upper caller passes an incorrect parameter c1 which
value is -926186479, and this issue has only effect with -Os (no effect with
-O0, or -O2 ...).