This patch series does something similar to what:

http://gcc.gnu.org/ml/gcc-patches/2010-11/msg02491.html

did, only it does it in a cleaner way and it addresses the problem more
generally.  It introduces a separate substructure (base class) for tree
nodes that include TREE_TYPE so that a tree node can use TREE_TYPE
without having to deal with TREE_CHAIN.  It then goes about making
changes where necessary to both use this new substructure and eliminate
unnecessary TREE_CHAIN usage.

Eliminating the block field from tree_exp would be another nice-to-have
for 4.7, but that's not on my radar of things to address at the moment.
(Matz, you want to do that? :)  Eliminating TREE_TYPE from tree_exp as
suggested on the wiki would be another interesting project, but not one
I plan on tackling.

The patch series touches every front-end in various places.  I have CC'd
the appropriate mailing lists with this introductory email, but I will
only CC those mailing lists on followup patches that touch the
appropriate FE.

I have not rigorously measured memory savings with this patch.  Based on
a (very small) sample, this patch saves ~5% of tree memory according to
dump_tree_statistics...though the amount of tree memory as reported by
dump_tree_statistics is somewhat suspect, since it doesn't include
statistics from copy_node_stat.

The patch series has been bootstrapped on x86_64-unknown-linux-gnu, both
in its entirety and with sub-patches along the way.  Indeed, the patches
were not developed in this order; the checking bits were introduced
first, then any bootstrap or testsuite failures were fixed up, then the
patches were committed in the proper order.

Nathan Froyd (18):
  add typed_tree structure
  enforce TREE_CHAIN and TREE_TYPE accesses
  remove TREE_CHAIN from *_CST nodes
  remove TREE_CHAIN from SSA_NAME nodes
  remove TREE_CHAIN from CONSTRUCTOR nodes
  define CASE_CHAIN accessor for CASE_LABEL_EXPR
  generalize build_case_label to the rest of the compiler
  convert cp *FOR_STMTs to use private scope fields
  convert cp IF_STMTs to use private scope fields
  convert cp SWITCH_STMTs to use private scope fields
  mark EXPR_PACK_EXPANSION as typed only
  make CASE_LABEL_EXPR not abuse TREE_CHAIN
  move TS_EXP to be a substructure of TS_TYPED
  move TS_STATEMENT_LIST to be a substructure of TS_TYPED
  move REAL_IDENTIFIER_TYPE_VALUE to be a field of lang_identifier
  make TS_IDENTIFIER be a substructure of TS_BASE
  introduce block_chainon and use BLOCK_CHAIN more
  make TS_BLOCK a substructure of TS_BASE

 gcc/ada/gcc-interface/ada-tree.h |    2 +-
 gcc/ada/gcc-interface/misc.c     |   16 ++++++
 gcc/ada/gcc-interface/trans.c    |    5 +-
 gcc/ada/gcc-interface/utils.c    |    4 +-
 gcc/c-decl.c                     |    8 ++-
 gcc/c-family/c-common.c          |   14 +++++-
 gcc/c-family/c-common.h          |   20 +++++---
 gcc/c-family/c-semantics.c       |   28 ++++-------
 gcc/c-lang.c                     |    2 +
 gcc/c-parser.c                   |    2 +-
 gcc/c-typeck.c                   |    2 +-
 gcc/cp/cp-lang.c                 |   22 +--------
 gcc/cp/cp-objcp-common.c         |   74 +++++++++++++++++++++++++++
 gcc/cp/cp-objcp-common.h         |    1 +
 gcc/cp/cp-tree.def               |   19 ++++---
 gcc/cp/cp-tree.h                 |   43 ++++++++++------
 gcc/cp/decl.c                    |   28 ++++++----
 gcc/cp/decl2.c                   |   20 ++++---
 gcc/cp/error.c                   |    2 +-
 gcc/cp/init.c                    |    6 +-
 gcc/cp/mangle.c                  |   28 +++++++---
 gcc/cp/name-lookup.c             |   10 ++--
 gcc/cp/pt.c                      |   40 +++++++++------
 gcc/cp/repo.c                    |    2 +-
 gcc/cp/rtti.c                    |    6 +-
 gcc/cp/search.c                  |    4 +-
 gcc/cp/semantics.c               |   41 +++++++++------
 gcc/cp/typeck.c                  |    4 +-
 gcc/except.c                     |    5 +-
 gcc/fortran/f95-lang.c           |    8 ++--
 gcc/fortran/trans-decl.c         |    2 +-
 gcc/fortran/trans-io.c           |    2 +-
 gcc/fortran/trans-stmt.c         |   14 ++---
 gcc/function.c                   |   28 ++++++++++
 gcc/function.h                   |    1 +
 gcc/gimplify.c                   |   14 +++---
 gcc/go/go-lang.c                 |    2 +-
 gcc/java/decl.c                  |   13 ++---
 gcc/java/expr.c                  |    9 ++--
 gcc/java/java-tree.h             |    2 +-
 gcc/lto-streamer-in.c            |    2 +-
 gcc/lto-streamer-out.c           |    2 +-
 gcc/lto-streamer.c               |    1 +
 gcc/lto/lto-tree.h               |    2 +-
 gcc/lto/lto.c                    |    3 +-
 gcc/objc/objc-act.c              |   18 +++++++
 gcc/objc/objc-act.h              |    1 +
 gcc/objc/objc-lang.c             |   32 +-----------
 gcc/objcp/objcp-lang.c           |   48 +-----------------
 gcc/omp-low.c                    |    7 +--
 gcc/print-tree.c                 |   11 +---
 gcc/tree-cfg.c                   |   12 ++--
 gcc/tree-eh.c                    |   22 +++-----
 gcc/tree-flow.h                  |    2 +-
 gcc/tree-inline.c                |    3 +-
 gcc/tree-iterator.c              |   17 ++----
 gcc/tree-ssanames.c              |   28 +++-------
 gcc/tree.c                       |   96 ++++++++++++-----------------------
 gcc/tree.def                     |    2 +-
 gcc/tree.h                       |  103 +++++++++++++++++++++++++++++--------
 gcc/treestruct.def               |    1 +
 gcc/varasm.c                     |    1 -
 62 files changed, 535 insertions(+), 432 deletions(-)

Reply via email to