diff options
author | Erick Ochoa <erick.ochoa@theobroma-systems.com> | 2020-05-14 16:00:00 +0200 |
---|---|---|
committer | Erick Ochoa <erick.ochoa@theobroma-systems.com> | 2020-06-03 16:05:57 +0200 |
commit | 7ecfa03289e7a6eb951a53737987c51e4ad25f4e (patch) | |
tree | 147ba79633accc02013aca486385465413053304 | |
parent | 8aba2fa4e530228b778ff052e392b7ebe10c4124 (diff) |
Refactored code works in mcf
-rw-r--r-- | gcc/ipa-escape-analysis.c | 32 | ||||
-rw-r--r-- | gcc/ipa-escape-analysis.h | 5 |
2 files changed, 27 insertions, 10 deletions
diff --git a/gcc/ipa-escape-analysis.c b/gcc/ipa-escape-analysis.c index 04023a406a5..6c4e9105254 100644 --- a/gcc/ipa-escape-analysis.c +++ b/gcc/ipa-escape-analysis.c @@ -36,6 +36,8 @@ #include "collect-types.h" #include "name-types.h" +#include "ipa-escape-analysis.h" + //#define FUZZ_MODE 1 namespace type_playground { @@ -290,6 +292,16 @@ collect_types_from_result_decl(const_tree expr, ptrset_t &types) } static void +collect_types_from_function_decl(const_tree expr, ptrset_t &types) +{ + assert_is_type(expr, FUNCTION_DECL); + const_tree decl_type = TREE_TYPE(expr); + gcc_assert(decl_type); + // This will collect return, arguments and decl_type itself + collect_types(decl_type, types); +} + +static void collect_types_from_expr(const_tree expr, ptrset_t &types) { // These are the codes I saw using csmith to fuzz. @@ -345,6 +357,9 @@ collect_types_from_expr(const_tree expr, ptrset_t &types) case STRING_CST: collect_types_from_string_cst(expr, types); break; + case FUNCTION_DECL: + collect_types_from_function_decl(expr, types); + break; default: log("tree_code: %s\n", get_tree_code_name(code)); gcc_unreachable(); @@ -491,7 +506,8 @@ collect_types_from_stmt_return(gimple *stmt, ptrset_t &types) { is_gimple_code(stmt, GIMPLE_RETURN); const_tree retval = gimple_return_retval(stmt); - gcc_assert(retval); + if (!retval) return; + collect_types_from_expr(retval, types); } @@ -515,6 +531,8 @@ collect_types_from_stmt(gimple *stmt, ptrset_t &types) break; case GIMPLE_LABEL: case GIMPLE_PREDICT: + case GIMPLE_DEBUG: + case GIMPLE_SWITCH: #ifdef FUZZ_MODE gcc_unreachable(); #endif @@ -529,20 +547,14 @@ collect_types_from_stmt(gimple *stmt, ptrset_t &types) } } + static void collect_types_from_cnode_decl(cgraph_node *cnode, ptrset_t &types) { gcc_assert(cnode); const_tree decl = cnode->decl; gcc_assert(decl); - const_tree decl_type = TREE_TYPE(decl); - gcc_assert(decl_type); - function *func = DECL_STRUCT_FUNCTION (decl); - gcc_assert(func); - push_cfun(func); - // This will collect return, arguments and decl_type itself - collect_types(decl_type, types); - pop_cfun(); + collect_types_from_function_decl(decl, types); } static void @@ -760,7 +772,7 @@ filter_out_types_in_set(ptrset_t &types) } -static void +void collect_types(ptrset_t &types) { collect_types_from_globals(types); diff --git a/gcc/ipa-escape-analysis.h b/gcc/ipa-escape-analysis.h new file mode 100644 index 00000000000..16611c2db56 --- /dev/null +++ b/gcc/ipa-escape-analysis.h @@ -0,0 +1,5 @@ +#pragma once + +#include "collect-types.h" + +void collect_types(ptrset_t &types); |