aboutsummaryrefslogtreecommitdiff
path: root/gcc/function-tests.c
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2016-10-12 14:59:56 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2016-10-12 14:59:56 +0000
commit4b77ac40f0fe35d541914de0227b5c37d88c619c (patch)
tree6f600c5fed34a8cdcd35c7c128cf15b652125813 /gcc/function-tests.c
parent2934018d2785fa77b1e1e4fdd5c92139210b5056 (diff)
downloadgcc-4b77ac40f0fe35d541914de0227b5c37d88c619c.zip
gcc-4b77ac40f0fe35d541914de0227b5c37d88c619c.tar.gz
gcc-4b77ac40f0fe35d541914de0227b5c37d88c619c.tar.bz2
print_rtx_function: integrate dumping of the CFG into the insn chain
gcc/ChangeLog: * function-tests.c: Include "print-rtl.h". (selftest::test_expansion_to_rtl): Call print_rtx_function on the function, and verify what is dumped. * print-rtl-function.c (print_edge): New function. (begin_any_block): New function. (end_any_block): New function. (can_have_basic_block_p): New function. (print_rtx_function): Track the basic blocks of insns in the chain, wrapping those that are within blocks within "(block)" directives. Remove the "(cfg)" directive. From-SVN: r241057
Diffstat (limited to 'gcc/function-tests.c')
-rw-r--r--gcc/function-tests.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/gcc/function-tests.c b/gcc/function-tests.c
index 4152cd3..049a07f9 100644
--- a/gcc/function-tests.c
+++ b/gcc/function-tests.c
@@ -78,6 +78,7 @@ along with GCC; see the file COPYING3. If not see
#include "ipa-ref.h"
#include "cgraph.h"
#include "selftest.h"
+#include "print-rtl.h"
#if CHECKING_P
@@ -643,6 +644,27 @@ test_expansion_to_rtl ()
/* ...etc; any further checks are likely to over-specify things
and run us into target dependencies. */
+
+ /* Verify that print_rtl_function is sane. */
+ named_temp_file tmp_out (".rtl");
+ FILE *outfile = fopen (tmp_out.get_filename (), "w");
+ print_rtx_function (outfile, fun);
+ fclose (outfile);
+
+ char *dump = read_file (SELFTEST_LOCATION, tmp_out.get_filename ());
+ ASSERT_STR_CONTAINS (dump, "(function \"test_fn\"\n");
+ ASSERT_STR_CONTAINS (dump, " (insn-chain\n");
+ ASSERT_STR_CONTAINS (dump, " (block 2\n");
+ ASSERT_STR_CONTAINS (dump, " (edge-from entry (flags \"FALLTHRU\"))\n");
+ ASSERT_STR_CONTAINS (dump, " (insn "); /* ...etc. */
+ ASSERT_STR_CONTAINS (dump, " (edge-to exit (flags \"FALLTHRU\"))\n");
+ ASSERT_STR_CONTAINS (dump, " ) ;; block 2\n");
+ ASSERT_STR_CONTAINS (dump, " ) ;; insn-chain\n");
+ ASSERT_STR_CONTAINS (dump, " (crtl\n");
+ ASSERT_STR_CONTAINS (dump, " ) ;; crtl\n");
+ ASSERT_STR_CONTAINS (dump, ") ;; function \"test_fn\"\n");
+
+ free (dump);
}
/* Run all of the selftests within this file. */