Bug 2001 - [5 Regression] ICE in final_scan_insn, at final.c:3020 on aarch64-linux-gnu
Summary: [5 Regression] ICE in final_scan_insn, at final.c:3020 on aarch64-linux-gnu
Status: RESOLVED NON REPRODUCIBLE
Alias: None
Product: GCC
Classification: Unclassified
Component: General (show other bugs)
Version: Linaro GCC 5
Hardware: Other Linux
: --- major
Target Milestone: ---
Assignee: Charles Baylis
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-20 15:10 UTC by doko
Modified: 2017-01-12 08:25 UTC (History)
4 users (show)

See Also:
Linux kernel version:


Attachments
preprocessed source (35.67 KB, application/x-xz)
2016-01-20 15:10 UTC, doko
Details

Note You need to log in before you can comment on or make changes to this bug.
Description doko 2016-01-20 15:10:14 UTC
Created attachment 443 [details]
preprocessed source

seen building btrfs-tools with -Os, Linaro 5-2016.01. works with -O2

int a, f, g, h;
enum { BTRFS_SEND_C_SNAPSHOT, BTRFS_SEND_C_MKFILE };
struct btrfs_send_ops {
  int (*snapshot)();
  int (*clone)(char, unsigned, unsigned, char *, unsigned, char *, unsigned,
               void *);
};
struct btrfs_send_stream {
  char read_buf[1024 * 64];
  int cmd;
  struct btrfs_send_ops *ops;
};
char b, c;
long d, e, i, j;
int fn1(int *, char *, ...);
int fn2();
void fn3();
static int fn4(struct btrfs_send_stream *p1) {
  char k;
  char l[1];
  long m;
  switch (p1->cmd) {
  case BTRFS_SEND_C_SNAPSHOT: {
    fn2(p1, c);
    int n;
    fn2(i, &n);
    if (sizeof i != n)
      goto tlv_get_failed;
    fn2(l);
    if (g)
      goto tlv_get_failed;
    fn2(p1, i & f);
    if (f)
      fn1(&a, "", (int)sizeof i, f);
    m = j;
  }
    p1->ops->snapshot(c, l);
  case BTRFS_SEND_C_MKFILE:
    fn3(&k);
    long o;
    int p = fn2(&o, &p);
    h = fn2(p1, l);
    if (g)
      goto tlv_get_failed;
    fn3(b);
    if (g)
      goto tlv_get_failed;
    fn2();
    p1->ops->clone(0, e, h, l, m, &b, d, p1);
  }
tlv_get_failed:;
}
void fn5(long p1) {
  struct btrfs_send_stream s;
  long q;
  while (1) {
    fn4(&s);
    q++;
    if (p1 && q >= p1)
      goto out;
  }
out:;
}

$ gcc -c -Os -fPIC send-stream.i
send-stream.c: In function 'btrfs_read_and_process_send_stream':
send-stream.c:64:1: error: could not split insn
 }
 ^
(insn:TI 370 378 373 (set (mem/c:DI (plus:DI (reg/f:DI 29 x29)
                (const_int 128 [0x80])) [16 %sfp+-65968 S8 A64])
        (plus:DI (plus:DI (reg/f:DI 29 x29)
                (const_int 48 [0x30]))
            (const_int 66008 [0x101d8]))) send-stream.c:313 95 {*adddi3_pluslong}
     (expr_list:REG_EQUIV (plus:DI (reg/f:DI 64 sfp)
            (const_int -40 [0xffffffffffffffd8]))
        (nil)))
send-stream.c:499:1: internal compiler error: in final_scan_insn, at final.c:3020
0x913bef _fatal_insn(char const*, rtx_def const*, char const*, int, char const*)
        ../../src/gcc/rtl-error.c:110
0x734f6b final_scan_insn(rtx_insn*, _IO_FILE*, int, int, int*)
        ../../src/gcc/final.c:3020
0x73522f final(rtx_insn*, _IO_FILE*, int)
        ../../src/gcc/final.c:2089
0x735737 rest_of_handle_final
        ../../src/gcc/final.c:4488
0x735737 execute
        ../../src/gcc/final.c:4563
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
Comment 1 doko 2016-01-20 15:40:51 UTC
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/aarch64-linux-gnu/5/lto-wrapper
Target: aarch64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 5.3.1-6ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --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-libquadmath --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-arm64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-arm64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-arm64 --with-arch-directory=aarch64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-multiarch --disable-werror --enable-checking=release --build=aarch64-linux-gnu --host=aarch64-linux-gnu --target=aarch64-linux-gnu
Thread model: posix
gcc version 5.3.1 20160119 (Ubuntu/Linaro 5.3.1-6ubuntu2)
Comment 2 doko 2016-01-20 16:17:38 UTC
fails with -O2, works with -O1

$ cat pseed3.i
typedef int Nlm_Int4, ValNodePtr;
Nlm_Int4 b, e;
char c, d;
void fn1();
typedef struct { double patternProbability; } patternSearchItems;
char fn2();
void fn3();
patternSearchItems a;
void fn4() {
  Nlm_Int4 f[20000];
  char g[1];
  a = *(patternSearchItems *)fn3;
  while (fn2(c, d & e, b))
    if (a.patternProbability) {
      fn1(g);
      fn1(f);
    }
}
$ gcc-5 -O2 -fPIC -c pseed3.i 
pseed3.i: In function 'fn4':
pseed3.i:18:1: error: could not split insn
 }
 ^
(insn:TI 23 5 13 (set (mem/c:DI (plus:DI (reg/f:DI 29 x29)
                (const_int 104 [0x68])) [5 %sfp+-80024 S8 A64])
        (plus:DI (plus:DI (reg/f:DI 29 x29)
                (const_int 16 [0x10]))
            (const_int 80096 [0x138e0]))) pseed3.i:15 95 {*adddi3_pluslong}
     (expr_list:REG_EQUIV (plus:DI (reg/f:DI 64 sfp)
            (const_int -16 [0xfffffffffffffff0]))
        (nil)))
pseed3.i:18:1: internal compiler error: in final_scan_insn, at final.c:3020
0x913bef _fatal_insn(char const*, rtx_def const*, char const*, int, char const*)
        ../../src/gcc/rtl-error.c:110
0x734f6b final_scan_insn(rtx_insn*, _IO_FILE*, int, int, int*)
        ../../src/gcc/final.c:3020
0x73522f final(rtx_insn*, _IO_FILE*, int)
        ../../src/gcc/final.c:2089
0x735737 rest_of_handle_final
        ../../src/gcc/final.c:4488
0x735737 execute
        ../../src/gcc/final.c:4563
Please submit a full bug report,
with preprocessed source if appropriate.
Comment 3 doko 2016-01-20 17:50:44 UTC
apparently this can't be reproduced by Linaro; however I can see it fixed by backporting the patch for PR69176 from the trunk (revisions 231304 and 232540, and re-adding the VOIDmode parameter to gen_rtx_SET).
Comment 4 Charles Baylis 2017-01-12 08:25:27 UTC
We never managed to reproduce this.