This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
[TESTCASE] Minimized testcase for AltiVec segfault
- From: Daniel Egger <degger at fhm dot edu>
- To: GCC Developer Mailinglist <gcc at gcc dot gnu dot org>
- Cc: Aldy Hernandez <aldyh at redhat dot com>
- Date: 26 Feb 2002 14:14:33 +0100
- Subject: [TESTCASE] Minimized testcase for AltiVec segfault
Hija,
the attached testcase will segfault on powerpc-linux when compiled with
-O0.
egger@sonja:~$ /opt/gcc/bin/gcc -da -maltivec -save-temps -O0 -mregnames
test2.c -o test2 -Wall
test2.c: In function `do_something':
test2.c:7: warning: unused variable `zeros'
egger@sonja:~$ ./test2
Segmentation fault
Works with -O2:
egger@sonja:~$ /opt/gcc/bin/gcc -da -maltivec -save-temps -O2 -mregnames
test2.c -o test2 -Wall
test2.c: In function `do_something':
test2.c:7: warning: unused variable `zeros'
egger@sonja:~$ ./test2
egger@sonja:~$
do_something:
stwu %r1,-96(%r1)
stw %r31,92(%r1)
mr %r31,%r1
stw %r3,8(%r31)
lis %r9,.LC0@ha
la %r9,.LC0@l(%r9)
lvx %v0,0,%r9
li %r0,32
stvx %v0,%r31,%r0
li %r0,32
lvx %v0,%r31,%r0
li %r0,16
stvx %v0,%r31,%r0
lwz %r0,8(%r31)
stw %r0,48(%r31)
lwz %r9,48(%r31)
lvx %v0,0,%r9 <--- This is an offending line.
li %r0,56
stvx %v0,%r31,%r0
lwz %r9,48(%r31)
li %r0,56
lvx %v0,%r31,%r0
stvx %v0,0,%r9 <--- This is an offending line.
lwz %r11,0(%r1)
lwz %r31,-4(%r11)
mr %r1,%r11
blr
One problem with this marked lines is that there is no direct vector
load or vector store with the second argument being 0 to directly
address the memory at the pointer in the third argument which gcc seem
to assume exists.
Even worse for the store is that %r9 points to 0 and %r0 is 56 (while
it is probably assumed to be ignored) which means that address
generation is wrong anyway even if the syntax was right.
--
Servus,
Daniel
#include <altivec.h>
#include <malloc.h>
void
do_something (signed short *mem)
{
const vector signed short zeros = (vector signed short) {0,0,0,0,0,0,0};
vector signed short *vec;
vector signed short v1[1];
vec = (vector signed short *) mem;
v1[0] = vec[0];
vec[0] = v1[0];
}
int
main (void)
{
void *mem = memalign (128, 16);
if (mem)
{
do_something (mem);
free (mem);
}
return 0;
}