diff mbox

PING: PATCH: PR middle-end/45234: [4.4/4.5/4.6 Regression] ICE in expand_call, at calls.c:2845 when passing aligned function argument from unaligned stack after alloca

Message ID AANLkTinU5tc8jyoEED0WE4TeTu8cN81PyGBT7TLpKOLY@mail.gmail.com
State New
Headers show

Commit Message

H.J. Lu Aug. 26, 2010, 5:18 p.m. UTC
On Thu, Aug 26, 2010 at 9:19 AM, Dominique Dhumieres <dominiq@lps.ens.fr> wrote:
> On x86_64-apple-darwin10.4.0 this patch caused the following failures:
> FAIL: g++.dg/eh/async-unwind2.C execution test
> FAIL: gcc.c-torture/execute/struct-ret-1.c execution,  -Os
> FAIL: libgomp.c++/collapse-2.C  -O1  execution test
> FAIL: libgomp.c++/for-1.C  -O1  execution test
> FAIL: libgomp.c++/for-8.C  -O1  execution test
> at r163063 and with -m32.
>

I need to take pending_stack_adjust into account.  I am testing it on Linux/ia32
and Linux/x86-64. Can you try this new patch on Darwin?

Thanks.

Comments

Dominique d'Humières Aug. 26, 2010, 7:55 p.m. UTC | #1
> Can you try this new patch on Darwin?

Partial testing shows that the reported failures are fixed by
the new patch. I am starting a full regstrap, but won't get
the results before tomorrow.

Thanks,

Dominique
H.J. Lu Aug. 26, 2010, 8:19 p.m. UTC | #2
On Thu, Aug 26, 2010 at 12:55 PM, Dominique Dhumieres
<dominiq@lps.ens.fr> wrote:
>> Can you try this new patch on Darwin?
>
> Partial testing shows that the reported failures are fixed by
> the new patch. I am starting a full regstrap, but won't get
> the results before tomorrow.
>

I tested it on Linux/ia32 and Linux/x86-64.  There are no regressions.
Jack Howarth Sept. 2, 2010, 9:25 p.m. UTC | #3
On Thu, Aug 26, 2010 at 01:19:45PM -0700, H.J. Lu wrote:
> On Thu, Aug 26, 2010 at 12:55 PM, Dominique Dhumieres
> <dominiq@lps.ens.fr> wrote:
> >> Can you try this new patch on Darwin?
> >
> > Partial testing shows that the reported failures are fixed by
> > the new patch. I am starting a full regstrap, but won't get
> > the results before tomorrow.
> >
> 
> I tested it on Linux/ia32 and Linux/x86-64.  There are no regressions.
> 

H.J., 
    Tested gcc-pr45234-2.patch with http://gcc.gnu.org/ml/gcc-patches/2010-09/msg00184.html
on x86_64-apple-darwin10 with no regressions...

http://gcc.gnu.org/ml/gcc-testresults/2010-09/msg00168.html

currently regtesting the above two patches applied to r163768 with
the proposed fix for PR45484 applied as well (http://gcc.gnu.org/ml/gcc-bugs/2010-09/msg00315.html).
            Jack

> 
> 
> -- 
> H.J.
H.J. Lu Sept. 17, 2010, 3:55 p.m. UTC | #4
On Thu, Aug 26, 2010 at 10:18 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Thu, Aug 26, 2010 at 9:19 AM, Dominique Dhumieres <dominiq@lps.ens.fr> wrote:
>> On x86_64-apple-darwin10.4.0 this patch caused the following failures:
>> FAIL: g++.dg/eh/async-unwind2.C execution test
>> FAIL: gcc.c-torture/execute/struct-ret-1.c execution,  -Os
>> FAIL: libgomp.c++/collapse-2.C  -O1  execution test
>> FAIL: libgomp.c++/for-1.C  -O1  execution test
>> FAIL: libgomp.c++/for-8.C  -O1  execution test
>> at r163063 and with -m32.
>>
>
> I need to take pending_stack_adjust into account.  I am testing it on Linux/ia32
> and Linux/x86-64. Can you try this new patch on Darwin?
>

PING.

http://gcc.gnu.org/ml/gcc-patches/2010-08/msg01916.html
Richard Henderson Sept. 17, 2010, 5:52 p.m. UTC | #5
On 09/17/2010 08:55 AM, H.J. Lu wrote:
> On Thu, Aug 26, 2010 at 10:18 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Thu, Aug 26, 2010 at 9:19 AM, Dominique Dhumieres <dominiq@lps.ens.fr> wrote:
>>> On x86_64-apple-darwin10.4.0 this patch caused the following failures:
>>> FAIL: g++.dg/eh/async-unwind2.C execution test
>>> FAIL: gcc.c-torture/execute/struct-ret-1.c execution,  -Os
>>> FAIL: libgomp.c++/collapse-2.C  -O1  execution test
>>> FAIL: libgomp.c++/for-1.C  -O1  execution test
>>> FAIL: libgomp.c++/for-8.C  -O1  execution test
>>> at r163063 and with -m32.
>>>
>>
>> I need to take pending_stack_adjust into account.  I am testing it on Linux/ia32
>> and Linux/x86-64. Can you try this new patch on Darwin?
>>
> 
> PING.
> 
> http://gcc.gnu.org/ml/gcc-patches/2010-08/msg01916.html

This is ok, I guess.

All these sorts of scattered patches suggests that it would be 
better to have a new pass scan the entire function to collect
the desired stack alignment, rather than scatter code all over
the place.  That's probably not in the cards for 4.6 though,
unless someone gets busy in a hurry.


r~
H.J. Lu Sept. 20, 2010, 7:33 p.m. UTC | #6
On Fri, Sep 17, 2010 at 10:52 AM, Richard Henderson <rth@redhat.com> wrote:
> On 09/17/2010 08:55 AM, H.J. Lu wrote:
>> On Thu, Aug 26, 2010 at 10:18 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>> On Thu, Aug 26, 2010 at 9:19 AM, Dominique Dhumieres <dominiq@lps.ens.fr> wrote:
>>>> On x86_64-apple-darwin10.4.0 this patch caused the following failures:
>>>> FAIL: g++.dg/eh/async-unwind2.C execution test
>>>> FAIL: gcc.c-torture/execute/struct-ret-1.c execution,  -Os
>>>> FAIL: libgomp.c++/collapse-2.C  -O1  execution test
>>>> FAIL: libgomp.c++/for-1.C  -O1  execution test
>>>> FAIL: libgomp.c++/for-8.C  -O1  execution test
>>>> at r163063 and with -m32.
>>>>
>>>
>>> I need to take pending_stack_adjust into account.  I am testing it on Linux/ia32
>>> and Linux/x86-64. Can you try this new patch on Darwin?
>>>
>>
>> PING.
>>
>> http://gcc.gnu.org/ml/gcc-patches/2010-08/msg01916.html
>
> This is ok, I guess.
>
> All these sorts of scattered patches suggests that it would be
> better to have a new pass scan the entire function to collect
> the desired stack alignment, rather than scatter code all over
> the place.  That's probably not in the cards for 4.6 though,
> unless someone gets busy in a hurry.
>

OK to backport it to 4.4/4.5 branches?

Thanks.
Richard Henderson Sept. 20, 2010, 8:18 p.m. UTC | #7
On 09/20/2010 12:33 PM, H.J. Lu wrote:
> OK to backport it to 4.4/4.5 branches?

Yeah, sure.


r~
Eric Botcazou Sept. 21, 2010, 7:30 p.m. UTC | #8
> > OK to backport it to 4.4/4.5 branches?
>
> Yeah, sure.

This badly breaks on i586 though.  On the 4.5 branch:

                === gcc tests ===

Schedule of variations:
    unix

Running target unix
Using /usr/share/dejagnu/baseboards/unix.exp as board description file for 
target.
Using /usr/share/dejagnu/config/unix.exp as generic interface file for target.
Using /home/eric/svn/gcc-4_5-branch/gcc/testsuite/config/default.exp as 
tool-and-target-specific interface file.
Running /home/eric/svn/gcc-4_5-branch/gcc/testsuite/gcc.dg/compat/struct-layout-1.exp ...
FAIL: tmpdir-gcc.dg-struct-layout-1/t001 c_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-gcc.dg-struct-layout-1/t003 c_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-gcc.dg-struct-layout-1/t004 c_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-gcc.dg-struct-layout-1/t005 c_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-gcc.dg-struct-layout-1/t006 c_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-gcc.dg-struct-layout-1/t007 c_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-gcc.dg-struct-layout-1/t009 c_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-gcc.dg-struct-layout-1/t011 c_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-gcc.dg-struct-layout-1/t012 c_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-gcc.dg-struct-layout-1/t013 c_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-gcc.dg-struct-layout-1/t014 c_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-gcc.dg-struct-layout-1/t015 c_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-gcc.dg-struct-layout-1/t016 c_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-gcc.dg-struct-layout-1/t017 c_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-gcc.dg-struct-layout-1/t018 c_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-gcc.dg-struct-layout-1/t019 c_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-gcc.dg-struct-layout-1/t020 c_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-gcc.dg-struct-layout-1/t021 c_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-gcc.dg-struct-layout-1/t022 c_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-gcc.dg-struct-layout-1/t023 c_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-gcc.dg-struct-layout-1/t024 c_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-gcc.dg-struct-layout-1/t025 c_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-gcc.dg-struct-layout-1/t026 c_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-gcc.dg-struct-layout-1/t027 c_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-gcc.dg-struct-layout-1/t028 c_compat_x_tst.o compile,  (internal 
compiler error)

                === gcc Summary ===

# of expected passes            65
# of unexpected failures        25
# of unresolved testcases       50


                === g++ tests ===

Schedule of variations:
    unix

Running target unix
Using /usr/share/dejagnu/baseboards/unix.exp as board description file for 
target.
Using /usr/share/dejagnu/config/unix.exp as generic interface file for target.
Using /home/eric/svn/gcc-4_5-branch/gcc/testsuite/config/default.exp as 
tool-and-target-specific interface file.
Running /home/eric/svn/gcc-4_5-branch/gcc/testsuite/g++.dg/compat/struct-layout-1.exp ...
FAIL: tmpdir-g++.dg-struct-layout-1/t003 cp_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-g++.dg-struct-layout-1/t004 cp_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-g++.dg-struct-layout-1/t008 cp_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-g++.dg-struct-layout-1/t010 cp_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-g++.dg-struct-layout-1/t012 cp_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-g++.dg-struct-layout-1/t013 cp_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-g++.dg-struct-layout-1/t016 cp_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-g++.dg-struct-layout-1/t017 cp_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-g++.dg-struct-layout-1/t018 cp_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-g++.dg-struct-layout-1/t019 cp_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-g++.dg-struct-layout-1/t020 cp_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-g++.dg-struct-layout-1/t021 cp_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-g++.dg-struct-layout-1/t022 cp_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-g++.dg-struct-layout-1/t023 cp_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-g++.dg-struct-layout-1/t024 cp_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-g++.dg-struct-layout-1/t025 cp_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-g++.dg-struct-layout-1/t026 cp_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-g++.dg-struct-layout-1/t027 cp_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-g++.dg-struct-layout-1/t028 cp_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-g++.dg-struct-layout-1/t029 cp_compat_x_tst.o compile,  (internal 
compiler error)
FAIL: tmpdir-g++.dg-struct-layout-1/t030 cp_compat_x_tst.o compile,  (internal 
compiler error)

                === g++ Summary ===

# of expected passes            87
# of unexpected failures        21
# of unresolved testcases       42
Jakub Jelinek Sept. 22, 2010, 4:47 p.m. UTC | #9
On Tue, Sep 21, 2010 at 09:30:16PM +0200, Eric Botcazou wrote:
> > > OK to backport it to 4.4/4.5 branches?
> >
> > Yeah, sure.
> 
> This badly breaks on i586 though.  On the 4.5 branch:

Here is a shorter testcase:

/* { dg-do compile } */
/* { dg-options "-march=i586" { target ilp32 } } */

struct S { union { double b[4]; } a[18]; } s, a[5];
void foo (struct S);
struct S bar (struct S, struct S *, struct S);

void
foo (struct S arg)
{
}

void
baz (void)
{
  foo (bar (s, &a[1], a[2]));
}

Unless this is resolved soon, I think the 4.5/4.4 backports of this patch
should be reverted.

	Jakub
diff mbox

Patch

diff --git a/gcc/calls.c b/gcc/calls.c
index cd0d9c5..87b5808 100644
--- a/gcc/calls.c
+++ b/gcc/calls.c
@@ -2377,6 +2377,19 @@  expand_call (tree exp, rtx target, int ignore)
 
   preferred_unit_stack_boundary = preferred_stack_boundary / BITS_PER_UNIT;
 
+  if (SUPPORTS_STACK_ALIGNMENT)
+    {
+      /* All variable sized adjustments must be multiple of preferred
+	 stack boundary.  Stack alignment may change preferred stack
+	 boundary after variable sized adjustments have been made.  We
+	 need to compensate it here.  */
+      unsigned HOST_WIDE_INT delta
+	= ((stack_pointer_delta - pending_stack_adjust)
+	   % preferred_unit_stack_boundary);
+      if (delta)
+	anti_adjust_stack (GEN_INT (preferred_unit_stack_boundary - delta));
+    }
+
   /* We want to make two insn chains; one for a sibling call, the other
      for a normal call.  We will select one of the two chains after
      initial RTL generation is complete.  */
--- /dev/null	2010-07-23 13:04:30.193381062 -0700
+++ gcc/gcc/testsuite/gcc.dg/torture/stackalign/alloca-5.c	2010-08-10 06:29:57.308629935 -0700
@@ -0,0 +1,32 @@ 
+/* PR middle-end/45234 */
+/* { dg-do run { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
+/* { dg-options "-m32 -mincoming-stack-boundary=2 -mpreferred-stack-boundary=2" } */
+
+#include "check.h"
+
+void
+__attribute__ ((noinline))
+bar (__float128 f)
+{
+  check (&f, __alignof__(f));
+}
+
+int
+main (void)
+{
+  char *p = __builtin_alloca (6);
+
+  bar (0);
+
+  __builtin_strncpy (p, "good", 5);
+  if (__builtin_strncmp (p, "good", 5) != 0)
+    {
+#ifdef DEBUG
+      p[size] = '\0';
+      printf ("Failed: %s != good\n", p);
+#endif
+     abort ();
+    }
+
+  return 0;
+}