From bba561d39df03b6b2abd31ed15c4b17b87f11826 Mon Sep 17 00:00:00 2001 From: Erick Ochoa Date: Fri, 5 Jun 2020 13:14:02 +0200 Subject: seems that type equality is working needs more testing --- gcc/ipa-prototype.c | 22 ++++++++++++++++------ gcc/type-canonical-equality.c | 11 +++++++++-- gcc/type-incomplete-equality.c | 8 ++++---- gcc/type-structural-equality.c | 7 +++++++ 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/gcc/ipa-prototype.c b/gcc/ipa-prototype.c index 846c484b4c2..d4b61abd39c 100644 --- a/gcc/ipa-prototype.c +++ b/gcc/ipa-prototype.c @@ -201,13 +201,23 @@ fix_escaping_types_in_set(ptrset_t &types) //const bool interesting_case = eq_type_compare(type_esc, type_non); //TODO: We are going to need a different type comparison because this one //fails to take into account the recursion... - const bool interesting_case = structuralEquality.equal(type_esc, type_non); - if (!interesting_case) continue; - TypeStringifier stringifier; - std::string type_esc_name = stringifier.stringify(type_esc); - std::string type_non_name = stringifier.stringify(type_non); - log("**NOT** checking for incompleteness %s == %s\n", type_esc_name.c_str(), type_non_name.c_str()); + std::string type_esc_name = TypeStringifier::get_type_identifier(type_esc); + std::string type_non_name = TypeStringifier::get_type_identifier(type_non); + std::string file("FILE"); + std::string file_t("FILE_T"); + bool i_care = type_esc_name.compare(file); + i_care |= type_esc_name.compare(file_t); + i_care |= type_non_name.compare(file); + i_care |= type_non_name.compare(file_t); + + type_esc_name = stringifier.stringify(type_esc); + type_non_name = stringifier.stringify(type_non); + log("checking for incompleteness %s == %s\n", type_esc_name.c_str(), type_non_name.c_str()); + + const bool equal = structuralEquality.equal(type_esc, type_non); + if (!equal) continue; + fixed_point_reached = false; // Add incomplete to escaping diff --git a/gcc/type-canonical-equality.c b/gcc/type-canonical-equality.c index f6e88f624c2..b3b6b4b224a 100644 --- a/gcc/type-canonical-equality.c +++ b/gcc/type-canonical-equality.c @@ -34,6 +34,7 @@ #include "type-structural-equality.hpp" #include "type-structural-main-variant.hpp" #include "type-canonical-equality.hpp" +#include "type-stringifier.hpp" bool TypeCanonicalEquality::_equal(const_tree l, const_tree r) @@ -46,8 +47,14 @@ TypeCanonicalEquality::_equal(const_tree l, const_tree r) const bool can_compare_canonical = canonical_l && canonical_r; if (!can_compare_canonical) return TypeStructuralEquality::_equal(l, r); - const bool different = canonical_l == canonical_r; - if (different) return false; + const bool different = canonical_l != canonical_r; + const std::string n_l = TypeStringifier::get_type_identifier(l); + const std::string n_r = TypeStringifier::get_type_identifier(r); + if (different) { + log ("canonical %s %s\n", n_l.c_str(), n_r.c_str()); + return false; + } + log ("main variant %s %s\n", n_l.c_str(), n_r.c_str()); return TypeStructuralEqualityMainVariant::_equal(l, r); } diff --git a/gcc/type-incomplete-equality.c b/gcc/type-incomplete-equality.c index ad49b5ee5a5..5f2adc5f86a 100644 --- a/gcc/type-incomplete-equality.c +++ b/gcc/type-incomplete-equality.c @@ -44,10 +44,10 @@ TypeIncompleteEquality::_equal(const_tree l, const_tree r) if (!valid_inputs) return l == r; // if any of these are incomplete, then we can only compare using identifiers... - const bool complete_l = is_complete(l); - const bool complete_r = is_complete(r); - const bool can_compare_completely = complete_l && complete_r; - if (can_compare_completely) return TypeCanonicalEquality::_equal(l, r); + const bool incomplete_l = is_incomplete(l); + const bool incomplete_r = is_incomplete(r); + const bool can_compare_incompletely = incomplete_l && incomplete_r; + if (!can_compare_incompletely) return TypeCanonicalEquality::_equal(l, r); const std::string n_l = TypeStringifier::get_type_identifier(l); const std::string n_r = TypeStringifier::get_type_identifier(r); diff --git a/gcc/type-structural-equality.c b/gcc/type-structural-equality.c index 95daf04f7aa..ca1c64c15eb 100644 --- a/gcc/type-structural-equality.c +++ b/gcc/type-structural-equality.c @@ -32,6 +32,7 @@ #include "types-inlines.h" #include "type-structural-equality.hpp" +#include "type-stringifier.hpp" bool TypeStructuralEquality::equal(const_tree l, const_tree r) @@ -45,11 +46,17 @@ TypeStructuralEquality::_equal(const_tree l, const_tree r) bool valid_inputs = l && r; if (!valid_inputs) return l == r; + const std::string n_l = TypeStringifier::get_type_identifier(l); + const std::string n_r = TypeStringifier::get_type_identifier(r); + log ("structurally %s %s\n", n_l.c_str(), n_r.c_str()); + + bool equal_codes = _equal_code(l, r); if (!equal_codes) return equal_codes; bool recurse_l = set_l.find(l) != set_l.end(); bool recurse_r = set_r.find(r) != set_r.end(); + // TODO: Is this the case every time? bool recurse = recurse_l || recurse_r; if (recurse) return recurse; -- cgit v1.2.3