Bug 69129

Summary: [6 Regression] ICE in get_attr_got, at config/mips/mips.md:694 on mips-linux-gnu
Product: gcc Reporter: Matthias Klose <doko>
Component: targetAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: nickc, sje
Priority: P3 Keywords: ice-on-valid-code
Version: 6.0   
Target Milestone: 6.0   
Host: Target: mips-linux-gnu, mipsel-linux-gnu
Build: Known to work: 5.3.1
Known to fail: 6.0 Last reconfirmed:

Description Matthias Klose 2016-01-03 22:12:28 UTC
seen with trunk 20160103, building libgfortran

$ gcc/build/./gcc/xgcc -B/scratch/packages/cross/6/gcc-6-cross-1/gcc/build/./gcc/ -std=gnu11 -fcx-fortran-rules -ffunction-sections -fdata-sections -g -O2  -minterlink-mips16 -c maxval_r4.i

../../../src/libgfortran/generated/maxval_r4.c: In function 'maxval_r4':
../../../src/libgfortran/generated/maxval_r4.c:200:1: error: unrecognizable insn:

(insn 691 690 693 2 (parallel [
            (set (mem/c:SI (plus:SI (reg/f:SI 29 $sp)
                        (const_int 16 [0x10])) [11  S4 A32])
                (unspec:SI [
                        (const_int 16 [0x10])
                        (reg:SI 28 $28)
                    ] UNSPEC_POTENTIAL_CPRESTORE))
            (clobber (scratch:SI))
        ]) ../../../src/libgfortran/generated/maxval_r4.c:42 -1
     (expr_list:REG_DEAD (reg:SI 28 $28)
        (nil)))
../../../src/libgfortran/generated/maxval_r4.c:200:1: internal compiler error: in get_attr_got, at config/mips/mips.md:694
0x8f29a8 _fatal_insn(char const*, rtx_def const*, char const*, int, char const*)
        ../../src/gcc/rtl-error.c:108
0x8f29d9 _fatal_insn_not_found(rtx_def const*, char const*, int, char const*)
        ../../src/gcc/rtl-error.c:116
0xc2a486 get_attr_got(rtx_insn*)
        ../../src/gcc/config/mips/mips.md:694
0xb82f98 mips_insn_has_flexible_gp_ref_p
        ../../src/gcc/config/mips/mips.c:9927
0xb75ea7 mips_find_gp_ref
        ../../src/gcc/config/mips/mips.c:9858
0xb81f51 mips_global_pointer
        ../../src/gcc/config/mips/mips.c:9979
0xb81f51 mips_compute_frame_info
        ../../src/gcc/config/mips/mips.c:10350
0xb8c7ae mips_initial_elimination_offset(int, int)
        ../../src/gcc/config/mips/mips.c:10591
0x8f42b3 rtx_addr_can_trap_p_1
        ../../src/gcc/rtlanal.c:618
0x8f415f rtx_addr_can_trap_p_1
        ../../src/gcc/rtlanal.c:678
0x8f7d3e may_trap_p_1(rtx_def const*, unsigned int)
        ../../src/gcc/rtlanal.c:2819
0x67fc64 can_move_insns_across(rtx_insn*, rtx_insn*, rtx_insn*, rtx_insn*, basic_block_def*, bitmap_head*, bitmap_head*, rtx_insn**)
        ../../src/gcc/df-problems.c:4156
0xd234d7 dead_or_predicable
        ../../src/gcc/ifcvt.c:5079
0xd2905e find_if_case_1
        ../../src/gcc/ifcvt.c:4770
0xd2905e find_if_header
        ../../src/gcc/ifcvt.c:4171
0xd2905e if_convert
        ../../src/gcc/ifcvt.c:5305
0xd29b2d execute
        ../../src/gcc/ifcvt.c:5495
Please submit a full bug report,
with preprocessed source if appropriate.


_Noreturn fn1() __attribute__((__visibility__("hidden")));
fn2(struct gfc_array_r4 *p1) {
  int a[7];
  float *b;
  int c, n;
  if (c != p1)
    fn1();
  n = 0;
  for (; c; n++) {
    int d;
    if (a[n] != d)
      fn1(n);
  }
  b = p1;
  while (1) {
    *b = 3.40282347e38f;
    if (a[0])
      return;
  }
}
Comment 1 Steve Ellcey 2016-01-06 00:27:16 UTC
I could not reproduce this with todays (Jan 5, 2016) top-of-tree.  I built mips-linux-gnu and mipsel-linux-gnu with Fortran and the library built just fine.  I also tried the test case that was included and that also compiled.
I got some warnings, but no ICE.

I was building a cross compiler running on x86 linux (ubuntu 12.04) and I tried mips-linux-gnu and mipsel-linux-gnu targets.
Comment 2 Matthias Klose 2016-01-06 10:19:17 UTC
rechecked with today's trunk on Debian unstable, reproduced. The compiler is configured with:

configure -v --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-6 --enable-shared --enable-linker-build-id  --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libsanitizer --disable-libquadmath --enable-plugin --with-system-zlib --enable-multiarch --enable-multilib --with-arch-32=mips32r2 --with-fp-32=xx --enable-targets=all --with-arch-64=mips64r2 --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=mips-linux-gnu --program-prefix=mips-linux-gnu- --includedir=/usr/mips-linux-gnu/include

according to
https://buildd.debian.org/status/logs.php?pkg=gcc-snapshot&arch=mipsel

the libgfortran failure is first seen with trunk 20150722 in native builds.
Comment 3 Matthias Klose 2016-01-09 14:09:08 UTC
still seen with r232188
Comment 4 Paul Hua 2016-01-19 12:56:59 UTC
The bug same as pr69012 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69012
Comment 5 Nick Clifton 2016-01-19 13:54:59 UTC
Hi Guys,

  I was able to reproduce the bug as specified.  It turns out that there is a race condition in mips_compute_frame which can result in fields in the frame structure being used before they are initialised.  I have submitted a possible patch for review here:

https://gcc.gnu.org/ml/gcc-patches/2016-01/msg01407.html

Cheers
  Nick
Comment 6 Nick Clifton 2016-01-21 14:07:33 UTC
Author: nickc
Date: Thu Jan 21 14:07:01 2016
New Revision: 232674

URL: https://gcc.gnu.org/viewcvs?rev=232674&root=gcc&view=rev
Log:
	PR target/69129
	PR target/69012
	* config/mips/mips.c (mips_compute_frame_info): Initialise
	args_size and hard_frame_pointer_offset fields of the frame
	structure before calling mips_global_pointer.

	PR target/69129
	* gcc.target/mips/pr69129.c: New.

Added:
    trunk/gcc/testsuite/gcc.target/mips/pr69129.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/mips/mips.c
    trunk/gcc/testsuite/ChangeLog
Comment 7 Nick Clifton 2016-01-21 14:08:10 UTC
I have now checked in the patch.  The same patch was also generated for PR 69012, so that PR can probably be closed as well.