summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErick Ochoa <erick.ochoa@theobroma-systems.com>2020-04-30 11:19:04 +0200
committerErick Ochoa <erick.ochoa@theobroma-systems.com>2020-04-30 11:19:04 +0200
commit5e7f343e9db384f11126f7ca7048e6ed133c4d9f (patch)
treeacc2127a507b2844f583b038d5f8e4740f0bfa9d
parent87113f307eded45ae3e51cb58c788cec8936a36d (diff)
-rw-r--r--gcc/ipa-str-reorg-dead-field-eliminate.c54
1 files changed, 43 insertions, 11 deletions
diff --git a/gcc/ipa-str-reorg-dead-field-eliminate.c b/gcc/ipa-str-reorg-dead-field-eliminate.c
index 9241156d0f0..727033bc6c0 100644
--- a/gcc/ipa-str-reorg-dead-field-eliminate.c
+++ b/gcc/ipa-str-reorg-dead-field-eliminate.c
@@ -94,6 +94,7 @@ substitute_type (tree expr, const_tree new_type)
{
gcc_assert(expr);
gcc_assert(new_type);
+ const_tree old_type = TREE_TYPE(expr);
TREE_TYPE(expr) = const_to_tree(new_type);
}
@@ -910,8 +911,8 @@ collect_parm_declarations (cgraph_node *cnode,
if (is_inside)
continue;
- const char *type_identifier = get_type_name (type);
- test_log ("collecting,%s", 0, type_identifier);
+ //const char *type_identifier = get_type_name (type);
+ //test_log ("collecting,%s", 0, type_identifier);
decl_map.add (type);
}
}
@@ -1040,8 +1041,8 @@ collect_local_declarations (cgraph_node *cnode,
continue;
tree type = TREE_TYPE (var_decl);
- const char *type_identifier = get_type_name (type);
- test_log ("collecting,%s", 0, type_identifier);
+ //const char *type_identifier = get_type_name (type);
+ //test_log ("collecting,%s", 0, type_identifier);
decl_map.add (type);
}
}
@@ -1066,8 +1067,8 @@ collect_global_declaration (varpool_node *vnode,
}
tree type = TREE_TYPE (vnode->decl);
- const char *type_identifier = get_type_name (type);
- test_log ("collecting,%s", 0, type_identifier);
+ //const char *type_identifier = get_type_name (type);
+ //test_log ("collecting,%s", 0, type_identifier);
decl_map.add (type);
}
}
@@ -1125,7 +1126,7 @@ make_new_record_based_on_typedef (const_tree _typedef, t_map *mod_type_map)
bool is_typedef = _typedef != TYPE_MAIN_VARIANT(_typedef);
gcc_assert(is_typedef);
tree new_main_variant = (tree) get_new_type_main_variant(_typedef, mod_type_map);
- tree new_type = build_variant_type_copy(new_main_variant);
+ tree new_type = build_type_variant(new_main_variant, TYPE_READONLY(_typedef), TYPE_VOLATILE(_typedef));
const char *new_name = make_record_name_based_on_old (_typedef);
tree new_record_name = get_identifier (new_name);
TYPE_NAME (new_type) = new_record_name;
@@ -1222,6 +1223,8 @@ make_new_record_based_on_old (const_tree old,
}
layout_type (new_record);
+ tree new_type = build_type_variant(new_record, TYPE_READONLY(old), TYPE_VOLATILE(old));
+ layout_type (new_type);
for (tree new_field = TYPE_FIELDS (new_record); new_field;
@@ -1720,9 +1723,11 @@ rewrite_ssa_name_def (tree expr, t_map &type_map,
tree ssa_name_var = SSA_NAME_VAR (expr);
delete_info_t *delete_info = type_map.get (type);
const_tree *new_type_ptr = delete_info ? &(delete_info->new_record) : NULL;
+ tree new_type_2 = NULL;
if (new_type_ptr)
{
- substitute_type(expr, new_type_ptr);
+ new_type_2 = build_type_variant(const_to_tree(*new_type_ptr), TYPE_READONLY(type), TYPE_VOLATILE(type));
+ substitute_type(expr, new_type_2);
// TODO: I had some cases where ssa_name_var was not set.
// Not sure why...
// I need to investigate
@@ -1731,12 +1736,12 @@ rewrite_ssa_name_def (tree expr, t_map &type_map,
// and there is something else that I need to change
if (ssa_name_var)
{
- substitute_type(ssa_name_var, new_type_ptr);
+ substitute_type(ssa_name_var, new_type_2);
relayout_decl (ssa_name_var);
}
}
- return new_type_ptr;
+ return new_type_2;
}
static bool
@@ -2322,6 +2327,27 @@ rewrite_assign (gimple *stmt, gimple_stmt_iterator &gsi,
}
static bool
+rewrite_return (gimple *stmt, gimple_stmt_iterator &gsi,
+ t_map &type_map)
+{
+ gcc_assert (stmt);
+ test_print_gimple_stmt (stmt);
+ greturn *retisn = dyn_cast<greturn *> (stmt);
+ gcc_assert(retisn);
+ tree retval = gimple_return_retval(retisn);
+ if (!retval) return false;
+
+ tree decl = DECL_RESULT (current_function_decl);
+ rewrite_expr(decl, type_map, 0);
+
+ rewrite_expr (retval, type_map, 0);
+ tree retval_type = TREE_TYPE(retval);
+ gcc_assert(retval_type);
+ log("return type %s\n", get_type_name(retval_type));
+ return false;
+}
+
+static bool
rewrite_stmt (gimple *stmt, gimple_stmt_iterator &gsi,
t_map &type_map,
t_map &inverse)
@@ -2343,6 +2369,9 @@ rewrite_stmt (gimple *stmt, gimple_stmt_iterator &gsi,
case GIMPLE_PHI:
rewrite_phi (stmt, gsi, type_map);
break;
+ case GIMPLE_RETURN:
+ rewrite_return (stmt, gsi, type_map);
+ break;
default:
{
const char *const gimple_code_str = gimple_code_name[code];
@@ -2456,7 +2485,9 @@ rewrite_local_decl (tree var_decl, t_map &type_map)
test_write ("rewriting,local_decl");
test_print_generic_decl (var_decl);
test_write (",");
+ //TODO: Doing an experiment, we might need to keep qualifications...
substitute_type(var_decl, new_type);
+
// Keep this relayout_decl
relayout_decl (var_decl);
test_print_generic_decl (var_decl);
@@ -2537,7 +2568,8 @@ rewrite_function_return_type (tree expr,
return;
const_tree new_type = delete_info->new_record;
- substitute_type(function_type, new_type);
+ tree new_type_2 = build_type_variant(const_to_tree(new_type), TYPE_READONLY(function_return_type), TYPE_VOLATILE(function_return_type));
+ substitute_type(function_type, new_type_2);
// Do not use relayout_decl(cnode->decl);
tree function_type_2 = TREE_TYPE (expr);
tree function_return_type_2 = TREE_TYPE (function_type_2);