public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Shrink tree_block
@ 2007-11-24 23:31 Richard Guenther
  2007-11-24 23:33 ` Andrew Pinski
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Guenther @ 2007-11-24 23:31 UTC (permalink / raw)
  To: gcc-patches


This shrinks tree_block by noting that with mapped location the
block locus now pairs with the flags.  Also blocks do not need
a type and access to the chain member of tree_common is conveniently
wrapped with BLOCK_CHAIN.

So, bootstrapped and tested on x86_64-unknown-linux-gnu, I'll apply
this as a memory-savings regression fix later.

Richard.

2007-11-24  Richard Guenther  <rguenther@suse.de>

	* tree.h (BLOCK_CHAIN): Use tree_block.chain.
	(struct tree_block): Inherit from tree_base, add chain
	member.  Move locus member next to flags.

Index: tree.h
===================================================================
*** tree.h	(revision 130396)
--- tree.h	(working copy)
*************** struct varray_head_tag;
*** 2007,2013 ****
  #define BLOCK_SUPERCONTEXT(NODE) (BLOCK_CHECK (NODE)->block.supercontext)
  /* Note: when changing this, make sure to find the places
     that use chainon or nreverse.  */
! #define BLOCK_CHAIN(NODE) TREE_CHAIN (BLOCK_CHECK (NODE))
  #define BLOCK_ABSTRACT_ORIGIN(NODE) (BLOCK_CHECK (NODE)->block.abstract_origin)
  #define BLOCK_ABSTRACT(NODE) (BLOCK_CHECK (NODE)->block.abstract_flag)
  
--- 2008,2014 ----
  #define BLOCK_SUPERCONTEXT(NODE) (BLOCK_CHECK (NODE)->block.supercontext)
  /* Note: when changing this, make sure to find the places
     that use chainon or nreverse.  */
! #define BLOCK_CHAIN(NODE) (BLOCK_CHECK (NODE)->block.chain)
  #define BLOCK_ABSTRACT_ORIGIN(NODE) (BLOCK_CHECK (NODE)->block.abstract_origin)
  #define BLOCK_ABSTRACT(NODE) (BLOCK_CHECK (NODE)->block.abstract_flag)
  
*************** struct varray_head_tag;
*** 2054,2072 ****
  
  struct tree_block GTY(())
  {
!   struct tree_common common;
  
    unsigned handler_block_flag : 1;
    unsigned abstract_flag : 1;
    unsigned block_num : 30;
  
    tree vars;
    tree subblocks;
    tree supercontext;
    tree abstract_origin;
    tree fragment_origin;
    tree fragment_chain;
-   location_t locus;
  };
  \f
  /* Define fields and accessors for nodes representing data types.  */
--- 2055,2075 ----
  
  struct tree_block GTY(())
  {
!   struct tree_base base;
!   tree chain;
  
    unsigned handler_block_flag : 1;
    unsigned abstract_flag : 1;
    unsigned block_num : 30;
  
+   location_t locus;
+ 
    tree vars;
    tree subblocks;
    tree supercontext;
    tree abstract_origin;
    tree fragment_origin;
    tree fragment_chain;
  };
  \f
  /* Define fields and accessors for nodes representing data types.  */

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Shrink tree_block
  2007-11-24 23:31 [PATCH] Shrink tree_block Richard Guenther
@ 2007-11-24 23:33 ` Andrew Pinski
  2007-11-25 19:18   ` Richard Guenther
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Pinski @ 2007-11-24 23:33 UTC (permalink / raw)
  To: Richard Guenther; +Cc: gcc-patches

On 11/24/07, Richard Guenther <rguenther@suse.de> wrote:
> This shrinks tree_block by noting that with mapped location the
> block locus now pairs with the flags.  Also blocks do not need
> a type and access to the chain member of tree_common is conveniently
> wrapped with BLOCK_CHAIN.
>
> So, bootstrapped and tested on x86_64-unknown-linux-gnu, I'll apply
> this as a memory-savings regression fix later.

This is not complete, you need to have BLOCK return true for GIMPLE_TUPLE_P.

And you should have GENERIC_NEXT for BLOCKs return BLOCK_CHAIN.

Thanks,
Andrew Pinski

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Shrink tree_block
  2007-11-24 23:33 ` Andrew Pinski
@ 2007-11-25 19:18   ` Richard Guenther
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Guenther @ 2007-11-25 19:18 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: gcc-patches

On Sat, 24 Nov 2007, Andrew Pinski wrote:

> On 11/24/07, Richard Guenther <rguenther@suse.de> wrote:
> > This shrinks tree_block by noting that with mapped location the
> > block locus now pairs with the flags.  Also blocks do not need
> > a type and access to the chain member of tree_common is conveniently
> > wrapped with BLOCK_CHAIN.
> >
> > So, bootstrapped and tested on x86_64-unknown-linux-gnu, I'll apply
> > this as a memory-savings regression fix later.
> 
> This is not complete, you need to have BLOCK return true for GIMPLE_TUPLE_P.
> 
> And you should have GENERIC_NEXT for BLOCKs return BLOCK_CHAIN.

Right.  But then we notice that when we try to replace all relevant
TREE_CHAIN accesses with BLOCK_CHAIN that at least the C++ and the Ada
frontends use chainon and nreverse to manipulate block chains.  So
this has to wait for stage1.

Nevertheless re-ordering locus saves 8 bytes on x86_64 and together
with that I put in the TREE_CHAIN -> BLOCK_CHAIN where appropriate
as obvious.

Bootstrapped and tested on x86_64-unknown-linux-gnu for all languages
(including Ada and obj-c++).

Committed to mainline.

Richard.

2007-11-25  Richard Guenther  <rguenther@suse.de>

	* tree.h (struct tree_block): Move locus member next to
	flags.
	* c-decl.c (SCOPE_LIST_APPEND): Use BLOCK_CHAIN.
	(SCOPE_LIST_CONCAT): Likewise.
	(pop_scope): Likewise.
	* function.c (instantiate_decls_1): Likewise.
	(setjmp_vars_warning): Likewise.
	* emit-rtl.c (set_used_decls): Likewise.
	* tree-inline.c (add_lexical_block): Likewise.

	cp/
	decl.c (poplevel): Use BLOCK_CHAIN.

	ada/
	utils.c (gnat_pushlevel): Use BLOCK_CHAIN.
	(gnat_poplevel): Likewise.

Index: cp/decl.c
===================================================================
*** cp/decl.c	(revision 130398)
--- cp/decl.c	(working copy)
*************** poplevel (int keep, int reverse, int fun
*** 587,593 ****
  
    /* In each subblock, record that this is its superior.  */
    if (keep >= 0)
!     for (link = subblocks; link; link = TREE_CHAIN (link))
        BLOCK_SUPERCONTEXT (link) = block;
  
    /* We still support the old for-scope rules, whereby the variables
--- 587,593 ----
  
    /* In each subblock, record that this is its superior.  */
    if (keep >= 0)
!     for (link = subblocks; link; link = BLOCK_CHAIN (link))
        BLOCK_SUPERCONTEXT (link) = block;
  
    /* We still support the old for-scope rules, whereby the variables
Index: ada/utils.c
===================================================================
*** ada/utils.c	(revision 130398)
--- ada/utils.c	(working copy)
*************** gnat_pushlevel ()
*** 298,305 ****
    if (free_block_chain)
      {
        newlevel->block = free_block_chain;
!       free_block_chain = TREE_CHAIN (free_block_chain);
!       TREE_CHAIN (newlevel->block) = NULL_TREE;
      }
    else
      newlevel->block = make_node (BLOCK);
--- 298,305 ----
    if (free_block_chain)
      {
        newlevel->block = free_block_chain;
!       free_block_chain = BLOCK_CHAIN (free_block_chain);
!       BLOCK_CHAIN (newlevel->block) = NULL_TREE;
      }
    else
      newlevel->block = make_node (BLOCK);
*************** gnat_poplevel ()
*** 365,376 ****
        BLOCK_SUBBLOCKS (level->chain->block)
  	= chainon (BLOCK_SUBBLOCKS (block),
  		   BLOCK_SUBBLOCKS (level->chain->block));
!       TREE_CHAIN (block) = free_block_chain;
        free_block_chain = block;
      }
    else
      {
!       TREE_CHAIN (block) = BLOCK_SUBBLOCKS (level->chain->block);
        BLOCK_SUBBLOCKS (level->chain->block) = block;
        TREE_USED (block) = 1;
        set_block_for_group (block);
--- 365,376 ----
        BLOCK_SUBBLOCKS (level->chain->block)
  	= chainon (BLOCK_SUBBLOCKS (block),
  		   BLOCK_SUBBLOCKS (level->chain->block));
!       BLOCK_CHAIN (block) = free_block_chain;
        free_block_chain = block;
      }
    else
      {
!       BLOCK_CHAIN (block) = BLOCK_SUBBLOCKS (level->chain->block);
        BLOCK_SUBBLOCKS (level->chain->block) = block;
        TREE_USED (block) = 1;
        set_block_for_group (block);
Index: c-decl.c
===================================================================
*** c-decl.c	(revision 130398)
--- c-decl.c	(working copy)
*************** static GTY((deletable)) struct c_binding
*** 375,381 ****
    struct c_scope *s_ = (scope);				\
    tree d_ = (decl);					\
    if (s_->list##_last)					\
!     TREE_CHAIN (s_->list##_last) = d_;			\
    else							\
      s_->list = d_;					\
    s_->list##_last = d_;					\
--- 375,381 ----
    struct c_scope *s_ = (scope);				\
    tree d_ = (decl);					\
    if (s_->list##_last)					\
!     BLOCK_CHAIN (s_->list##_last) = d_;			\
    else							\
      s_->list = d_;					\
    s_->list##_last = d_;					\
*************** static GTY((deletable)) struct c_binding
*** 386,392 ****
    struct c_scope *t_ = (tscope);				\
    struct c_scope *f_ = (fscope);				\
    if (t_->to##_last)						\
!     TREE_CHAIN (t_->to##_last) = f_->from;			\
    else								\
      t_->to = f_->from;						\
    t_->to##_last = f_->from##_last;				\
--- 386,392 ----
    struct c_scope *t_ = (tscope);				\
    struct c_scope *f_ = (fscope);				\
    if (t_->to##_last)						\
!     BLOCK_CHAIN (t_->to##_last) = f_->from;			\
    else								\
      t_->to = f_->from;						\
    t_->to##_last = f_->from##_last;				\
*************** pop_scope (void)
*** 693,699 ****
        TREE_USED (block) = 1;
  
        /* In each subblock, record that this is its superior.  */
!       for (p = scope->blocks; p; p = TREE_CHAIN (p))
  	BLOCK_SUPERCONTEXT (p) = block;
  
        BLOCK_VARS (block) = 0;
--- 693,699 ----
        TREE_USED (block) = 1;
  
        /* In each subblock, record that this is its superior.  */
!       for (p = scope->blocks; p; p = BLOCK_CHAIN (p))
  	BLOCK_SUPERCONTEXT (p) = block;
  
        BLOCK_VARS (block) = 0;
Index: function.c
===================================================================
*** function.c	(revision 130398)
--- function.c	(working copy)
*************** instantiate_decls_1 (tree let)
*** 1635,1641 ****
      }
  
    /* Process all subblocks.  */
!   for (t = BLOCK_SUBBLOCKS (let); t; t = TREE_CHAIN (t))
      instantiate_decls_1 (t);
  }
  
--- 1635,1641 ----
      }
  
    /* Process all subblocks.  */
!   for (t = BLOCK_SUBBLOCKS (let); t; t = BLOCK_CHAIN (t))
      instantiate_decls_1 (t);
  }
  
*************** setjmp_vars_warning (bitmap setjmp_cross
*** 3542,3548 ****
                   " %<longjmp%> or %<vfork%>", decl);
      }
  
!   for (sub = BLOCK_SUBBLOCKS (block); sub; sub = TREE_CHAIN (sub))
      setjmp_vars_warning (setjmp_crosses, sub);
  }
  
--- 3542,3548 ----
                   " %<longjmp%> or %<vfork%>", decl);
      }
  
!   for (sub = BLOCK_SUBBLOCKS (block); sub; sub = BLOCK_CHAIN (sub))
      setjmp_vars_warning (setjmp_crosses, sub);
  }
  
Index: emit-rtl.c
===================================================================
*** emit-rtl.c	(revision 130398)
--- emit-rtl.c	(working copy)
*************** set_used_decls (tree blk)
*** 2441,2447 ****
        set_used_flags (DECL_RTL (t));
  
    /* Now process sub-blocks.  */
!   for (t = BLOCK_SUBBLOCKS (blk); t; t = TREE_CHAIN (t))
      set_used_decls (t);
  }
  
--- 2441,2447 ----
        set_used_flags (DECL_RTL (t));
  
    /* Now process sub-blocks.  */
!   for (t = BLOCK_SUBBLOCKS (blk); t; t = BLOCK_CHAIN (t))
      set_used_decls (t);
  }
  
Index: tree-inline.c
===================================================================
*** tree-inline.c	(revision 130398)
--- tree-inline.c	(working copy)
*************** add_lexical_block (tree current_block, t
*** 2474,2480 ****
    /* Walk to the last sub-block.  */
    for (blk_p = &BLOCK_SUBBLOCKS (current_block);
         *blk_p;
!        blk_p = &TREE_CHAIN (*blk_p))
      ;
    *blk_p = new_block;
    BLOCK_SUPERCONTEXT (new_block) = current_block;
--- 2474,2480 ----
    /* Walk to the last sub-block.  */
    for (blk_p = &BLOCK_SUBBLOCKS (current_block);
         *blk_p;
!        blk_p = &BLOCK_CHAIN (*blk_p))
      ;
    *blk_p = new_block;
    BLOCK_SUPERCONTEXT (new_block) = current_block;
Index: tree.h
===================================================================
--- tree.h	(revision 130398)
+++ tree.h	(working copy)
@@ -2060,13 +2060,14 @@ struct tree_block GTY(())
   unsigned abstract_flag : 1;
   unsigned block_num : 30;
 
+  location_t locus;
+
   tree vars;
   tree subblocks;
   tree supercontext;
   tree abstract_origin;
   tree fragment_origin;
   tree fragment_chain;
-  location_t locus;
 };
 \f
 /* Define fields and accessors for nodes representing data types.  */

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-11-25 14:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-24 23:31 [PATCH] Shrink tree_block Richard Guenther
2007-11-24 23:33 ` Andrew Pinski
2007-11-25 19:18   ` Richard Guenther

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).