This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix wrong common symbol size in LTO symtabs.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]