On 09/12/14 01:25, Richard Sandiford wrote:
Jeff Law <l...@redhat.com> writes:
On 09/08/14 09:26, Richard Sandiford wrote:
This patch adds a destructor to target_ira_int, so that the data structures
it points to are freed when the parent target_globals is freed. It fixes
a memory leak with non-default subtargets.
Tested on x86_64-linux-gnu. OK to install?
Thanks,
Richard
gcc/
* ira.h (ira_finish_once): Delete.
* ira-int.h (target_ira_int::~target_ira_int): Declare.
(target_ira_int::free_ira_costs): Likewise.
(target_ira_int::free_register_move_costs): Likewise.
(ira_finish_costs_once): Delete.
* ira.c (free_register_move_costs): Replace with...
(target_ira_int::free_register_move_costs): ...this new function.
(target_ira_int::~target_ira_int): Define.
(ira_init): Call free_register_move_costs as a member function rather
than a global function.
(ira_finish_once): Delete.
* ira-costs.c (free_ira_costs): Replace with...
(target_ira_int::free_ira_costs): ...this new function.
(ira_init_costs): Call free_ira_costs as a member function rather
than a global function.
(ira_finish_costs_once): Delete.
* target-globals.c (target_globals::~target_globals): Call the
target_ira_int destructor.
* toplev.c: Include lra.h.
(finalize): Call lra_finish_once rather than ira_finish_once.
Consider making target_ira_int a class. OK for the trunk.
jeff
I'd prefer to keep it as a struct if that's OK. At the moment these
target structures are just collections of variables that are accessed
directly, so it doesn't really feel like a proper OO class "yet".
Also (more minor) changing it from a struct to a class would mean
updating all references to the structure, to avoid the clang warning
about mismatched tags. There would then be some weird-looking
inconsistencies in the target-globals code.
It's OK with me. I just wanted you to consider it, clearly you have :-)
jeff