summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErick Ochoa <erick.ochoa@theobroma-systems.com>2020-04-27 11:27:17 +0200
committerErick Ochoa <erick.ochoa@theobroma-systems.com>2020-05-14 14:45:52 +0200
commitc1acdb74061920465dd8ad6dca93b3ce46872ba4 (patch)
tree4df7359a51b335d561cd8c2daf71a311aabc443e
parentaa6fcc71a746535ce19dabe8773931688e7ea87e (diff)
Fixes infinite loop bug correctly
-rw-r--r--gcc/ipa-str-reorg-dead-field-eliminate.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/gcc/ipa-str-reorg-dead-field-eliminate.c b/gcc/ipa-str-reorg-dead-field-eliminate.c
index 27c67245b81..7a6d7191cca 100644
--- a/gcc/ipa-str-reorg-dead-field-eliminate.c
+++ b/gcc/ipa-str-reorg-dead-field-eliminate.c
@@ -587,6 +587,7 @@ struct cstrless {
};
std::set<const char*, cstrless> interesting_records;
std::set<const char*, cstrless> interesting_fields;
+std::set<const char*, cstrless> updated_functions;
static bool
is_interesting_struct_escape_analysis(const_tree record)
@@ -1941,7 +1942,7 @@ rewrite_pointer_plus_def_rhs_integer_constant (tree pointer,
tree integer_constant_type = TREE_TYPE (integer_constant);
- int new_offset = old_offset / old_struct_size * new_struct_size + modulo;
+ int new_offset = old_offset / old_struct_size * new_struct_size;
tree new_constant = build_int_cst (integer_constant_type, new_offset);
return new_constant;
}
@@ -2340,6 +2341,20 @@ rewrite_function_body (cgraph_node *cnode,
t_map &inverse)
{
gcc_assert (cnode);
+ const char* name_s = cnode->name();
+ const char* dot = strstr(name_s, "."); // Updated functions have a dot on them.
+ // If there's a dot, we need to do a memcpy
+ // of the string name[0:dot]
+ size_t n = dot ? dot - name_s : strlen(name_s);
+ char precanon[100];
+ const char* canonical = dot ? strncpy(precanon, name_s, n) : name_s;
+ bool already_processed = updated_functions.find(name_s) != updated_functions.end();
+ log("original name %s\n", name_s);
+ log("canonical name %s\n", canonical);
+ log("already processed ? %s\n", already_processed ? "true" : "false");
+ if (already_processed) return;
+
+ updated_functions.insert(name_s);
cnode->get_untransformed_body ();
basic_block bb = NULL;
function *func = DECL_STRUCT_FUNCTION (cnode->decl);