public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/35771]  New: Call expander ignores type alignment
@ 2008-03-30 22:11 hjl dot tools at gmail dot com
  2008-03-30 23:59 ` [Bug middle-end/35771] " hjl dot tools at gmail dot com
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: hjl dot tools at gmail dot com @ 2008-03-30 22:11 UTC (permalink / raw)
  To: gcc-bugs

Call expander ignores type alignment. But caller honors type alignment.
It usually isn't a problem until the argument is passed via stack. We
have a mismatch between caller and callee:

bash-3.2$ cat x.c
typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__));

__m128  __attribute__((noinline))
iszero (__m128 x)
{
  return x;
}

typedef  __m128 __attribute__((aligned(1))) unaligned;

__m128  __attribute__((noinline))
foo (__m128 a1, __m128 a2, __m128 a3, __m128 a4,
     __m128 a5, __m128 a6, __m128 a7, __m128 a8,
     int b1, int b2, int b3, int b4, int b5, int b6, int b7, unaligned y)
{
  return iszero (y);
}

int
main (void)
{
  unaligned x;
  __m128 y, x0 = { 0 };
  x = x0; 
  y = foo (x0, x0, x0, x0, x0, x0, x0, x0, 1, 2, 3, 4, 5, 6, 7, x);
  return __builtin_memcmp (&y, &x0, sizeof (y));
}
bash-3.2$ make
/export/build/gnu/gcc/build-x86_64-linux/stage1-gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/stage1-gcc/ -O -g    -c -o x.o x.c
/export/build/gnu/gcc/build-x86_64-linux/stage1-gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/stage1-gcc/   x.o   -o x
./x
make: *** [all] Segmentation fault
bash-3.2$ gdb x
GNU gdb Red Hat Linux (6.6-45.fc8rh)
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu"...
Using host libthread_db library "/lib64/libthread_db.so.1".
(gdb) r
Starting program: /export/home/hjl/bugs/gcc/35767/x 

Program received signal SIGSEGV, Segmentation fault.
foo (a1={0, 0, 0, 0}, a2={0, 0, 0, 0}, a3={0, 0, 0, 0}, a4={0, 0, 0, 0}, a5=
      {0, 0, 0, 0}, a6={0, 0, 0, 0}, a7={0, 0, 0, 0}, a8={0, 0, 0, 0}, b1=1, 
    b2=2, b3=3, b4=4, b5=5, b6=6, b7=7, y={5.87934249e-39, 0, 0, 0}) at x.c:16
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^
                                          Should be {0, 0, 0, 0}
16        return iszero (y);
Missing separate debuginfos, use: debuginfo-install glibc.x86_64
(gdb) f 1
#1  0x00000000004004c3 in main () at x.c:25
25        y = foo (x0, x0, x0, x0, x0, x0, x0, x0, 1, 2, 3, 4, 5, 6, 7, x);
(gdb) p x
No symbol "x" in current context.
(gdb) p x0
$1 = {0, 0, 0, 0}
(gdb) 

The segfault is PR 35767.


-- 
           Summary: Call expander ignores type alignment
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hjl dot tools at gmail dot com
GCC target triplet: x86_64-unknown-linux-gnu
 BugsThisDependsOn: 35767


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


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

end of thread, other threads:[~2008-05-29 16:08 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-30 22:11 [Bug middle-end/35771] New: Call expander ignores type alignment hjl dot tools at gmail dot com
2008-03-30 23:59 ` [Bug middle-end/35771] " hjl dot tools at gmail dot com
2008-03-31  2:05 ` hjl dot tools at gmail dot com
2008-03-31  4:47 ` hjl dot tools at gmail dot com
2008-03-31 13:50 ` hjl dot tools at gmail dot com
2008-05-27 20:20 ` hjl at gcc dot gnu dot org
2008-05-27 20:22 ` hjl dot tools at gmail dot com
2008-05-28 22:57 ` hjl dot tools at gmail dot com
2008-05-28 23:26 ` hjl dot tools at gmail dot com
2008-05-29  4:41 ` hjl dot tools at gmail dot com
2008-05-29 12:36 ` hjl at gcc dot gnu dot org
2008-05-29 16:08 ` 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).