public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Port symtab/cgraph/varpool nodes to use C++ inheritance
@ 2013-08-16  0:58 David Malcolm
  2013-08-16  0:58 ` [PATCH 2/2] Autogenerated fixes of "->symbol." to "->" David Malcolm
                   ` (2 more replies)
  0 siblings, 3 replies; 39+ messages in thread
From: David Malcolm @ 2013-08-16  0:58 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jan Hubicka, David Malcolm

Honza: following up from our IRC chat, I've ported the symtab, cgraph
and varpool nodes from the current hand-coded inheritance-in-C scheme
to being a C+ class hierarchy.

I know you're in the middle of making lots of other changes to this code,
so I've written a script to automate the parts of the conversion where
appropriate - see below.

In summary,
  struct GTY(()) symtab_node_base
becomes:
  class GTY((user)) symtab_node_base

and the subclasses:
  struct GTY(()) cgraph_node
and:
  struct GTY(()) varpool_node

become (respectively):
  struct GTY((user)) cgraph_node : public symtab_node_base
and:
  class GTY((user)) varpool_node : public symtab_node_base

The symtab_node_def union goes away, as do the "symbol" fields at the
top of the two subclasses.

I kept the existing names for things, and the "struct" for cgraph_node
since it is often referred to as "struct cgraph_node".

The patch is in three parts; all three are needed.

  * a fix for a bug in gengtype:
      http://gcc.gnu.org/ml/gcc-patches/2013-08/msg00882.html
    This is needed to avoid generating a malfunctioning gtype-desc.c
    *some* of the time - in capriciously changing ways as the sources
    change... :(   I sent it separately since I'm running into this
    issue with other changes I'm trying out; it "randomly" appears
    when trying to use GTY((user)).

  * Patch 1 of the 2 in this series is the hand-written part of the
    conversion.  This makes the changes above, plus various workarounds
    for dealing with yet more issues in how gengtype handles
    GTY((user)).

  * Patch 2 of the 2 in this series is the autogenerated part.
    Currently to access the base symtab fields of a cgraph or varpool
    node, the code has e.g.

       node->symbol.decl

    whereas with C++ inheritance, the "symbol" field is no more, and we
    directly use the base-class field:

       node->decl
    
    The script that makes the patch is for Python (2.7), and is in:
       https://github.com/davidmalcolm/gcc-refactoring-scripts
    as refactor_symtab.py and there's a test suite in
    test_refactor_symtab.py.   It's basically a glorified sed, but it
    also autogenerates the ChangeLog entries.  It expects the gcc
    checkout to be in a sister directory named "src".

Successfully bootstrapped and regtested on x86_64-unknown-linux-gnu
(using all three patches together, showing same results as an unpatched
source tree).

How does this look?  Are there other automated changes you'd like me
to make?   How should I go about getting this into trunk, given that you
have many other changes to this code on the way?

Thanks; hope this is helpful
Dave

David Malcolm (2):
  Convert symtab, cgraph and varpool nodes into a real class hierarchy
  Autogenerated fixes of "->symbol." to "->"

 gcc/ada/gcc-interface/trans.c |   2 +-
 gcc/ada/gcc-interface/utils.c |   2 +-
 gcc/asan.c                    |  10 +-
 gcc/c-family/c-gimplify.c     |   2 +-
 gcc/c-family/c-pragma.c       |   2 +-
 gcc/cfgexpand.c               |   2 +-
 gcc/cgraph.c                  | 480 ++++++++++++++++++++++++++++++------------
 gcc/cgraph.h                  | 150 +++++++------
 gcc/cgraphbuild.c             |  10 +-
 gcc/cgraphclones.c            |  84 ++++----
 gcc/cgraphunit.c              | 260 +++++++++++------------
 gcc/config/i386/i386.c        |  18 +-
 gcc/coverage.c                |   4 +-
 gcc/cp/call.c                 |   2 +-
 gcc/cp/decl2.c                |  24 +--
 gcc/cp/tree.c                 |   4 +-
 gcc/dbxout.c                  |   2 +-
 gcc/dwarf2out.c               |   4 +-
 gcc/gimple-fold.c             |   8 +-
 gcc/gimplify.c                |   4 +-
 gcc/ipa-cp.c                  |  66 +++---
 gcc/ipa-inline-analysis.c     |  48 ++---
 gcc/ipa-inline-transform.c    |  46 ++--
 gcc/ipa-inline.c              | 166 +++++++--------
 gcc/ipa-prop.c                |  56 ++---
 gcc/ipa-pure-const.c          |  54 ++---
 gcc/ipa-ref-inline.h          |   4 +-
 gcc/ipa-ref.c                 |  14 +-
 gcc/ipa-ref.h                 |   6 +-
 gcc/ipa-reference.c           |  60 +++---
 gcc/ipa-split.c               |  26 +--
 gcc/ipa-utils.c               |  46 ++--
 gcc/ipa.c                     | 410 ++++++++++++++++++------------------
 gcc/is-a.h                    |   8 +-
 gcc/java/decl.c               |   2 +-
 gcc/lto-cgraph.c              | 224 ++++++++++----------
 gcc/lto-streamer-in.c         |   4 +-
 gcc/lto-streamer-out.c        |  38 ++--
 gcc/lto-symtab.c              | 198 ++++++++---------
 gcc/lto/lto-partition.c       | 126 +++++------
 gcc/lto/lto.c                 |  26 +--
 gcc/passes.c                  |  28 +--
 gcc/symtab.c                  | 372 ++++++++++++++++----------------
 gcc/toplev.c                  |   6 +-
 gcc/trans-mem.c               |  94 ++++-----
 gcc/tree-eh.c                 |   4 +-
 gcc/tree-emutls.c             |  38 ++--
 gcc/tree-inline.c             |  36 ++--
 gcc/tree-nested.c             |  10 +-
 gcc/tree-pretty-print.c       |   2 +-
 gcc/tree-profile.c            |  20 +-
 gcc/tree-sra.c                |  20 +-
 gcc/tree-ssa-structalias.c    |  40 ++--
 gcc/tree-vectorizer.c         |   2 +-
 gcc/tree.c                    |  10 +-
 gcc/value-prof.c              |  18 +-
 gcc/varasm.c                  |  30 +--
 gcc/varpool.c                 | 118 +++++------
 58 files changed, 1881 insertions(+), 1669 deletions(-)

-- 
1.7.11.7

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

end of thread, other threads:[~2013-10-31 21:32 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-16  0:58 [PATCH 0/2] Port symtab/cgraph/varpool nodes to use C++ inheritance David Malcolm
2013-08-16  0:58 ` [PATCH 2/2] Autogenerated fixes of "->symbol." to "->" David Malcolm
2013-08-16  0:58 ` [PATCH 1/2] Convert symtab, cgraph and varpool nodes into a real class hierarchy David Malcolm
2013-08-20 21:26   ` Jan Hubicka
2013-08-20 21:31     ` Steven Bosscher
2013-08-20 21:34       ` Jan Hubicka
2013-08-20 21:42         ` Jan Hubicka
2013-08-27 11:10   ` Richard Biener
2013-08-27 11:48     ` Jan Hubicka
2013-08-27 12:17       ` Richard Biener
2013-08-27 12:50         ` Jan Hubicka
2013-08-27 15:25     ` Mike Stump
2013-08-28  9:37       ` Richard Biener
2013-08-28 17:06         ` Mike Stump
2013-08-29 10:16           ` Richard Biener
2013-08-20 21:06 ` [PATCH 0/2] Port symtab/cgraph/varpool nodes to use C++ inheritance Jan Hubicka
2013-08-21 10:03   ` Martin Jambor
2013-08-26 22:27   ` David Malcolm
2013-09-09 19:32   ` [PATCH v2 0/6] Port symtab/cgraph/varpool nodes to use C++ inheritance; rename types David Malcolm
2013-09-09 19:32     ` [PATCH v2 6/6] Update hand-written GTY routines for type renaming David Malcolm
2013-09-10 13:46       ` Jan Hubicka
2013-09-09 19:32     ` [PATCH v2 3/6] Split symtab_node declarations onto multiple lines David Malcolm
2013-09-10 13:38       ` Jan Hubicka
2013-10-30 16:12         ` David Malcolm
2013-09-09 19:32     ` [PATCH v2 2/6] Automated conversion of symtab to class hierarchy David Malcolm
2013-09-10 13:37       ` Jan Hubicka
2013-09-09 19:33     ` [PATCH v2 1/6] Convert symtab, cgraph and varpool nodes into a real " David Malcolm
2013-09-10  9:14       ` Richard Biener
2013-09-10 13:36       ` Jan Hubicka
2013-09-17 21:10         ` David Malcolm
2013-09-18  8:05           ` Jan Hubicka
2013-09-18 10:37             ` Richard Biener
2013-09-09 19:43     ` [PATCH v2 4/6] Remove symtab_node and const_symtab_node typedefs David Malcolm
2013-09-10 13:39       ` Jan Hubicka
2013-10-31 23:38         ` symtab_node is now a struct, not a pointer (was Re: [PATCH v2 4/6] Remove symtab_node and const_symtab_node typedefs.) David Malcolm
2013-09-09 20:49     ` [PATCH v2 5/6] Automated renaming of symtab types David Malcolm
2013-09-10 13:40       ` Jan Hubicka
2013-09-10 13:04     ` [PATCH v2 0/6] Port symtab/cgraph/varpool nodes to use C++ inheritance; rename types Jan Hubicka
2013-09-11  1:34       ` David Malcolm

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).