gcc-4.9 miscompiles linux kernel zlib for armv3

Bug #1307197 reported by Arnd Bergmann
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Linaro GCC
New
Undecided
Kugan Vivekanandarajah
gcc
Fix Released
Medium

Bug Description

I did some more kernel build tests with random configurations, using the latest gcc-4.9 snapshot (20140413)

$ arm-linux-gnueabihf-gcc-4.9.0 --version
arm-linux-gnueabihf-gcc-4.9.0 (GCC) 4.9.0 20140413 (prerelease)

$ arm-linux-gnueabihf-gcc-4.9.0 -O -march=armv3 /tmp/inffast.i
/tmp/inffast.i: In function 'inflate_fast':
/tmp/inffast.i:385:1: internal compiler error: Segmentation fault
 }
 ^
0x997a5f crash_signal
        ../../gcc/toplev.c:337
0xc46dbb arm_reload_in_hi(rtx_def**)
        ../../gcc/config/arm/arm.c:14944
0xcb5b24 gen_reload_inhi(rtx_def*, rtx_def*, rtx_def*)
        ../../gcc/config/arm/arm.md:7049
0x8924c3 insn_gen_fn::operator()(rtx_def*, rtx_def*, rtx_def*) const
        ../../gcc/recog.h:285
0x8924c3 check_and_process_move
        ../../gcc/lra-constraints.c:1061
0x8924c3 curr_insn_transform
        ../../gcc/lra-constraints.c:3283
0x893134 lra_constraints(bool)
        ../../gcc/lra-constraints.c:4216
0x883c2c lra(_IO_FILE*)
        ../../gcc/lra.c:2353
0x845276 do_reload
        ../../gcc/ira.c:5457
0x845276 rest_of_handle_reload
        ../../gcc/ira.c:5598
0x845276 execute
        ../../gcc/ira.c:5627

The source code comes from the Linux kernel, but is fact a copy of the popular zlib library. I have taken all unrelated code out of the preprocessed source file, but have not attempted to reduce the inflate_fast funcion any further. The same problem happens with today's gcc-4.10.0 snapshot (20140413).

Revision history for this message
Arnd Bergmann (arnd-arndb) wrote :
Revision history for this message
Kugan Vivekanandarajah (kugan-vivekanandarajah) wrote :
Revision history for this message
Arnd Bergmann (arnd-arndb) wrote :

Should this get mirrored into the main gcc bug tracker?

Revision history for this message
Kugan Vivekanandarajah (kugan-vivekanandarajah) wrote :

It fails only for armv3 and below and works for armv4 and above. Looks likes another LRA issue and works when -mno-lra is used. I will create a bug report upstream.

Revision history for this message
Kugan Vivekanandarajah (kugan-vivekanandarajah) wrote :

reload_inhi pattern has

witn -mno-lra operands[0], operands[1] and operands[2] are
(reg:HI 1 r1)
(mem/c:HI (reg/f:SI 13 sp) [0 %sfp+-8 S2 A64])
(reg:DI 0 r0)

with lra, operands[0], operands[1] and operands[2] are
(reg:SI 144)
(reg/v:HI 117 [ g ])
(reg:DI 145)

operand[1] for reload_inhi is arm_reload_memory_operand and looks like LRA is doing something wrong.

Stack trace:

0x95de1f crash_signal
 /home/kugan/work/sources/gcc-fsf/trunk/gcc/toplev.c:337
0xc0d096 arm_reload_in_hi(rtx_def**)
 /home/kugan/work/sources/gcc-fsf/trunk/gcc/config/arm/arm.c:14945
0xc7be24 gen_reload_inhi(rtx_def*, rtx_def*, rtx_def*)
 /home/kugan/work/sources/gcc-fsf/trunk/gcc/config/arm/arm.md:7049
0x8588e3 insn_gen_fn::operator()(rtx_def*, rtx_def*, rtx_def*) const
 /home/kugan/work/sources/gcc-fsf/trunk/gcc/recog.h:285
0x8588e3 check_and_process_move
 /home/kugan/work/sources/gcc-fsf/trunk/gcc/lra-constraints.c:1061
0x8588e3 curr_insn_transform
 /home/kugan/work/sources/gcc-fsf/trunk/gcc/lra-constraints.c:3268
0x859554 lra_constraints(bool)
 /home/kugan/work/sources/gcc-fsf/trunk/gcc/lra-constraints.c:4201
0x84a02c lra(_IO_FILE*)
 /home/kugan/work/sources/gcc-fsf/trunk/gcc/lra.c:2353
0x80b676 do_reload
 /home/kugan/work/sources/gcc-fsf/trunk/gcc/ira.c:5457
0x80b676 rest_of_handle_reload
 /home/kugan/work/sources/gcc-fsf/trunk/gcc/ira.c:5598
0x80b676 execute
 /home/kugan/work/sources/gcc-fsf/trunk/gcc/ira.c:5627
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.

Revision history for this message
In , Kugan (kugan) wrote :

Created attachment 33392
testcase

rm-none-linux-gnueabi-gcc -O -march=armv3 inffast.i
inffast.i: In function ‘inflate_fast’:
inffast.i:385:1: internal compiler error: Segmentation fault
 }
 ^
0x9b878f crash_signal
 /home/kugan/work/sources/gcc-fsf/trunk/gcc/toplev.c:337
0xc90cf6 arm_reload_in_hi(rtx_def**)
 /home/kugan/work/sources/gcc-fsf/trunk/gcc/config/arm/arm.c:15279
0xd025cc gen_reload_inhi(rtx_def*, rtx_def*, rtx_def*)
 /home/kugan/work/sources/gcc-fsf/trunk/gcc/config/arm/arm.md:6346
0x89ca2b insn_gen_fn::operator()(rtx_def*, rtx_def*, rtx_def*) const
 /home/kugan/work/sources/gcc-fsf/trunk/gcc/recog.h:309
0x89ca2b check_and_process_move
 /home/kugan/work/sources/gcc-fsf/trunk/gcc/lra-constraints.c:1163
0x89ca2b curr_insn_transform
 /home/kugan/work/sources/gcc-fsf/trunk/gcc/lra-constraints.c:3270
0x89d5ac lra_constraints(bool)
 /home/kugan/work/sources/gcc-fsf/trunk/gcc/lra-constraints.c:4200
0x88a59f lra(_IO_FILE*)
 /home/kugan/work/sources/gcc-fsf/trunk/gcc/lra.c:2189
0x848da6 do_reload
 /home/kugan/work/sources/gcc-fsf/trunk/gcc/ira.c:5306
0x848da6 execute
 /home/kugan/work/sources/gcc-fsf/trunk/gcc/ira.c:5465
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.

arm-none-linux-gnueabi-gcc -v
Using built-in specs.
COLLECT_GCC=/home/kugan/work/builds/gcc-fsf-trunk/tools/bin/arm-none-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/home/kugan/work/builds/gcc-fsf-trunk/tools/libexec/gcc/arm-none-linux-gnueabi/5.0.0/lto-wrapper
Target: arm-none-linux-gnueabi
Configured with: /home/kugan/work/sources/gcc-fsf/trunk/configure --target=arm-none-linux-gnueabi --prefix=/home/kugan/work/builds/gcc-fsf-trunk/tools --with-sysroot=/home/kugan/work/builds/gcc-fsf-trunk/sysroot-arm-none-linux-gnueabi --disable-libssp --disable-libgomp --disable-libmudflap --disable-libatomic --disable-libquadmath --without-libquadmath --enable-languages=c --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=softfp --with-thumb
Thread model: posix
gcc version 5.0.0 20140820 (experimental) (GCC)

Revision history for this message
In , Kugan (kugan) wrote :
Revision history for this message
Kugan Vivekanandarajah (kugan-vivekanandarajah) wrote :
Changed in gcc:
importance: Unknown → Medium
status: Unknown → New
Revision history for this message
In , Rguenth (rguenth) wrote :

Not exactly "miscompile"

Changed in gcc-linaro:
assignee: nobody → Kugan Vivekanandarajah (kugan-vivekanandarajah)
Changed in gcc:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.