public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/50444] New: unaligned movdqa instruction after inlining
@ 2011-09-17 17:12 john.salmon at deshaw dot com
  2011-09-25 15:45 ` [Bug c/50444] " john.salmon at deshaw dot com
                   ` (21 more replies)
  0 siblings, 22 replies; 23+ messages in thread
From: john.salmon at deshaw dot com @ 2011-09-17 17:12 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 50444
           Summary: unaligned movdqa instruction after inlining
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: john.salmon@deshaw.com


Created attachment 25309
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25309
C example

On Linux, x86_64, the attached code segfaults when compiled with
gcc4.6.1 and gcc4.6.0.  There's no problem with gcc-4.5.3, nor
when -O1 is removed.

gdb reports that the instruction at the pc when it segfaults is:

   movdqa %xmm0, 0x28(%rbx)

and that 0x28(%rbx) is only 8-bit aligned.  It looks like the
alignment requirement of the movdqa instruction has somehow been
"forgotten" in the optimization that inlined the call to both caster()
and ssefunc() and eliminated the memcpys.

salmonj@drdlogin0039.en.desres$ desres-cleanenv -m gcc/4.6.1-23A/bin gcc -Wall
-O1 e2.c
salmonj@drdlogin0039.en.desres$ a.out
Segmentation fault (core dumped)
salmonj@drdlogin0039.en.desres$ gdb a.out
GNU gdb (GDB) 7.0.1
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /d/en/salmonj-0/junk/misalign/a.out...done.
(gdb) r
Starting program: /d/en/salmonj-0/junk/misalign/a.out 
warning: no loadable sections found in added symbol-file system-supplied DSO at
0x2aaaaaaab000

Program received signal SIGSEGV, Segmentation fault.
_mm_xor_si128 (e=0x7fffffffc070) at e2.c:51
51            e->v = caster(*incr(&e->c), e->key);
(gdb) x /10i $pc
0x400504 <method+28>:    movdqa %xmm0,0x28(%rbx)
0x400509 <method+33>:    movq   $0x4,0x20(%rbx)
0x400511 <method+41>:    mov    0x20(%rbx),%rax
0x400515 <method+45>:    lea    -0x1(%rax),%rdx
0x400519 <method+49>:    mov    %rdx,0x20(%rbx)
0x40051d <method+53>:    mov    0x24(%rbx,%rax,4),%eax
0x400521 <method+57>:    pop    %rbx
0x400522 <method+58>:    retq   
0x400523 <main>:    push   %rbx
0x400524 <main+1>:    add    $0xffffffffffffff80,%rsp
(gdb) info reg
rax            0x7fffffffc080    140737488339072
rbx            0x7fffffffc070    140737488339056
rcx            0x400570    4195696
rdx            0x7fffffffc1a8    140737488339368
rsi            0x7fffffffc198    140737488339352
rdi            0x7fffffffc080    140737488339072
rbp            0x0    0x0
rsp            0x7fffffffc020    0x7fffffffc020
r8             0x3f8b3532d0    272918459088
r9             0x3f8ac0d730    272910833456
r10            0x0    0
r11            0x3f8b01d8a0    272915093664
r12            0x0    0
r13            0x7fffffffc190    140737488339344
r14            0x0    0
r15            0x0    0
rip            0x400504    0x400504 <method+28>
eflags         0x10202    [ IF RF ]
cs             0x33    51
ss             0x2b    43
ds             0x0    0
es             0x0    0
fs             0x0    0
gs             0x0    0
fctrl          0x37f    895
fstat          0x0    0
ftag           0xffff    65535
fiseg          0x0    0
fioff          0x0    0
foseg          0x0    0
fooff          0x0    0
fop            0x0    0
mxcsr          0x1f80    [ IM DM ZM OM UM PM ]
(gdb)


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

end of thread, other threads:[~2013-04-12 16:17 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-17 17:12 [Bug c/50444] New: unaligned movdqa instruction after inlining john.salmon at deshaw dot com
2011-09-25 15:45 ` [Bug c/50444] " john.salmon at deshaw dot com
2011-09-25 18:06 ` rguenth at gcc dot gnu.org
2011-09-26 17:46 ` hjl.tools at gmail dot com
2011-09-26 17:56 ` [Bug c/50444] -ftree-isa ignores alignment hjl.tools at gmail dot com
2011-09-26 20:06 ` hjl.tools at gmail dot com
2011-09-27  8:59 ` rguenther at suse dot de
2011-10-24  7:55 ` [Bug tree-optimization/50444] [4.6/4.7 Regression] -ftree-sra " rguenth at gcc dot gnu.org
2011-10-26 17:38 ` jakub at gcc dot gnu.org
2011-10-27 10:19 ` rguenth at gcc dot gnu.org
2011-12-16 19:59 ` jamborm at gcc dot gnu.org
2011-12-17 15:41 ` ebotcazou at gcc dot gnu.org
2012-01-12 13:47 ` jamborm at gcc dot gnu.org
2012-01-16 15:43 ` rguenth at gcc dot gnu.org
2012-01-16 15:58 ` rguenth at gcc dot gnu.org
2012-01-18 11:57 ` jamborm at gcc dot gnu.org
2012-01-20 14:27 ` rguenth at gcc dot gnu.org
2012-01-20 15:54 ` rguenth at gcc dot gnu.org
2012-01-27 15:12 ` rguenth at gcc dot gnu.org
2012-01-27 15:23 ` rguenth at gcc dot gnu.org
2012-01-27 15:29 ` [Bug tree-optimization/50444] [4.6 " rguenth at gcc dot gnu.org
2012-03-01 15:21 ` jakub at gcc dot gnu.org
2013-04-12 16:17 ` jakub at gcc dot gnu.org

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