summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErick Ochoa <erick.ochoa@theobroma-systems.com>2020-12-09 09:44:28 +0100
committerErick Ochoa <erick.ochoa@theobroma-systems.com>2020-12-22 09:39:36 +0100
commitfff21978a76e6b89a1a6cd705a5b5f0870892017 (patch)
treee14dc5b8eb02690a25a086a686dec70ab3ed14ef
parent2397742640376f12a6794f5437f228d5846dfe99 (diff)
Fixes errors created during STL migrationgcc_master_new8
-rw-r--r--gcc/ipa-dfe.c81
-rw-r--r--gcc/ipa-field-reorder.c4
-rw-r--r--gcc/ipa-type-escape-analysis.c44
-rw-r--r--gcc/ipa-type-escape-analysis.h24
4 files changed, 117 insertions, 36 deletions
diff --git a/gcc/ipa-dfe.c b/gcc/ipa-dfe.c
index 98427e8e423..f9242342cb6 100644
--- a/gcc/ipa-dfe.c
+++ b/gcc/ipa-dfe.c
@@ -189,16 +189,25 @@ get_types_replacement (record_field_offset_map4_t &record_field_offset_map2,
type_stringifier stringifier;
type_reconstructor reconstructor (record_field_offset_map2, "reorg", map2, field_map2);
+
+ std::set<tree> temp;
for (hash_set<tree>::iterator i = to_modify.begin (),
e = to_modify.end ();
i != e; ++i)
{
+ temp.insert (*i);
+ }
+
+ for (std::set<tree>::const_iterator i = temp.begin (),
+ e = temp.end ();
+ i != e; ++i)
+ {
tree record = *i;
reconstructor.walk (TYPE_MAIN_VARIANT (record));
}
- for (hash_set<tree>::iterator i = to_modify.begin (),
- e = to_modify.end ();
+ for (std::set<tree>::const_iterator i = temp.begin (),
+ e = temp.end ();
i != e; ++i)
{
tree record = *i;
@@ -678,8 +687,10 @@ type_reconstructor::_walk_field_post (tree t)
tree record = for_reference2.last ();
field_offsets2_t **field_offsets_ptr = _records2.get(record);
- if (!field_offsets_ptr) return;
- field_offsets2_t *field_offsets = *field_offsets_ptr;
+ field_offsets2_t *field_offsets = field_offsets_ptr ? *field_offsets_ptr : new field_offsets2_t;
+ if (!field_offsets_ptr) {
+ _records2.put(record, field_offsets);
+ }
// What's the field offset?
unsigned f_byte_offset = tree_to_uhwi (DECL_FIELD_OFFSET (t));
unsigned f_bit_offset = tree_to_uhwi (DECL_FIELD_BIT_OFFSET (t));
@@ -1080,8 +1091,7 @@ expr_type_rewriter::handle_pointer_arithmetic_constants (gimple *s, tree p,
if (!is_valid_input)
{
- if (dump_file)
- print_gimple_expr (dump_file, s, 0);
+ //if (dump_file) print_gimple_expr (dump_file, s, 0);
log ("\n%d = %d / %d * %d\n", new_integer_cst_int, old_integer_cst_int,
old_size_int, new_size_int);
}
@@ -1095,12 +1105,65 @@ expr_type_rewriter::_walk_post (tree e)
gcc_assert (e);
tree t = TREE_TYPE (e);
const bool in_map = _map2.get(t);
+ if (dump_file && TREE_CODE(e) == ARRAY_REF)
+ {
+ print_generic_expr (dump_file, e, TDF_NONE);
+ fprintf(dump_file, "\n");
+ fprintf(dump_file, "type: %s\n", type_stringifier::get_type_identifier(t).c_str());
+ type_stringifier _ts;
+ fprintf(dump_file, "long type: %s\n", _ts.stringify(TREE_TYPE(t)).c_str());
+ }
+
+ if (TREE_CODE(e) == ARRAY_REF && dump_file)
+ {
+ tree op_0 = TREE_OPERAND (e, 0);
+ fprintf(dump_file, "op_0: \n");
+ print_generic_expr (dump_file, op_0, TDF_NONE);
+ fprintf(dump_file, "\n");
+ fprintf(dump_file, "type: %s\n", type_stringifier::get_type_identifier(TREE_TYPE(op_0)).c_str());
+ type_stringifier _ts;
+ fprintf(dump_file, "long type: %s\n", _ts.stringify(TREE_TYPE(op_0)).c_str());
+ fprintf(dump_file, "code: %s\n", get_tree_code_name( TREE_CODE(op_0)));
+ tree op_1 = TREE_OPERAND (e, 1);
+ fprintf(dump_file, "op_1: \n");
+ print_generic_expr (dump_file, op_1, TDF_NONE);
+ fprintf(dump_file, "\n");
+ fprintf(dump_file, "type: %s\n", type_stringifier::get_type_identifier(TREE_TYPE(op_1)).c_str());
+ fprintf(dump_file, "code: %s\n", get_tree_code_name( TREE_CODE(op_1)));
+
+ }
if (!in_map)
return;
+ if (dump_file) fprintf(dump_file, "in map\n");
tree r_t = *_map2.get(t);
tree _e = tree_to_tree (e);
TREE_TYPE (_e) = r_t;
+
+ if (TREE_CODE(e) == ARRAY_REF)
+ {
+ tree op_0 = TREE_OPERAND (_e, 0);
+ if (op_0) {
+ TREE_TYPE(TREE_TYPE(op_0)) = r_t;
+ }
+ }
+ if (TREE_CODE(e) == ARRAY_REF && dump_file)
+ {
+ tree op_0 = TREE_OPERAND (_e, 0);
+ fprintf(dump_file, "op_0: \n");
+ print_generic_expr (dump_file, op_0, TDF_NONE);
+ fprintf(dump_file, "\n");
+ type_stringifier _ts;
+ fprintf(dump_file, "type: %s\n", type_stringifier::get_type_identifier(TREE_TYPE(op_0)).c_str());
+ fprintf(dump_file, "long type: %s\n", _ts.stringify(TREE_TYPE(op_0)).c_str());
+ fprintf(dump_file, "code: %s\n", get_tree_code_name( TREE_CODE(op_0)));
+ tree op_1 = TREE_OPERAND (e, 1);
+ fprintf(dump_file, "op_1: \n");
+ print_generic_expr (dump_file, op_1, TDF_NONE);
+ fprintf(dump_file, "\n");
+ fprintf(dump_file, "type: %s\n", type_stringifier::get_type_identifier(TREE_TYPE(op_1)).c_str());
+ fprintf(dump_file, "code: %s\n", get_tree_code_name( TREE_CODE(op_1)));
+ }
}
/* Rewrite Field. */
@@ -1273,12 +1336,10 @@ gimple_type_rewriter::_walk_pre_gassign (gassign *s)
case POINTER_PLUS_EXPR:
case POINTER_DIFF_EXPR:
log ("am i handling pointer arithmetic?\n");
- if (dump_file)
- print_gimple_stmt (dump_file, s, 0);
+ //if (dump_file) print_gimple_stmt (dump_file, s, 0);
log ("\n");
handle_pointer_arithmetic (s);
- if (dump_file)
- print_gimple_stmt (dump_file, s, 0);
+ //if (dump_file) print_gimple_stmt (dump_file, s, 0);
log ("\n");
break;
default:
diff --git a/gcc/ipa-field-reorder.c b/gcc/ipa-field-reorder.c
index e4c2ff4a62b..08ec107f8d3 100644
--- a/gcc/ipa-field-reorder.c
+++ b/gcc/ipa-field-reorder.c
@@ -523,6 +523,7 @@ get_reordered_field_maps (record_field_offset_map4_t &record_field_offset_map2,
TypeReconstructorFieldReordering reconstructor (record_field_offset_map2,
"reorder", map2, field_map2);
+
for (hash_set<tree>::iterator i = to_modify.begin (),
e = to_modify.end ();
i != e; ++i)
@@ -584,7 +585,7 @@ lto_fr_execute ()
log ("here in field reordering \n");
// Analysis.
detected_incompatible_syntax = false;
- hash_map<tree, bool> *whitelisted2 = get_whitelisted_nodes2();
+ hash_map<tree, bool> *whitelisted2 = get_whitelisted_nodes2 ();
tpartitions2_t escaping_nonescaping_sets;
partition_types_into_escaping_nonescaping (escaping_nonescaping_sets, whitelisted2);
record_field_map4_t record_field_map;
@@ -598,6 +599,7 @@ lto_fr_execute ()
// Prepare for transformation.
hash_set<tree> to_modify;
+
get_all_types_pointing_to (record_field_offset_map,
escaping_nonescaping_sets, to_modify);
diff --git a/gcc/ipa-type-escape-analysis.c b/gcc/ipa-type-escape-analysis.c
index f4917a96b54..13a4aada521 100644
--- a/gcc/ipa-type-escape-analysis.c
+++ b/gcc/ipa-type-escape-analysis.c
@@ -175,6 +175,7 @@ along with GCC; see the file COPYING3. If not see
#define ABORT_IF_NOT_C true
bool detected_incompatible_syntax = false;
+bool still_whitelisting = true;
// Main function that drives dfe.
static unsigned int
@@ -292,7 +293,6 @@ get_whitelisted_nodes2 ()
vec<cgraph_node *> worklist = vNULL;
for (hash_set<cgraph_node*>::iterator i = leaf_nodes.begin(), e = leaf_nodes.end (); i != e; ++i)
{
- if (dump_file) fprintf (dump_file, "is a leaf node %s\n", (*i)->name ());
worklist.safe_push (*i);
}
@@ -309,7 +309,6 @@ get_whitelisted_nodes2 ()
if (detected_incompatible_syntax) return map;
cgraph_node *i = worklist[0];
worklist.ordered_remove (0);
- if (dump_file) fprintf (dump_file, "analyzing %s %p\n", i->name (), (void*)i);
tpartitions2_t temp;
gimple_white_lister whitelister(temp);
whitelister._walk_cnode (i);
@@ -335,6 +334,7 @@ get_whitelisted_nodes2 ()
}
}
+ still_whitelisting = false;
return map;
}
@@ -1888,22 +1888,32 @@ expr_collector::_walk_pre (tree e)
if (RECORD_TYPE != TREE_CODE (t)) return;
- if (_type_collector.ptrset2.records.is_empty ()) {
- _type_collector.ptrset2.records.add (TYPE_MAIN_VARIANT (t));
+ if (!still_whitelisting) return;
+
+ if (ptrset3->is_empty ()) {
+ gcc_assert (TYPE_P (t));
+ gcc_assert (TYPE_P (TYPE_MAIN_VARIANT (t)));
+ ptrset3->add (TYPE_MAIN_VARIANT (t));
+ log ("we are adding something to whitelisting for the very first time!\n");
return;
}
- for (auto
- i = _type_collector.ptrset2.records.begin (),
- e = _type_collector.ptrset2.records.end (); i != e; ++i)
+ bool same = true;
+ for (hash_set<tree>::iterator
+ i = ptrset3->begin (),
+ e = ptrset3->end (); i != e; ++i)
{
tree r = *i;
type_incomplete_equality structuralEquality;
- bool is_same = structuralEquality.equal (TYPE_MAIN_VARIANT (r), TYPE_MAIN_VARIANT (t));
- if (is_same) continue;
+ // WHY!?!?!?!
+ gcc_assert (TYPE_P (r));
+ gcc_assert (TYPE_MAIN_VARIANT (r));
+ same &= structuralEquality.equal (TYPE_MAIN_VARIANT (r), TYPE_MAIN_VARIANT (t));
+ if (!same) break;
+ }
- type_stringifier stringifier;
- _type_collector.ptrset2.records.add (TYPE_MAIN_VARIANT (t));
+ if (!same) {
+ ptrset3->add (TYPE_MAIN_VARIANT (t));
}
}
@@ -2280,9 +2290,9 @@ expr_escaper::_walk_SSA_NAME_pre (tree e)
bool whitelisted = in_map && *_whitelisted2->get (curr_node->decl);
if (whitelisted) return;
- if (dump_file) print_generic_stmt(dump_file, e);
+ //if (dump_file) print_generic_stmt(dump_file, e);
log ("\n");
- if (dump_file) print_generic_stmt(dump_file, prev_expr);
+ //if (dump_file) print_generic_stmt(dump_file, prev_expr);
log ("\n");
_r.type_is_casted = !structuralEquality.equal (mref_type, ssa_type);
@@ -3153,7 +3163,7 @@ type_partitions2_s::in_complement (tree type)
std::string
type_stringifier::stringify (tree t)
{
- if (!dump_file)
+ if (!dump_file || !t)
return std::string ("");
_stringification.clear ();
gcc_assert (t);
@@ -3350,18 +3360,18 @@ std::string
type_stringifier::get_type_identifier (tree t)
{
if (detected_incompatible_syntax)
- return std::string ("");
+ return std::string ("incompatible syntax");
tree name = TYPE_NAME (t);
bool no_name = NULL_TREE == name;
if (no_name)
- return std::string ("");
+ return std::string ("NULL_TREE == name");
const enum tree_code name_code = TREE_CODE (name);
const bool is_name_type_decl = TYPE_DECL == name_code;
name = is_name_type_decl ? DECL_NAME (name) : name;
no_name = NULL_TREE == name;
if (no_name)
- return std::string ("");
+ return std::string ("NULL_TREE == name");
const char *identifier_ptr = IDENTIFIER_POINTER (name);
gcc_assert (identifier_ptr);
return std::string (identifier_ptr);
diff --git a/gcc/ipa-type-escape-analysis.h b/gcc/ipa-type-escape-analysis.h
index 702e13e62ba..8fe8246969f 100644
--- a/gcc/ipa-type-escape-analysis.h
+++ b/gcc/ipa-type-escape-analysis.h
@@ -27,7 +27,7 @@ void log (const char *const fmt, ...) __attribute__((format(printf, 1, 0)));
inline void
log (const char *const fmt, ...)
{
- if (!dump_file)
+ //if (!dump_file)
return;
va_list args;
@@ -438,9 +438,6 @@ struct type_partitions2_s
/* The set of all non escaping types. */
tset2_t non_escaping;
- /* The set of all records. */
- tset2_t records;
-
/* Determine if we have seen this type before. */
bool in_universe (tree);
@@ -465,7 +462,11 @@ class type_collector : public type_walker
public:
type_collector (tpartitions2_t &ptrset)
: ptrset2(ptrset)
- {};
+ {
+ };
+ ~type_collector()
+ {
+ };
/* Main interface. */
void collect (tree t);
@@ -645,8 +646,14 @@ class expr_collector : public expr_walker
{
public:
expr_collector (tpartitions2_t &p)
- : _type_collector (p)
- {};
+ : _type_collector (p), ptrset3(NULL)
+ {
+ ptrset3 = new hash_set<tree>();
+ };
+ ~expr_collector ()
+ {
+ delete ptrset3;
+ };
/* Holds the result after collecting from all trees. */
tpartitions2_t get_record_reaching_trees ()
@@ -654,6 +661,7 @@ public:
return _type_collector.get_record_reaching_trees ();
}
+ hash_set<tree> *ptrset3;
type_collector _type_collector;
private:
@@ -731,7 +739,7 @@ public:
}
unsigned int how_many_records =
- _expr_collector._type_collector.ptrset2.records.elements ();
+ _expr_collector.ptrset3->elements ();
return how_many_records <= 1;
}