From 9e34db2e031f28f7cc622b6955c241b47bbc081e Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Mon, 11 Jul 2016 14:39:14 +0000 Subject: [PATCH] Support running the selftests under valgrind 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 | 11 +++++++++++ gcc/Makefile.in | 6 ++++++ gcc/function-tests.c | 4 ++++ gcc/tree-cfg.c | 6 ++++++ 4 files changed, 27 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d0dde932049..1abee42bb9b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2016-07-11 David Malcolm + + * 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 PR tree-optimization/71816 diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 5e7422da0c0..1a4b5d7f476 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -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) diff --git a/gcc/function-tests.c b/gcc/function-tests.c index c8188e769fa..edd355fa153 100644 --- a/gcc/function-tests.c +++ b/gcc/function-tests.c @@ -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) diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 0fac49c3860..6d6943503fe 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -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 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 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 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 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 (); -- 2.30.2