This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix wrong common symbol size in LTO symtabs.
- From: Dave Korn <dave dot korn dot cygwin at gmail dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 10 Nov 2010 00:42:39 +0000
- Subject: Re: [PATCH] Fix wrong common symbol size in LTO symtabs.
- References: <4CD9BFE1.20703@gmail.com> <4CD9BD91.1090404@redhat.com>
On 09/11/2010 21:30, Richard Henderson wrote:
> On 11/09/2010 01:40 PM, Dave Korn wrote:
>> - size = (((uint64_t) TREE_INT_CST_HIGH (DECL_SIZE (t))) << 32)
>> - | TREE_INT_CST_LOW (DECL_SIZE (t));
>> + size = (((uint64_t) TREE_INT_CST_HIGH (DECL_SIZE_UNIT (t))) << 32)
>> + | TREE_INT_CST_LOW (DECL_SIZE_UNIT (t));
>
> Note this is wrong for 64-bit HWI. Better is
>
> size = int_size_in_bytes (t);
>
> You'll get a -1 if it's not representable as HWI.
Apart from the possible size restriction, there's another difference here.
The code here uses DECL_SIZE[_UNIT] (t), but calling int_size_in_bytes returns
TYPE_SIZE_UNIT (TYPE_MAIN_VARIANT (t)). Could that ever be semantically
significant?
Otherwise, how about writing it as:
size = (HOST_BITS_PER_WIDE_INT >= 64)
? int_size_in_bytes (t)
: (((uint64_t) TREE_INT_CST_HIGH (DECL_SIZE_UNIT (t))) << 32)
| TREE_INT_CST_LOW (DECL_SIZE_UNIT (t));
(I'm sure we'll get complaints from fortran users about their >2GB COMMON
arrays if we don't do /something/ for the 32-bit HWINT case.)
cheers,
DaveK