diff options
author | Erick Ochoa <erick.ochoa@theobroma-systems.com> | 2020-11-30 15:12:55 +0100 |
---|---|---|
committer | Erick Ochoa <erick.ochoa@theobroma-systems.com> | 2020-11-30 15:12:55 +0100 |
commit | 5980da7c775e1c89e54e9cbd3df8b820a6cb3b8f (patch) | |
tree | 0d70b89c3e1dc629a8f97fd1a5928c373786e7f1 | |
parent | 1fe2bb196582d096e8b822cf469aabc9476aec66 (diff) |
Remove STL from specific_type_collector
-rw-r--r-- | gcc/ipa-dfe.c | 69 | ||||
-rw-r--r-- | gcc/ipa-dfe.h | 12 |
2 files changed, 40 insertions, 41 deletions
diff --git a/gcc/ipa-dfe.c b/gcc/ipa-dfe.c index bfbcce01940..a2f580069dd 100644 --- a/gcc/ipa-dfe.c +++ b/gcc/ipa-dfe.c @@ -135,7 +135,6 @@ get_all_types_pointing_to (record_field_offset_map_t record_field_offset_map, { const tset_t &non_escaping = casting.non_escaping; - std::set<tree> specific_types; type_stringifier stringifier; hash_set<tree> specific_types2; hash_map<tree, field_offsets_t> record_field_offset_map2; @@ -156,11 +155,10 @@ get_all_types_pointing_to (record_field_offset_map_t record_field_offset_map, i != e; ++i) { tree record = (*i).first; - specific_types.insert (record); specific_types2.add (record); } - specific_type_collector specifier (specific_types, &specific_types2); + specific_type_collector specifier (&specific_types2); // SpecificTypeCollector will collect all types which point to the types in // the set. @@ -200,18 +198,24 @@ get_types_replacement (record_field_offset_map_t record_field_offset_map, std::set<tree> to_modify) { type_stringifier stringifier; + hash_set<tree> to_modify2; + + for (std::set<tree>::iterator i = to_modify.begin(), e = to_modify.end(); i != e; ++i) + { + to_modify2.add (*i); + } type_reconstructor reconstructor (record_field_offset_map, "reorg"); - for (std::set<tree>::const_iterator i = to_modify.begin (), - e = to_modify.end (); + for (hash_set<tree>::iterator i = to_modify2.begin (), + e = to_modify2.end (); i != e; ++i) { tree record = *i; reconstructor.walk (TYPE_MAIN_VARIANT (record)); } - for (std::set<tree>::const_iterator i = to_modify.begin (), - e = to_modify.end (); + for (hash_set<tree>::iterator i = to_modify2.begin (), + e = to_modify2.end (); i != e; ++i) { tree record = *i; @@ -219,19 +223,26 @@ get_types_replacement (record_field_offset_map_t record_field_offset_map, } reorg_record_map_t map = reconstructor.get_map (); + reorg_record_map2_t map2; + + for (auto i = map.begin(), e = map.end(); i != e; ++i) + { + map2.put(i->first, i->second); + } + reorg_field_map_t field_map = reconstructor.get_field_map (); // Here, we are just making sure that we are not doing anything too crazy. // Also, we found some types for which TYPE_CACHED_VALUES_P is not being // rewritten. This is probably indicative of a bug in TypeReconstructor. - for (std::map<tree, tree>::const_iterator i = map.begin (), - e = map.end (); + for (hash_map<tree, tree>::iterator i = map2.begin (), + e = map2.end (); i != e; ++i) { - tree o_record = i->first; + tree o_record = (*i).first; std::string o_name = stringifier.stringify (o_record); log ("original: %s\n", o_name.c_str ()); - tree r_record = i->second; + tree r_record = (*i).second; std::string r_name = r_record ? stringifier.stringify (r_record) : std::string (""); log ("modified: %s\n", r_name.c_str ()); @@ -243,15 +254,16 @@ get_types_replacement (record_field_offset_map_t record_field_offset_map, TYPE_CACHED_VALUES_P (_o_record) = false; TYPE_CACHED_VALUES_P (m_record) = false; - bool in_map = map.find (m_record) != map.end (); + bool in_map = map2.get (m_record); if (!in_map) continue; - tree mm_record = map[m_record]; + tree mm_record = *map2.get (m_record); // Info: I think this is no longer needed... // Please verify TYPE_MAIN_VARIANT (r_record) = mm_record; } + // TODO: Ok, we will need to change this some time... return std::make_pair (map, field_map); } @@ -271,12 +283,6 @@ substitute_types_in_program (reorg_record_map_t map, /* Return a set of trees which point to the set of trees * that can be modified. */ -std::set<tree> -specific_type_collector::get_set () -{ - return to_return; -} - hash_set<tree> specific_type_collector::get_set2 () { @@ -286,37 +292,37 @@ specific_type_collector::get_set2 () void specific_type_collector::_walk_POINTER_TYPE_pre (tree t) { - path.insert (t); + path2.add (t); } void specific_type_collector::_walk_POINTER_TYPE_post (tree t) { - path.erase (t); + path2.remove (t); } void specific_type_collector::_walk_ARRAY_TYPE_pre (tree t) { - path.insert (t); + path2.add (t); } void specific_type_collector::_walk_ARRAY_TYPE_post (tree t) { - path.erase (t); + path2.remove (t); } void specific_type_collector::_walk_UNION_TYPE_pre (tree t) { - path.insert (t); + path2.add (t); } void specific_type_collector::_walk_UNION_TYPE_post (tree t) { - path.erase (t); + path2.remove (t); } /* If we find a RECORD_TYPE which is of interest, place @@ -328,23 +334,22 @@ specific_type_collector::_walk_RECORD_TYPE_pre (tree t) const bool in_set = _collect_these_types2->contains (t); const bool must_collect = in_set; - path.insert (t); + path2.add (t); if (!must_collect) return; - for (std::set<tree>::const_iterator i = path.begin (), - e = path.end (); - i != e; ++i) - { + for (hash_set<tree>::iterator i = path2.begin(), e = path2.end(); i != e; ++i) + { tree type = *i; to_return2.add (type); - } + } + } void specific_type_collector::_walk_RECORD_TYPE_post (tree t) { - path.erase (t); + path2.remove (t); } /* diff --git a/gcc/ipa-dfe.h b/gcc/ipa-dfe.h index 4fca29254b0..d869a52a31f 100644 --- a/gcc/ipa-dfe.h +++ b/gcc/ipa-dfe.h @@ -29,27 +29,20 @@ class specific_type_collector : public type_walker { public: /* C is the set of types that are to be looked for. */ - specific_type_collector (std::set<tree> &c, hash_set<tree> *c2) : _collect_these_types (c), _collect_these_types2 (c2) + specific_type_collector (hash_set<tree> *c2) : _collect_these_types2 (c2) {}; /* Get final result of all types which point to types in C. */ - std::set<tree> get_set (); - hash_set<tree> get_set2 (); private: - /* _collect_these_types holds the input. */ - const std::set<tree> &_collect_these_types; - hash_set<tree> *_collect_these_types2; /* Working set that holds final result. */ - std::set<tree> to_return; - hash_set<tree> to_return2; /* Sets which reach current subtype. */ - std::set<tree> path; + hash_set<tree> path2; /* Push or pop from path. */ virtual void _walk_ARRAY_TYPE_pre (tree t); @@ -66,6 +59,7 @@ private: /* Map old RECORD_TYPE -> new RECORD_TYPE. */ typedef std::map<tree, tree> reorg_record_map_t; +typedef hash_map<tree, tree> reorg_record_map2_t; /* Map RECORD_TYPE -> (FIELD_DECL -> delete). */ typedef std::map<tree, std::pair<tree, bool> > reorg_field_map_t; |