* 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