This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix EQ_ATTR_ALT size calculation (PR bootstrap/87417)
- From: Richard Sandiford <rdsandiford at googlemail dot com>
- To: Ilya Leoshkevich <iii at linux dot ibm dot com>
- Cc: gcc-patches at gcc dot gnu dot org, krebbel at linux dot ibm dot com, rdapp at linux dot ibm dot com, ro at CeBiTec dot Uni-Bielefeld dot DE
- Date: Tue, 25 Sep 2018 06:15:00 +0100
- Subject: Re: [PATCH] Fix EQ_ATTR_ALT size calculation (PR bootstrap/87417)
- References: <20180924214916.12356-1-iii@linux.ibm.com>
Ilya Leoshkevich <iii@linux.ibm.com> writes:
> Bootstrap and regtest running on s390x-redhat-linux.
>
> "r264537: Change EQ_ATTR_ALT to support up to 64 alternatives" changed
> the format of EQ_ATTR_ALT from ii to ww. This broke the bootstrap on
> 32-bit systems, because the formula for rtx_code_size assumed that only
> certain codes contain HOST_WIDE_INTs. This did not surface on 64-bit
> systems, because rtunion is 8 bytes anyway, but on 32-bit systems it's
> only 4 bytes. This resulted in out-of-bounds writes and memory
> corruptions in genattrtab.
>
> gcc/ChangeLog:
>
> 2018-09-24 Ilya Leoshkevich <iii@linux.ibm.com>
>
> PR bootstrap/87417
> * rtl.c (rtx_code_size): Take into account that EQ_ATTR_ALT
> contains HOST_WIDE_INTs when computing its size.
OK. Thanks for the quick fix.
Richard
> ---
> gcc/rtl.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/gcc/rtl.c b/gcc/rtl.c
> index f9146afcf2c..ca5c25c422f 100644
> --- a/gcc/rtl.c
> +++ b/gcc/rtl.c
> @@ -110,8 +110,7 @@ const enum rtx_class rtx_class[NUM_RTX_CODE] = {
>
> const unsigned char rtx_code_size[NUM_RTX_CODE] = {
> #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) \
> - (((ENUM) == CONST_INT || (ENUM) == CONST_DOUBLE \
> - || (ENUM) == CONST_FIXED || (ENUM) == CONST_WIDE_INT) \
> + ((FORMAT)[0] == 'w' \
> ? RTX_HDR_SIZE + (sizeof FORMAT - 1) * sizeof (HOST_WIDE_INT) \
> : (ENUM) == REG \
> ? RTX_HDR_SIZE + sizeof (reg_info) \