The following patch series eliminates the mutable global variables
representing GCC's passes, allowing for multiple compilation contexts in
one process, potentially with different combinations of passes
(e.g. JIT-compilation of JavaScript in one thread, JIT-compilation
of OpenGL shader programs in another) and with pass instances owning
additional data, including GC references.

The opt_pass hierarchy becomes a true C++ class hierarchy.

Patch 1 introduces a gcc::pipeline class and moves various non-GTY
globals relating to pass management into it.  The gcc::context gains its
first field: a pointer to the gcc::pipeline instance.

Patch 2 adds a new autogenerated file: pass-instances.def, built from
passes.def.  We need this in patch 3 and patch 11 in order to be able
to generate fields of class pipeline via macros (so that passes with
multiple instances can have unique field names).

Patches 3, 4 and 5 convert passes from C structs to C++ classes.

Patch 6 replaces XNEW/memcpy calls using fixed sizes with invocations
of opt_pass::clone, thus avoiding hard-coding the sizes of pass
subclasses, allowing opt_pass subclasses to have additional fields.

Patches 7 and 8 show a simple example of moving non-GTY state from being
global to being pass instance data.

Patch 9 adds enough special-casing to gengtype to allow it to cope
with types that are within the gcc namespace.

Patches 10 and 11 integrate the new classes with GTY (i.e. gcc::context,
the opt_pass class hierarchy and gcc::pipeline), so that pass instances
can own refs to GC-managed data.

I've successfully bootstrapped the *end result* of the patch series on
x86_64-unknown-linux-gnu: all testcases show the same results as an
unpatched build (relative to r201251).

OK for trunk? (I will bootstrap each of the above logical groups of
patches before committing).

Thanks
Dave


David Malcolm (11):
  Introduce beginnings of a pipeline class.
  Generate pass-instances.def
  Handwritten part of conversion of passes to C++ classes
  Automated conversion of passes to C++ classes
  Add -fno-rtti when building plugins.
  Rewrite how instances of passes are cloned
  Introduce virtual functions in
    testsuite/gcc.dg/plugin/one_time_plugin.c
  Example of converting global state to per-pass state
  Support "gcc" namespace in gengtype
  Make gcc::context be GC-managed
  Make opt_pass and gcc::pipeline be GC-managed

 gcc/Makefile.in                                    |  24 +-
 gcc/asan.c                                         | 109 ++-
 gcc/auto-inc-dec.c                                 |  52 +-
 gcc/bb-reorder.c                                   | 156 ++--
 gcc/bt-load.c                                      | 108 ++-
 gcc/cfgcleanup.c                                   | 102 ++-
 gcc/cfgexpand.c                                    |  55 +-
 gcc/cfgrtl.c                                       | 153 ++--
 gcc/cgraphbuild.c                                  | 157 ++--
 gcc/cgraphunit.c                                   |  28 +-
 gcc/combine-stack-adj.c                            |  52 +-
 gcc/combine.c                                      |  52 +-
 gcc/compare-elim.c                                 |  55 +-
 gcc/config/epiphany/epiphany.h                     |   4 +-
 gcc/config/epiphany/mode-switch-use.c              |  51 +-
 gcc/config/epiphany/resolve-sw-modes.c             |  53 +-
 gcc/config/i386/i386.c                             |  60 +-
 gcc/config/i386/t-i386                             |   2 +-
 gcc/config/mips/mips.c                             |  53 +-
 gcc/config/sparc/sparc.c                           |  54 +-
 gcc/context.c                                      |  46 +
 gcc/context.h                                      |  57 +-
 gcc/cprop.c                                        |  55 +-
 gcc/cse.c                                          | 164 ++--
 gcc/dce.c                                          | 104 ++-
 gcc/df-core.c                                      | 161 ++--
 gcc/dse.c                                          | 108 ++-
 gcc/dwarf2cfi.c                                    |  54 +-
 gcc/except.c                                       | 107 ++-
 gcc/final.c                                        | 204 +++--
 gcc/function.c                                     | 216 +++--
 gcc/fwprop.c                                       | 107 ++-
 gcc/gcse.c                                         | 108 ++-
 gcc/gen-pass-instances.awk                         |  66 ++
 gcc/gengtype.c                                     |  19 +-
 gcc/gimple-low.c                                   |  51 +-
 gcc/gimple-ssa-strength-reduction.c                |  54 +-
 gcc/ifcvt.c                                        | 157 ++--
 gcc/init-regs.c                                    |  52 +-
 gcc/ipa-cp.c                                       |  75 +-
 gcc/ipa-inline-analysis.c                          |  56 +-
 gcc/ipa-inline.c                                   | 122 ++-
 gcc/ipa-pure-const.c                               | 123 ++-
 gcc/ipa-reference.c                                |  72 +-
 gcc/ipa-split.c                                    | 104 ++-
 gcc/ipa.c                                          | 318 ++++---
 gcc/ira.c                                          | 102 ++-
 gcc/jump.c                                         |  51 +-
 gcc/loop-init.c                                    | 378 +++++---
 gcc/lower-subreg.c                                 | 106 ++-
 gcc/lto-cgraph.c                                   |   9 +-
 gcc/lto-streamer-out.c                             | 138 +--
 gcc/lto/Make-lang.in                               |   3 +-
 gcc/lto/lto.c                                      |   4 +-
 gcc/mode-switching.c                               |  53 +-
 gcc/modulo-sched.c                                 |  57 +-
 gcc/omp-low.c                                      | 163 ++--
 gcc/passes.c                                       | 764 ++++++++++++----
 gcc/pipeline.h                                     | 139 +++
 gcc/postreload-gcse.c                              |  53 +-
 gcc/postreload.c                                   |  53 +-
 gcc/predict.c                                      | 108 ++-
 gcc/recog.c                                        | 325 ++++---
 gcc/ree.c                                          |  53 +-
 gcc/reg-stack.c                                    | 102 ++-
 gcc/regcprop.c                                     |  53 +-
 gcc/reginfo.c                                      |  51 +-
 gcc/regmove.c                                      |  52 +-
 gcc/regrename.c                                    |  53 +-
 gcc/reorg.c                                        | 104 ++-
 gcc/sched-rgn.c                                    | 112 ++-
 gcc/stack-ptr-mod.c                                |  51 +-
 gcc/statistics.c                                   |   7 +-
 gcc/store-motion.c                                 |  54 +-
 gcc/testsuite/c-c++-common/vector-init-2.c         |   2 +-
 gcc/testsuite/g++.dg/plugin/dumb_plugin.c          |  55 +-
 gcc/testsuite/g++.dg/plugin/selfassign.c           |  55 +-
 gcc/testsuite/gcc.dg/cpp/mac-eol-at-eof.c          |   2 +-
 gcc/testsuite/gcc.dg/plugin/one_time_plugin.c      |  66 +-
 gcc/testsuite/gcc.dg/plugin/selfassign.c           |  55 +-
 gcc/testsuite/gcc.target/mips/mulsize-3.c          |   2 +-
 gcc/testsuite/gcc.target/mips/mulsize-4.c          |   2 +-
 .../gcc.target/x86_64/abi/callabi/callabi.h        |   2 +-
 gcc/testsuite/lib/plugin-support.exp               |   2 +-
 gcc/toplev.c                                       |   7 +-
 gcc/toplev.h                                       |   1 -
 gcc/tracer.c                                       |  53 +-
 gcc/trans-mem.c                                    | 377 +++++---
 gcc/tree-call-cdce.c                               |  52 +-
 gcc/tree-cfg.c                                     | 267 ++++--
 gcc/tree-cfgcleanup.c                              |  53 +-
 gcc/tree-complex.c                                 | 106 ++-
 gcc/tree-eh.c                                      | 261 ++++--
 gcc/tree-emutls.c                                  |  52 +-
 gcc/tree-if-conv.c                                 |  53 +-
 gcc/tree-into-ssa.c                                |  54 +-
 gcc/tree-loop-distribution.c                       |  52 +-
 gcc/tree-mudflap.c                                 | 106 ++-
 gcc/tree-nomudflap.c                               | 102 ++-
 gcc/tree-nrv.c                                     | 103 ++-
 gcc/tree-object-size.c                             |  52 +-
 gcc/tree-optimize.c                                | 105 ++-
 gcc/tree-pass.h                                    | 641 ++++++++------
 gcc/tree-profile.c                                 |  52 +-
 gcc/tree-sra.c                                     | 158 ++--
 gcc/tree-ssa-ccp.c                                 | 109 ++-
 gcc/tree-ssa-copy.c                                |  56 +-
 gcc/tree-ssa-copyrename.c                          |  53 +-
 gcc/tree-ssa-dce.c                                 | 160 ++--
 gcc/tree-ssa-dom.c                                 | 116 ++-
 gcc/tree-ssa-dse.c                                 |  53 +-
 gcc/tree-ssa-forwprop.c                            |  54 +-
 gcc/tree-ssa-ifcombine.c                           |  53 +-
 gcc/tree-ssa-loop-ch.c                             |  55 +-
 gcc/tree-ssa-loop.c                                | 973 ++++++++++++++-------
 gcc/tree-ssa-math-opts.c                           | 215 +++--
 gcc/tree-ssa-phiopt.c                              | 111 ++-
 gcc/tree-ssa-phiprop.c                             |  53 +-
 gcc/tree-ssa-pre.c                                 | 106 ++-
 gcc/tree-ssa-reassoc.c                             |  57 +-
 gcc/tree-ssa-sink.c                                |  56 +-
 gcc/tree-ssa-strlen.c                              |  52 +-
 gcc/tree-ssa-structalias.c                         | 160 ++--
 gcc/tree-ssa-uncprop.c                             |  53 +-
 gcc/tree-ssa-uninit.c                              |  53 +-
 gcc/tree-ssa.c                                     | 153 ++--
 gcc/tree-ssanames.c                                |  51 +-
 gcc/tree-stdarg.c                                  |  52 +-
 gcc/tree-switch-conversion.c                       |  57 +-
 gcc/tree-tailcall.c                                | 105 ++-
 gcc/tree-vect-generic.c                            | 116 ++-
 gcc/tree-vectorizer.c                              | 109 ++-
 gcc/tree-vrp.c                                     |  58 +-
 gcc/tree.c                                         |  53 +-
 gcc/tsan.c                                         | 105 ++-
 gcc/var-tracking.c                                 |  55 +-
 gcc/web.c                                          |  52 +-
 137 files changed, 9295 insertions(+), 4557 deletions(-)
 create mode 100644 gcc/gen-pass-instances.awk
 create mode 100644 gcc/pipeline.h

-- 
1.7.11.7

Reply via email to