summaryrefslogtreecommitdiff
path: root/gcc/ipa-str-reorg-dead-field-eliminate.c
diff options
context:
space:
mode:
authorErick Ochoa <erick.ochoa@theobroma-systems.com>2020-02-11 20:57:39 +0100
committerErick Ochoa <erick.ochoa@theobroma-systems.com>2020-05-14 14:45:33 +0200
commit8b50609a83f97d606caccd330da679eed7a6a01f (patch)
tree4f019a005d4db88b2bce1be1313300f9c1cc0e6b /gcc/ipa-str-reorg-dead-field-eliminate.c
parent0f5d7d81da66e05b35fcea85a0a8c9b12a3d69ae (diff)
passes function pointer test
Diffstat (limited to 'gcc/ipa-str-reorg-dead-field-eliminate.c')
-rw-r--r--gcc/ipa-str-reorg-dead-field-eliminate.c54
1 files changed, 41 insertions, 13 deletions
diff --git a/gcc/ipa-str-reorg-dead-field-eliminate.c b/gcc/ipa-str-reorg-dead-field-eliminate.c
index 45f7612a423..3ec26abaf3c 100644
--- a/gcc/ipa-str-reorg-dead-field-eliminate.c
+++ b/gcc/ipa-str-reorg-dead-field-eliminate.c
@@ -1281,10 +1281,15 @@ rewrite_integer_cst_def(tree expr, hash_map<const_tree, const_tree> &type_map, c
return true;
}
+static void rewrite_function_parms(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent);
+static void rewrite_function_return_type(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent);
+
static bool
rewrite_function_decl_def(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
-{
- gcc_unreachable();
+{
+ rewrite_function_parms(expr, type_map, indent + 4);
+ rewrite_function_return_type(expr, type_map, indent + 4);
+ return false;
}
static bool
@@ -1872,11 +1877,13 @@ rewrite_local_decls(cgraph_node *cnode, hash_map<const_tree, const_tree> &type_m
}
static void
-rewrite_function_parms(cgraph_node *cnode, hash_map<const_tree, const_tree> &type_map)
+rewrite_function_parms(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
{
- //TODO: Do we need to do get_untransformed_body here?
- //TODO: Do we need to somehow relayout the whole function itself?
- for (tree parm = DECL_ARGUMENTS(cnode->decl); parm; parm = DECL_CHAIN(parm))
+ enum tree_code code = TREE_CODE(expr);
+ bool is_function_decl = code == FUNCTION_DECL;
+ gcc_assert(is_function_decl);
+
+ for (tree parm = DECL_ARGUMENTS(expr); parm; parm = DECL_CHAIN(parm))
{
tree parm_type = TREE_TYPE(parm);
const_tree *type_ptr = type_map.get(parm_type);
@@ -1888,30 +1895,51 @@ rewrite_function_parms(cgraph_node *cnode, hash_map<const_tree, const_tree> &typ
tree parm_type_2 = TREE_TYPE(parm);
test_log("after rewrite_function_arg %s", 0, get_type_name(parm_type_2));
}
+
}
static void
-rewrite_function_return_type(cgraph_node *cnode, hash_map<const_tree, const_tree> &type_map)
+rewrite_function_parms(cgraph_node *cnode, hash_map<const_tree, const_tree> &type_map)
{
+ //TODO: Do we need to do get_untransformed_body here?
+ //TODO: Do we need to somehow relayout the whole function itself?
+ rewrite_function_parms(cnode->decl, type_map, 0);
+}
+
+static void
+rewrite_function_return_type(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
+{
+ enum tree_code code = TREE_CODE(expr);
+ bool is_function_decl = code == FUNCTION_DECL;
+ gcc_assert(is_function_decl);
+
+ tree function_type = TREE_TYPE(expr);
- gcc_assert(TREE_CODE(cnode->decl) == FUNCTION_DECL);
- tree function_type = TREE_TYPE(cnode->decl);
- gcc_assert(function_type);
// TODO: We do not support method's yet.
gcc_assert(TREE_CODE(function_type) == FUNCTION_TYPE);
tree function_return_type = TREE_TYPE(function_type);
//TODO: What happens with void return
gcc_assert(function_return_type);
- test_log("before rewrite_function_return_type %s", 0, get_type_name(function_return_type));
+ test_log("before rewrite_function_return_type %s", indent, get_type_name(function_return_type));
const_tree *new_type_ptr = type_map.get(function_return_type);
if (!new_type_ptr) return;
TREE_TYPE(function_type) = (tree) *new_type_ptr;
//relayout_decl(cnode->decl);
- tree function_type_2 = TREE_TYPE(cnode->decl);
+ tree function_type_2 = TREE_TYPE(expr);
tree function_return_type_2 = TREE_TYPE(function_type_2);
- test_log("after rewrite_function_return_type %s", 0, get_type_name(function_return_type_2));
+ test_log("after rewrite_function_return_type %s", indent, get_type_name(function_return_type_2));
+}
+
+static void
+rewrite_function_return_type(cgraph_node *cnode, hash_map<const_tree, const_tree> &type_map)
+{
+
+ gcc_assert(TREE_CODE(cnode->decl) == FUNCTION_DECL);
+ tree function_type = TREE_TYPE(cnode->decl);
+ gcc_assert(function_type);
+ rewrite_function_return_type(cnode->decl, type_map, 0);
}
static void