diff options
author | Erick Ochoa <erick.ochoa@theobroma-systems.com> | 2020-03-10 10:54:34 +0100 |
---|---|---|
committer | Erick Ochoa <erick.ochoa@theobroma-systems.com> | 2020-04-28 23:35:49 +0200 |
commit | 205fa31d7e52e2be3686b3dce704e2da5871f1d0 (patch) | |
tree | b2c5f99a0656772c67086102d4c21c9a13fe6efc | |
parent | 4d2dbb54bd00a4d32c417afbb86c73ff10be1d54 (diff) |
Fixes typedefs
-rw-r--r-- | gcc/ipa-hello-world.c | 31 | ||||
-rw-r--r-- | gcc/ipa-str-reorg-utils.c | 15 | ||||
-rw-r--r-- | gcc/ipa-str-reorg-utils.h | 1 |
3 files changed, 39 insertions, 8 deletions
diff --git a/gcc/ipa-hello-world.c b/gcc/ipa-hello-world.c index 6d902a03ecf..dd8c692286f 100644 --- a/gcc/ipa-hello-world.c +++ b/gcc/ipa-hello-world.c @@ -618,14 +618,14 @@ print_function (cgraph_node *cnode) dump_function_to_file (cnode->decl, dump_file, TDF_NONE); } -static void +static bool cast_to_void_in_assign(const_tree lhs, const_tree rhs, type_map &escape_map) { gcc_assert(lhs); gcc_assert(rhs); - tree tree_type_lhs = TREE_TYPE(lhs); + const_tree tree_type_lhs = TREE_TYPE(lhs); gcc_assert(tree_type_lhs); - tree tree_type_rhs = TREE_TYPE(rhs); + const_tree tree_type_rhs = TREE_TYPE(rhs); gcc_assert(tree_type_rhs); const char* const type_name_lhs = get_type_name(tree_type_lhs); const char* const type_name_rhs = get_type_name(tree_type_rhs); @@ -634,11 +634,16 @@ cast_to_void_in_assign(const_tree lhs, const_tree rhs, type_map &escape_map) bool is_var_decl = VAR_DECL == tree_code_rhs; bool is_var_decl_or_ssa_name = is_ssa_name || is_var_decl; log("lhs = %s, rhs = %s\n", type_name_lhs, type_name_rhs); - if (!is_var_decl_or_ssa_name) return; - - bool is_casting_stmt = TYPE_MAIN_VARIANT(tree_type_lhs) != TYPE_MAIN_VARIANT(tree_type_rhs); + if (!is_var_decl_or_ssa_name) return false; + + // We need to find out the base... + const_tree base_type_lhs = get_base_type(tree_type_lhs); + gcc_assert(base_type_lhs); + const_tree base_type_rhs = get_base_type(tree_type_rhs); + gcc_assert(base_type_rhs); + bool is_casting_stmt = TYPE_MAIN_VARIANT(base_type_lhs) != TYPE_MAIN_VARIANT(base_type_rhs); log("is casting stmt ? %s\n", is_casting_stmt ? "true" : "false"); - if (!is_casting_stmt) return; + if (!is_casting_stmt) return false; log("escaping lhs %s\n", type_name_lhs); escaping_reason reason = new_escaping_reason(); @@ -647,6 +652,7 @@ cast_to_void_in_assign(const_tree lhs, const_tree rhs, type_map &escape_map) log("escaping rhs %s\n", type_name_rhs); update_escape_info(tree_type_rhs, escape_map, is_casting_stmt, reason); + return true; } static void @@ -663,7 +669,16 @@ cast_to_void_in_assign (gimple *stmt, type_map &escape_map) { tree lhs = gimple_assign_lhs(stmt); tree rhs = gimple_assign_rhs1(stmt); - cast_to_void_in_assign(lhs, rhs, escape_map); + bool retval = cast_to_void_in_assign(lhs, rhs, escape_map); + if (!retval) break; + + tree tree_type_lhs = TYPE_MAIN_VARIANT(TREE_TYPE(lhs)); + tree tree_type_rhs = TYPE_MAIN_VARIANT(TREE_TYPE(rhs)); + const char* const type_name_lhs = get_type_name(tree_type_lhs); + const char* const type_name_rhs = get_type_name(tree_type_rhs); + log("type casting %s != %s ", type_name_lhs, type_name_rhs); + if (dump_file) print_gimple_stmt (dump_file, stmt, 0, TDF_NONE); + log("\n"); } default: break; diff --git a/gcc/ipa-str-reorg-utils.c b/gcc/ipa-str-reorg-utils.c index 6cfdc491ddb..af2ec906911 100644 --- a/gcc/ipa-str-reorg-utils.c +++ b/gcc/ipa-str-reorg-utils.c @@ -62,6 +62,21 @@ get_base_type_from_pointer_type (const_tree pointer_type) unsigned int indirection_level; return get_base_type_from_pointer_type (pointer_type, indirection_level); } + +const_tree +get_base_type (const_tree type) +{ + enum tree_code tree_code_type = TREE_CODE(type); + switch (tree_code_type) + { + case ARRAY_TYPE: return get_base_type_from_array_type(type); break; + case POINTER_TYPE: return get_base_type_from_pointer_type(type); break; + default: return type; break; + } + + gcc_unreachable(); + return NULL; +} const char * make_pointer_name (const_tree pointer) { diff --git a/gcc/ipa-str-reorg-utils.h b/gcc/ipa-str-reorg-utils.h index 13136197244..4874929afb7 100644 --- a/gcc/ipa-str-reorg-utils.h +++ b/gcc/ipa-str-reorg-utils.h @@ -28,6 +28,7 @@ const_tree get_base_type_from_array_type (const_tree array_type, unsigned int &i const_tree get_base_type_from_array_type (const_tree array_type); const_tree get_base_type_from_pointer_type (const_tree pointer_type, unsigned int &indirection_level); const_tree get_base_type_from_pointer_type (const_tree pointer_type); +const_tree get_base_type (const_tree type); |