Running the jit testsuite under valgrind showed various memory leaks.

Some are per-invocation of the compiler, and hence only affect
libgccjit.so (although presumably it's useful to cc1 etc to get
valgrind clean).

Others appear to be per-function and hence affect the non-JIT use
cases.

The following patch kit fixes most of the leaks.

It also adds a contrib/valgrind.supp suppressions file, for sparseset
(though I see now that gcc/configure.ac can detect if
valgrind/memcheck.h is available and use it if
  --enable-valgrind-annotations
Should I instead require that option when doing such testing?).

Successfully bootstrapped&regrtested the cumulative effect of the
patches on x86_64-unknown-linux-gnu (Fedora 20).

Are the non-JIT parts OK for trunk?
(Presumably I can give myself approval for the JIT parts)

David Malcolm (21):
  PR jit/63854: Fix memory leak within gcc_options
  PR jit/63854: Fix memory leak of reginfo.c: valid_mode_changes_obstack
  PR jit/63854: Fix memory leaks within
    context/pass_manager/dump_manager
  PR jit/63854: Fix memory leak within bb-reorder.c
  PR jit/63854: Fix memory leak of save_decoded_options
  PR jit/63854: Fix leak of opts_obstack
  PR jit/63854: Fix leak of optimization_summary_obstack
  PR jit/63854: Add ira_costs_c_finalize
  PR jit/63854: Don't leak producer_string in dwarf2out.c
  PR jit/63854: Fix leak of worklist within jit-recording.c
  PR jit/63854: Fix leak of "avail" within tree-ssa-pre.c
  PR jit/63854: Add a valgrind suppresion file
  PR jit/63854: Add support for running "make check-jit" under valgrind
  PR jit/63854: Fix leak of paths within jump threading
  PR jit/63854: lra.c: Fix leak of point_freq_vec's buffer when calling
    lra_inheritance
  PR jit/63854: Add all_late_ipa_passes to GCC_PASS_LISTS
  PR jit/63854: Fix leaking vec in jit
  PR jit/63854: Add "long-term" allocator to gcc::context
  PR jit/63854: Fix leak of ipa hooks
  PR jit/63854: Fix leak in ipa-icf.c
  PR jit/63854: Fix leaks in test-fuzzer.c

 contrib/valgrind.supp              | 11 ++++++
 gcc/bb-reorder.c                   |  2 +-
 gcc/config/alpha/alpha.c           |  4 +-
 gcc/config/i386/i386.c             |  2 +-
 gcc/config/rl78/rl78.c             |  4 +-
 gcc/config/rs6000/rs6000.c         |  2 +-
 gcc/context.c                      | 24 ++++++++++++
 gcc/context.h                      | 47 +++++++++++++++++++++++
 gcc/dumpfile.c                     | 47 +++++++++++++++++------
 gcc/dumpfile.h                     | 11 +++++-
 gcc/dwarf2out.c                    |  2 +
 gcc/ipa-icf.c                      |  1 +
 gcc/ipa-prop.c                     |  3 +-
 gcc/ipa-reference.c                | 17 +++++++-
 gcc/ira-costs.c                    |  6 +++
 gcc/ira.h                          |  3 ++
 gcc/jit/jit-playback.c             | 73 +++++++++++++++++++++++++++++------
 gcc/jit/jit-playback.h             | 27 ++++++++-----
 gcc/jit/jit-recording.c            | 19 +++++----
 gcc/jit/jit-recording.h            | 26 ++++++-------
 gcc/lra.c                          |  1 +
 gcc/opts.c                         |  8 ++++
 gcc/opts.h                         |  1 +
 gcc/pass_manager.h                 |  3 ++
 gcc/passes.c                       | 39 ++++++++++++++++++-
 gcc/reginfo.c                      |  2 +-
 gcc/statistics.c                   |  3 +-
 gcc/testsuite/jit.dg/jit.exp       | 79 +++++++++++++++++++++++++++++++++++++-
 gcc/testsuite/jit.dg/test-fuzzer.c |  6 +++
 gcc/toplev.c                       | 20 ++++++++--
 gcc/tree-ssa-pre.c                 |  2 +-
 gcc/tree-ssa-threadedge.c          |  1 +
 gcc/tree-ssa-threadupdate.c        |  1 +
 gcc/tree.c                         | 17 +++++---
 34 files changed, 434 insertions(+), 80 deletions(-)
 create mode 100644 contrib/valgrind.supp

-- 
1.8.5.3

Reply via email to