This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 6/9] df selftests
On 09/08/2016 06:30 PM, David Malcolm wrote:
gcc/ChangeLog:
* df-core.c: Include selftest.h and selftest-rtl.h.
(selftest::dataflow_test::dataflow_test): New ctor.
(selftest::dataflow_test::~dataflow_test): New dtor.
(selftest::test_df_single_set): New function.
(selftest::df_core_c_tests): New function.
* selftest-run-tests.c (selftest::run_tests): Call it.
* selftest.h (selftest::df_core_c_tests): New decl.
---
gcc/df-core.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++
gcc/selftest-run-tests.c | 1 +
gcc/selftest.h | 1 +
3 files changed, 79 insertions(+)
diff --git a/gcc/df-core.c b/gcc/df-core.c
index e531d58..cb8e2f9 100644
--- a/gcc/df-core.c
+++ b/gcc/df-core.c
@@ -384,6 +384,8 @@ are write-only operations.
#include "cfganal.h"
#include "tree-pass.h"
#include "cfgloop.h"
+#include "selftest.h"
+#include "selftest-rtl.h"
static void *df_get_bb_info (struct dataflow *, unsigned int);
static void df_set_bb_info (struct dataflow *, unsigned int, void *);
@@ -2482,3 +2484,78 @@ debug_df_chain (struct df_link *link)
df_chain_dump (link, stderr);
fputc ('\n', stderr);
}
+
+#if CHECKING_P
+
+namespace selftest {
+
+/* dataflow_test's constructor. Initialize df. */
+
+dataflow_test::dataflow_test ()
+{
+ rest_of_handle_df_initialize ();
+}
+
+/* dataflow_test's destructor. Clean up df. */
+
+dataflow_test::~dataflow_test ()
+{
+ rest_of_handle_df_finish ();
+}
+
+/* Verify df_note on a trivial function. */
+
+void
+test_df_single_set ()
+{
+ const char *input_dump
+ = "(insn 1 0 0 2 (set (reg:SI 100) (reg:SI 101)) -1 (nil))\n";
+ rtl_dump_test t (input_dump, 100);
+ //print_rtl_with_bb (stdout, get_insns (), 1024);
Obviously this call to pritn_rtl_with_bb should disappear...
+
+ dataflow_test dftest;
+
+ df_note_add_problem ();
+ df_analyze ();
+ //df_dump (stderr);
ANd this call to df_dump.
+
+ ASSERT_EQ (SET_SRC (PATTERN (insn)), note0->element ());
+ ASSERT_EQ (REG_DEAD, REG_NOTE_KIND (note0));
+
+ ASSERT_EQ (SET_DEST (PATTERN (insn)), note1->element ());
+ ASSERT_EQ (REG_UNUSED, REG_NOTE_KIND (note1));
I don't think the ordering of the notes is guaranteed.
Like the other RTL test I've looked at, I'd be real curious to know if
you get any uninitialized memory reads if you run this test under valgrind.
jeff