summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErick Ochoa <erick.ochoa@theobroma-systems.com>2020-05-16 10:05:12 +0200
committerErick Ochoa <erick.ochoa@theobroma-systems.com>2020-09-08 08:59:56 +0200
commit1df9f1fcc9ee2cd26503f9ec52e67c38b95d02f4 (patch)
treeec2a6269f05611706e803952690cba94c172dc54
parentacd8fc707e06f3b7b0439410aa07add38a80750b (diff)
move is_gimple_code to inlines
-rw-r--r--gcc/ipa-hello-world.c72
-rw-r--r--gcc/ipa-type-collector.c8
-rw-r--r--gcc/types-inlines.h9
3 files changed, 81 insertions, 8 deletions
diff --git a/gcc/ipa-hello-world.c b/gcc/ipa-hello-world.c
index e35fdf01145..1c8eaf285d8 100644
--- a/gcc/ipa-hello-world.c
+++ b/gcc/ipa-hello-world.c
@@ -335,6 +335,78 @@ mark_escaping_function(ptrset_t &types, typemap &calc, cgraph_node *cnode)
}
static void
+calculate_escaping_types_from_cast(ptrset_t &types, typemap &calc, gimple *stmt)
+{
+ is_gimple_code(stmt, GIMPLE_ASSIGN);
+ const_tree lhs = gimple_assign_lhs(stmt);
+ gcc_assert(lhs);
+ const_tree rhs = gimple_assign_rhs1(stmt);
+ gcc_assert(rhs);
+
+}
+
+static void
+calculate_escaping_types_from_assign(ptrset_t &types, typemap &calc, gimple *stmt)
+{
+ is_gimple_code(stmt, GIMPLE_ASSIGN);
+ // If it is a cast, we must look at the lhs and the rhs...
+ const enum gimple_rhs_class gclass = gimple_assign_rhs_class(stmt);
+ switch(gclass)
+ {
+ case GIMPLE_TERNARY_RHS:
+ /* fall-through */
+ case GIMPLE_BINARY_RHS:
+ /* fall-through */
+ case GIMPLE_UNARY_RHS:
+ case GIMPLE_SINGLE_RHS:
+ calculate_escaping_types_from_cast(types, calc, stmt);
+ break;
+ default:
+ gcc_unreachable();
+ break;
+ }
+}
+
+static void
+calculate_escaping_types_from_stmt(ptrset_t &types, typemap &calc, undefset &undef, gimple *stmt)
+{
+ // Should be the same as ipa-type-collector.c
+ // Otherwise, we might be skipping exploring some paths...
+ gcc_assert(stmt);
+ const enum gimple_code code = gimple_code (stmt);
+ switch (code)
+ {
+ case GIMPLE_ASSIGN:
+ calculate_escaping_types_from_assign(types, calc, stmt);
+ break;
+ case GIMPLE_CALL:
+ calculate_escaping_types_from_call(types, calc, undef, stmt);
+ break;
+ case GIMPLE_COND:
+ calculate_escaping_types_from_cond(types, calc, stmt);
+ break;
+ case GIMPLE_RETURN:
+ calculate_escaping_types_from_return(types, calc, stmt);
+ break;
+ case GIMPLE_LABEL:
+ case GIMPLE_PREDICT:
+ case GIMPLE_DEBUG:
+ case GIMPLE_SWITCH:
+#ifdef FUZZ_MODE
+ gcc_unreachable();
+#endif
+ break;
+ default:
+ {
+ const char* name = gimple_code_name[code];
+ log("gimple code name %s\n", name);
+ gcc_unreachable();
+ }
+ break;
+ }
+}
+
+static void
calculate_escaping_types_from_bb(ptrset_t &types, typemap &calc, undefset &undef, basic_block bb)
{
gcc_assert(bb);
diff --git a/gcc/ipa-type-collector.c b/gcc/ipa-type-collector.c
index 2d3a74198c6..696abb61a6f 100644
--- a/gcc/ipa-type-collector.c
+++ b/gcc/ipa-type-collector.c
@@ -74,14 +74,6 @@ static type_comparison_func_t comparisons[type_comparisons] = {
}
static void collect_types_from_expr(const_tree expr, ptrset_t &types);
-inline void
-is_gimple_code(gimple *stmt, const enum gimple_code ex_code)
-{
- gcc_assert(stmt);
- const enum gimple_code ob_code = gimple_code(stmt);
- const bool succeeds = ex_code == ob_code;
- gcc_assert(succeeds);
-}
inline void
is_gimple_rhs_class(gimple *stmt, const enum gimple_rhs_class ex_class)
diff --git a/gcc/types-inlines.h b/gcc/types-inlines.h
index 340108fcf8f..e9d35d95cc1 100644
--- a/gcc/types-inlines.h
+++ b/gcc/types-inlines.h
@@ -13,6 +13,15 @@ log(const char* const fmt, ...)
}
inline void
+is_gimple_code(gimple *stmt, const enum gimple_code ex_code)
+{
+ gcc_assert(stmt);
+ const enum gimple_code ob_code = gimple_code(stmt);
+ const bool succeeds = ex_code == ob_code;
+ gcc_assert(succeeds);
+}
+
+inline void
assert_is_complete(const_tree a)
{
gcc_assert(a);