diff options
author | Erick Ochoa <erick.ochoa@theobroma-systems.com> | 2020-12-01 13:06:33 +0100 |
---|---|---|
committer | Erick Ochoa <erick.ochoa@theobroma-systems.com> | 2020-12-01 13:06:33 +0100 |
commit | 405109c1e14cf78d6bad9684d9309e799f7a3e29 (patch) | |
tree | a99e5ae3bf2bac32755b8b980673fe261c1136b7 | |
parent | 3980bf1aae19f85c29e309f5e34ad0072a5106dc (diff) |
type accessor progress
-rw-r--r-- | gcc/ipa-dfe.c | 1 | ||||
-rw-r--r-- | gcc/ipa-dfe.h | 4 | ||||
-rw-r--r-- | gcc/ipa-type-escape-analysis.c | 6 | ||||
-rw-r--r-- | gcc/ipa-type-escape-analysis.h | 25 |
4 files changed, 28 insertions, 8 deletions
diff --git a/gcc/ipa-dfe.c b/gcc/ipa-dfe.c index a56b4f717cf..25990504634 100644 --- a/gcc/ipa-dfe.c +++ b/gcc/ipa-dfe.c @@ -266,7 +266,6 @@ get_types_replacement (record_field_offset_map_t record_field_offset_map, } // TODO: Ok, we will need to change this some time... - return std::make_pair (map, field_map); } diff --git a/gcc/ipa-dfe.h b/gcc/ipa-dfe.h index 6e63062f526..8a57c0d8aa8 100644 --- a/gcc/ipa-dfe.h +++ b/gcc/ipa-dfe.h @@ -231,16 +231,14 @@ public: private: // Old RECORD_TYPE -> new RECORD_TYPE. - //reorg_record_map_t _map; reorg_record_map2_t* _map2; // Old FIELD_DECL -> new FIELD_DECL. - //reorg_field_map_t _fields; reorg_field_map2_t* _fields2; // New RECORD_TYPE -> old RECORD_TYPE. - //std::map<tree, tree> _imap; hash_map<tree, tree>* _imap2; + void _walk_post (tree e); // Substitute types and create new offset. diff --git a/gcc/ipa-type-escape-analysis.c b/gcc/ipa-type-escape-analysis.c index 06cab5531c7..5cc43c246b2 100644 --- a/gcc/ipa-type-escape-analysis.c +++ b/gcc/ipa-type-escape-analysis.c @@ -2797,7 +2797,8 @@ gimple_caster::_walk_pre_gcall (gcall *s) bool type_accessor::is_memoized (tree t) { - return memoized_map.find (t) != memoized_map.end (); + return memoized_map2.contains (t); + //return memoized_map.find (t) != memoized_map.end (); } /* Add all fields in struct to memoized map. */ @@ -2805,7 +2806,8 @@ void type_accessor::_walk_RECORD_TYPE_pre (tree t) { add_all_fields_in_struct (t); - memoized_map.insert (t); + memoized_map2.add (t); + //memoized_map.insert (t); } /* Initialize all fields as neither read nor written. */ diff --git a/gcc/ipa-type-escape-analysis.h b/gcc/ipa-type-escape-analysis.h index dc30725b4a7..96f726f58ba 100644 --- a/gcc/ipa-type-escape-analysis.h +++ b/gcc/ipa-type-escape-analysis.h @@ -1126,23 +1126,44 @@ const unsigned Write = 0x02u; // maps FIELD_DECL -> bitflag. typedef std::map<tree, unsigned> field_access_map_t; +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; // Class used to determine if a FIELD is read, written or never accessed. class type_accessor : public type_walker { public: type_accessor (record_field_map_t &map) : _map (map) - {}; + { + for (auto i = map.begin(), e = map.end(); i != e; ++i) + { + field_access_map2_t *field_access_map_new = new field_access_map2_t; + field_access_map_t field_access_map = i->second; + for (auto j = field_access_map.begin(), f = field_access_map.end(); j != f; ++j) + { + field_access_map_new->put (j->first, j->second); + } + _map2[i->first] = field_access_map_new; + } + }; + ~type_accessor() + { + for (auto i = _map2.begin(), e = _map2.end(); i != e; ++i) + { + delete _map2.at(i->first); + } + }; 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. - std::set<tree> memoized_map; + hash_set<tree> memoized_map2; // If a RECORD_TYPE is walked into, add all fields in struct to // record_field_map. |