public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/39907]  New: Aligned access to unaligned address
@ 2009-04-26 12:44 irar at il dot ibm dot com
  2009-04-26 16:54 ` [Bug tree-optimization/39907] " rguenth at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: irar at il dot ibm dot com @ 2009-04-26 12:44 UTC (permalink / raw)
  To: gcc-bugs

The following code (a reduced gcc.target/x86_64/abi/test_struct_returning.c)
fails during execution with segmentation fault when compiled with -O1
-ftree-vectorize -fno-vect-cost-model asm-support.S  (in directory
gcc.target/x86_64/abi/):

#include <stdio.h>
#include "defines.h"
#include "macros.h"
#include "args.h"

struct S_600
{
 float f[4];
};

struct S_600 f_600 ()
{
  struct S_600 s;
  int i;

  for (i = 0; i < 4; i++)
    s.f[i] = 42;
  return s;
}

int
main (void)
{
  struct S_600 s;
  s = WRAP_RET(f_600) ();

  return 0;
}

The failure occurs in 
0x000000000040063b in f_600 ()
1: x/i $pc  0x40063b <f_600+7>: movaps %xmm0,0xffffffffffffffd8(%rsp)
(gdb)

Program received signal SIGSEGV, Segmentation fault.
0x000000000040063b in f_600 ()
1: x/i $pc  0x40063b <f_600+7>: movaps %xmm0,0xffffffffffffffd8(%rsp)

rsp            0x7fff408944c0   0x7fff408944c0
xmm0           {v4_float = {0x2a, 0x2a, 0x2a, 0x2a}, v2_double = {0xc00002114,
0xc00002114}, v16_int8 = {0x0, 0x0, 0x28,
    0x42, 0x0, 0x0, 0x28, 0x42, 0x0, 0x0, 0x28, 0x42, 0x0, 0x0, 0x28, 0x42},
v8_int16 = {0x0, 0x4228, 0x0, 0x4228, 0x0,
    0x4228, 0x0, 0x4228}, v4_int32 = {0x42280000, 0x42280000, 0x42280000,
0x42280000}, v2_int64 = {0x4228000042280000,
    0x4228000042280000}, uint128 = 0x42280000422800004228000042280000}

The alignment is forced by the vectorizer in function
vect_compute_data_ref_alignment() the same way as in pass
pass_ipa_increase_alignment. But if 's' is global and not local in f_600 (i.e.,
when the alignment is forced in pass_ipa_increase_alignment) there is no
segfault.

I also tried to remove WRAP_RET(), and put f_600 and main in different files
(in order to prevent their elimination). But this way there was no segfault
either.

Another check: if the vectorizer forces alignment but also uses peeling (with
the help of a hack), there is still a segfault:
0x000000000040065f in f_600 ()
1: x/i $pc  0x40065f <f_600+43>:        movaps 362(%rip),%xmm0        #
0x4007d0 <_IO_stdin_used+16>
(gdb)

1: x/i $pc  0x400666 <f_600+50>:        movaps %xmm0,(%rdx)
(gdb)

Program received signal SIGSEGV, Segmentation fault.
0x0000000000400666 in f_600 ()
1: x/i $pc  0x400666 <f_600+50>:        movaps %xmm0,(%rdx)
(gdb) info all-registers

rdx            0x7fff2a759358   140733905736536
rip            0x400666 0x400666 <f_600+50>

If after forcing the alignment, the vectorizer escapes and doesn't do anything
else, there is no segfault.


-- 
           Summary: Aligned access to unaligned address
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: irar at il dot ibm dot com
 GCC build triplet: x86_64-suse-linux
  GCC host triplet: x86_64-suse-linux
GCC target triplet: x86_64-suse-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39907


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

* [Bug tree-optimization/39907] Aligned access to unaligned address
  2009-04-26 12:44 [Bug tree-optimization/39907] New: Aligned access to unaligned address irar at il dot ibm dot com
@ 2009-04-26 16:54 ` rguenth at gcc dot gnu dot org
  2009-04-27  5:56 ` irar at il dot ibm dot com
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-04-26 16:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2009-04-26 16:54 -------
*** Bug 39908 has been marked as a duplicate of this bug. ***


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39907


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

* [Bug tree-optimization/39907] Aligned access to unaligned address
  2009-04-26 12:44 [Bug tree-optimization/39907] New: Aligned access to unaligned address irar at il dot ibm dot com
  2009-04-26 16:54 ` [Bug tree-optimization/39907] " rguenth at gcc dot gnu dot org
@ 2009-04-27  5:56 ` irar at il dot ibm dot com
  2009-05-18 10:04 ` rguenth at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: irar at il dot ibm dot com @ 2009-04-27  5:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from irar at il dot ibm dot com  2009-04-27 05:55 -------
*** Bug 39926 has been marked as a duplicate of this bug. ***


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39907


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

* [Bug tree-optimization/39907] Aligned access to unaligned address
  2009-04-26 12:44 [Bug tree-optimization/39907] New: Aligned access to unaligned address irar at il dot ibm dot com
  2009-04-26 16:54 ` [Bug tree-optimization/39907] " rguenth at gcc dot gnu dot org
  2009-04-27  5:56 ` irar at il dot ibm dot com
@ 2009-05-18 10:04 ` rguenth at gcc dot gnu dot org
  2009-05-18 14:25 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-05-18 10:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rguenth at gcc dot gnu dot org  2009-05-18 10:03 -------
The bug is that

snapshot_ret:
        movq    %rdi, rdi(%rip)
        call    *callthis(%rip)

does not preserve stack alignment.  But we assume that correct alignment
is preserved over the indirect function call(?).

HJ?


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hjl at gcc dot gnu dot org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-05-18 10:03:55
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39907


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

* [Bug tree-optimization/39907] Aligned access to unaligned address
  2009-04-26 12:44 [Bug tree-optimization/39907] New: Aligned access to unaligned address irar at il dot ibm dot com
                   ` (2 preceding siblings ...)
  2009-05-18 10:04 ` rguenth at gcc dot gnu dot org
@ 2009-05-18 14:25 ` pinskia at gcc dot gnu dot org
  2009-05-18 16:40 ` [Bug testsuite/39907] " hjl dot tools at gmail dot com
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-05-18 14:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2009-05-18 14:25 -------
(In reply to comment #3)
> The bug is that
> 
> snapshot_ret:
>         movq    %rdi, rdi(%rip)
>         call    *callthis(%rip)
> 
> does not preserve stack alignment.  But we assume that correct alignment
> is preserved over the indirect function call(?).

Are you sure that this is not an inline-asm?  


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39907


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

* [Bug testsuite/39907] Aligned access to unaligned address
  2009-04-26 12:44 [Bug tree-optimization/39907] New: Aligned access to unaligned address irar at il dot ibm dot com
                   ` (3 preceding siblings ...)
  2009-05-18 14:25 ` pinskia at gcc dot gnu dot org
@ 2009-05-18 16:40 ` hjl dot tools at gmail dot com
  2009-05-18 16:53 ` hjl at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: hjl dot tools at gmail dot com @ 2009-05-18 16:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from hjl dot tools at gmail dot com  2009-05-18 16:39 -------
A patch is posted at

http://gcc.gnu.org/ml/gcc-patches/2009-05/msg01156.html


-- 

hjl dot tools at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |http://gcc.gnu.org/ml/gcc-
                   |                            |patches/2009-
                   |                            |05/msg01156.html
          Component|tree-optimization           |testsuite
           Keywords|wrong-code                  |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39907


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

* [Bug testsuite/39907] Aligned access to unaligned address
  2009-04-26 12:44 [Bug tree-optimization/39907] New: Aligned access to unaligned address irar at il dot ibm dot com
                   ` (4 preceding siblings ...)
  2009-05-18 16:40 ` [Bug testsuite/39907] " hjl dot tools at gmail dot com
@ 2009-05-18 16:53 ` hjl at gcc dot gnu dot org
  2009-05-18 16:54 ` hjl at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: hjl at gcc dot gnu dot org @ 2009-05-18 16:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from hjl at gcc dot gnu dot org  2009-05-18 16:53 -------
Subject: Bug 39907

Author: hjl
Date: Mon May 18 16:53:25 2009
New Revision: 147667

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=147667
Log:
2009-05-18  H.J. Lu  <hongjiu.lu@intel.com>

        PR testsuite/39907
        * gcc.target/x86_64/abi/asm-support.S (snapshot_ret): Preserve
        stack alignment.

Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.target/x86_64/abi/asm-support.S


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39907


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

* [Bug testsuite/39907] Aligned access to unaligned address
  2009-04-26 12:44 [Bug tree-optimization/39907] New: Aligned access to unaligned address irar at il dot ibm dot com
                   ` (5 preceding siblings ...)
  2009-05-18 16:53 ` hjl at gcc dot gnu dot org
@ 2009-05-18 16:54 ` hjl at gcc dot gnu dot org
  2009-05-18 16:57 ` hjl at gcc dot gnu dot org
  2009-05-18 16:58 ` hjl dot tools at gmail dot com
  8 siblings, 0 replies; 10+ messages in thread
From: hjl at gcc dot gnu dot org @ 2009-05-18 16:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from hjl at gcc dot gnu dot org  2009-05-18 16:54 -------
Subject: Bug 39907

Author: hjl
Date: Mon May 18 16:54:31 2009
New Revision: 147668

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=147668
Log:
2009-05-18  H.J. Lu  <hongjiu.lu@intel.com>

        Backport from mainline:
        2009-05-18  H.J. Lu  <hongjiu.lu@intel.com>

        PR testsuite/39907
        * gcc.target/x86_64/abi/asm-support.S (snapshot_ret): Preserve
        stack alignment.

Modified:
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_4-branch/gcc/testsuite/gcc.target/x86_64/abi/asm-support.S


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39907


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

* [Bug testsuite/39907] Aligned access to unaligned address
  2009-04-26 12:44 [Bug tree-optimization/39907] New: Aligned access to unaligned address irar at il dot ibm dot com
                   ` (6 preceding siblings ...)
  2009-05-18 16:54 ` hjl at gcc dot gnu dot org
@ 2009-05-18 16:57 ` hjl at gcc dot gnu dot org
  2009-05-18 16:58 ` hjl dot tools at gmail dot com
  8 siblings, 0 replies; 10+ messages in thread
From: hjl at gcc dot gnu dot org @ 2009-05-18 16:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from hjl at gcc dot gnu dot org  2009-05-18 16:56 -------
Subject: Bug 39907

Author: hjl
Date: Mon May 18 16:56:42 2009
New Revision: 147669

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=147669
Log:
2009-05-18  H.J. Lu  <hongjiu.lu@intel.com>

        PR testsuite/39907
        * gcc.target/x86_64/abi/asm-support.s (snapshot_ret): Preserve
        stack alignment.

Modified:
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_3-branch/gcc/testsuite/gcc.target/x86_64/abi/asm-support.s


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39907


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

* [Bug testsuite/39907] Aligned access to unaligned address
  2009-04-26 12:44 [Bug tree-optimization/39907] New: Aligned access to unaligned address irar at il dot ibm dot com
                   ` (7 preceding siblings ...)
  2009-05-18 16:57 ` hjl at gcc dot gnu dot org
@ 2009-05-18 16:58 ` hjl dot tools at gmail dot com
  8 siblings, 0 replies; 10+ messages in thread
From: hjl dot tools at gmail dot com @ 2009-05-18 16:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from hjl dot tools at gmail dot com  2009-05-18 16:58 -------
Fixed.


-- 

hjl dot tools at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.3.4


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39907


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

end of thread, other threads:[~2009-05-18 16:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-26 12:44 [Bug tree-optimization/39907] New: Aligned access to unaligned address irar at il dot ibm dot com
2009-04-26 16:54 ` [Bug tree-optimization/39907] " rguenth at gcc dot gnu dot org
2009-04-27  5:56 ` irar at il dot ibm dot com
2009-05-18 10:04 ` rguenth at gcc dot gnu dot org
2009-05-18 14:25 ` pinskia at gcc dot gnu dot org
2009-05-18 16:40 ` [Bug testsuite/39907] " hjl dot tools at gmail dot com
2009-05-18 16:53 ` hjl at gcc dot gnu dot org
2009-05-18 16:54 ` hjl at gcc dot gnu dot org
2009-05-18 16:57 ` hjl at gcc dot gnu dot org
2009-05-18 16:58 ` hjl dot tools at gmail dot com

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).