diff options
Diffstat (limited to 'gcc/ipa-escape-analysis.c')
-rw-r--r-- | gcc/ipa-escape-analysis.c | 32 |
1 files changed, 22 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); |