diff options
author | Erick Ochoa <erick.ochoa@theobroma-systems.com> | 2020-06-25 10:46:17 +0200 |
---|---|---|
committer | Erick Ochoa <erick.ochoa@theobroma-systems.com> | 2020-06-26 12:42:33 +0200 |
commit | a1d7a5ef1d88c6e83b6d8633a65aea6071736e53 (patch) | |
tree | e91c31e3fa4966ac52b6788ab306473160dd5271 | |
parent | bd73fc9f1e941eb5d64fc49c14bc379a5d4672fc (diff) |
still not working on x264
-rw-r--r-- | gcc/gimple-walker.c | 32 | ||||
-rw-r--r-- | gcc/ipa-type-escape-analysis.c | 18 | ||||
-rw-r--r-- | gcc/type-reconstructor.c | 24 |
3 files changed, 39 insertions, 35 deletions
diff --git a/gcc/gimple-walker.c b/gcc/gimple-walker.c index b1cf0c3a51d..1a858419c27 100644 --- a/gcc/gimple-walker.c +++ b/gcc/gimple-walker.c @@ -169,37 +169,19 @@ GimpleWalker::_walk(basic_block bb) { gcc_assert(bb); bool first = true; - for (auto gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) + gimple_stmt_iterator gsi = gsi_start_bb(bb); + + while (!gsi_end_p(gsi)) { gimple *stmt = gsi_stmt(gsi); walk(stmt); - - if (_deleted && !first) - { - unlink_stmt_vdef (stmt); - gsi_remove(&gsi, true); - gsi_prev(&gsi); - } - - bool old_deleted = _deleted; - while (_deleted && first) - { - unlink_stmt_vdef (stmt); - gsi_remove(&gsi, true); - old_deleted = _deleted; - _deleted = false; - stmt = gsi_stmt(gsi); - if (!stmt) break; // we might have deleted and was end of basic block? - walk(stmt); - if (gsi_end_p(gsi)) break; - } - - if (old_deleted && gsi_end_p (gsi)) break; - - first = false; + if (_deleted) unlink_stmt_vdef (stmt); + if (_deleted) { gsi_remove(&gsi, true); } + else { gsi_next(&gsi); } _deleted = false; } + for (gimple_stmt_iterator gsi = gsi_start_phis(bb); !gsi_end_p(gsi); gsi_next(&gsi)) { gimple *stmt = gsi_stmt(gsi); diff --git a/gcc/ipa-type-escape-analysis.c b/gcc/ipa-type-escape-analysis.c index d69b3368b7f..ea6e517d0b8 100644 --- a/gcc/ipa-type-escape-analysis.c +++ b/gcc/ipa-type-escape-analysis.c @@ -227,6 +227,7 @@ collect_types() const typeset &non_escaping = casting.non_escaping; std::vector<const_tree> to_erase; + std::set<const_tree> to_keep; for (auto i = record_field_offset_map.begin(), e = record_field_offset_map.end(); i != e; ++i) { const_tree record = i->first; @@ -247,6 +248,7 @@ collect_types() field_offset.erase(f_offset); continue; } + to_keep.insert(record); field_offset.insert(f_offset); has_fields_that_can_be_deleted = true; log("%s.%s may be deleted\n", TypeStringifier::get_type_identifier(record).c_str(), TypeStringifier::get_field_identifier(field).c_str()); @@ -279,6 +281,7 @@ collect_types() std::string name_from = stringifier.stringify(TYPE_MAIN_VARIANT(record)); bool points_to_record = false; const_tree tt = record; + //TODO: //This is our little hack to make sure that we are @@ -303,6 +306,7 @@ collect_types() std::string name_from = stringifier.stringify(record); bool points_to_record = false; const_tree tt = record; + //TODO: //This is our little hack to make sure that we are @@ -333,15 +337,21 @@ collect_types() std::string name_from = stringifier.stringify(o_record); std::string name_to = stringifier.stringify(r_record); std::string name_to_mv = stringifier.stringify(m_record); + bool c_f = TYPE_CACHED_VALUES_P(o_record); + bool c_t = TYPE_CACHED_VALUES_P(r_record); + bool c_m = TYPE_CACHED_VALUES_P(m_record); + TYPE_CACHED_VALUES_P((tree)o_record) = false; + TYPE_CACHED_VALUES_P((tree)m_record) = false; - log("map f: %s\n", name_from.c_str()); - log("map t: %s\n", name_to.c_str()); - log("map m: %s\n", name_to_mv.c_str()); + log("map f: %s TYPE_CACHED_VALUES_P %s \n", name_from.c_str(), c_f ? "t" : "f"); + log("map t: %s TYPE_CACHED_VALUES_P %s \n", name_to.c_str(), c_t ? "t" : "f"); + log("map m: %s TYPE_CACHED_VALUES_P %s \n", name_to_mv.c_str(), c_m ? "t" : "f"); bool in_map = map.find(m_record) != map.end(); if (!in_map) continue; tree mm_record = map[m_record]; std::string name_to_mmv = stringifier.stringify(mm_record); - log("map m2: %s\n", name_to_mmv.c_str()); + bool c_m2 = TYPE_CACHED_VALUES_P(mm_record); + log("map m2: %s TYPE_CACHED_VALUES_P %s\n", name_to_mmv.c_str(), c_m2 ? "t" : "f"); // TODO: This is a hack... TYPE_MAIN_VARIANT(r_record) = mm_record; // Do we need to layout the type again? diff --git a/gcc/type-reconstructor.c b/gcc/type-reconstructor.c index 5adb6220b5d..91d4f383ea7 100644 --- a/gcc/type-reconstructor.c +++ b/gcc/type-reconstructor.c @@ -108,6 +108,9 @@ TypeReconstructor::is_memoized(const_tree t) { const bool already_changed = _reorg_map.find(t) != _reorg_map.end(); mark_all_pointing_here_as_modified(); + const bool has_typed_cached_values = TYPE_CACHED_VALUES_P (t); + TypeStringifier stringifier; + std::string name = stringifier.stringify(t); return already_changed; } @@ -188,6 +191,13 @@ TypeReconstructor::_walk_ARRAY_TYPE_post(const_tree t) //std::string name = stringifier.stringify(copy); log("are we going to crash is modified %s %s\n", is_modified ? "t" : "f", TypeStringifier::get_type_identifier(copy).c_str()); if (is_modified) layout_type(copy); + TYPE_CACHED_VALUES_P (copy) = false; + //TYPE_CACHED_VALUES (copy) = TYPE_CACHED_VALUES(t); + tree tt = (tree)t; + while (TREE_TYPE(tt)) { tt = TREE_TYPE(tt); }; + + const bool points_to_record = TREE_CODE(tt) == RECORD_TYPE; + if (!points_to_record) return; _reorg_map[t] = is_modified ? copy : (tree)t; } @@ -219,6 +229,14 @@ TypeReconstructor::_walk_POINTER_TYPE_post(const_tree t) // This is useful so that we go again through type layout //TYPE_SIZE(copy) = is_modified ? NULL : TYPE_SIZE(copy); //if (is_modified) layout_type(copy); + TYPE_CACHED_VALUES_P (copy) = false; + //TYPE_CACHED_VALUES (copy) = TYPE_CACHED_VALUES(t); + //Let's just make sure that we are pointing to a a struct... + + tree tt = (tree)t; + while (TREE_TYPE(tt)) { tt = TREE_TYPE(tt); }; + const bool points_to_record = TREE_CODE(tt) == RECORD_TYPE; + if (!points_to_record) return; _reorg_map[t] = is_modified ? copy : (tree)t; } @@ -370,12 +388,6 @@ TypeReconstructor::_walk_field_post(const_tree t) // What record does this field belongs to? const_tree record = for_reference.top(); - // Is this a record that has a field that might be deleted? - const bool is_record_interesting = _records.find(record) != _records.end(); - if (!is_record_interesting) { - return; - } - field_offsets_t field_offsets = _records[record]; // What's the field offset? unsigned f_byte_offset = tree_to_uhwi(DECL_FIELD_OFFSET(t)); |