Bug 40587 - [4.4/4.5 Regression] Revision 139590 caused ICE in emit_swap_insn at reg-stack.c:827
Summary: [4.4/4.5 Regression] Revision 139590 caused ICE in emit_swap_insn at reg-stac...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: 4.4.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-29 12:50 UTC by Philip Blakely
Modified: 2019-09-05 04:35 UTC (History)
3 users (show)

See Also:
Host:
Target: i586-redhat-linux
Build:
Known to work: 4.3.4
Known to fail: 4.4.0
Last reconfirmed: 2009-06-29 14:36:37


Attachments
Minimal test-case test.f (144 bytes, text/plain)
2009-06-29 12:51 UTC, Philip Blakely
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Philip Blakely 2009-06-29 12:50:18 UTC
See attached test-case, test.f:

> gfortran -c test.f -O1
Compiles OK

> gfortran -c test.f -O2
test.f: In function "test":
test.f:13: internal compiler error: in emit_swap_insn, at reg-stack.c:827

> gfortran -v
Using built-in specs.
Target: i586-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch=i586 --build=i586-redhat-linux
Thread model: posix
gcc version 4.4.0 20090506 (Red Hat 4.4.0-4) (GCC) 

> uname -a
Linux pmblakely 2.6.29.5-191.fc11.i686.PAE #1 SMP Tue Jun 16 23:19:53 EDT 2009 i686 i686 i386 GNU/Linux

This looks similar to the test-case for bug 39607 (fixed), in that the ICE occurs when returned/class variables are only updated if a certain condition holds, and otherwise a separate function is called, resulting in those variables not being updated.

Note that the test-case for bug 39607 compiles correctly (i.e. no ICE) for this version of gcc, so it's not a case of that patch not having gone through for this compiler version.
Comment 1 Philip Blakely 2009-06-29 12:51:26 UTC
Created attachment 18091 [details]
Minimal test-case test.f
Comment 2 Andrew Pinski 2009-06-29 14:25:41 UTC
Didn't GCC say report the bug to http://bugzilla.redhat.com/bugzilla ?
Comment 3 Philip Blakely 2009-06-29 14:28:47 UTC
(In reply to comment #2)
> Didn't GCC say report the bug to http://bugzilla.redhat.com/bugzilla ?
> 

Oh, yes. Sorry. I'll post it there.
Comment 4 Uroš Bizjak 2009-06-29 14:36:37 UTC
The test also fails with FSF 4.4.1 and 4.5.0, but not with 4.3.4, which makes for 4.4 regression.
Comment 5 H.J. Lu 2009-06-29 16:18:00 UTC
Revision 139590 (IRA):

http://gcc.gnu.org/ml/gcc-cvs/2008-08/msg01152.html

is very likely the cause.
Comment 6 H.J. Lu 2009-06-29 16:57:15 UTC
Revision 139590 is the cause.
Comment 7 Vladimir Makarov 2009-07-03 12:38:50 UTC
Thanks for reporting this.  I started to work on the PR.
Comment 8 Vladimir Makarov 2009-07-03 21:30:07 UTC
The problem was in usage of df_get_live_out in ira.c::build_insn_chain instead of DF_LR_OUT.  Later contains r58 (assigned to st0 register) and it creates restore insn for st0 after the call and prevents reg-stack crashing.

The original IRA patch used DF_LR_OUT.  After removing the old RA, accidentally IRA started to use df_get_live_out used by the old RA.

I'll send a patch solving the problem soon.
Comment 9 Vladimir Makarov 2009-07-03 22:36:50 UTC
Subject: Bug 40587

Author: vmakarov
Date: Fri Jul  3 22:36:31 2009
New Revision: 149212

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=149212
Log:
2009-07-03  Vladimir Makarov  <vmakarov@redhat.com>

	PR target/40587
	* ira.c (build_insn_chain): Use DF_LR_OUT instead of
	df_get_live_out.
	* testsuite/gfortran.dg/pr40587.f: New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/pr40587.f
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/ira.c

Comment 10 Vladimir Makarov 2009-07-03 22:46:42 UTC
Subject: Bug 40587

Author: vmakarov
Date: Fri Jul  3 22:46:30 2009
New Revision: 149213

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=149213
Log:
2009-07-03  Vladimir Makarov  <vmakarov@redhat.com>

	PR target/40587
	* ira.c (build_insn_chain): Use DF_LR_OUT instead of
	df_get_live_out.
	* testsuite/gfortran.dg/pr40587.f: New test.


Added:
    branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/pr40587.f
Modified:
    branches/gcc-4_4-branch/gcc/ChangeLog
    branches/gcc-4_4-branch/gcc/ira.c

Comment 11 Uroš Bizjak 2009-07-04 08:39:40 UTC
Fixed.