build_trtable function from posix/regex.c is miscompiled on ppc64-linux with
-mcpu=power6. The $v31 register is used within the function and is therefore
saved in prologue and restored in epilogue, but as the function uses alloca,
it is restored from different memory slot than it was saved into.
Options used:
-fpreprocessed -quiet -m64 -mcpu=power6 -mno-minimal-toc -mnew-mnemonics
-mlong-double-128 -g -O3 -std=gnu99 -fgnu89-inline -fasynchronous-unwind-tables
-fmerge-all-constants -fpic
The interesting lines in the assembly are:
.build_trtable:
...
li 0,320
...
stdu 1,-496(1)
stvx 31,1,0
mfvrsave 0
mr 31,1
...
ld 0,0(1)
...
stdu 0,-12304(1)
...
li 0,320
lvx 31,1,0
ld 1,0(1)
...
blr
The above is with the trunk gcc, but 4.3 is similar.
Unlike this, gcc 4.1 saved the vector register early:
li 0,-176
stvx 31,1,0
as first two insns in the routine, before first stdu, and restored after
incrementing stack pointer back:
ld 1,0(1)
mr 3,0
li 0,-176
lwz 12,-148(1)
lvx 31,1,0
So, with 4.1.x this works, but with 4.3/trunk $v31 will get the value of a
memory slot 12304 bytes (i.e. the size of alloca) below where it was actually
saved.
--
Summary: [4.3/4.4 Regression] 64-bit power6 glibc miscompilation
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jakub at gcc dot gnu dot org
GCC target triplet: powerpc64-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35907