Bug 63740 - [4.9 Regression] GCC 4.9.2 bootstrap fails on ARM, haifa-sched.c:6507:1: internal compiler error: in lra_create
Summary: [4.9 Regression] GCC 4.9.2 bootstrap fails on ARM, haifa-sched.c:6507:1: inte...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: bootstrap (show other bugs)
Version: 4.9.2
: P1 normal
Target Milestone: 4.9.3
Assignee: Vladimir Makarov
URL:
Keywords:
: 63771 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-11-04 20:34 UTC by Aaro Koskinen
Modified: 2015-06-23 07:27 UTC (History)
9 users (show)

See Also:
Host: arm-unknown-linux-gnueabi
Target: arm-unknown-linux-gnueabi
Build: arm-unknown-linux-gnueabi
Known to work: 4.9.1
Known to fail: 4.9.2
Last reconfirmed: 2014-11-04 00:00:00


Attachments
haifa-sched preprocessed source (188.76 KB, application/octet-stream)
2014-11-04 21:28 UTC, Aaro Koskinen
Details
haifa-sched.ii.gz (188.76 KB, application/gzip)
2014-11-05 10:41 UTC, Aaro Koskinen
Details
haifa-sched.s.gz (58.61 KB, application/gzip)
2014-11-05 10:43 UTC, Aaro Koskinen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Aaro Koskinen 2014-11-04 20:34:15 UTC
GCC 4.9.2 native bootstrap on ARM fails with ICE from the second stage compiler:

/home/aaro/gcctest/build/./prev-gcc/xg++ -B/home/aaro/gcctest/build/./prev-gcc/ -B/usr/local/arm-unknown-linux-gnueabi/bin/ -nostdinc++ -B/home/aaro/gcctest/build/prev-arm-unknown-linux-gnueabi/libstdc++-v3/src/.libs -B/home/aaro/gcctest/build/prev-arm-unknown-linux-gnueabi/libstdc++-v3/libsupc++/.libs  -I/home/aaro/gcctest/build/prev-arm-unknown-linux-gnueabi/libstdc++-v3/include/arm-unknown-linux-gnueabi  -I/home/aaro/gcctest/build/prev-arm-unknown-linux-gnueabi/libstdc++-v3/include  -I/home/aaro/gcctest/gcc-4.9.2/libstdc++-v3/libsupc++ -L/home/aaro/gcctest/build/prev-arm-unknown-linux-gnueabi/libstdc++-v3/src/.libs -L/home/aaro/gcctest/build/prev-arm-unknown-linux-gnueabi/libstdc++-v3/libsupc++/.libs -c   -g -O2 -gtoggle -DIN_GCC    -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings   -DHAVE_CONFIG_H -I. -I. -I../../gcc-4.9.2/gcc -I../../gcc-4.9.2/gcc/. -I../../gcc-4.9.2/gcc/../include -I../../gcc-4.9.2/gcc/../libcpp/include  -I../../gcc-4.9.2/gcc/../libdecnumber -I../../gcc-4.9.2/gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc-4.9.2/gcc/../libbacktrace    -o haifa-sched.o -MT haifa-sched.o -MMD -MP -MF ./.deps/haifa-sched.TPo ../../gcc-4.9.2/gcc/haifa-sched.c
../../gcc-4.9.2/gcc/haifa-sched.c: In function 'bool schedule_block(basic_block_def**, state_t)':
../../gcc-4.9.2/gcc/haifa-sched.c:6507:1: internal compiler error: in lra_create_copy, at lra.c:1532
 }
 ^
0x8a2ac7 lra_create_copy(int, int, int)
        ../../gcc-4.9.2/gcc/lra.c:1532
0x8cbaaf process_bb_lives
        ../../gcc-4.9.2/gcc/lra-lives.c:568
0x8cd583 lra_create_live_ranges(bool)
        ../../gcc-4.9.2/gcc/lra-lives.c:1008
0x8a51ef lra(_IO_FILE*)
        ../../gcc-4.9.2/gcc/lra.c:2372
0x83df07 do_reload
        ../../gcc-4.9.2/gcc/ira.c:5457
0x83e35b rest_of_handle_reload
        ../../gcc-4.9.2/gcc/ira.c:5598
0x83e3d3 execute
        ../../gcc-4.9.2/gcc/ira.c:5627
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.

The host GCC is 4.9.2 (cross-compiled on x86_64 using GCC 4.9.2).

Configure command for bootstrap was:

$ ../gcc-4.9.2/configure --with-arch=armv4t --with-float=soft --disable-nls --enable-languages=c,c++ --host=arm-unknown-linux-gnueabi --build=arm-unknown-linux-gnueabi --target=arm-unknown-linux-gnueabi --with-system-zlib --with-sysroot=/ --disable-static --enable-shared
Comment 1 Richard Biener 2014-11-04 21:00:24 UTC
Can you provide preprocessed source of haifa-sched.c for the failing command?
Comment 2 Aaro Koskinen 2014-11-04 21:28:31 UTC
Created attachment 33885 [details]
haifa-sched preprocessed source

This is the preprocessed source of haifa-sched produced with full original xg++ command line with -E added.

I had to compress it as the plain/text version exceeded the 1000 KB attachment limit.
Comment 3 ktkachov 2014-11-05 10:04:21 UTC
(In reply to Aaro Koskinen from comment #2)
> Created attachment 33885 [details]
> haifa-sched preprocessed source
> 
> This is the preprocessed source of haifa-sched produced with full original
> xg++ command line with -E added.
> 
> I had to compress it as the plain/text version exceeded the 1000 KB
> attachment limit.

I'm getting a whole bunch of frontend errors (and it seems that the .i file is actually another .gz file that needs to be uncompressed again?)

Could you please produce the preprocessed output by adding -save-temps to the command line?
Comment 4 Aaro Koskinen 2014-11-05 10:41:57 UTC
Created attachment 33889 [details]
haifa-sched.ii.gz

haifa-sched.ii (gzipped) from -save-temps.
Comment 5 Aaro Koskinen 2014-11-05 10:43:02 UTC
Created attachment 33890 [details]
haifa-sched.s.gz

haifa-sched.s (gzipped) from -save-temps.
Comment 6 Aaro Koskinen 2014-11-05 12:48:23 UTC
(In reply to Aaro Koskinen from comment #0)
> GCC 4.9.2 native bootstrap on ARM fails with ICE from the second stage
> compiler:
> 
> /home/aaro/gcctest/build/./prev-gcc/xg++

Correction: stage_curr says "stage2" after the failure. So the error is coming from a compiler built in stage1.
Comment 7 Aaro Koskinen 2014-11-09 12:59:22 UTC
Result from bisection (4.9 git branch):

611da9dd72a4c9d9ece2a8d24612e4aee435414a is the first bad commit
commit 611da9dd72a4c9d9ece2a8d24612e4aee435414a
Author: jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Wed Oct 1 14:42:46 2014 +0000

        Backported from mainline
        2014-09-18  Vladimir Makarov  <vmakarov@redhat.com>
    
        PR debug/63285
        * haifa-sched.c (schedule_block): Advance cycle at the end of BB
        if advance != 0.
Comment 8 Aaro Koskinen 2014-11-12 19:46:21 UTC
ICE backtrace seems to be same as in Bug 61430. The fix for that has not been backported to 4.9 branch. I tested it and it seems to fix the issue at hand.

The fix: https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=211701

This patch should probably be backported as it is not currently possible to
compile GCC 4.9.2 release on ARM (or maybe some newer ARM archs work).
Comment 9 Richard Biener 2014-11-24 13:47:49 UTC
Mark P1 so we don't forget to do that.
Comment 10 Ramana Radhakrishnan 2014-12-12 15:00:26 UTC
Useful to CC the original author :)
Comment 11 Ramana Radhakrishnan 2015-01-16 15:27:48 UTC
*** Bug 63771 has been marked as a duplicate of this bug. ***
Comment 12 Jakub Jelinek 2015-06-17 13:40:51 UTC
Any progress on this?
Comment 13 Maxim Kuvyrkov 2015-06-17 13:44:12 UTC
(In reply to Jakub Jelinek from comment #12)
> Any progress on this?

This has slipped off my radar.  Thanks for the ping, I'm working on this now.
Comment 14 Maxim Kuvyrkov 2015-06-17 14:50:36 UTC
OK, I'm not sorry after all, this was not supposed to be on my radar :-).

Re-assigning to the right person -- Vladimir.
Comment 15 Vladimir Makarov 2015-06-22 18:16:41 UTC
The insn in question is
 (insn 3598 3597 6907 395 (parallel [
            (set (reg:CC 100 cc)
                (compare:CC (reg:SI 307 [ ls$2 ])
                    (const_int 0 [0])))
            (set (reg:SI 192 [ D.62648 ])
                (reg:SI 307 [ ls$2 ]))
        ]) ../../gcc-4.9.2/gcc/haifa-sched.c:6368 204 {*movsi_compare0}
     (expr_list:REG_DEAD (reg:SI 307 [ ls$2 ])
        (expr_list:REG_UNUSED (reg:CC 100 cc)
            (nil))))

The insn definition is

(define_insn "*movsi_compare0"
  [(set (reg:CC CC_REGNUM)
        (compare:CC (match_operand:SI 1 "s_register_operand" "0,r")
                    (const_int 0)))
   (set (match_operand:SI 0 "s_register_operand" "=r,r")
        (match_dup 1))]

LRA choosing the first alternative where the 0 and 1 operand should be the same and generates

(insn 3598 7755 7756 395 (parallel [
            (set (reg:CC 100 cc)
                (compare:CC (reg:SI 3686 [orig:192 D.62648 ] [192])
                    (const_int 0 [0])))
            (set (reg:SI 3686 [orig:192 D.62648 ] [192])
                (reg:SI 3686 [orig:192 D.62648 ] [192]))
        ]) ../../gcc-4.9.2/gcc/haifa-sched.c:6368 204 {*movsi_compare0}
     (expr_list:REG_DEAD (reg:SI 307 [ ls$2 ])
        (expr_list:REG_UNUSED (reg:CC 100 cc)
            (nil))))

The generated ins is ok.  The code in lra_lives.c::process_bb_lives is

          if (dst_regno >= lra_constraint_new_regno_start
              && src_regno >= lra_constraint_new_regno_start)
            lra_create_copy (dst_regno, src_regno, freq);

The code was written to process reload insns only but insn 3598 looks like reload because it is a single_set insn (reg 100 is unused).

lra_create_copy has an assertion that dst_regno and src_regno are different which fails.

The fix should be trivial.  I'll commit it soon.
Comment 16 Vladimir Makarov 2015-06-22 18:17:59 UTC
Author: vmakarov
Date: Mon Jun 22 18:17:28 2015
New Revision: 224752

URL: https://gcc.gnu.org/viewcvs?rev=224752&root=gcc&view=rev
Log:
2015-06-22  Vladimir Makarov  <vmakarov@redhat.com>

	PR bootstrap/63740
	* lra-lives.c (process_bb_lives): Check insn copying the same
	reload pseudo and don't create a copy for it.


Modified:
    branches/gcc-4_9-branch/gcc/ChangeLog
    branches/gcc-4_9-branch/gcc/lra-lives.c
Comment 17 Vladimir Makarov 2015-06-22 18:46:29 UTC
Author: vmakarov
Date: Mon Jun 22 18:45:58 2015
New Revision: 224753

URL: https://gcc.gnu.org/viewcvs?rev=224753&root=gcc&view=rev
Log:
2015-06-22  Vladimir Makarov  <vmakarov@redhat.com>

	PR bootstrap/63740
	* lra-lives.c (process_bb_lives): Check insn copying the same
	reload pseudo and don't create a copy for it.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/lra-lives.c
Comment 18 Vladimir Makarov 2015-06-22 20:48:37 UTC
Author: vmakarov
Date: Mon Jun 22 20:48:05 2015
New Revision: 224761

URL: https://gcc.gnu.org/viewcvs?rev=224761&root=gcc&view=rev
Log:
2015-06-22  Vladimir Makarov  <vmakarov@redhat.com>

	PR bootstrap/63740
	* lra-lives.c (process_bb_lives): Check insn copying the same
	reload pseudo and don't create a copy for it.


Modified:
    branches/gcc-5-branch/gcc/ChangeLog
    branches/gcc-5-branch/gcc/lra-lives.c
Comment 19 Jakub Jelinek 2015-06-23 07:27:26 UTC
Fixed.