This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/39926] New: Aligned access to unaligned address
- From: "irar at il dot ibm dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 Apr 2009 05:52:53 -0000
- Subject: [Bug tree-optimization/39926] New: Aligned access to unaligned address
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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=39926