[PATCH] Pack dwarf2_per_cu_data a bit better

Tom Tromey tom@tromey.com
Thu Apr 1 02:15:31 GMT 2021


This rearranges dwarf2_per_cu_data a little.  On x86-64 Fedora this
saves 16 bytes at, I believe, essentially no cost.

gdb/ChangeLog
2021-03-31  Tom Tromey  <tom@tromey.com>

	* dwarf2/read.h (struct dwarf2_per_cu_data): Pack.
---
 gdb/ChangeLog     |  4 ++++
 gdb/dwarf2/read.h | 24 ++++++++++++------------
 2 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h
index 82ab3879a5b..ffcd0aad2b8 100644
--- a/gdb/dwarf2/read.h
+++ b/gdb/dwarf2/read.h
@@ -474,20 +474,26 @@ 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;
+
   /* Our index in the unshared "symtabs" vector.  */
   unsigned index;
 
+  /* The unit type of this CU.  */
+  ENUM_BITFIELD (dwarf_unit_type) unit_type : 8;
+
+  /* The language of this CU.  */
+  ENUM_BITFIELD (language) lang : 8;
+
   /* The section this CU/TU lives in.
      If the DIE refers to a DWO file, this is always the original die,
      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
-- 
2.26.2



More information about the Gdb-patches mailing list