Shrink size of dwarf2_per_cu_data

I noticed some holes in struct dwarf2_per_cu_data.  This patch
rearranges the type slightly, and shrinks the size of some fields.
This reduces it from 136 bytes to 112 bytes (on x86-64).

I also reduced the size of the DWARF "version" fields in a couple of
spots.  It seemed needless to use a short to hold a value that ranges
from 2 to 5, and this also helped the goal of shrinking
dwarf2_per_cu_data.

2021-04-21  Tom Tromey  <tom@tromey.com>

	* dwarf2/read.h (struct dwarf2_per_cu_data) <dwarf_version>: Now
	unsigned char.
	(struct dwarf2_per_cu_data): Rearrange.
	* dwarf2/comp-unit.h (struct comp_unit_head) <version>: Now
	unsigned char.
	(struct comp_unit_head): Rearrange.
	* dwarf2/comp-unit.c (read_comp_unit_head): Update.
This commit is contained in:
Tom Tromey
2021-04-21 16:10:44 -06:00
parent 6d5702a5eb
commit 7e7a35fbca
4 changed files with 34 additions and 24 deletions

View File

@@ -438,7 +438,7 @@ struct dwarf2_per_cu_data
unsigned int length;
/* DWARF standard version this data has been read from (such as 4 or 5). */
short dwarf_version;
unsigned char dwarf_version;
/* Flag indicating this compilation unit will be read in before
any of the current compilation units are processed. */
@@ -474,6 +474,18 @@ struct dwarf2_per_cu_data
This flag is only valid if is_debug_types is true. */
unsigned int tu_read : 1;
/* True if HEADER has been read in.
Don't access this field directly. It should be private, but we can't make
it private at the moment. */
mutable bool m_header_read_in : 1;
/* The unit type of this CU. */
ENUM_BITFIELD (dwarf_unit_type) unit_type : 8;
/* The language of this CU. */
ENUM_BITFIELD (language) lang : LANGUAGE_BITS;
/* Our index in the unshared "symtabs" vector. */
unsigned index;
@@ -482,12 +494,6 @@ struct dwarf2_per_cu_data
not the DWO file. */
struct dwarf2_section_info *section;
/* The unit type of this CU. */
enum dwarf_unit_type unit_type;
/* The language of this CU. */
enum language lang;
/* Backlink to the owner of this. */
dwarf2_per_bfd *per_bfd;
@@ -500,12 +506,6 @@ struct dwarf2_per_cu_data
should be private, but we can't make it private at the moment. */
mutable comp_unit_head m_header;
/* True if HEADER has been read in.
Don't access this field directly. It should be private, but we can't make
it private at the moment. */
mutable bool m_header_read_in;
/* When dwarf2_per_bfd::using_index is true, the 'quick' field
is active. Otherwise, the 'psymtab' field is active. */
union