This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
S/390: Fix another va_arg ABI bug
- From: Ulrich Weigand <weigand at immd1 dot informatik dot uni-erlangen dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 13 Jun 2003 15:12:40 +0200 (MET DST)
- Subject: S/390: Fix another va_arg ABI bug
Hello,
this fixes yet another va_arg ABI bug detected by Janis' new tests.
Specifically, when passing a non-integral type of less than word
size in integer registers (e.g. struct of size 2), the va_arg code
would incorrectly access the high-order part of the register save
area slot instead of the low-order part.
Bootstrapped/regtested on s390-ibm-linux and s390x-ibm-linux (fixes
the struct-by-value regressions); applied to CVS head.
ChangeLog:
* config/s390/s390.c (s390_va_arg): Fix alignment when retrieving
non-integral types from integer register save area slots.
Index: gcc/config/s390/s390.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/s390.c,v
retrieving revision 1.94
diff -c -p -r1.94 s390.c
*** gcc/config/s390/s390.c 12 Jun 2003 13:47:52 -0000 1.94
--- gcc/config/s390/s390.c 13 Jun 2003 00:04:40 -0000
*************** s390_va_arg (valist, type)
*** 6073,6085 ****
reg = gpr;
n_reg = (size + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
sav_ofs = 2 * UNITS_PER_WORD;
! if (TARGET_64BIT)
! sav_ofs += TYPE_MODE (type) == SImode ? 4 :
! TYPE_MODE (type) == HImode ? 6 :
! TYPE_MODE (type) == QImode ? 7 : 0;
! else
! sav_ofs += TYPE_MODE (type) == HImode ? 2 :
! TYPE_MODE (type) == QImode ? 3 : 0;
sav_scale = UNITS_PER_WORD;
if (n_reg > 1)
--- 6073,6080 ----
reg = gpr;
n_reg = (size + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
sav_ofs = 2 * UNITS_PER_WORD;
! if (size < UNITS_PER_WORD)
! sav_ofs += UNITS_PER_WORD - size;
sav_scale = UNITS_PER_WORD;
if (n_reg > 1)
--
Dr. Ulrich Weigand
weigand@informatik.uni-erlangen.de