This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/50444] New: unaligned movdqa instruction after inlining
- From: "john.salmon at deshaw dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 17 Sep 2011 15:34:18 +0000
- Subject: [Bug c/50444] New: unaligned movdqa instruction after inlining
- Auto-submitted: auto-generated
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)