From: David Malcolm <dmalcolm@redhat.com>
To: gcc-patches@gcc.gnu.org
Cc: David Malcolm <dmalcolm@redhat.com>
Subject: [PATCH 07/16] Add test-functions.c to unittests
Date: Tue, 27 Oct 2015 19:32:00 -0000 [thread overview]
Message-ID: <1445975355-37660-8-git-send-email-dmalcolm@redhat.com> (raw)
In-Reply-To: <1445975355-37660-1-git-send-email-dmalcolm@redhat.com>
gcc/testsuite/ChangeLog:
* unittests/test-functions.c: New file.
---
gcc/testsuite/unittests/test-functions.c | 645 +++++++++++++++++++++++++++++++
1 file changed, 645 insertions(+)
create mode 100644 gcc/testsuite/unittests/test-functions.c
diff --git a/gcc/testsuite/unittests/test-functions.c b/gcc/testsuite/unittests/test-functions.c
new file mode 100644
index 0000000..56630b5
--- /dev/null
+++ b/gcc/testsuite/unittests/test-functions.c
@@ -0,0 +1,645 @@
+/* Unit tests for function-handling.
+ Copyright (C) 2015 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#include "config.h"
+#include "gtest/gtest.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "opts.h"
+#include "signop.h"
+#include "hash-set.h"
+#include "fixed-value.h"
+#include "alias.h"
+#include "flags.h"
+#include "symtab.h"
+#include "tree-core.h"
+#include "stor-layout.h"
+#include "tree.h"
+#include "stringpool.h"
+#include "stor-layout.h"
+#include "rtl.h"
+#include "predict.h"
+#include "vec.h"
+#include "hashtab.h"
+#include "hash-set.h"
+#include "machmode.h"
+#include "hard-reg-set.h"
+#include "input.h"
+#include "function.h"
+#include "dominance.h"
+#include "cfg.h"
+#include "cfganal.h"
+#include "basic-block.h"
+#include "tree-ssa-alias.h"
+#include "internal-fn.h"
+#include "gimple-fold.h"
+#include "gimple-expr.h"
+#include "toplev.h"
+#include "print-tree.h"
+#include "tree-iterator.h"
+#include "gimplify.h"
+#include "tree-cfg.h"
+#include "basic-block.h"
+#include "double-int.h"
+#include "alias.h"
+#include "symtab.h"
+#include "wide-int.h"
+#include "inchash.h"
+#include "tree.h"
+#include "fold-const.h"
+#include "stor-layout.h"
+#include "stmt.h"
+#include "hash-table.h"
+#include "tree-ssa-alias.h"
+#include "internal-fn.h"
+#include "gimple-expr.h"
+#include "is-a.h"
+#include "gimple.h"
+#include "tree-pass.h"
+#include "context.h"
+#include "hash-map.h"
+#include "plugin-api.h"
+#include "ipa-ref.h"
+#include "cgraph.h"
+
+namespace {
+
+class function_test : public ::testing::Test
+{
+ protected:
+ tree
+ make_fndecl (tree return_type,
+ const char *name,
+ vec <tree> ¶m_types,
+ bool is_variadic = false)
+ {
+ tree fn_type;
+ if (is_variadic)
+ fn_type = build_varargs_function_type_array (return_type,
+ param_types.length (),
+ param_types.address ());
+ else
+ fn_type = build_function_type_array (return_type,
+ param_types.length (),
+ param_types.address ());
+ /* FIXME: this uses input_location: */
+ tree fndecl = build_fn_decl (name, fn_type);
+
+ return fndecl;
+ }
+};
+
+TEST_F (function_test, fndecl_int_void)
+{
+ auto_vec <tree> param_types;
+ tree fndecl = make_fndecl (integer_type_node,
+ "test_fndecl_int_void",
+ param_types);
+ ASSERT_TRUE (fndecl != NULL);
+ if (0)
+ debug_tree (fndecl);
+
+ /* Verify name of decl. */
+ tree declname = DECL_NAME (fndecl);
+ ASSERT_TRUE (declname != NULL);
+ EXPECT_EQ (IDENTIFIER_NODE, TREE_CODE (declname));
+ /* We expect it to use a *copy* of the string we passed in. */
+ const char *identifier_ptr = IDENTIFIER_POINTER (declname);
+ EXPECT_NE ("test_fndecl_int_void", identifier_ptr);
+ EXPECT_EQ (0, strcmp ("test_fndecl_int_void", identifier_ptr));
+
+ /* Verify type of fndecl. */
+ EXPECT_EQ (FUNCTION_DECL, TREE_CODE (fndecl));
+ tree fntype = TREE_TYPE (fndecl);
+ EXPECT_EQ (FUNCTION_TYPE, TREE_CODE (fntype));
+
+ /* Verify return type. */
+ EXPECT_EQ (integer_type_node, TREE_TYPE (fntype));
+
+ /* Verify "void" args. */
+ tree argtypes = TYPE_ARG_TYPES (fntype);
+ EXPECT_EQ (TREE_LIST, TREE_CODE (argtypes));
+ EXPECT_EQ (void_type_node, TREE_VALUE (argtypes));
+ EXPECT_EQ (NULL, TREE_CHAIN (argtypes));
+}
+
+TEST_F (function_test, fndecl_float_intchar)
+{
+ auto_vec <tree> param_types;
+ param_types.safe_push (integer_type_node);
+ param_types.safe_push (char_type_node);
+ tree fndecl = make_fndecl (float_type_node,
+ "test_fndecl_float_intchar",
+ param_types);
+ ASSERT_TRUE (fndecl != NULL);
+ if (0)
+ debug_tree (fndecl);
+
+ /* Verify name of decl. */
+ tree declname = DECL_NAME (fndecl);
+ ASSERT_TRUE (declname != NULL);
+ EXPECT_EQ (IDENTIFIER_NODE, TREE_CODE (declname));
+ /* We expect it to use a *copy* of the string we passed in. */
+ const char *identifier_ptr = IDENTIFIER_POINTER (declname);
+ EXPECT_NE ("test_fndecl_float_intchar", identifier_ptr);
+ EXPECT_EQ (0, strcmp ("test_fndecl_float_intchar", identifier_ptr));
+
+ /* Verify type of fndecl. */
+ EXPECT_EQ (FUNCTION_DECL, TREE_CODE (fndecl));
+ tree fntype = TREE_TYPE (fndecl);
+ EXPECT_EQ (FUNCTION_TYPE, TREE_CODE (fntype));
+
+ /* Verify return type. */
+ EXPECT_EQ (float_type_node, TREE_TYPE (fntype));
+
+ /* Verify "(int, char)" args. */
+ tree arg0 = TYPE_ARG_TYPES (fntype);
+ EXPECT_EQ (TREE_LIST, TREE_CODE (arg0));
+ EXPECT_EQ (integer_type_node, TREE_VALUE (arg0));
+ tree arg1 = TREE_CHAIN (arg0);
+ ASSERT_TRUE (arg1 != NULL);
+ EXPECT_EQ (TREE_LIST, TREE_CODE (arg1));
+ EXPECT_EQ (char_type_node, TREE_VALUE (arg1));
+ tree argterm = TREE_CHAIN (arg1);
+ ASSERT_TRUE (argterm != NULL);
+ EXPECT_EQ (TREE_LIST, TREE_CODE (argterm));
+ EXPECT_EQ (void_type_node, TREE_VALUE (argterm));
+ EXPECT_EQ (NULL, TREE_CHAIN (argterm));
+}
+
+/* The test cases using this fixture take a trivial function:
+
+ int test_fn (void) { return 42; }
+
+ and test various conversions done to it:
+
+ - gimplification
+ - construction of the CFG
+ - conversion to SSA form
+ - expansion to RTL form
+
+ In avoid having one overlong test case, this is broken
+ up into separate test cases for each stage, with helper methods
+ in this fixture to minimize code duplication.
+
+ Another approach would be to attempt to directly construct a function
+ in the appropriate representation at each stage, though presumably
+ that would exhibit different kinds of failure compared to this
+ approach. */
+
+class representation_test : public function_test
+{
+ protected:
+ /* Construct this function:
+ int test_fn (void) { return 42; }
+ in generic tree form. Return the fndecl. */
+ tree
+ build_trivial_generic_function ()
+ {
+ auto_vec <tree> param_types;
+ tree fndecl = make_fndecl (integer_type_node,
+ "test_fn",
+ param_types);
+ EXPECT_TRUE (fndecl != NULL);
+
+ /* Populate the function. */
+ tree retval = build_decl (UNKNOWN_LOCATION, RESULT_DECL,
+ NULL_TREE, integer_type_node);
+ DECL_ARTIFICIAL (retval) = 1;
+ DECL_IGNORED_P (retval) = 1;
+ DECL_RESULT (fndecl) = retval;
+
+ /* Create a BIND_EXPR, and within it, a statement list. */
+ tree stmt_list = alloc_stmt_list ();
+ tree_stmt_iterator stmt_iter = tsi_start (stmt_list);
+ tree block = make_node (BLOCK);
+ tree bind_expr =
+ build3 (BIND_EXPR, void_type_node, NULL, stmt_list, block);
+
+ tree modify_retval = build2 (MODIFY_EXPR,
+ integer_type_node,
+ retval,
+ build_int_cst (integer_type_node, 42));
+ tree return_stmt = build1 (RETURN_EXPR,
+ integer_type_node,
+ modify_retval);
+ tsi_link_after (&stmt_iter, return_stmt, TSI_CONTINUE_LINKING);
+
+ DECL_INITIAL (fndecl) = block;
+
+ /* how to add to function? the following appears to be how to
+ set the body of a fndecl: */
+ DECL_SAVED_TREE(fndecl) = bind_expr;
+
+ /* Ensure that locals appear in the debuginfo. */
+ BLOCK_VARS (block) = BIND_EXPR_VARS (bind_expr);
+
+ if (0)
+ debug_tree (fndecl);
+
+ return fndecl;
+ }
+
+ /* Construct this function:
+ int test_fn (void) { return 42; }
+ in "high gimple" form. Return the fndecl. */
+ tree
+ build_trivial_high_gimple_function ()
+ {
+ /* Construct a trivial function, and gimplify it: */
+ tree fndecl = build_trivial_generic_function ();
+ gimplify_function_tree (fndecl);
+ return fndecl;
+ }
+
+ /* Build a CFG for a function in gimple form. */
+ void
+ build_cfg (tree fndecl)
+ {
+ function *fun = DECL_STRUCT_FUNCTION (fndecl);
+ ASSERT_TRUE (fun != NULL);
+ EXPECT_EQ (fndecl, fun->decl);
+
+ /* We first have to lower control flow; for our trivial test function
+ this gives us:
+ test_fn ()
+ {
+ D.56 = 42;
+ goto <D.57>;
+ <D.57>:
+ return D.56;
+ }
+ */
+ gimple_opt_pass *lower_cf_pass = make_pass_lower_cf (g);
+ push_cfun (fun);
+ lower_cf_pass->execute (fun);
+ pop_cfun ();
+ if (0)
+ dump_function_to_file (fndecl, stderr, 0);
+
+ /* We can now convert to CFG form; for our trivial test function this
+ gives us:
+ test_fn ()
+ {
+ <bb 2>:
+ D.56 = 42;
+ return D.56;
+ }
+ */
+ gimple_opt_pass *build_cfg_pass = make_pass_build_cfg (g);
+ push_cfun (fun);
+ build_cfg_pass->execute (fun);
+ pop_cfun ();
+ if (0)
+ dump_function_to_file (fndecl, stderr, 0);
+ }
+
+ /* Convert a gimple+CFG function to SSA form. */
+ void
+ convert_to_ssa (tree fndecl)
+ {
+ function *fun = DECL_STRUCT_FUNCTION (fndecl);
+ ASSERT_TRUE (fun != NULL);
+ EXPECT_EQ (fndecl, fun->decl);
+
+ gimple_opt_pass *pass_init_datastructures =
+ make_pass_init_datastructures (g);
+ gimple_opt_pass *build_ssa_pass = make_pass_build_ssa (g);
+ push_cfun (fun);
+ pass_init_datastructures->execute (fun);
+ build_ssa_pass->execute (fun);
+ pop_cfun ();
+ }
+
+ /* Assuming we have a simple 3-block CFG like this:
+ [ENTRY] -> [block2] -> [EXIT]
+ get the "real" basic block (block 2). */
+ basic_block
+ get_real_block (function *fun)
+ {
+ EXPECT_TRUE (fun->cfg != NULL);
+ EXPECT_EQ (3, n_basic_blocks_for_fn (fun));
+ basic_block bb2 = (*fun->cfg->x_basic_block_info)[2];
+ EXPECT_TRUE (bb2 != NULL);
+ return bb2;
+ }
+
+ /* Verify that we have a simple 3-block CFG: the two "fake" ones, and
+ a "real" one:
+ [ENTRY] -> [block2] -> [EXIT]. */
+ void
+ verify_three_block_cfg (function *fun)
+ {
+ ASSERT_TRUE (fun->cfg != NULL);
+ EXPECT_EQ (3, n_basic_blocks_for_fn (fun));
+ EXPECT_EQ (2, n_edges_for_fn (fun));
+
+ /* The "fake" basic blocks. */
+ basic_block entry = ENTRY_BLOCK_PTR_FOR_FN (fun);
+ ASSERT_TRUE (entry != NULL);
+ EXPECT_EQ (ENTRY_BLOCK, entry->index);
+
+ basic_block exit = EXIT_BLOCK_PTR_FOR_FN (fun);
+ ASSERT_TRUE (exit != NULL);
+ EXPECT_EQ (EXIT_BLOCK, exit->index);
+
+ /* The "real" basic block. */
+ basic_block bb2 = get_real_block (fun);
+ ASSERT_TRUE (bb2 != NULL);
+ EXPECT_EQ (2, bb2->index);
+
+ /* Verify connectivity. */
+ EXPECT_EQ (NULL, entry->preds);
+ EXPECT_EQ (1, entry->succs->length ());
+
+ edge from_entry_to_bb2 = (*entry->succs)[0];
+ EXPECT_EQ (entry, from_entry_to_bb2->src);
+ EXPECT_EQ (bb2, from_entry_to_bb2->dest);
+
+ EXPECT_EQ (1, bb2->preds->length ());
+ EXPECT_EQ (from_entry_to_bb2, (*bb2->preds)[0]);
+ EXPECT_EQ (1, bb2->succs->length ());
+
+ edge from_bb2_to_exit = (*bb2->succs)[0];
+ EXPECT_EQ (bb2, from_bb2_to_exit->src);
+ EXPECT_EQ (exit, from_bb2_to_exit->dest);
+
+ EXPECT_EQ (1, exit->preds->length ());
+ EXPECT_EQ (from_bb2_to_exit, (*exit->preds)[0]);
+ EXPECT_EQ (NULL, exit->succs);
+ }
+
+ /* As above, but additionally verify the gimple statements are sane. */
+ void
+ verify_three_block_gimple_cfg (function *fun)
+ {
+ verify_three_block_cfg (fun);
+
+ /* The "fake" basic blocks should be flagged as gimple, but with have no
+ statements. */
+ basic_block entry = ENTRY_BLOCK_PTR_FOR_FN (fun);
+ ASSERT_TRUE (entry != NULL);
+ EXPECT_EQ (0, entry->flags & BB_RTL);
+ EXPECT_EQ (NULL, bb_seq (entry));
+
+ basic_block exit = EXIT_BLOCK_PTR_FOR_FN (fun);
+ ASSERT_TRUE (exit != NULL);
+ EXPECT_EQ (0, entry->flags & BB_RTL);
+ EXPECT_EQ (NULL, bb_seq (exit));
+
+ /* The "real" basic block should be flagged as gimple, and have one
+ or more statements. */
+ basic_block bb2 = get_real_block (fun);
+ ASSERT_TRUE (bb2 != NULL);
+ EXPECT_EQ (0, entry->flags & BB_RTL);
+ EXPECT_TRUE (bb_seq (bb2) != NULL);
+ }
+
+ /* As above, but additionally verify the RTL insns are sane. */
+ void
+ verify_three_block_rtl_cfg (function *fun)
+ {
+ verify_three_block_cfg (fun);
+
+ /* The "fake" basic blocks should be flagged as RTL, but with no
+ insns. */
+ basic_block entry = ENTRY_BLOCK_PTR_FOR_FN (fun);
+ ASSERT_TRUE (entry != NULL);
+ EXPECT_EQ (BB_RTL, entry->flags & BB_RTL);
+ EXPECT_EQ (NULL, BB_HEAD (entry));
+
+ basic_block exit = EXIT_BLOCK_PTR_FOR_FN (fun);
+ ASSERT_TRUE (exit != NULL);
+ EXPECT_EQ (BB_RTL, entry->flags & BB_RTL);
+ EXPECT_EQ (NULL, BB_HEAD (exit));
+
+ /* The "real" basic block should be flagged as RTL, and have one
+ or more insns. */
+ basic_block bb2 = get_real_block (fun);
+ ASSERT_TRUE (bb2 != NULL);
+ EXPECT_EQ (BB_RTL, entry->flags & BB_RTL);
+ EXPECT_TRUE (BB_HEAD (bb2) != NULL);
+ }
+
+};
+
+/* Test converting our trivial function:
+ int test_fn (void) { return 42; }
+ to gimple form. */
+
+TEST_F (representation_test, gimplification)
+{
+ tree fndecl = build_trivial_generic_function ();
+
+ /* Convert to gimple: */
+ gimplify_function_tree (fndecl);
+
+ if (0)
+ dump_function_to_file (fndecl, stderr, 0);
+
+ /* Verify that we got gimple out of it. */
+
+ /* The function is now in GIMPLE form but the CFG has not been
+ built yet. */
+
+ /* We should have a struct function for the decl. */
+ function *fun = DECL_STRUCT_FUNCTION (fndecl);
+ ASSERT_TRUE (fun != NULL);
+ EXPECT_EQ (fndecl, fun->decl);
+
+ /* We expect a GIMPLE_BIND, with two gimple statements within it:
+ tmp = 42;
+ return tmp; */
+
+ gimple_seq seq_fn_body = gimple_body (fndecl);
+ EXPECT_TRUE (seq_fn_body != NULL);
+ gimple *bind_stmt = gimple_seq_first_stmt (seq_fn_body);
+ EXPECT_EQ (GIMPLE_BIND, gimple_code (bind_stmt));
+ EXPECT_EQ (NULL, bind_stmt->next);
+
+ gimple_seq seq_bind_body = gimple_bind_body (as_a <gbind *> (bind_stmt));
+
+ /* Verify that we have the 2 statements we expect. */
+ EXPECT_TRUE (seq_bind_body != NULL);
+ gimple *stmt1 = gimple_seq_first_stmt (seq_bind_body);
+ ASSERT_TRUE (stmt1 != NULL);
+ EXPECT_EQ (GIMPLE_ASSIGN, gimple_code (stmt1));
+ gimple *stmt2 = stmt1->next;
+ ASSERT_TRUE (stmt2 != NULL);
+ EXPECT_EQ (stmt1, stmt2->prev);
+ EXPECT_EQ (GIMPLE_RETURN, gimple_code (stmt2));
+}
+
+/* Test of building a CFG for a function in high gimple form. */
+
+TEST_F (representation_test, building_cfg)
+{
+ /* Construct a trivial function, and gimplify it: */
+ tree fndecl = build_trivial_high_gimple_function ();
+ function *fun = DECL_STRUCT_FUNCTION (fndecl);
+ ASSERT_TRUE (fun != NULL);
+
+ /* Build a CFG. */
+ build_cfg (fndecl);
+
+ /* The CFG-building code constructs a 4-block cfg (with
+ ENTRY and EXIT):
+ test_fn ()
+ {
+ <bb 2>:
+ D.65 = 42;
+
+ <bb 3>:
+ return D.65;
+ }
+ and then ought to merge blocks 2 and 3 in cleanup_tree_cfg.
+
+ Hence we should end up with a simple 3-block cfg, the two "fake" ones,
+ and a "real" one:
+ [ENTRY] -> [block2] -> [EXIT]
+ with code like this:
+ test_fn ()
+ {
+ <bb 2>:
+ D.56 = 42;
+ return D.56;
+ }
+ */
+ verify_three_block_gimple_cfg (fun);
+
+ /* Verify the statements within the "real" block. */
+ basic_block bb2 = get_real_block (fun);
+ gimple *stmt_a = gimple_seq_first_stmt (bb_seq (bb2));
+ EXPECT_EQ (GIMPLE_ASSIGN, gimple_code (stmt_a));
+ gimple *stmt_b = stmt_a->next;
+ EXPECT_EQ (GIMPLE_RETURN, gimple_code (stmt_b));
+ EXPECT_EQ (NULL, stmt_b->next);
+}
+
+/* Test of conversion of gimple to SSA form. */
+TEST_F (representation_test, conversion_to_ssa)
+{
+ /* As above, construct a trivial function, gimplify it, and build a CFG: */
+ tree fndecl = build_trivial_high_gimple_function ();
+ function *fun = DECL_STRUCT_FUNCTION (fndecl);
+ ASSERT_TRUE (fun != NULL);
+ build_cfg (fndecl);
+
+ convert_to_ssa (fndecl);
+
+ verify_three_block_gimple_cfg (fun);
+
+ /* For out trivial test function we should now have something like
+ this:
+ test_fn ()
+ {
+ <bb 2>:
+ _1 = 42;
+ return _1;
+ }
+ */
+ if (0)
+ dump_function_to_file (fndecl, stderr, 0);
+ basic_block bb2 = get_real_block (fun);
+ gimple *stmt_a = gimple_seq_first_stmt (bb_seq (bb2));
+ EXPECT_EQ (GIMPLE_ASSIGN, gimple_code (stmt_a));
+
+ gimple *stmt_b = stmt_a->next;
+ EXPECT_EQ (GIMPLE_RETURN, gimple_code (stmt_b));
+ EXPECT_EQ (NULL, stmt_b->next);
+
+ greturn *return_stmt = as_a <greturn *> (stmt_b);
+ EXPECT_EQ (SSA_NAME, TREE_CODE (gimple_return_retval (return_stmt)));
+}
+
+/* Test of expansion from gimple-ssa to RTL. */
+
+TEST_F (representation_test, expansion_to_rtl)
+{
+ /* As above, construct a trivial function, gimplify it, build a CFG,
+ and convert to SSA: */
+ tree fndecl = build_trivial_high_gimple_function ();
+ function *fun = DECL_STRUCT_FUNCTION (fndecl);
+ ASSERT_TRUE (fun != NULL);
+ build_cfg (fndecl);
+ convert_to_ssa (fndecl);
+
+ /* We need a cgraph_node for it. */
+ cgraph_node::get_create (fndecl);
+ /* Normally, cgraph_node::expand () would call
+ init_function_start (and a bunch of other stuff),
+ and invoke the expand pass, but it also runs
+ all of the other passes. So just do the minimum
+ needed to get from gimple-SSA to RTL. */
+ rtl_opt_pass *expand_pass = make_pass_expand (g);
+ push_cfun (fun);
+ init_function_start (fndecl);
+ expand_pass->execute (fun);
+ pop_cfun ();
+
+ /* On x86_64, I get this:
+ (note 3 1 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK)
+ (note 2 3 5 2 NOTE_INSN_FUNCTION_BEG)
+ (insn 5 2 6 2 (set (reg:SI 87 [ D.59 ])
+ (const_int 42 [0x2a])) -1 (nil))
+ (insn 6 5 10 2 (set (reg:SI 88 [ <retval> ])
+ (reg:SI 87 [ D.59 ])) -1 (nil))
+ (insn 10 6 11 2 (set (reg/i:SI 0 ax)
+ (reg:SI 88 [ <retval> ])) -1 (nil))
+ (insn 11 10 0 2 (use (reg/i:SI 0 ax)) -1 (nil))
+ */
+ if (0)
+ dump_function_to_file (fndecl, stderr, 0);
+
+ verify_three_block_rtl_cfg (fun);
+
+ /* Verify as much of the RTL as we can whilst avoiding
+ target-specific behavior. */
+ basic_block bb2 = get_real_block (fun);
+
+ /* Expect a NOTE_INSN_BASIC_BLOCK... */
+ rtx_insn *insn = BB_HEAD (bb2);
+ ASSERT_TRUE (insn != NULL);
+ EXPECT_EQ (NOTE, insn->code);
+ EXPECT_EQ (NOTE_INSN_BASIC_BLOCK, NOTE_KIND (insn));
+ EXPECT_EQ (bb2, NOTE_BASIC_BLOCK (insn));
+
+ /* ...followed by a NOTE_INSN_FUNCTION_BEG... */
+ insn = NEXT_INSN (insn);
+ ASSERT_TRUE (insn != NULL);
+ EXPECT_EQ (NOTE, insn->code);
+ EXPECT_EQ (NOTE_INSN_FUNCTION_BEG, NOTE_KIND (insn));
+
+ /* ...followed by a SET of a reg to the const value. */
+ insn = NEXT_INSN (insn);
+ ASSERT_TRUE (insn != NULL);
+ EXPECT_EQ (INSN, insn->code);
+ rtx pat = PATTERN (insn);
+ ASSERT_TRUE (pat != NULL);
+ EXPECT_EQ (SET, pat->code);
+ EXPECT_EQ (REG, SET_DEST (pat)->code);
+ EXPECT_EQ (CONST_INT, SET_SRC (pat)->code);
+ EXPECT_EQ (42, INTVAL (SET_SRC (pat)));
+
+ /* ...etc; any further checks are likely to over-specify things
+ and run us into target dependencies. */
+}
+
+} // anon namespace
--
1.8.5.3
next prev parent reply other threads:[~2015-10-27 19:32 UTC|newest]
Thread overview: 176+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-10 15:10 [PATCH 00/17] RFC: Addding a unit testing framework to gcc David Malcolm
2015-06-10 15:10 ` [PATCH 12/17] Add test-tree.c to gcc/unittests David Malcolm
2015-06-10 15:10 ` [PATCH 07/17] Add test-gimple.c " David Malcolm
2015-06-10 15:10 ` [PATCH 10/17] Add test-locations.c " David Malcolm
2015-06-10 15:10 ` [PATCH 05/17] Add test-functions.c " David Malcolm
2015-06-10 15:10 ` [PATCH 08/17] Add test-hash-map.c " David Malcolm
2015-06-10 15:10 ` [PATCH 11/17] Add test-rtl.c " David Malcolm
2015-06-10 15:10 ` [PATCH 04/17] Add test-folding.c " David Malcolm
2015-06-10 15:10 ` [PATCH 09/17] Add test-hash-set.c " David Malcolm
2015-06-10 15:10 ` [PATCH 01/17] Add Make-lang.in and config-lang.in " David Malcolm
2015-06-10 15:10 ` [PATCH 02/17] Add test-bitmap.c " David Malcolm
2015-06-23 19:17 ` Jeff Law
2015-06-10 15:17 ` [PATCH 03/17] Add test-cfg.c " David Malcolm
2015-06-23 19:26 ` Jeff Law
2015-06-25 18:13 ` David Malcolm
2015-06-10 15:25 ` [PATCH 17/17] toplev.c: move location_adhoc_data_fini call David Malcolm
2015-06-10 15:26 ` [PATCH 16/17] Add unittests-main.c to gcc/unittests David Malcolm
2015-06-10 15:26 ` [PATCH 13/17] Add test-vec.c " David Malcolm
2015-06-10 15:28 ` [PATCH 06/17] Add test-ggc.c " David Malcolm
2015-06-10 15:28 ` [PATCH 15/17] Add unittests-frontend.c " David Malcolm
2015-06-10 15:34 ` [PATCH 14/17] Add test-wide-int.c " David Malcolm
2015-06-10 16:19 ` [PATCH 00/17] RFC: Addding a unit testing framework to gcc Jakub Jelinek
2015-06-10 16:25 ` Richard Biener
2015-06-10 17:56 ` David Malcolm
2015-06-10 23:42 ` Jakub Jelinek
2015-06-17 20:36 ` [PATCH/RFC]: unittesting v2: as a plugin (was Re: [PATCH 00/17] RFC: Addding a unit testing framework to gcc) David Malcolm
2015-06-23 19:29 ` Jeff Law
2015-10-27 19:31 ` [PATCH 00/16] Unit tests framework (v3) David Malcolm
2015-10-27 19:31 ` [PATCH 11/16] Add test-hash-set.c to unittests David Malcolm
2015-10-30 4:54 ` Jeff Law
2015-10-27 19:31 ` [PATCH 05/16] Add test-et-forest.c " David Malcolm
2015-10-30 4:11 ` Jeff Law
2015-10-27 19:31 ` [PATCH 15/16] Add test-vec.c " David Malcolm
2015-10-30 5:10 ` Jeff Law
2015-10-27 19:31 ` [PATCH 01/16] Add unittest infrastructure David Malcolm
2015-10-30 5:20 ` Jeff Law
2015-10-27 19:31 ` [PATCH 03/16] Add test-bitmap.c to unittests David Malcolm
2015-10-29 21:36 ` Jeff Law
2015-10-27 19:32 ` [PATCH 04/16] Add test-cfg.c " David Malcolm
2015-10-29 22:23 ` Jeff Law
2015-10-27 19:32 ` [PATCH 10/16] Add test-hash-map.c " David Malcolm
2015-10-30 4:57 ` Jeff Law
2015-10-27 19:32 ` David Malcolm [this message]
2015-10-30 5:19 ` [PATCH 07/16] Add test-functions.c " Jeff Law
2015-10-27 19:35 ` [PATCH 06/16] Add test-folding.c " David Malcolm
2015-10-30 5:06 ` Jeff Law
2015-10-27 19:48 ` [PATCH 14/16] Add test-tree.c " David Malcolm
2015-10-30 5:00 ` Jeff Law
2015-10-27 19:49 ` [PATCH 08/16] Add test-ggc.c " David Malcolm
2015-10-30 5:08 ` Jeff Law
2015-10-27 19:49 ` [PATCH 12/16] Add test-locations.c " David Malcolm
2015-10-30 5:09 ` Jeff Law
2015-10-27 19:50 ` [PATCH 13/16] Add test-rtl.c " David Malcolm
2015-10-30 4:58 ` Jeff Law
2015-10-31 20:36 ` Segher Boessenkool
2015-10-27 19:51 ` [PATCH 16/16] Add test-wide-int.c " David Malcolm
2015-10-30 5:15 ` Jeff Law
2015-10-27 19:58 ` [PATCH 09/16] Add test-gimple.c " David Malcolm
2015-10-28 12:39 ` Richard Biener
2015-10-28 12:44 ` Richard Biener
2015-10-28 16:22 ` Jeff Law
2015-10-30 5:02 ` Jeff Law
2015-10-27 20:16 ` [PATCH 00/16] Unit tests framework (v3) David Malcolm
2015-10-30 5:28 ` Jeff Law
2015-10-28 11:53 ` Bernd Schmidt
2015-10-28 13:02 ` Bernd Schmidt
2015-10-29 16:20 ` David Malcolm
2015-10-29 19:38 ` Jeff Law
2015-10-29 22:32 ` Mike Stump
2015-10-30 3:59 ` Jeff Law
2015-10-29 19:21 ` Jeff Law
2015-10-30 10:54 ` Bernd Schmidt
2015-10-30 16:08 ` Jeff Law
2015-11-16 18:17 ` Bernd Schmidt
2015-11-16 18:48 ` David Malcolm
2015-11-16 21:22 ` Bernd Schmidt
2015-11-16 23:12 ` Jeff Law
2015-11-17 1:54 ` Mike Stump
2015-11-17 12:51 ` Bernd Schmidt
2015-11-17 18:06 ` Jeff Law
2015-11-19 16:46 ` [PATCH 00/15] Unittests framework v4: -fself-test David Malcolm
2015-11-19 16:46 ` [PATCH 05/15] Add selftests to fold-const.c David Malcolm
2015-11-19 16:46 ` [PATCH 02/15] Add selftests to bitmap.c David Malcolm
2015-11-20 10:41 ` Richard Biener
2015-11-24 21:13 ` Jeff Law
2015-11-19 16:46 ` [PATCH 09/15] Add hash-map-tests.c David Malcolm
2015-11-19 16:46 ` [PATCH 10/15] Add hash-set-tests.c David Malcolm
2015-11-19 16:46 ` [PATCH 07/15] Fix warning in function-tests.c David Malcolm
2015-11-19 16:46 ` [PATCH 03/15] Add selftests to tree-cfg.c David Malcolm
2015-11-19 16:46 ` [PATCH 08/15] Add selftests to gimple.c David Malcolm
2015-11-19 16:46 ` [PATCH 14/15] Add selftests to vec.c David Malcolm
2015-11-19 16:46 ` [PATCH 13/15] Add selftests to tree.c David Malcolm
2015-11-19 16:46 ` [PATCH 15/15] RFC: Add ggc-tests.c David Malcolm
2015-11-19 16:46 ` [PATCH 04/15] Add selftests to et-forest.c David Malcolm
2015-11-19 16:46 ` [PATCH 01/15] Selftest framework (unittests v4) David Malcolm
2015-11-19 17:35 ` Bernd Schmidt
2015-11-19 18:08 ` David Malcolm
2015-11-19 18:15 ` Mike Stump
2015-11-19 18:44 ` Bernd Schmidt
2015-11-19 20:04 ` Mikhail Maltsev
2015-11-24 20:45 ` Jeff Law
2015-11-25 2:43 ` David Malcolm
2015-11-25 10:56 ` Bernd Schmidt
2015-11-25 16:57 ` Mike Stump
2015-11-29 18:10 ` Jeff Law
2015-11-25 22:58 ` David Malcolm
2015-11-25 7:43 ` Trevor Saunders
2015-11-25 22:53 ` David Malcolm
2015-11-26 13:00 ` Bernd Schmidt
2015-11-30 23:05 ` Jeff Law
2015-11-24 20:29 ` Jeff Law
2015-11-24 22:43 ` Jeff Law
2015-11-19 16:46 ` [PATCH 06/15] Add function-tests.c David Malcolm
2015-11-19 17:03 ` [PATCH 11/15] Add selftests to input.c David Malcolm
2015-11-19 17:03 ` [PATCH 12/15] Add rtl-tests.c David Malcolm
2016-06-01 20:54 ` [PATCH 00/21] Add -fself-test framework for fast, early unit-testing (unittests v5) David Malcolm
2016-06-01 20:54 ` [PATCH 02/21] Makefile.in integration David Malcolm
2016-06-01 20:54 ` [PATCH 09/21] Add selftests to et-forest.c David Malcolm
2016-06-01 20:54 ` [PATCH 03/21] Various selftest::runner tweaks David Malcolm
2016-06-01 20:54 ` [PATCH 17/21] Add hash-set-tests.c David Malcolm
2016-06-01 20:54 ` [PATCH 07/21] Add selftests to bitmap.c David Malcolm
2016-06-01 20:54 ` [PATCH 04/21] Add -fself-test-regex= David Malcolm
2016-06-01 20:54 ` [PATCH 01/21] Selftest framework (unittests v5) David Malcolm
2016-06-01 20:54 ` [PATCH 10/21] Add selftests to fold-const.c David Malcolm
2016-06-01 20:54 ` [PATCH 20/21] Add selftests to tree.c David Malcolm
2016-06-01 20:54 ` [PATCH 18/21] Add selftests to input.c David Malcolm
2016-06-01 21:09 ` [PATCH 12/21] Fix warning in function-tests.c David Malcolm
2016-06-01 21:10 ` [PATCH 21/21] Add selftests to vec.c David Malcolm
2016-06-01 21:10 ` [PATCH 08/21] Add selftests to tree-cfg.c David Malcolm
2016-06-01 21:10 ` [PATCH 11/21] Add function-tests.c David Malcolm
2016-06-01 21:10 ` [PATCH 06/21] Convert Levenshtein test from a plugin to a selftest David Malcolm
2016-06-01 21:11 ` [PATCH 16/21] Add hash-map-tests.c David Malcolm
2016-06-01 21:20 ` [PATCH 00/21] Add -fself-test framework for fast, early unit-testing (unittests v5) Sandra Loosemore
2016-06-02 13:08 ` David Malcolm
2016-06-01 21:21 ` [PATCH 05/21] Add selftests for diagnostic-show-locus.c David Malcolm
2016-06-01 21:22 ` [PATCH 19/21] Add rtl-tests.c David Malcolm
2016-06-01 21:23 ` [PATCH 15/21] Add selftests to gimple.c David Malcolm
2016-06-01 21:26 ` [PATCH 14/21] Remove x86_64-isms in function-tests.c David Malcolm
2016-06-01 21:29 ` [PATCH 13/21] Fixup to function-tests.c David Malcolm
2016-06-02 10:30 ` [PATCH 00/21] Add -fself-test framework for fast, early unit-testing (unittests v5) Bernd Schmidt
2016-06-02 13:41 ` David Malcolm
2016-06-02 20:41 ` [PATCH 00/16] v6 of -fself-test/unit-testing patch David Malcolm
2016-06-02 20:41 ` [PATCH 10/16] Add hash-map-tests.c David Malcolm
2016-06-02 20:41 ` [PATCH 01/16] Core of selftest framework (v6) David Malcolm
2016-06-02 23:21 ` Bernd Schmidt
2016-06-03 18:47 ` [PATCH] Selftest framework (v7) David Malcolm
2016-06-05 11:38 ` Bernd Schmidt
2016-06-06 14:17 ` David Malcolm
2016-06-06 14:41 ` Bernd Schmidt
2016-06-06 17:18 ` [Committed] Selftest framework (v8) David Malcolm
2016-06-06 21:47 ` [PATCH] Selftest framework (v7) Trevor Saunders
2016-06-06 21:57 ` Jakub Jelinek
2016-06-07 2:07 ` Trevor Saunders
2016-06-07 14:18 ` David Malcolm
2016-06-08 0:23 ` Trevor Saunders
2016-06-02 20:41 ` [PATCH 04/16] bitmap.c: add selftests David Malcolm
2016-06-02 20:41 ` [PATCH 09/16] gimple.c: " David Malcolm
2016-06-02 20:41 ` [PATCH 05/16] tree-cfg.c: " David Malcolm
2016-06-02 20:41 ` [PATCH 02/16] diagnostic-show-locus.c: " David Malcolm
2016-06-02 20:41 ` [PATCH 03/16] spellcheck.c: convert Levenshtein test from a plugin to a selftest David Malcolm
2016-06-02 20:57 ` [PATCH 08/16] Add function-tests.c David Malcolm
2016-06-02 20:58 ` [PATCH 14/16] tree.c: add selftests David Malcolm
2016-06-02 21:03 ` [PATCH 16/16] wide-int.cc: " David Malcolm
2016-06-02 21:03 ` [PATCH 13/16] Add rtl-tests.c David Malcolm
2016-06-02 21:03 ` [PATCH 12/16] input.c: add selftests David Malcolm
2016-06-02 21:06 ` [PATCH 15/16] vec.c: " David Malcolm
2016-06-02 21:09 ` [PATCH 06/16] et-forest.c: " David Malcolm
2016-06-02 21:09 ` [PATCH 11/16] Add hash-set-tests.c David Malcolm
2016-06-02 21:09 ` [PATCH 07/16] fold-const.c: add selftests David Malcolm
2015-10-28 16:05 ` [PATCH 00/16] Unit tests framework (v3) Jeff Law
2015-10-28 20:26 ` Mike Stump
2015-06-23 19:06 ` [PATCH 00/17] RFC: Addding a unit testing framework to gcc Jeff Law
2015-06-23 20:04 ` Mike Stump
2015-06-10 18:21 ` David Malcolm
2015-06-10 22:15 ` Jakub Jelinek
2015-06-11 14:49 ` Martin Liška
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1445975355-37660-8-git-send-email-dmalcolm@redhat.com \
--to=dmalcolm@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).