Bug 32335 - libgcc build failure, ICE in cselib_record_set, at cselib.c:1508
Summary: libgcc build failure, ICE in cselib_record_set, at cselib.c:1508
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-14 10:17 UTC by Rask Ingemann Lambertsen
Modified: 2007-06-29 21:10 UTC (History)
6 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: avr-unknown-elf
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2007-06-16 18:27:10


Attachments
gcc/xgcc -O2 libgcc2.i should trigger the bug (7.41 KB, text/plain)
2007-06-16 17:53 UTC, Mike Stein
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rask Ingemann Lambertsen 2007-06-14 10:17:26 UTC
Here's how I configure gcc:

/n/08/rask/src/gcc/configure --target=m32c-unknown-elf --disable-libgfortran --disable-multilib --disable-nls --with-newlib --enable-sim --disable-gdb

The error message:

/home/rask/build/gcc-m32c-unknown-elf/./gcc/xgcc -B/home/rask/build/gcc-m32c-unknown-elf/./gcc/ -nostdinc -B/home/rask/build/gcc-m32c-unknown-elf/m32c-unknown-elf/newlib/ -isystem /home/rask/build/gcc-m32c-unknown-elf/m32c-unknown-elf/newlib/targ-include -isystem /n/08/rask/src/gcc/newlib/libc/include -B/home/rask/build/gcc-m32c-unknown-elf/m32c-unknown-elf/libgloss/m32c -L/home/rask/build/gcc-m32c-unknown-elf/m32c-unknown-elf/libgloss/libnosys -L/n/08/rask/src/gcc/libgloss/m32c -B/usr/local/m32c-unknown-elf/bin/ -B/usr/local/m32c-unknown-elf/lib/ -isystem /usr/local/m32c-unknown-elf/include -isystem /usr/local/m32c-unknown-elf/sys-include -L/home/rask/build/gcc-m32c-unknown-elf/./ld -O2 -g -O2 -O2  -O2 -g -O2  -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE   -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -g  -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -Dinhibit_libc  -I. -I. -I../.././gcc -I/n/08/rask/src/gcc/libgcc -I/n/08/rask/src/gcc/libgcc/. -I/n/08/rask/src/gcc/libgcc/../gcc -I/n/08/rask/src/gcc/libgcc/../include  -o _muldi3.o -MT _muldi3.o -MD -MP -MF _muldi3.dep -DL_muldi3 -c /n/08/rask/src/gcc/libgcc/../gcc/libgcc2.c \

/n/08/rask/src/gcc/libgcc/../gcc/libgcc2.c: In function '__muldi3':
/n/08/rask/src/gcc/libgcc/../gcc/libgcc2.c:566: internal compiler error: in cselib_record_set, at cselib.c:1508
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
make[2]: *** [_muldi3.o] Error 1
make[2]: Leaving directory `/home/rask/build/gcc-m32c-unknown-elf/m32c-unknown-elf/libgcc'
make[1]: *** [all-target-libgcc] Error 2
make[1]: Leaving directory `/home/rask/build/gcc-m32c-unknown-elf'
make: *** [all] Error 2
Comment 1 Mike Stein 2007-06-16 16:57:41 UTC
The avr target has the same problem:

/n/07/mstein/svn/trunk/libgcc/../gcc/libgcc2.c: In function '__muldi3':
/n/07/mstein/svn/trunk/libgcc/../gcc/libgcc2.c:566: internal compiler error: in
cselib_record_set, at cselib.c:1508
Comment 2 Kenneth Zadeck 2007-06-16 17:37:24 UTC
please include the preprocessed source (the .i file) and the command line to compiler this.
Comment 3 Mike Stein 2007-06-16 17:53:57 UTC
Created attachment 13715 [details]
gcc/xgcc -O2 libgcc2.i should trigger the bug
Comment 4 Kenneth Zadeck 2007-06-17 01:23:25 UTC
Subject: Re:  libgcc build failure, ICE in cselib_record_set,
 at cselib.c:1508

zadeck at naturalbridge dot com wrote:

the new dse code is failing during a call to cselib.  However I do not
believe that the new dse is to blame.  Here is the issue.

Dse is failing at

#0  fancy_abort (file=0xc3cf76 "../../gcc32335/gcc/cselib.c", line=1508,
    function=0xc3d9f0 "cselib_record_set")
    at ../../gcc32335/gcc/diagnostic.c:656
#1  0x000000000056e59e in cselib_record_set (dest=0x2b5212d6a4e0,
    src_elt=0x1075ca0, dest_addr_elt=0x0) at
../../gcc32335/gcc/cselib.c:1508

which is the only assert in cselib_record_set.
The insn that it is chocking on is a parallel

(jump_insn 268 267 269 6
/n/07/mstein/svn/trunk/libgcc/../gcc/libgcc2.c:566 (parallel [
            (set (reg:PSI 8 sp)
                (reg:PSI 7 fb))
            (set (reg:PSI 7 fb)
                (mem:PSI (reg:PSI 8 sp) [0 S4 A8]))
            (set (reg:PSI 8 sp)
                (plus:PSI (reg:PSI 8 sp)
                    (const_int 2 [0x2])))
            (return)
        ]) -1 (nil))
$2 = void

i assume that the thing that cselib does not like is the fact that sp is
being set twice in the same insn.  I guess on thinking about it, I
really do not like this insn either. 

I checked to make sure that this was not auto-inc code on drugs.  the
same failure happens with -fno-auto-inc-dec. 

I think that dse is hitting this bug, not because the dataflow merge is
doing something stupid but because this port is (and most likely has
been for a long time) doing something stupid and the new dse code is
asking cselib to go where no cselib has gone before.

Comments?
Comment 5 Rask Ingemann Lambertsen 2007-06-17 08:43:14 UTC
I agree that the insn is invalid. It probably should be something like this:

 (parallel [
             (set (reg:PSI 7 fb)
                 (mem:PSI (reg:PSI 7 fb) [0 S4 A8]))
             (set (reg:PSI 8 sp)
                 (plus:PSI (reg:PSI 7 fb)
                     (const_int 2 [0x2])))
             (return)
         ])

I.e. one set of sp and fb each. The faulty pattern is named "epilogue_exitd". The two patterns "prologue_enter_16" and "prologue_enter_24" are also broken in that they use 
(parallel [
    ... (pre_dec (SP_REGNO))
    (set (SP_REGNO) ...)
])
which is just another invalid use of PARALLEL. DJ?

On the AVR, my bets are on the define_insn "call_prologue_saves" with two sets of (reg:HI SP_REG) inside the implicit parallel.
Comment 6 Kenneth Zadeck 2007-06-17 14:01:07 UTC
Subject: Re:  libgcc build failure, ICE in cselib_record_set,
 at cselib.c:1508

rask at sygehus dot dk wrote:
> ------- Comment #5 from rask at sygehus dot dk  2007-06-17 08:43 -------
> I agree that the insn is invalid. It probably should be something like this:
>
>  (parallel [
>              (set (reg:PSI 7 fb)
>                  (mem:PSI (reg:PSI 7 fb) [0 S4 A8]))
>              (set (reg:PSI 8 sp)
>                  (plus:PSI (reg:PSI 7 fb)
>                      (const_int 2 [0x2])))
>              (return)
>          ])
>
> I.e. one set of sp and fb each. The faulty pattern is named "epilogue_exitd".
> The two patterns "prologue_enter_16" and "prologue_enter_24" are also broken in
> that they use 
> (parallel [
>     ... (pre_dec (SP_REGNO))
>     (set (SP_REGNO) ...)
> ])
> which is just another invalid use of PARALLEL. DJ?
>
> On the AVR, my bets are on the define_insn "call_prologue_saves" with two sets
> of (reg:HI SP_REG) inside the implicit parallel.
>
>
>   
i assume that you will resolve this with the port maintainers and
contact me when you hit the next dataflow related problem.

Good luck.

Kenny
Comment 7 patchapp@dberlin.org 2007-06-18 12:40:30 UTC
Subject: Bug number PR target/32335

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-06/msg01233.html
Comment 8 aesok 2007-06-18 13:33:49 UTC
Im working on patch for avr target.

Anatoly.
Comment 9 Rask Ingemann Lambertsen 2007-06-19 17:35:28 UTC
Subject: Bug 32335

Author: rask
Date: Tue Jun 19 17:35:16 2007
New Revision: 125853

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=125853
Log:
2007-06-19  Rask Ingemann Lambertsen  <rask@sygehus.dk>

	PR target/32335
	* config/m32c/m32c.c: Include dataflow header file.
	(m32c_emit_prologue): Adjust for prologue insn change.
	* config/m32c/prologue.md (prologue_enter_16): Only modify SP_REGNO
	once inside a PARALLEL. Assume frame size passed in operand 0
	includes space to save the fb register.
	(prologue_enter_24): Likewise.
	(epilogue_exitd): Only modify SP_REGNO once inside a PARALLEL.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/m32c/m32c.c
    trunk/gcc/config/m32c/prologue.md

Comment 10 Rask Ingemann Lambertsen 2007-06-20 13:41:43 UTC
I'm adding the m32c back because the testcase for bug 32069 fails with optimization turned on:

$ ./xgcc -B./ /n/08/rask/src/gcc/gcc/testsuite/gcc.dg/pr32069.c -S -dp -o /dev/null -O1
/n/08/rask/src/gcc/gcc/testsuite/gcc.dg/pr32069.c: In function 'segfault':
/n/08/rask/src/gcc/gcc/testsuite/gcc.dg/pr32069.c:7: internal compiler error: in cselib_record_set, at cselib.c:1508

(gdb) call debug_rtx(insn)
(jump_insn 62 61 63 2 /n/08/rask/src/gcc/gcc/testsuite/gcc.dg/pr32069.c:7 (parallel [
            (set (reg:PSI 8 sp)
                (plus:PSI (reg:PSI 7 fb)
                    (const_int 2 [0x2])))
            (set (reg:PSI 7 fb)
                (mem:PSI (reg:PSI 7 fb) [0 S4 A8]))
            (return)
        ]) -1 (nil))
Comment 11 Rask Ingemann Lambertsen 2007-06-20 13:52:23 UTC
Ah, notice the mismatch in register sizes between prologue and epilogue:
(insn/f 59 5 60 2 /n/08/rask/src/gcc/gcc/testsuite/gcc.dg/pr32069.c:5 (parallel [
            (set/f (mem:HI (plus:HI (reg/f:HI 8 sp)
                        (const_int -2 [0xfffffffe])) [0 S2 A8])
                (reg/f:HI 7 fb))
            (set/f (reg/f:HI 7 fb)
                (reg/f:HI 8 sp))
            (set/f (reg/f:HI 8 sp)
                (minus:HI (reg/f:HI 8 sp)
                    (const_int 2 [0x2])))
        ]) -1 (nil))
Comment 12 patchapp@dberlin.org 2007-06-20 19:35:17 UTC
Subject: Bug number PR target/32335

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-06/msg01501.html
Comment 13 Rask Ingemann Lambertsen 2007-06-20 19:57:49 UTC
Subject: Bug 32335

Author: rask
Date: Wed Jun 20 19:57:32 2007
New Revision: 125892

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=125892
Log:
2007-06-20  Rask Ingemann Lambertsen  <rask@sygehus.dk>

	PR target/32335
	* config/m32c/m32c.c (m32c_emit_epilogue): Use new HImode epilogue
	for TARGET_A16.
	* config/m32c/prologue.md (epilogue_exitd_16): New.
	(epilogue_reit_16): New.
	(epilogue_exitd): Rename to epilogue_exitd_24.
	(epilogue_reit): Rename to epilogue_reit_24.

Modified:
    trunk/gcc/config/m32c/m32c.c
    trunk/gcc/config/m32c/prologue.md

Comment 14 Rask Ingemann Lambertsen 2007-06-20 19:59:13 UTC
Subject: Bug 32335

Author: rask
Date: Wed Jun 20 19:58:57 2007
New Revision: 125893

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=125893
Log:
2007-06-20  Rask Ingemann Lambertsen  <rask@sygehus.dk>

	PR target/32335
	* config/m32c/m32c.c (m32c_emit_epilogue): Use new HImode epilogue
	for TARGET_A16.
	* config/m32c/prologue.md (epilogue_exitd_16): New.
	(epilogue_reit_16): New.
	(epilogue_exitd): Rename to epilogue_exitd_24.
	(epilogue_reit): Rename to epilogue_reit_24.

Modified:
    trunk/gcc/ChangeLog

Comment 15 aesok 2007-06-29 20:06:10 UTC
Subject: Bug 32335

Author: aesok
Date: Fri Jun 29 20:05:56 2007
New Revision: 126121

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=126121
Log:
	PR target/32335
	* config/avr/avr.c: Include dataflow header file.
	(expand_prologue): Adjust for prologue insn change.
	* config/avr/avr.md (call_prologue_saves): Only modify REG_SP once
	inside a insn.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/avr/avr.c
    trunk/gcc/config/avr/avr.md

Comment 16 aesok 2007-06-29 20:15:05 UTC
Fixed for avr target.
Comment 17 Rask Ingemann Lambertsen 2007-06-29 21:10:27 UTC
Fixed for both m32c and avr, so closing.