diff mbox series

Come up with ggc_delete.

Message ID 6dd9c199-9896-db63-118d-40f0477d0099@suse.cz
State New
Headers show
Series Come up with ggc_delete. | expand

Commit Message

Martin Liška Oct. 30, 2019, 3:01 p.m. UTC
Hi.

There's a small code refactoring.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin

Comments

Jeff Law Nov. 1, 2019, 9:55 p.m. UTC | #1
On 10/30/19 9:01 AM, Martin Liška wrote:
> Hi.
> 
> There's a small code refactoring.
> 
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
> 
> Ready to be installed?
> Thanks,
> Martin
> 
> 
> 0001-Come-up-with-ggc_delete.patch
> 
> From dc92c8c3e31887b23ef419bc60e3c1607d0e9e53 Mon Sep 17 00:00:00 2001
> From: Martin Liska <mliska@suse.cz>
> Date: Wed, 30 Oct 2019 12:50:51 +0100
> Subject: [PATCH] Come up with ggc_delete.
> 
> gcc/ChangeLog:
> 
> 2019-10-30  Martin Liska  <mliska@suse.cz>
> 
> 	* 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.

OK
jeff
diff mbox series

Patch

From dc92c8c3e31887b23ef419bc60e3c1607d0e9e53 Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Wed, 30 Oct 2019 12:50:51 +0100
Subject: [PATCH] Come up with ggc_delete.

gcc/ChangeLog:

2019-10-30  Martin Liska  <mliska@suse.cz>

	* 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.
---
 gcc/ggc.h           | 10 ++++++++++
 gcc/ipa-fnsummary.c |  3 +--
 gcc/ipa-prop.c      |  6 ++----
 gcc/ipa-sra.c       |  3 +--
 4 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/gcc/ggc.h b/gcc/ggc.h
index d5735d09ced..3e661ae730d 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 <typename T>
+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 5eee2416dd7..8f20d7e6b2a 100644
--- a/gcc/ipa-fnsummary.c
+++ b/gcc/ipa-fnsummary.c
@@ -3873,8 +3873,7 @@  ipa_free_fn_summary (void)
 {
   if (!ipa_call_summaries)
     return;
-  ipa_fn_summaries->~fast_function_summary <ipa_fn_summary *, va_gc> ();
-  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 336d271874d..91ac0fe7f4f 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -3740,8 +3740,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;
 }
 
@@ -3750,8 +3749,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 8f028438556..7367441b105 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.23.0