From patchwork Wed Jul 15 08:16:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giuliano Procida X-Patchwork-Id: 40099 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A0FB7386F46E; Wed, 15 Jul 2020 08:16:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A0FB7386F46E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594801000; bh=flNBOg6I0EmtVob+Uqjnr0rX/woHpbL6F4wFQiE8EVk=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:Cc:From; b=gOOt47/fUTEW4G4o/eFkcIxsXeJfQ4MgpGMRA06Ko0saohIEtjnMWFM5DW1Bu7Igj YzSD4CfZSUgNBk1xOyIOBbElwsiwArDGSr5ecCohEWtKLHHFvR1gyk9lL9yOcuQd8t EwIGgBkOPvYUn+tU7oODVLsxAyMg09lWrA3o//68= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by sourceware.org (Postfix) with ESMTPS id 504993861970 for ; Wed, 15 Jul 2020 08:16:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 504993861970 Received: by mail-yb1-xb4a.google.com with SMTP id m81so1986030ybf.6 for ; Wed, 15 Jul 2020 01:16:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=flNBOg6I0EmtVob+Uqjnr0rX/woHpbL6F4wFQiE8EVk=; b=nNpstYeBjVI6j3x0LIreZgthIV/aSx4aYgPOAcLNA9XXSIiOv22WyGa5Pgp8M8rlH4 +0DFqgcMAZ/vZnO7Hycj6JG1uolwUy6yoLjnhnSxzRyauhlX3+2jyBgLDha0Vx2onEDp Qyc5Chb4HcCzcad0PBqjo+/BFaeosOnspWS5oG0YE1myDxoOAHNXwDYJhMQEJJQf5i3w Ev78YhQKdipNLjDX8NYfVIhY9HK2K1nvUfGhdjGPsj6nZRMQLmq5J13XSppVgJ9YWyup qypsmRDh3RO+D/QlC+KWSkQ8DWwlWqbTS0oB3nbJP4chKgMzORYd4G+knLX+Ct5AMx9a Tyzg== X-Gm-Message-State: AOAM532F11ph66aINGgtz1oLr/9LVAsdsj1OrxKNJ915S0kSBd9glEe8 7oFWpWkqoCypKSl9+PXmG7YFhF9RcGHyfHqXmJsQby9f4Aa+by49tYt/dWOMHwiojBHMtvta03p XnCReUxizAdw2+WKFxOVGMdfqzccdbOuCsihJTHIDSrTIo99CeNVvQ2ZNmf+DxzIWRpUORFg= X-Google-Smtp-Source: ABdhPJyKMEv0TRHMybO4B1HIVuP/a+RIgG8R5LOBFvQU22dT1vTmvrHYATef6VytMx99j8qF53C9KlDyZ04/yA== X-Received: by 2002:a25:50c2:: with SMTP id e185mr15319311ybb.204.1594800997697; Wed, 15 Jul 2020 01:16:37 -0700 (PDT) Date: Wed, 15 Jul 2020 09:16:25 +0100 Message-Id: <20200715081631.2076978-1-gprocida@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.27.0.389.gc38d7665816-goog Subject: [PATCH 1/7] Simplify type equality infinite recursion logic To: libabigail@sourceware.org X-Spam-Status: No, score=-22.7 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Giuliano Procida via Libabigail From: Giuliano Procida Reply-To: Giuliano Procida Cc: kernel-team@android.com Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" Function types don't introduce new names so cannot cause self references and so there is no need to track currently being compared function types. Typedefs do introduce new names but cannot refer directly to themselves or be forward-declared. Enums introduce new names but cannot refer to anything other than integral types. Therefore each self reference must be via a class, struct or union type. This commit removes the extra logic for function types. Note that this short-cutting could actually be done at every level of type comparison but it's unknown whether this would buy any performance advantage. * src/abg-ir.cc (struct environment::priv): Drop member fn_types_being_compared_. (mark_as_being_compared): Drop function_type overload. (unmark_as_being_compared): Likewise. (comparison_started): Likewise. (equals): In the function_type overload, inline and remove the RETURN macro, bearing in mind that its argument was almost always false and the unmark_as_being_compared method is gone. (types_are_being_compared): Remove the code relating to function types being compared. Signed-off-by: Giuliano Procida --- src/abg-ir.cc | 80 +++++++-------------------------------------------- 1 file changed, 11 insertions(+), 69 deletions(-) diff --git a/src/abg-ir.cc b/src/abg-ir.cc index 6040e1d7..5d605dd7 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -2636,7 +2636,6 @@ struct environment::priv type_base_sptr void_type_; type_base_sptr variadic_marker_type_; unordered_set classes_being_compared_; - unordered_set fn_types_being_compared_; vector extra_live_types_; interned_string_pool string_pool_; bool canonicalization_is_done_; @@ -16448,44 +16447,7 @@ struct function_type::priv priv(type_base_sptr return_type) : return_type_(return_type) {} - - /// Mark a given @ref function_type as being compared. - /// - /// @param type the @ref function_type to mark as being compared. - void - mark_as_being_compared(const function_type& type) const - { - const environment* env = type.get_environment(); - ABG_ASSERT(env); - env->priv_->fn_types_being_compared_.insert(&type); - } - - /// If a given @ref function_type was marked as being compared, this - /// function unmarks it. - /// - /// @param type the @ref function_type to mark as *NOT* being - /// compared. - void - unmark_as_being_compared(const function_type& type) const - { - const environment* env = type.get_environment(); - ABG_ASSERT(env); - env->priv_->fn_types_being_compared_.erase(&type); - } - - /// Tests if a @ref function_type is currently being compared. - /// - /// @param type the function type to take into account. - /// - /// @return true if @p type is being compared. - bool - comparison_started(const function_type& type) const - { - const environment* env = type.get_environment(); - ABG_ASSERT(env); - return env->priv_->fn_types_being_compared_.count(&type); - } -};// end struc function_type::priv +};// end struct function_type::priv /// This function is automatically invoked whenever an instance of /// this type is canonicalized. @@ -16718,22 +16680,6 @@ equals(const function_type& lhs, const function_type& rhs, change_kind* k) { -#define RETURN(value) \ - do { \ - lhs.priv_->unmark_as_being_compared(lhs); \ - lhs.priv_->unmark_as_being_compared(rhs); \ - if (value == true) \ - maybe_propagate_canonical_type(lhs, rhs); \ - return value; \ - } while(0) - - if (lhs.priv_->comparison_started(lhs) - || lhs.priv_->comparison_started(rhs)) - return true; - - lhs.priv_->mark_as_being_compared(lhs); - lhs.priv_->mark_as_being_compared(rhs); - bool result = true; if (!lhs.type_base::operator==(rhs)) @@ -16742,7 +16688,7 @@ equals(const function_type& lhs, if (k) *k |= LOCAL_TYPE_CHANGE_KIND; else - RETURN(result); + return result; } class_or_union* lhs_class = 0, *rhs_class = 0; @@ -16760,7 +16706,7 @@ equals(const function_type& lhs, if (k) *k |= LOCAL_TYPE_CHANGE_KIND; else - RETURN(result); + return result; } else if (lhs_class && (lhs_class->get_qualified_name() @@ -16770,7 +16716,7 @@ equals(const function_type& lhs, if (k) *k |= LOCAL_TYPE_CHANGE_KIND; else - RETURN(result); + return result; } // Then compare the return type; Beware if it's t's a class type @@ -16808,7 +16754,7 @@ equals(const function_type& lhs, *k |= SUBTYPE_CHANGE_KIND; } else - RETURN(result); + return result; } } else @@ -16818,7 +16764,7 @@ equals(const function_type& lhs, if (k) *k |= SUBTYPE_CHANGE_KIND; else - RETURN(result); + return result; } class_decl* lcl = 0, * rcl = 0; @@ -16851,7 +16797,7 @@ equals(const function_type& lhs, *k |= SUBTYPE_CHANGE_KIND; } else - RETURN(result); + return result; } } @@ -16862,11 +16808,12 @@ equals(const function_type& lhs, if (k) *k |= LOCAL_NON_TYPE_CHANGE_KIND; else - RETURN(result); + return result; } - RETURN(result); -#undef RETURN + if (result) + maybe_propagate_canonical_type(lhs, rhs); + return result; } /// Get the parameter of the function. @@ -19594,11 +19541,6 @@ types_are_being_compared(const type_base& lhs_type, return (l_cou->priv_->comparison_started(*l_cou) || l_cou->priv_->comparison_started(*r_cou)); - if (function_type *l_fn_type = is_function_type(l)) - if (function_type *r_fn_type = is_function_type(r)) - return (l_fn_type->priv_->comparison_started(*l_fn_type) - || l_fn_type->priv_->comparison_started(*r_fn_type)); - return false; }