Patchwork pack dwarf2out.c:die_node better on 64-bit hosts

login
register
mail settings
Submitter Nathan Froyd
Date Aug. 10, 2010, 1:52 p.m.
Message ID <20100810135201.GP4130@codesourcery.com>
Download mbox | patch
Permalink /patch/61385/
State New
Headers show

Comments

Nathan Froyd - Aug. 10, 2010, 1:52 p.m.
The current layout of die_struct has an unnecessary hole and padding:

struct die_struct {
        enum dwarf_tag             die_tag;              /*     0     4 */

        /* XXX 4 bytes hole, try to pack */

        union die_symbol_or_type_node die_id;            /*     8     8 */
        VEC_dw_attr_node_gc *      die_attr;             /*    16     8 */
        dw_die_ref                 die_parent;           /*    24     8 */
        dw_die_ref                 die_child;            /*    32     8 */
        dw_die_ref                 die_sib;              /*    40     8 */
        dw_die_ref                 die_definition;       /*    48     8 */
        dw_offset                  die_offset;           /*    56     8 */
        /* --- cacheline 1 boundary (64 bytes) --- */
        long unsigned int          die_abbrev;           /*    64     8 */
        int                        die_mark;             /*    72     4 */
        int                        die_perennial_p;      /*    76     4 */
        unsigned int               decl_id;              /*    80     4 */

        /* size: 88, cachelines: 2 */
        /* sum members: 80, holes: 1, sum holes: 4 */
        /* padding: 4 */
        /* last cacheline: 24 bytes */
};      /* definitions: 1 */

We can do better by moving die_tag to the end of the structure, which
reduces its size by 8 bytes on 64-bit hosts.

Tested on x86_64-unknown-linux-gnu.  OK to commit?

-Nathan

	* dwarf2out.c (struct die_struct): Move die_tag to the end.
Richard Henderson - Aug. 10, 2010, 2:18 p.m.
On 08/10/2010 06:52 AM, Nathan Froyd wrote:
> 	* dwarf2out.c (struct die_struct): Move die_tag to the end.

Ok.

Patch

Index: dwarf2out.c
===================================================================
--- dwarf2out.c	(revision 163046)
+++ dwarf2out.c	(working copy)
@@ -5672,7 +5672,6 @@  DEF_VEC_ALLOC_O(dw_attr_node,gc);
    die_sib.  die_child points to the node *before* the "first" child node.  */
 
 typedef struct GTY((chain_circular ("%h.die_sib"))) die_struct {
-  enum dwarf_tag die_tag;
   union die_symbol_or_type_node
     {
       char * GTY ((tag ("0"))) die_symbol;
@@ -5690,6 +5689,7 @@  typedef struct GTY((chain_circular ("%h.
   /* Die is used and must not be pruned as unused.  */
   int die_perennial_p;
   unsigned int decl_id;
+  enum dwarf_tag die_tag;
 }
 die_node;