Support running the selftests under valgrind
authorDavid Malcolm <dmalcolm@redhat.com>
Mon, 11 Jul 2016 14:39:14 +0000 (14:39 +0000)
committerDavid Malcolm <dmalcolm@gcc.gnu.org>
Mon, 11 Jul 2016 14:39:14 +0000 (14:39 +0000)
gcc/ChangeLog:
* Makefile.in (selftest-valgrind): New phony target.
* function-tests.c (selftest::build_cfg): Delete pass instances
created by the test.
(selftest::convert_to_ssa): Likewise.
(selftest::test_expansion_to_rtl): Likewise.
* tree-cfg.c (selftest::test_linear_chain): Release dominator
vectors.
(selftest::test_diamond): Likewise.

From-SVN: r238209

gcc/ChangeLog
gcc/Makefile.in
gcc/function-tests.c
gcc/tree-cfg.c

index d0dde932049ba2e1eebd9cb087fadf1f1dab60b5..1abee42bb9bd10d772a3e20b5059dedf9482dae9 100644 (file)
@@ -1,3 +1,14 @@
+2016-07-11  David Malcolm  <dmalcolm@redhat.com>
+
+       * Makefile.in (selftest-valgrind): New phony target.
+       * function-tests.c (selftest::build_cfg): Delete pass instances
+       created by the test.
+       (selftest::convert_to_ssa): Likewise.
+       (selftest::test_expansion_to_rtl): Likewise.
+       * tree-cfg.c (selftest::test_linear_chain): Release dominator
+       vectors.
+       (selftest::test_diamond): Likewise.
+
 2016-07-11  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/71816
index 5e7422da0c0c4aacd980a3d3f959b3c35ce1ae13..1a4b5d7f476f54b543dabe77ccd574e04948ed2f 100644 (file)
@@ -1869,6 +1869,12 @@ s-selftest: $(GCC_PASSES) cc1$(exeext) stmp-int-hdrs
 selftest-gdb: $(GCC_PASSES) cc1$(exeext) stmp-int-hdrs
        $(GCC_FOR_TARGET) -xc -S -c /dev/null -fself-test -wrapper gdb,--args
 
+# Convenience method for running selftests under valgrind:
+.PHONY: selftest-valgrind
+selftest-valgrind: $(GCC_PASSES) cc1$(exeext) stmp-int-hdrs
+       $(GCC_FOR_TARGET) -xc -S -c /dev/null -fself-test \
+         -wrapper valgrind,--leak-check=full
+
 # Recompile all the language-independent object files.
 # This is used only if the user explicitly asks for it.
 compilations: $(BACKEND)
index c8188e769fa03ae6ee4bade3bc08364819b9e907..edd355fa15338a23454af5d59ff37dba29ff44a0 100644 (file)
@@ -296,6 +296,7 @@ build_cfg (tree fndecl)
   push_cfun (fun);
   lower_cf_pass->execute (fun);
   pop_cfun ();
+  delete lower_cf_pass;
 
   /* We can now convert to CFG form; for our trivial test function this
      gives us:
@@ -310,6 +311,7 @@ build_cfg (tree fndecl)
   push_cfun (fun);
   build_cfg_pass->execute (fun);
   pop_cfun ();
+  delete build_cfg_pass;
 }
 
 /* Convert a gimple+CFG function to SSA form.  */
@@ -325,6 +327,7 @@ convert_to_ssa (tree fndecl)
   push_cfun (fun);
   build_ssa_pass->execute (fun);
   pop_cfun ();
+  delete build_ssa_pass;
 }
 
 /* Assuming we have a simple 3-block CFG like this:
@@ -594,6 +597,7 @@ test_expansion_to_rtl ()
   init_function_start (fndecl);
   expand_pass->execute (fun);
   pop_cfun ();
+  delete expand_pass;
 
   /* On x86_64, I get this:
        (note 3 1 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK)
index 0fac49c38602a40e3422d113aa85d55b4c727d65..6d6943503fe911a7e43ae9ab86776cf7a23b4f2c 100644 (file)
@@ -9276,6 +9276,7 @@ test_linear_chain ()
   ASSERT_EQ (1, dom_by_b.length ());
   ASSERT_EQ (bb_c, dom_by_b[0]);
   free_dominance_info (CDI_DOMINATORS);
+  dom_by_b.release ();
 
   /* Similarly for post-dominance: each BB in our chain is post-dominated
      by the one after it.  */
@@ -9286,6 +9287,7 @@ test_linear_chain ()
   ASSERT_EQ (1, postdom_by_b.length ());
   ASSERT_EQ (bb_a, postdom_by_b[0]);
   free_dominance_info (CDI_POST_DOMINATORS);
+  postdom_by_b.release ();
 
   pop_cfun ();
 }
@@ -9346,8 +9348,10 @@ test_diamond ()
   ASSERT_EQ (bb_a, get_immediate_dominator (CDI_DOMINATORS, bb_d));
   vec<basic_block> dom_by_a = get_dominated_by (CDI_DOMINATORS, bb_a);
   ASSERT_EQ (3, dom_by_a.length ()); /* B, C, D, in some order.  */
+  dom_by_a.release ();
   vec<basic_block> dom_by_b = get_dominated_by (CDI_DOMINATORS, bb_b);
   ASSERT_EQ (0, dom_by_b.length ());
+  dom_by_b.release ();
   free_dominance_info (CDI_DOMINATORS);
 
   /* Similarly for post-dominance.  */
@@ -9357,8 +9361,10 @@ test_diamond ()
   ASSERT_EQ (bb_d, get_immediate_dominator (CDI_POST_DOMINATORS, bb_c));
   vec<basic_block> postdom_by_d = get_dominated_by (CDI_POST_DOMINATORS, bb_d);
   ASSERT_EQ (3, postdom_by_d.length ()); /* A, B, C in some order.  */
+  postdom_by_d.release ();
   vec<basic_block> postdom_by_b = get_dominated_by (CDI_POST_DOMINATORS, bb_b);
   ASSERT_EQ (0, postdom_by_b.length ());
+  postdom_by_b.release ();
   free_dominance_info (CDI_POST_DOMINATORS);
 
   pop_cfun ();