summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErick Ochoa <erick.ochoa@theobroma-systems.com>2020-12-01 16:14:55 +0100
committerErick Ochoa <erick.ochoa@theobroma-systems.com>2020-12-01 16:14:55 +0100
commit856fc2c02ed285ac278fee234081d2d23fcfb9ac (patch)
tree2bd53ee2869d0ecda7a96b3feea50f112f1d0b3f
parent3fa58dd721d930a764238b233120ef830aaeab60 (diff)
the error disappeared
-rw-r--r--gcc/ipa-type-escape-analysis.c61
-rw-r--r--gcc/ipa-type-escape-analysis.h14
2 files changed, 57 insertions, 18 deletions
diff --git a/gcc/ipa-type-escape-analysis.c b/gcc/ipa-type-escape-analysis.c
index 433efbb52b8..17cdb075da9 100644
--- a/gcc/ipa-type-escape-analysis.c
+++ b/gcc/ipa-type-escape-analysis.c
@@ -2794,10 +2794,32 @@ gimple_caster::_walk_pre_gcall (gcall *s)
_expr_escaper.update (lhs, ret_reason);
}
-record_field_map_t&
-type_accessor::get_map_ref()
+bool
+type_accessor::is_in_record_field_map(tree t)
+{
+ return _map2.find(t) != _map2.end();
+}
+
+field_access_map_t
+type_accessor::get_from_record_field_map(tree t)
+{
+ gcc_assert(_map2.at(t));
+ return *_map2.at(t);
+}
+
+void
+type_accessor::put_in_record_field_map(tree t, field_access_map_t f)
{
- return _map;
+ field_access_map_t *f2 = new field_access_map_t;
+ if (_map2.find(t) != _map2.end())
+ {
+ delete _map2[t];
+ }
+ for (auto i = f.begin(), e = f.end(); i != e; ++i)
+ {
+ f2->insert({i->first, i->second});
+ }
+ _map2[t] = f2;
}
bool
@@ -2823,9 +2845,9 @@ type_accessor::add_all_fields_in_struct (tree t)
if (!is_record)
return;
- const bool record_already_in_map = _map.find (t) != _map.end ();
+ const bool record_already_in_map = is_in_record_field_map(t);
field_access_map_t field_map;
- field_map = record_already_in_map ? _map[t] : field_map;
+ field_map = record_already_in_map ? get_from_record_field_map(t) : field_map;
// Let's add all fields to the field map as empty.
for (tree field = TYPE_FIELDS (t); field; field = DECL_CHAIN (field))
@@ -2837,13 +2859,22 @@ type_accessor::add_all_fields_in_struct (tree t)
field_map[field] = Empty;
}
- _map[t] = field_map;
+ put_in_record_field_map(t, field_map);
}
record_field_map_t
type_accessor::get_map ()
{
- return _map;
+ // here we need to translate
+ // record_field_map2_t to record_field_map
+ record_field_map_t return_value;
+ for (auto i = _map2.begin(), e = _map2.end(); i != e; ++i)
+ {
+ if (!(i->second)) continue;
+ return_value.insert({i->first, *(i->second)});
+ }
+ return return_value;
+ //return _map2;
}
record_field_map_t
@@ -2933,9 +2964,9 @@ expr_accessor::_walk_ADDR_EXPR_pre (__attribute__ ((unused)) tree e)
unsigned offset_int = tree_to_uhwi (offset) % type_size_int;
// We need to get the field that corresponds to the offset_int
const bool record_already_in_map
- = _type_accessor.get_map_ref().find (addr_expr_t) != _type_accessor.get_map_ref().end ();
+ = _type_accessor.is_in_record_field_map (addr_expr_t);
field_access_map_t field_map;
- field_map = record_already_in_map ? _type_accessor.get_map_ref()[addr_expr_t] : field_map;
+ field_map = record_already_in_map ? _type_accessor.get_from_record_field_map(addr_expr_t) : field_map;
// UNSAFE! But it is necesseary for testing...
// Unless there is someone who is smarter that finds another way to test this.
@@ -2964,7 +2995,7 @@ expr_accessor::_walk_ADDR_EXPR_pre (__attribute__ ((unused)) tree e)
prev_access |= Read;
field_map[field] = prev_access;
add_all_fields_in_struct (addr_expr_t);
- _type_accessor.get_map_ref()[addr_expr_t] = field_map;
+ _type_accessor.put_in_record_field_map(addr_expr_t, field_map);
if (f_offset == offset_int)
break;
@@ -2996,16 +3027,16 @@ expr_accessor::_walk_COMPONENT_REF_pre (tree e)
log ("%s.%s\n", type_stringifier::get_type_identifier (op0_t).c_str(),
type_stringifier::get_field_identifier (op1).c_str());
const bool record_already_in_map
- = _type_accessor.get_map_ref().find (op0_t) != _type_accessor.get_map_ref().end ();
+ = _type_accessor.is_in_record_field_map (op0_t);
field_access_map_t field_map;
- field_map = record_already_in_map ? _type_accessor.get_map_ref()[op0_t] : field_map;
+ field_map = record_already_in_map ? _type_accessor.get_from_record_field_map(op0_t) : field_map;
const bool field_already_in_map = field_map.find (op1) != field_map.end ();
unsigned prev_access = field_already_in_map ? field_map[op1] : Empty;
prev_access |= _access;
field_map[op1] = prev_access;
add_all_fields_in_struct (op0_t);
- _type_accessor.get_map_ref()[op0_t] = field_map;
+ _type_accessor.put_in_record_field_map(op0_t, field_map);
if (_stack.size () < 4)
return;
@@ -3045,7 +3076,7 @@ expr_accessor::_walk_COMPONENT_REF_pre (tree e)
prev_access |= Read;
field_map[field] = prev_access;
add_all_fields_in_struct (t);
- _type_accessor.get_map_ref()[t] = field_map;
+ _type_accessor.put_in_record_field_map(t, field_map);
}
}
@@ -3053,6 +3084,7 @@ expr_accessor::_walk_COMPONENT_REF_pre (tree e)
void
expr_accessor::print_accesses ()
{
+ /*
for (std::map<tree, field_access_map_t>::const_iterator i
= _type_accessor.get_map_ref().begin (),
e = _type_accessor.get_map_ref().end ();
@@ -3074,6 +3106,7 @@ expr_accessor::print_accesses ()
log ("%s.%s = 0x%04x\n", name_r.c_str (), name_f.c_str (), access);
}
}
+ */
}
/* RECORD_TYPE -> (FIELD_DECL -> bitflag)
diff --git a/gcc/ipa-type-escape-analysis.h b/gcc/ipa-type-escape-analysis.h
index b8d281feb94..4f3a0866660 100644
--- a/gcc/ipa-type-escape-analysis.h
+++ b/gcc/ipa-type-escape-analysis.h
@@ -1130,7 +1130,7 @@ typedef hash_map<tree, unsigned> field_access_map2_t;
// maps RECORD_TYPE -> (FIELD_DECL -> bitflag).
typedef std::map<tree, field_access_map_t> record_field_map_t;
-typedef std::map<tree, field_access_map2_t*> record_field_map2_t;
+typedef std::map<tree, field_access_map_t*> record_field_map2_t;
// Class used to determine if a FIELD is read, written or never accessed.
class type_accessor : public type_walker
@@ -1141,16 +1141,22 @@ public:
~type_accessor()
{
+ for (auto i = _map2.begin(), e = _map2.end(); i != e; ++i)
+ {
+ field_access_map_t *temp = i->second;
+ delete temp;
+ }
};
- record_field_map_t &get_map_ref();
-
record_field_map_t get_map ();
+ bool is_in_record_field_map(tree t);
+ field_access_map_t get_from_record_field_map(tree t);
+ void put_in_record_field_map(tree t, field_access_map_t);
private:
// maps RECORD -> (FIELD_DECL -> bitflag).
- record_field_map_t _map;
+ record_field_map2_t _map2;
// set of trees which are memoized and we don't need to look into them.
hash_set<tree> memoized_map2;