Bug 60193 - [4.7/4.8 regression] ICE on big nested frame
Summary: [4.7/4.8 regression] ICE on big nested frame
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.7.4
: P3 normal
Target Milestone: 4.7.4
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on: 56807
Blocks:
  Show dependency treegraph
 
Reported: 2014-02-14 09:29 UTC by Eric Botcazou
Modified: 2014-02-18 13:49 UTC (History)
2 users (show)

See Also:
Host:
Target: x86_64-*-mingw
Build:
Known to work:
Known to fail:
Last reconfirmed: 2014-02-14 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Botcazou 2014-02-14 09:29:37 UTC
The fix for PR target/56807 has introduced ICEs on big nested frames:

eric@polaris:~/gnat/bugs/N213-061> cat t.c
void foo (int i)
{
  void nested (void)
  {
    char arr[1U << 31];
    arr[i] = 0;
  }

  nested ();
}
eric@polaris:~/gnat/bugs/N213-061> ~/gnat/gnat7_47/x86_64-pc-mingw32/gcc/cc1 -quiet t.c
t.c: In function 'nested':
t.c:7:3: internal compiler error: in change_address_1, at emit-rtl.c:2001
Please submit a full bug report,
with preprocessed source if appropriate.
Contact <http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 Kai Tietz 2014-02-14 09:39:22 UTC
Hmm, I can't reproduce this with recent 4.9 gcc.  There is no ICE.
Comment 2 Kai Tietz 2014-02-14 09:51:06 UTC
I built recent 4.8 cross-compiler and tested.  Again no ICE for this testcase
Comment 3 Eric Botcazou 2014-02-14 10:00:47 UTC
Sorry, minor pilot error, try with:

void foo (int i)
{
  void nested (void)
  {
    char arr[(1U << 31) + 4];
    arr[i] = 0;
  }

  nested ();
}
Comment 4 Kai Tietz 2014-02-14 10:21:19 UTC
Confirmed.  It seems to be related to array-size?!?

During debugging I found that r10 seems to live, and rax doesn't. I will look into it.
Comment 5 Kai Tietz 2014-02-14 11:03:50 UTC
Ok found issue.  Problem is that x86_64 instructions have a maximum-offset of 2^31.  Legitimate instruction doesn't detect here that constant is unsigned, so it fails.  Nevertheless issue would happen always too for (1U << 32) even for x86_64 abi.
Solution might be here to use the eax-register for addressing instead of constant.
Comment 6 Kai Tietz 2014-02-14 11:52:00 UTC
Patch posted to ML at http://gcc.gnu.org/ml/gcc-patches/2014-02/msg00900.html
Comment 7 Kai Tietz 2014-02-18 12:49:47 UTC
Author: ktietz
Date: Tue Feb 18 12:49:15 2014
New Revision: 207844

URL: http://gcc.gnu.org/viewcvs?rev=207844&root=gcc&view=rev
Log:
2014-02-18  Kai Tietz  <ktietz@redhat.com>

	PR target/60193
	* config/i386/i386.c (ix86_expand_prologue): Use
	rax register as displacement for restoring %r10, %rax.
	Additional fix wrong offset for restoring both-registers.

2014-02-18  Kai Tietz  <ktietz@redhat.com>

	PR target/60193
	* gcc.target/i386/nest-1.c: New testcase.


Added:
    trunk/gcc/testsuite/gcc.target/i386/nest-1.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c
    trunk/gcc/testsuite/ChangeLog
Comment 8 Jakub Jelinek 2014-02-18 12:53:37 UTC
Fixed on the trunk then.
Comment 9 Kai Tietz 2014-02-18 12:58:03 UTC
Author: ktietz
Date: Tue Feb 18 12:57:32 2014
New Revision: 207845

URL: http://gcc.gnu.org/viewcvs?rev=207845&root=gcc&view=rev
Log:
2014-02-18  Kai Tietz  <ktietz@redhat.com>

	Backport from mainline
	PR target/60193
	* config/i386/i386.c (ix86_expand_prologue): Use
	rax register as displacement for restoring %r10, %rax.
	Additional fix wrong offset for restoring both-registers.

2014-02-18  Kai Tietz  <ktietz@redhat.com>

	PR target/60193
	* gcc.target/i386/nest-1.c: New testcase.


Added:
    branches/gcc-4_8-branch/gcc/testsuite/gcc.target/i386/nest-1.c
Modified:
    branches/gcc-4_8-branch/gcc/ChangeLog
    branches/gcc-4_8-branch/gcc/config/i386/i386.c
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog
Comment 10 Kai Tietz 2014-02-18 13:47:09 UTC
Author: ktietz
Date: Tue Feb 18 13:46:38 2014
New Revision: 207846

URL: http://gcc.gnu.org/viewcvs?rev=207846&root=gcc&view=rev
Log:
2014-02-18  Kai Tietz  <ktietz@redhat.com>

	Backport from mainline
	PR target/60193
	* config/i386/i386.c (ix86_expand_prologue): Use
	rax register as displacement for restoring %r10, %rax.
	Additional fix wrong offset for restoring both-registers.

2014-02-18  Kai Tietz  <ktietz@redhat.com>

	PR target/60193
	* gcc.target/i386/nest-1.c: New testcase.


Added:
    branches/gcc-4_7-branch/gcc/testsuite/gcc.target/i386/nest-1.c
Modified:
    branches/gcc-4_7-branch/gcc/ChangeLog
    branches/gcc-4_7-branch/gcc/config/i386/i386.c
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
Comment 11 Kai Tietz 2014-02-18 13:49:32 UTC
Fixed on all open branches.  Close bug