This is the mail archive of the 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: [lto] PATCH: preserve precision of odd-sized integral types

Sandra Loosemore wrote:
This patch addresses one of the weirdnesses Kenny noted that showed up when reading and writing bit_size_type (68 bit precision) through the DWARF encoding. OK to commit?

2006-10-10 Sandra Loosemore <>

	* gcc/dwarf2out.c (base_type_die): Add DW_AT_bit_size and
	DW_AT_bit_offset attributes for integral types with a precision
	smaller than the bit size of their containing object.
	* gcc/lto/lto.c (lto_read_base_type_DIE): Do the inverse when
	constructing integral types.

This is cool because it's the first example of one of the positive side-effects I've been expecting from LTO: we'll get better debug information!

! byte_size = int_size_in_bytes (type);
! add_AT_unsigned (base_type_result, DW_AT_byte_size, byte_size);
add_AT_unsigned (base_type_result, DW_AT_encoding, encoding);
+ /* Emit information to allow the LTO front end to reconstruct integral
+ types whose precision is less than the bit width of their containing
+ object, e.g., bitsizetype. */

I don't think the LTO comment here is appropriate. This is just generating more correct debugging information.

+   if (TREE_CODE (type) == INTEGER_TYPE
+       && TYPE_PRECISION (type) < byte_size * BITS_PER_UNIT)
+     {
+       add_AT_unsigned (base_type_result, DW_AT_bit_size,
+ 		       TYPE_PRECISION (type));
+       add_AT_unsigned (base_type_result, DW_AT_bit_offset,
+ 		       byte_size * BITS_PER_UNIT - TYPE_PRECISION (type));
+     }

Does DW_AT_bit_offset probably depend on the {bit,byte}-endianness of the target? The DWARF spec says:

"The bit offset attribute describes the offset in bits of the high order bit of a value of the given type from the high order bit of the storage unit used to contain that value."

So, for a big-endian system, I'd sort-of expect the value to be zero. Daniel, can you help here? I see that in the reader, you check that that the values are as you expect in this respect, but I'm not sure that the data you're emitting is correct for big-endian systems.

Mark Mitchell
(650) 331-3385 x713

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