public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, i386]: Fix PR target/48723
@ 2011-04-22 19:01 Uros Bizjak
  2011-04-22 22:29 ` Eric Botcazou
       [not found] ` <201104302356.06183.ebotcazou@adacore.com>
  0 siblings, 2 replies; 6+ messages in thread
From: Uros Bizjak @ 2011-04-22 19:01 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 779 bytes --]

Hello!

Attached one-liner fixes PR target/48723, ICE in
ix86_expand_prologue() with -fstack-check + function returning struct,
on corei7-avx. The problem was, that we forgot to update accounting
info when ix86_adjust_stack_and_probe adjusted stack pointer (in this
particular case, m->fs.sp_offset was set by stack realignment code for
AVX 32byte stack alignment.

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.

testsuite/ChangeLog:

2011-04-22  Uros Bizjak  <ubizjak@gmail.com>

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

Tested on x86_64-pc-linux-gnu {,-m32} AVX target.

Patch was committed to mainline and 4.6 branch.

Uros.

[-- Attachment #2: p.diff.txt --]
[-- Type: text/plain, Size: 776 bytes --]

Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 172860)
+++ config/i386/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
Index: testsuite/gcc.target/i386/pr48723.c
===================================================================
--- testsuite/gcc.target/i386/pr48723.c	(revision 0)
+++ testsuite/gcc.target/i386/pr48723.c	(revision 0)
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-fstack-check -mavx" } */
+
+struct S0
+{
+  int f0, f1, f2, f3;
+} g_106;
+
+struct S0
+func_99 ()
+{
+  return (g_106);
+}

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH, i386]: Fix PR target/48723
  2011-04-22 19:01 [PATCH, i386]: Fix PR target/48723 Uros Bizjak
@ 2011-04-22 22:29 ` Eric Botcazou
  2011-04-23  9:10   ` Uros Bizjak
  2011-04-23 10:39   ` Uros Bizjak
       [not found] ` <201104302356.06183.ebotcazou@adacore.com>
  1 sibling, 2 replies; 6+ messages in thread
From: Eric Botcazou @ 2011-04-22 22:29 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: gcc-patches

> Attached one-liner fixes PR target/48723, ICE in
> ix86_expand_prologue() with -fstack-check + function returning struct,
> on corei7-avx. The problem was, that we forgot to update accounting
> info when ix86_adjust_stack_and_probe adjusted stack pointer (in this
> particular case, m->fs.sp_offset was set by stack realignment code for
> AVX 32byte stack alignment.

Take a look at line 10165 of config/i386/i386.c.

-- 
Eric Botcazou

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH, i386]: Fix PR target/48723
  2011-04-22 22:29 ` Eric Botcazou
@ 2011-04-23  9:10   ` Uros Bizjak
  2011-04-30 21:23     ` Eric Botcazou
  2011-04-23 10:39   ` Uros Bizjak
  1 sibling, 1 reply; 6+ messages in thread
From: Uros Bizjak @ 2011-04-23  9:10 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: gcc-patches

On Fri, Apr 22, 2011 at 11:38 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> Attached one-liner fixes PR target/48723, ICE in
>> ix86_expand_prologue() with -fstack-check + function returning struct,
>> on corei7-avx. The problem was, that we forgot to update accounting
>> info when ix86_adjust_stack_and_probe adjusted stack pointer (in this
>> particular case, m->fs.sp_offset was set by stack realignment code for
>> AVX 32byte stack alignment.
>
> Take a look at line 10165 of config/i386/i386.c.


Index: i386.c
===================================================================
--- i386.c	(revision 172866)
+++ i386.c	(working copy)
@@ -10149,7 +10149,7 @@ ix86_adjust_stack_and_probe (const HOST_
   /* Even if the stack pointer isn't the CFA register, we need to correctly
      describe the adjustments made to it, in particular differentiate the
      frame-related ones from the frame-unrelated ones.  */
-  if (size > 0)
+  if (size != 0)
     {
       rtx expr = gen_rtx_SEQUENCE (VOIDmode, rtvec_alloc (2));
       XVECEXP (expr, 0, 0)

Uros.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH, i386]: Fix PR target/48723
  2011-04-22 22:29 ` Eric Botcazou
  2011-04-23  9:10   ` Uros Bizjak
@ 2011-04-23 10:39   ` Uros Bizjak
  1 sibling, 0 replies; 6+ messages in thread
From: Uros Bizjak @ 2011-04-23 10:39 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: gcc-patches

On Fri, Apr 22, 2011 at 11:38 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:

>> Attached one-liner fixes PR target/48723, ICE in
>> ix86_expand_prologue() with -fstack-check + function returning struct,
>> on corei7-avx. The problem was, that we forgot to update accounting
>> info when ix86_adjust_stack_and_probe adjusted stack pointer (in this
>> particular case, m->fs.sp_offset was set by stack realignment code for
>> AVX 32byte stack alignment.
>
> Take a look at line 10165 of config/i386/i386.c.

I have reverted my original patch.

Uros.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH, i386]: Fix PR target/48723
  2011-04-23  9:10   ` Uros Bizjak
@ 2011-04-30 21:23     ` Eric Botcazou
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Botcazou @ 2011-04-30 21:23 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1203 bytes --]

On Saturday 23 April 2011 09:35:38 Uros Bizjak wrote:
> Index: i386.c
> ===================================================================
> --- i386.c	(revision 172866)
> +++ i386.c	(working copy)
> @@ -10149,7 +10149,7 @@ ix86_adjust_stack_and_probe (const HOST_
>    /* Even if the stack pointer isn't the CFA register, we need to
> correctly describe the adjustments made to it, in particular differentiate
> the frame-related ones from the frame-unrelated ones.  */
> -  if (size > 0)
> +  if (size != 0)
>      {
>        rtx expr = gen_rtx_SEQUENCE (VOIDmode, rtvec_alloc (2));
>        XVECEXP (expr, 0, 0)

Probing for a negative size doesn't make much sense; we shouldn't be there if 
the size to allocate is negative.  Is that really intended?  The code without 
stack checking is:

        pushq   %rbp
.LCFI0:
        movq    %rsp, %rbp
.LCFI1:
        andq    $-32, %rsp
        addq    $16, %rsp

which looks weird.  If this is nevertheless correct, then the fix for the 
problem is attached.  Tested on x86_64-suse-linux.


	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.


-- 
Eric Botcazou

[-- Attachment #2: pr48723.diff --]
[-- Type: text/x-diff, Size: 715 bytes --]

Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 173209)
+++ config/i386/i386.c	(working copy)
@@ -10619,8 +10619,8 @@ ix86_expand_prologue (void)
     }
 
   /* The stack has already been decremented by the instruction calling us
-     so we need to probe unconditionally to preserve the protection area.  */
-  if (flag_stack_check == STATIC_BUILTIN_STACK_CHECK)
+     so probe if the size is non-negative to preserve the protection area.  */
+  if (allocate >= 0 && flag_stack_check == STATIC_BUILTIN_STACK_CHECK)
     {
       /* We expect the registers to be saved when probes are used.  */
       gcc_assert (int_registers_saved);

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH, i386]: Fix PR target/48723
       [not found]   ` <BANLkTikeVF8NGfT3NCY3f2nTUzSWP-ehXg@mail.gmail.com>
@ 2011-05-01  8:15     ` Eric Botcazou
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Botcazou @ 2011-05-01  8:15 UTC (permalink / raw)
  To: H.J. Lu; +Cc: gcc-patches, Uros Bizjak

> What is wrong? x86-64 has 128byte redzone.

Nothing wrong, just strange.  ISTM that it doesn't serve any useful purpose.
And I'm not sure that the rest of the code in ix86_expand_prologue is really 
prepared for a negative size either.

-- 
Eric Botcazou

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-05-01  8:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-22 19:01 [PATCH, i386]: Fix PR target/48723 Uros Bizjak
2011-04-22 22:29 ` Eric Botcazou
2011-04-23  9:10   ` Uros Bizjak
2011-04-30 21:23     ` Eric Botcazou
2011-04-23 10:39   ` Uros Bizjak
     [not found] ` <201104302356.06183.ebotcazou@adacore.com>
     [not found]   ` <BANLkTikeVF8NGfT3NCY3f2nTUzSWP-ehXg@mail.gmail.com>
2011-05-01  8:15     ` Eric Botcazou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).