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 AANLkTi=-6+62LS3aWr0-fk0pmGxxNh_d4K785O+hTURd@mail.gmail.com
State New
Headers show

Commit Message

H.J. Lu Sept. 23, 2010, 5:54 a.m. UTC
On Wed, Sep 22, 2010 at 5:28 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Wed, Sep 22, 2010 at 3:01 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Wed, Sep 22, 2010 at 9:47 AM, Jakub Jelinek <jakub@redhat.com> wrote:
>>> 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.
>>
>> I am testing this patch on trunk and 4.5.
>>
>> --
>> H.J.
>> ---
>> gcc/
>>
>> 2010-09-22  H.J. Lu  <hongjiu.lu@intel.com>
>>
>>        PR middle-end/45234
>>        * calls.c (expand_call): Don't call check all variable sized
>>        adjustments are multiple of preferred stack boundary after
>>        stack alignment when calling builtin functions.
>>
>> gcc/testsuite/
>>
>> 2010-09-22  Jakub Jelinek  <jakub@redhat.com>
>>
>>        PR middle-end/45234
>>        * gcc.target/i386/pr45234.c: New.
>>
>
> There are no regressions on trunk and 4.5. I configured
> --with-arch=i586 for 32bit
> gcc.  I am testing it on 4.4.
>

Here is the patch for 4.4.  There are no regressions.

OK for trunk/4.5/4.4?

Thanks.
diff mbox

Patch

diff --git a/gcc/calls.c b/gcc/calls.c
index d85b70a..4e09cc2 100644
--- a/gcc/calls.c
+++ b/gcc/calls.c
@@ -2374,7 +2374,7 @@  expand_call (tree exp, rtx target, int ignore)
 
   preferred_unit_stack_boundary = preferred_stack_boundary / BITS_PER_UNIT;
 
-  if (SUPPORTS_STACK_ALIGNMENT)
+  if (SUPPORTS_STACK_ALIGNMENT && fndecl && !DECL_IS_BUILTIN (fndecl))
     {
       /* All variable sized adjustments must be multiple of preferred
 	 stack boundary.  Stack alignment may change preferred stack
diff --git a/gcc/expr.c b/gcc/expr.c
index be332a7..d9463b4 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -1443,6 +1443,7 @@  init_block_move_fn (const char *asmspec)
 				       NULL_TREE);
 
       fn = build_decl (FUNCTION_DECL, fn, args);
+      DECL_SOURCE_LOCATION (fn) = UNKNOWN_LOCATION;
       DECL_EXTERNAL (fn) = 1;
       TREE_PUBLIC (fn) = 1;
       DECL_ARTIFICIAL (fn) = 1;
@@ -2713,6 +2714,7 @@  init_block_clear_fn (const char *asmspec)
 				       NULL_TREE);
 
       fn = build_decl (FUNCTION_DECL, fn, args);
+      DECL_SOURCE_LOCATION (fn) = UNKNOWN_LOCATION;
       DECL_EXTERNAL (fn) = 1;
       TREE_PUBLIC (fn) = 1;
       DECL_ARTIFICIAL (fn) = 1;
--- /dev/null	2010-09-09 09:16:30.485584932 -0700
+++ gcc-release/gcc/testsuite/gcc.target/i386/pr45234.c	2010-09-22 13:34:53.415871265 -0700
@@ -0,0 +1,17 @@ 
+/* { 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]));
+}