@@ -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,74 @@ 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 ()
+{
+ rtl_dump_test t (SELFTEST_LOCATION, locate_file ("single-set.rtl"));
+
+ dataflow_test dftest;
+
+ df_note_add_problem ();
+ df_analyze ();
+ df_finish_pass (false);
+
+ rtx_insn *insn = get_insn_by_uid (1);
+
+ ASSERT_NE (NULL, REG_NOTES (insn));
+ rtx_expr_list *note0 = as_a <rtx_expr_list *> (REG_NOTES (insn));
+
+ rtx_expr_list *note1 = note0->next ();
+ ASSERT_NE (NULL, note1);
+
+ ASSERT_EQ (NULL, note1->next ());
+
+ 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));
+
+ struct df_lr_bb_info *bb_info = df_lr_get_bb_info (2);
+ ASSERT_NE (NULL, bb_info);
+
+ /* "r100 = r101;" so we should have a use of r101. */
+ ASSERT_FALSE (bitmap_bit_p (&bb_info->use, t.effective_regno (100)));
+ ASSERT_TRUE (bitmap_bit_p (&bb_info->use, t.effective_regno (101)));
+
+ /* ...and a def of r100. */
+ ASSERT_TRUE (bitmap_bit_p (&bb_info->def, t.effective_regno (100)));
+ ASSERT_FALSE (bitmap_bit_p (&bb_info->def, t.effective_regno (101)));
+}
+
+/* Run all of the selftests within this file. */
+
+void
+df_core_c_tests ()
+{
+ test_df_single_set ();
+}
+
+} // namespace selftest
+
+#endif /* #if CHECKING_P */
@@ -71,6 +71,7 @@ selftest::run_tests ()
gimple_c_tests ();
rtl_tests_c_tests ();
read_rtl_function_c_tests ();
+ df_core_c_tests ();
/* Higher-level tests, or for components that other selftests don't
rely on. */
@@ -200,6 +200,7 @@ extern const char *path_to_src_gcc;
/* Declarations for specific families of tests (by source file), in
alphabetical order. */
extern void bitmap_c_tests ();
+extern void df_core_c_tests ();
extern void diagnostic_c_tests ();
extern void diagnostic_show_locus_c_tests ();
extern void edit_context_c_tests ();
new file mode 100644
@@ -0,0 +1,5 @@
+(function "test"
+ (insn-chain
+ (insn 1 0 0 2 (set (reg:SI 100) (reg:SI 101)) -1 (nil))
+ ) ;; insn-chain
+) ;; function