[PATCH] gcc: pass-manager: Fix memory leak. [PR jit/63854]
authorMarc Nieper-Wißkirchen <marc@nieper-wisskirchen.de>
Sat, 19 Mar 2022 17:42:26 +0000 (13:42 -0400)
committerJeff Law <jeffreyalaw@gmail.com>
Sat, 19 Mar 2022 17:43:02 +0000 (13:43 -0400)
commitbc84b61b00792ef38e1c2cd6b7280087e4fd2b57
treeb90925ec84ef643d3251f28079c8ce0df9739e46
parentb2dff6b2d9d6179e810724e91b539c79c7a7ac33
[PATCH] gcc: pass-manager: Fix memory leak. [PR jit/63854]

Before the patch, compiling the hello world example of libgccjit with
the external driver under Valgrind shows a loss of 12,611 (48 direct)
bytes.  After the patch, no memory leaks are reported anymore.
(Memory leaks occurring when using the internal driver are mostly in
the driver code in gcc/gcc.c and have to be fixed separately.)

The patch has been tested by fully bootstrapping the compiler with the
frontends C, C++, Fortran, LTO, ObjC, JIT and running the test suite
under a x86_64-pc-linux-gnu host.

gcc/ChangeLog:

PR jit/63854
* hash-traits.h (struct typed_const_free_remove): New.
(struct free_string_hash): New.
* pass_manager.h: Use free_string_hash.
* passes.cc (pass_manager::register_pass_name): Use free_string_hash.
(pass_manager::~pass_manager): Delete allocated m_name_to_pass_map.
gcc/hash-traits.h
gcc/pass_manager.h
gcc/passes.cc