Bug 48723 - ICE on function returning structure with -fstack-check on corei7-avx
Summary: ICE on function returning structure with -fstack-check on corei7-avx
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 4.6.1
Assignee: Eric Botcazou
URL: http://gcc.gnu.org/ml/gcc-patches/201...
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-22 08:58 UTC by Arthur O'Dwyer
Modified: 2011-05-03 07:23 UTC (History)
3 users (show)

See Also:
Host:
Target: x86-64-pc-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-04-22 09:57:45


Attachments
Output of "ajo-gcc -v -w -march=corei7-avx -O0 -fstack-check -c test1558415197-reduced.c" (816 bytes, text/plain)
2011-04-22 08:58 UTC, Arthur O'Dwyer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Arthur O'Dwyer 2011-04-22 08:58:51 UTC
Created attachment 24072 [details]
Output of "ajo-gcc -v -w -march=corei7-avx -O0  -fstack-check -c test1558415197-reduced.c"

This reproduces for me with svn revision 172796 (2011-04-20).  I'm on Ubuntu 10.10, x86-64.  Notice that corei7-avx is a new target in 4.6.0.

cat >test1558415197-reduced.c <<EOF
extern struct S0 {
   int f0, f1, f2, f3;
} g_106;
struct S0 func_99() {
   return (g_106);
}

EOF
gcc -w -march=corei7-avx -O0 -fstack-check test1558415197-reduced.c -c

test1558415197-reduced.c: In function ‘func_99’:
test1558415197-reduced.c:6:1: internal compiler error: in ix86_expand_prologue, at config/i386/i386.c:10721

This test case is reduced from the output of Csmith
(http://embed.cs.utah.edu/csmith/), using the following command line:
csmith --bitfields --packed-struct -s 1558415197 > test1558415197.c
Comment 1 Uroš Bizjak 2011-04-22 09:57:45 UTC
Confirmed.
Comment 2 Uroš Bizjak 2011-04-22 11:28:30 UTC
Patch in testing:

Index: i386.c
===================================================================
--- i386.c	(revision 172856)
+++ i386.c	(working copy)
@@ -10628,6 +10628,7 @@ ix86_expand_prologue (void)
       if (STACK_CHECK_MOVING_SP)
 	{
 	  ix86_adjust_stack_and_probe (allocate);
+	  m->fs.sp_offset += allocate;
 	  allocate = 0;
 	}
       else
Comment 3 uros 2011-04-22 18:40:26 UTC
Author: uros
Date: Fri Apr 22 18:40:23 2011
New Revision: 172866

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172866
Log:
	PR target/48723
	* config/i386/i386.c (ix86_expand_prologue): Update m->fs.sp_offset
	after the call to ix86_adjust_stack_and_probe.

testsuite/ChangeLog:

	PR target/48723
	* gcc.target/i386/pr48723.c: New test.


Added:
    trunk/gcc/testsuite/gcc.target/i386/pr48723.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c
    trunk/gcc/testsuite/ChangeLog
Comment 4 uros 2011-04-22 18:44:00 UTC
Author: uros
Date: Fri Apr 22 18:43:57 2011
New Revision: 172867

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172867
Log:
	PR target/48723
	* config/i386/i386.c (ix86_expand_prologue): Update m->fs.sp_offset
	after the call to ix86_adjust_stack_and_probe.

testsuite/ChangeLog:

	PR target/48723
	* gcc.target/i386/pr48723.c: New test.


Added:
    branches/gcc-4_6-branch/gcc/testsuite/gcc.target/i386/pr48723.c
Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/config/i386/i386.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
Comment 5 Uroš Bizjak 2011-04-22 18:56:22 UTC
Fixed, but triggers PR 48723 again.
Comment 6 Uroš Bizjak 2011-04-22 18:57:22 UTC
(In reply to comment #5)
> Fixed, but triggers PR 48723 again.

Eh, ICEs in the testcase for PR 48142.
Comment 7 uros 2011-04-23 07:41:48 UTC
Author: uros
Date: Sat Apr 23 07:41:43 2011
New Revision: 172893

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172893
Log:
	Revert:
	2011-04-22  Uros Bizjak  <ubizjak@gmail.com>

	PR target/48723
	* config/i386/i386.c (ix86_expand_prologue): Update m->fs.sp_offset
	after the call to ix86_adjust_stack_and_probe.

Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/config/i386/i386.c
Comment 8 uros 2011-04-23 07:43:54 UTC
Author: uros
Date: Sat Apr 23 07:43:50 2011
New Revision: 172894

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172894
Log:
	Revert:
	2011-04-22  Uros Bizjak  <ubizjak@gmail.com>

	PR target/48723
	* config/i386/i386.c (ix86_expand_prologue): Update m->fs.sp_offset
	after the call to ix86_adjust_stack_and_probe.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c
Comment 9 Zdenek Sojka 2011-04-26 06:10:02 UTC
This task is in state RESOLVED FIXED, but the testcase still ICEs in current trunk (r172940, x86_64-linux) as the fix was reverted. Where can I track this ICE? Thanks
Comment 10 Uroš Bizjak 2011-04-26 07:27:17 UTC
.
Comment 11 Eric Botcazou 2011-04-27 13:12:17 UTC
Fixing.  I'd suggest CCing me for anything related to -fstack-check.
Comment 12 Eric Botcazou 2011-05-03 07:20:06 UTC
Author: ebotcazou
Date: Tue May  3 07:20:01 2011
New Revision: 173288

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=173288
Log:
	PR target/48723
	* config/i386/i386.c (ix86_expand_prologue): Do not probe the stack
	for -fstack-check if the size to allocate is negative.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c
Comment 13 Eric Botcazou 2011-05-03 07:20:35 UTC
Author: ebotcazou
Date: Tue May  3 07:20:30 2011
New Revision: 173289

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=173289
Log:
	PR target/48723
	* config/i386/i386.c (ix86_expand_prologue): Do not probe the stack
	for -fstack-check if the size to allocate is negative.

Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/config/i386/i386.c
Comment 14 Eric Botcazou 2011-05-03 07:23:42 UTC
.