From ddf628e42fe261293cbbe39d0d8b38d30d852154 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Mon, 4 Nov 2019 10:11:14 +0100 Subject: [PATCH] Come up with ggc_delete. 2019-11-04 Martin Liska * ggc.h (ggc_delete): New function. * ipa-fnsummary.c (ipa_free_fn_summary): Use it. * ipa-prop.c (ipa_free_all_edge_args): Likewise. (ipa_free_all_node_params): Likewise. * ipa-sra.c (ipa_sra_analysis): Likewise. From-SVN: r277767 --- gcc/ChangeLog | 8 ++++++++ gcc/ggc.h | 10 ++++++++++ gcc/ipa-fnsummary.c | 3 +-- gcc/ipa-prop.c | 6 ++---- gcc/ipa-sra.c | 3 +-- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c108ac2..cdb5791 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2019-11-04 Martin Liska + + * ggc.h (ggc_delete): New function. + * ipa-fnsummary.c (ipa_free_fn_summary): Use it. + * ipa-prop.c (ipa_free_all_edge_args): Likewise. + (ipa_free_all_node_params): Likewise. + * ipa-sra.c (ipa_sra_analysis): Likewise. + 2019-11-02 Jan Hubicka * ipa-fnsummary.c (set_cond_stmt_execution_predicate, diff --git a/gcc/ggc.h b/gcc/ggc.h index c22fc37..6c64caa 100644 --- a/gcc/ggc.h +++ b/gcc/ggc.h @@ -242,6 +242,16 @@ ggc_alloc_atomic (size_t s CXX_MEM_STAT_INFO) return ggc_internal_alloc (s PASS_MEM_STAT); } +/* Call destructor and free the garbage collected memory. */ + +template +inline void +ggc_delete (T *ptr) +{ + ptr->~T (); + ggc_free (ptr); +} + /* Allocate a gc-able string, and fill it with LENGTH bytes from CONTENTS. If LENGTH is -1, then CONTENTS is assumed to be a null-terminated string and the memory sized accordingly. */ diff --git a/gcc/ipa-fnsummary.c b/gcc/ipa-fnsummary.c index 4a3cb76..72a01cf 100644 --- a/gcc/ipa-fnsummary.c +++ b/gcc/ipa-fnsummary.c @@ -4136,8 +4136,7 @@ ipa_free_fn_summary (void) { if (!ipa_call_summaries) return; - ipa_fn_summaries->~fast_function_summary (); - ggc_free (ipa_fn_summaries); + ggc_delete (ipa_fn_summaries); ipa_fn_summaries = NULL; delete ipa_call_summaries; ipa_call_summaries = NULL; diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index 83cf4d1..3a6e21b 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -3756,8 +3756,7 @@ ipa_free_all_edge_args (void) if (!ipa_edge_args_sum) return; - ipa_edge_args_sum->~ipa_edge_args_sum_t (); - ggc_free (ipa_edge_args_sum); + ggc_delete (ipa_edge_args_sum); ipa_edge_args_sum = NULL; } @@ -3766,8 +3765,7 @@ ipa_free_all_edge_args (void) void ipa_free_all_node_params (void) { - ipa_node_params_sum->~ipa_node_params_t (); - ggc_free (ipa_node_params_sum); + ggc_delete (ipa_node_params_sum); ipa_node_params_sum = NULL; } diff --git a/gcc/ipa-sra.c b/gcc/ipa-sra.c index 8f02843..7367441 100644 --- a/gcc/ipa-sra.c +++ b/gcc/ipa-sra.c @@ -3989,8 +3989,7 @@ ipa_sra_analysis (void) process_isra_node_results (node, clone_num_suffixes); delete clone_num_suffixes; - func_sums->~ipa_sra_function_summaries (); - ggc_free (func_sums); + ggc_delete (func_sums); func_sums = NULL; delete call_sums; call_sums = NULL; -- 2.7.4