public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: gcc-patches@gcc.gnu.org
Cc: David Malcolm <dmalcolm@redhat.com>
Subject: [PATCH 04/16] (approved) Expose forcibly_ggc_collect and run it after all selftests
Date: Wed, 05 Oct 2016 15:45:00 -0000	[thread overview]
Message-ID: <1475684110-2521-5-git-send-email-dmalcolm@redhat.com> (raw)
In-Reply-To: <1475684110-2521-1-git-send-email-dmalcolm@redhat.com>

Jeff:
> Seems reasonable and doesn't depend on earlier patches, right?
> Assuming that's correct it seems fine for the trunk whenever you want to
> install it.

gcc/ChangeLog:
	* ggc-tests.c (forcibly_ggc_collect): Rename to...
	(selftest::forcibly_ggc_collect): ...this, and remove "static".
	(test_basic_struct): Update for above renaming.
	(test_length): Likewise.
	(test_union): Likewise.
	(test_finalization): Likewise.
	(test_deletable_global): Likewise.
	(test_inheritance): Likewise.
	(test_chain_next): Likewise.
	(test_user_struct): Likewise.
	(test_tree_marking): Likewise.
	* selftest-run-tests.c (selftest::run_tests): Call
	selftest::forcibly_ggc_collect at the end of the selftests.
	* selftest.h (selftest::forcibly_ggc_collect): New decl.
---
 gcc/ggc-tests.c          | 28 ++++++++++++++--------------
 gcc/selftest-run-tests.c |  6 ++++++
 gcc/selftest.h           |  5 +++++
 3 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/gcc/ggc-tests.c b/gcc/ggc-tests.c
index 7f97231..b9cd276 100644
--- a/gcc/ggc-tests.c
+++ b/gcc/ggc-tests.c
@@ -27,19 +27,19 @@ along with GCC; see the file COPYING3.  If not see
 
 #if CHECKING_P
 
-/* The various GTY markers must be outside of a namespace to be seen by
-   gengtype, so we don't put this file within the selftest namespace.  */
-
 /* A helper function for writing ggc tests.  */
 
-static void
-forcibly_ggc_collect ()
+void
+selftest::forcibly_ggc_collect ()
 {
   ggc_force_collect = true;
   ggc_collect ();
   ggc_force_collect = false;
 }
 
+/* The various GTY markers must be outside of a namespace to be seen by
+   gengtype, so we don't put this file within the selftest namespace.  */
+
 \f
 
 /* Verify that a simple struct works, and that it can
@@ -58,7 +58,7 @@ test_basic_struct ()
   root_test_struct = ggc_cleared_alloc <test_struct> ();
   root_test_struct->other = ggc_cleared_alloc <test_struct> ();
 
-  forcibly_ggc_collect ();
+  selftest::forcibly_ggc_collect ();
 
   ASSERT_TRUE (ggc_marked_p (root_test_struct));
   ASSERT_TRUE (ggc_marked_p (root_test_struct->other));
@@ -88,7 +88,7 @@ test_length ()
   for (int i = 0; i < count; i++)
     root_test_of_length->elem[i] = ggc_cleared_alloc <test_of_length> ();
 
-  forcibly_ggc_collect ();
+  selftest::forcibly_ggc_collect ();
 
   ASSERT_TRUE (ggc_marked_p (root_test_of_length));
   for (int i = 0; i < count; i++)
@@ -162,7 +162,7 @@ test_union ()
   test_struct *referenced_by_other = ggc_cleared_alloc <test_struct> ();
   other->m_ptr = referenced_by_other;
 
-  forcibly_ggc_collect ();
+  selftest::forcibly_ggc_collect ();
 
   ASSERT_TRUE (ggc_marked_p (root_test_of_union_1));
   ASSERT_TRUE (ggc_marked_p (ts));
@@ -202,7 +202,7 @@ test_finalization ()
 
   test_struct_with_dtor::dtor_call_count = 0;
 
-  forcibly_ggc_collect ();
+  selftest::forcibly_ggc_collect ();
 
   /* Verify that the destructor was run for each instance.  */
   ASSERT_EQ (count, test_struct_with_dtor::dtor_call_count);
@@ -220,7 +220,7 @@ test_deletable_global ()
   test_of_deletable = ggc_cleared_alloc <test_struct> ();
   ASSERT_TRUE (test_of_deletable != NULL);
 
-  forcibly_ggc_collect ();
+  selftest::forcibly_ggc_collect ();
 
   ASSERT_EQ (NULL, test_of_deletable);
 }
@@ -293,7 +293,7 @@ test_inheritance ()
   test_some_subclass_as_base_ptr = new some_subclass ();
   test_some_other_subclass_as_base_ptr = new some_other_subclass ();
 
-  forcibly_ggc_collect ();
+  selftest::forcibly_ggc_collect ();
 
   /* Verify that the roots and everything referenced by them got marked
      (both for fields in the base class and those in subclasses).  */
@@ -372,7 +372,7 @@ test_chain_next ()
       tail_node = new_node;
     }
 
-  forcibly_ggc_collect ();
+  selftest::forcibly_ggc_collect ();
 
   /* If we got here, we survived.  */
 
@@ -439,7 +439,7 @@ test_user_struct ()
 
   num_calls_to_user_gt_ggc_mx = 0;
 
-  forcibly_ggc_collect ();
+  selftest::forcibly_ggc_collect ();
 
   ASSERT_TRUE (ggc_marked_p (root_user_struct_ptr));
   ASSERT_TRUE (ggc_marked_p (referenced));
@@ -457,7 +457,7 @@ test_tree_marking ()
 {
   dummy_unittesting_tree = build_int_cst (integer_type_node, 1066);
 
-  forcibly_ggc_collect ();
+  selftest::forcibly_ggc_collect ();
 
   ASSERT_TRUE (ggc_marked_p (dummy_unittesting_tree));
 }
diff --git a/gcc/selftest-run-tests.c b/gcc/selftest-run-tests.c
index d9d3ea1..54a9b0f 100644
--- a/gcc/selftest-run-tests.c
+++ b/gcc/selftest-run-tests.c
@@ -80,6 +80,12 @@ selftest::run_tests ()
   /* Run any lang-specific selftests.  */
   lang_hooks.run_lang_selftests ();
 
+  /* Force a GC at the end of the selftests, to shake out GC-related
+     issues.  For example, if any GC-managed items have buggy (or missing)
+     finalizers, this last collection will ensure that things that were
+     failed to be finalized can be detected by valgrind.  */
+  forcibly_ggc_collect ();
+
   /* Finished running tests.  */
   long finish_time = get_run_time ();
   long elapsed_time = finish_time - start_time;
diff --git a/gcc/selftest.h b/gcc/selftest.h
index 4c50217..86ad14c 100644
--- a/gcc/selftest.h
+++ b/gcc/selftest.h
@@ -182,6 +182,11 @@ class temp_override
   T m_old_value;
 };
 
+/* A helper function for writing tests that interact with the
+   garbage collector.  */
+
+extern void forcibly_ggc_collect ();
+
 /* Declarations for specific families of tests (by source file), in
    alphabetical order.  */
 extern void bitmap_c_tests ();
-- 
1.8.5.3

  parent reply	other threads:[~2016-10-05 15:44 UTC|newest]

Thread overview: 96+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-05 15:44 [PATCH 00/16] RTL frontend (v3) David Malcolm
2016-10-05 15:44 ` [PATCH 08/16] (partially-approved): Introduce selftest::locate_file David Malcolm
2016-10-05 16:10   ` Bernd Schmidt
2016-10-05 15:44 ` [PATCH 07/16] read-md: add some helper functions David Malcolm
2016-10-05 15:57   ` Bernd Schmidt
2016-10-05 15:44 ` [PATCH 11/16] df selftests (v3) David Malcolm
2016-10-05 15:44 ` [PATCH 01/16] read-md.c: Add various cleanups to ~rtx_reader David Malcolm
2016-10-05 15:51   ` Bernd Schmidt
2016-10-11 15:15     ` David Malcolm
2016-10-12 21:57       ` Richard Sandiford
2016-10-14 17:45         ` [PATCH] read-md.c: Move various state to within class rtx_reader David Malcolm
2016-10-17 11:05           ` Bernd Schmidt
2016-10-17 11:37           ` Richard Sandiford
2016-10-17 16:27             ` [PATCH] read-md.c: Move various state to within class rtx_reader (v3) David Malcolm
2016-10-17 20:23               ` Richard Sandiford
2016-10-05 15:45 ` [PATCH 10/16] Introduce class function_reader (v3) David Malcolm
2016-10-05 16:00   ` Bernd Schmidt
2016-10-07 13:44     ` David Malcolm
2016-10-10 18:53       ` Richard Sandiford
2016-10-05 15:45 ` [PATCH 15/16] RTL frontend (rtl1), on top of dump reader David Malcolm
2016-10-06 13:30   ` Bernd Schmidt
2016-10-06 19:53     ` RTL frontend input format again (was Re: [PATCH 15/16] RTL frontend (rtl1), on top of dump reader) David Malcolm
2016-10-06 19:59       ` David Malcolm
2016-10-07 10:38       ` Bernd Schmidt
2016-10-07 13:27         ` David Malcolm
2016-10-07 13:58           ` Bernd Schmidt
2016-10-07 18:08             ` David Malcolm
2016-10-12 10:45             ` [PATCH] print_rtx_function: integrate dumping of the CFG into the insn chain David Malcolm
2016-10-12 10:50               ` Bernd Schmidt
2016-10-12 17:17             ` [PATCH] Add a "compact" mode to print_rtx_function David Malcolm
2016-10-12 17:31               ` Bernd Schmidt
2016-10-12 20:06                 ` [PATCH] (v2) " David Malcolm
2016-10-13 10:21                   ` Bernd Schmidt
2016-10-13 15:22                     ` [PATCH] Omit INSN_LOCATION from compact dumps David Malcolm
2016-10-13 15:50                       ` Bernd Schmidt
2016-11-22 13:18                   ` [PATCH] (v2) Add a "compact" mode to print_rtx_function Dominik Vogt
2016-11-22 13:32                     ` Bernd Schmidt
2016-11-22 13:37                       ` Jakub Jelinek
2016-11-22 14:25                         ` David Malcolm
2016-11-22 14:39                           ` Dominik Vogt
2016-11-22 14:38                         ` Bernd Schmidt
2016-11-22 14:45                           ` Jakub Jelinek
2016-11-22 15:38                             ` David Malcolm
2016-11-25 16:37                               ` Dominik Vogt
2016-12-01 10:13                               ` [PING] " Dominik Vogt
2016-12-01 12:28                                 ` Bernd Schmidt
2016-12-02 12:36                                   ` Andreas Krebbel
2016-10-12 20:33                 ` [PATCH] Tweaks " David Malcolm
2016-10-13 10:24                   ` Bernd Schmidt
2016-10-13 14:08                     ` David Malcolm
2016-10-13 14:18                       ` Bernd Schmidt
2016-10-14 19:41                         ` [PATCH] (v2) " David Malcolm
2016-10-14 20:07                           ` Bernd Schmidt
2016-10-19 14:36             ` RTL frontend input format again (was Re: [PATCH 15/16] RTL frontend (rtl1), on top of dump reader) David Malcolm
2016-10-19 14:42               ` Bernd Schmidt
2016-10-19 17:19                 ` David Malcolm
2016-10-19 17:22                   ` Bernd Schmidt
2016-10-19 17:54                     ` David Malcolm
2016-10-20 13:55     ` INSN_UIDs " David Malcolm
2016-10-20 14:11       ` Bernd Schmidt
2016-10-20 14:20         ` David Malcolm
2016-10-20 14:22           ` Bernd Schmidt
2016-10-26 18:19         ` [PATCH] Show INSN_UIDs in compact mode David Malcolm
2016-10-26 18:20           ` Bernd Schmidt
2016-10-06 15:24   ` [PATCH 15/16] RTL frontend (rtl1), on top of dump reader Bernd Schmidt
2016-10-07 16:22     ` [PATCH] RTL frontend (rtl1), on top of dump reader (v4) David Malcolm
2016-10-05 15:45 ` [PATCH 05/16] Introduce rtl_data::init_stack_alignment David Malcolm
2016-10-05 15:52   ` Bernd Schmidt
2016-10-05 15:45 ` [PATCH 12/16] combine.c selftests (v2) David Malcolm
2016-10-05 15:45 ` [PATCH 13/16] cse.c selftests David Malcolm
2016-10-05 15:45 ` [PATCH 02/16] (approved) Add selftest::read_file David Malcolm
2016-10-05 15:45 ` [PATCH 16/16] Add "__RTL" to cc1 David Malcolm
2016-10-05 16:10   ` Joseph Myers
2016-10-07 15:27     ` [PATCH] Add "__RTL" to cc1 (v2) David Malcolm
2016-10-13 13:49       ` Richard Biener
2016-10-13 13:52         ` Bernd Schmidt
2016-10-14  9:33           ` Richard Biener
2016-10-14  9:48             ` Bernd Schmidt
2016-10-14  9:50               ` Richard Biener
2016-10-14 19:25             ` David Malcolm
2016-10-14 19:27               ` Bernd Schmidt
2016-10-14 19:35                 ` David Malcolm
2016-10-14 19:23         ` David Malcolm
2016-10-05 15:45 ` [PATCH 03/16] (approved) selftest.h: add temp_override fixture David Malcolm
2016-10-05 15:45 ` [PATCH 09/16] Split class rtx_reader into base_rtx_reader vs rtx_reader David Malcolm
2016-10-11 15:53   ` Bernd Schmidt
2016-10-18 20:30     ` David Malcolm
2016-10-19 14:45       ` Bernd Schmidt
2016-10-20 19:14         ` Richard Sandiford
2016-10-05 15:45 ` [PATCH 14/16] RTL interpreter (work-in-progress) David Malcolm
2016-10-05 15:45 ` David Malcolm [this message]
2016-10-05 15:45 ` [PATCH 06/16] Introduce emit_status::ensure_regno_capacity David Malcolm
2016-10-05 15:55   ` Bernd Schmidt
2016-11-18 20:47     ` [PATCH] Introduce emit_status::ensure_regno_capacity (v5) David Malcolm
2016-11-22 13:34       ` Bernd Schmidt
2016-10-05 15:55   ` [PATCH 06/16] Introduce emit_status::ensure_regno_capacity Bernd Schmidt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1475684110-2521-5-git-send-email-dmalcolm@redhat.com \
    --to=dmalcolm@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).