From 9abf8a9e06dd4f3487054dd7a1e7bbe9d2334e5f Mon Sep 17 00:00:00 2001 From: dnovillo Date: Thu, 14 Apr 2011 20:34:51 +0000 Subject: [PATCH] * lto-streamer-out.c (pack_ts_type_value_fields): Pack all bits of -1 value. * lto-streamer.h (bitpack_create): Assert that the value to pack does not overflow NBITS. * lto-streamer-in.c (unpack_ts_type_value_fields): Unpack BITS_PER_BITPACK_WORD bits for TYPE_ALIAS_SET. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/pph@172457 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog.pph | 9 +++++++++ gcc/lto-streamer-in.c | 2 +- gcc/lto-streamer-out.c | 3 ++- gcc/lto-streamer.h | 13 +++++-------- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/gcc/ChangeLog.pph b/gcc/ChangeLog.pph index 5e27cc28e11..551a320153c 100644 --- a/gcc/ChangeLog.pph +++ b/gcc/ChangeLog.pph @@ -1,5 +1,14 @@ 2011-04-14 Diego Novillo + * lto-streamer-out.c (pack_ts_type_value_fields): Pack all bits + of -1 value. + * lto-streamer.h (bitpack_create): Assert that the value to + pack does not overflow NBITS. + * lto-streamer-in.c (unpack_ts_type_value_fields): Unpack + BITS_PER_BITPACK_WORD bits for TYPE_ALIAS_SET. + +2011-04-14 Diego Novillo + * lto-streamer.h (bitpack_create): Only use the lower NBITS from VAL. diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c index 97b86cefdad..f04e03191ef 100644 --- a/gcc/lto-streamer-in.c +++ b/gcc/lto-streamer-in.c @@ -1734,7 +1734,7 @@ unpack_ts_type_value_fields (struct bitpack_d *bp, tree expr) TYPE_USER_ALIGN (expr) = (unsigned) bp_unpack_value (bp, 1); TYPE_READONLY (expr) = (unsigned) bp_unpack_value (bp, 1); TYPE_ALIGN (expr) = (unsigned) bp_unpack_value (bp, HOST_BITS_PER_INT); - TYPE_ALIAS_SET (expr) = bp_unpack_value (bp, HOST_BITS_PER_INT); + TYPE_ALIAS_SET (expr) = bp_unpack_value (bp, BITS_PER_BITPACK_WORD); } diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c index 3ccad8b995d..89ad9c559b5 100644 --- a/gcc/lto-streamer-out.c +++ b/gcc/lto-streamer-out.c @@ -518,7 +518,8 @@ pack_ts_type_value_fields (struct bitpack_d *bp, tree expr) bp_pack_value (bp, TYPE_USER_ALIGN (expr), 1); bp_pack_value (bp, TYPE_READONLY (expr), 1); bp_pack_value (bp, TYPE_ALIGN (expr), HOST_BITS_PER_INT); - bp_pack_value (bp, TYPE_ALIAS_SET (expr) == 0 ? 0 : -1, HOST_BITS_PER_INT); + bp_pack_value (bp, TYPE_ALIAS_SET (expr) == 0 ? 0 : -1, + BITS_PER_BITPACK_WORD); } diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h index 0d49430f79d..73afd4607d7 100644 --- a/gcc/lto-streamer.h +++ b/gcc/lto-streamer.h @@ -1190,18 +1190,15 @@ bitpack_create (struct lto_output_stream *s) static inline void bp_pack_value (struct bitpack_d *bp, bitpack_word_t val, unsigned nbits) { - bitpack_word_t mask, word; + bitpack_word_t word = bp->word; int pos = bp->pos; - word = bp->word; - + /* We shouldn't try to pack more bits than can fit in a bitpack word. */ gcc_assert (nbits > 0 && nbits <= BITS_PER_BITPACK_WORD); - /* Make sure that VAL only has the lower NBITS set. Generate a - mask with the lower NBITS set and use it to filter the upper - bits from VAL. */ - mask = ((bitpack_word_t) 1 << nbits) - 1; - val = val & mask; + /* The value to pack should not overflow NBITS. */ + gcc_assert (nbits == BITS_PER_BITPACK_WORD + || val <= ((bitpack_word_t) 1 << nbits)); /* If val does not fit into the current bitpack word switch to the next one. */ -- 2.11.4.GIT