From patchwork Mon Apr 26 14:27:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1470324 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=jvCTtJMw; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FTS1G1g2Cz9sSC for ; Tue, 27 Apr 2021 00:28:16 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C7E1A3838019; Mon, 26 Apr 2021 14:28:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C7E1A3838019 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1619447293; bh=Cz1nWBSgmwerQIpcgPgqEu5gA9B88j97nmBIQFJvdm8=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=jvCTtJMwjzsAIFJte6R9vL4K6fnLsWXMX+uvql3h97BgbZoggfO6IqKCGjJWKAkJR BZ1P1HbEV2IwC89FekGnhMu3i/vrliMlW9iizFuEGm+Wwe4G2lQakE56t1COs1zIuB 88VNt36LOtOSfusYLCaafdNqvPE2GoPXxHPpJLX0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 4FE90385800A for ; Mon, 26 Apr 2021 14:28:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4FE90385800A Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-239-RdY2xWMDNpSfM97yO0Wpiw-1; Mon, 26 Apr 2021 10:28:08 -0400 X-MC-Unique: RdY2xWMDNpSfM97yO0Wpiw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CB17A801FCE for ; Mon, 26 Apr 2021 14:28:07 +0000 (UTC) Received: from abulafia.quesejoda.com (ovpn-112-243.ams2.redhat.com [10.36.112.243]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5C5C860917; Mon, 26 Apr 2021 14:28:07 +0000 (UTC) Received: from abulafia.quesejoda.com (localhost [127.0.0.1]) by abulafia.quesejoda.com (8.16.1/8.15.2) with ESMTPS id 13QERuN51658264 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 26 Apr 2021 16:27:57 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.16.1/8.16.1/Submit) id 13QERo7Y1658263; Mon, 26 Apr 2021 16:27:50 +0200 To: Andrew MacLeod , GCC patches Subject: [PATCH] Add GTY support for irange. Date: Mon, 26 Apr 2021 16:27:43 +0200 Message-Id: <20210426142743.1658216-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Aldy Hernandez via Gcc-patches From: Aldy Hernandez Reply-To: Aldy Hernandez Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Right now we have GTY support for static storage iranges (int_range<>). However, there's no reason why the base class can't be used with GC, other than it was an oversight. For that matter, the base class has a pointer to the sub-range storage, so we can use the same implementation for both. This patch does so. I have also removed the DEFINE_INT_RANGE_GC_STUBS stuff, and have documented why we need a separate gt_pch_nx (int_range<1> *&) version. This has to do with hash-traits.h, which ipa-prop.c is using to store a value_range. The header file hash-traits.h is defining an extern of gt_pch_nx (int_range<1> *&) etc, instead of calling the more generic (int_range<1> *) which is already available. It seems suspect that has-traits.h has their own externs for GC functions, and if someone has a better solution, I'd be glad to hear it. OK? gcc/ChangeLog: * value-range.cc (DEFINE_INT_RANGE_GC_STUBS): Remove. (gt_pch_nx (int_range<1> *&)): New. (gt_ggc_mx (int_range<1> *&)): New. * value-range.h (class irange): Add GTY support for the base class. --- gcc/value-range.cc | 35 +++++++++++--------------- gcc/value-range.h | 63 ++++++++++++++++++++++++++++++---------------- 2 files changed, 56 insertions(+), 42 deletions(-) diff --git a/gcc/value-range.cc b/gcc/value-range.cc index 6b0dfb439ba..f987386c91e 100644 --- a/gcc/value-range.cc +++ b/gcc/value-range.cc @@ -2050,26 +2050,20 @@ vrp_operand_equal_p (const_tree val1, const_tree val2) return true; } -#define DEFINE_INT_RANGE_GC_STUBS(N) \ - void \ - gt_pch_nx (int_range *&x) \ - { \ - for (unsigned i = 0; i < N; ++i) \ - { \ - gt_pch_nx (x->m_ranges[i * 2]); \ - gt_pch_nx (x->m_ranges[i * 2 + 1]); \ - } \ - } \ - \ - void \ - gt_ggc_mx (int_range *&x) \ - { \ - for (unsigned i = 0; i < N; ++i) \ - { \ - gt_ggc_mx (x->m_ranges[i * 2]); \ - gt_ggc_mx (x->m_ranges[i * 2 + 1]); \ - } \ - } +// ?? These stubs are for ipa-prop.c which use a value_range in a +// hash_traits. hash-traits.h defines an extern of gt_ggc_mx (T &) +// instead of picking up the gt_ggc_mx (T *) version. +void +gt_pch_nx (int_range<1> *&x) +{ + return gt_pch_nx ((irange *) x); +} + +void +gt_ggc_mx (int_range<1> *&x) +{ + return gt_ggc_mx ((irange *) x); +} #define DEFINE_INT_RANGE_INSTANCE(N) \ template int_range::int_range(tree, tree, value_range_kind); \ @@ -2086,7 +2080,6 @@ DEFINE_INT_RANGE_INSTANCE(1) DEFINE_INT_RANGE_INSTANCE(2) DEFINE_INT_RANGE_INSTANCE(3) DEFINE_INT_RANGE_INSTANCE(255) -DEFINE_INT_RANGE_GC_STUBS(1) #if CHECKING_P #include "selftest.h" diff --git a/gcc/value-range.h b/gcc/value-range.h index d2c3ce958d3..b2075935a23 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h @@ -41,7 +41,7 @@ enum value_range_kind // // This is the base class without any storage. -class irange +class GTY((user)) irange { friend class irange_allocator; public: @@ -126,6 +126,10 @@ protected: void copy_legacy_to_multi_range (const irange &); private: + friend void gt_ggc_mx (irange *); + friend void gt_pch_nx (irange *); + friend void gt_pch_nx (irange *, gt_pointer_operator, void *); + void irange_set_1bit_anti_range (tree, tree); bool irange_varying_p () const; @@ -155,11 +159,10 @@ private: template friend void gt_pch_nx (int_range *); template friend void gt_pch_nx (int_range *, gt_pointer_operator, void *); - // ?? hash-traits.h has its own extern for these, which is causing - // them to never be picked up by the templates. For now, define - // elsewhere. - //template friend void gt_ggc_mx (int_range *&); - //template friend void gt_pch_nx (int_range *&); + + // ?? These stubs are for ipa-prop.c which use a value_range in a + // hash_traits. hash-traits.h defines an extern of gt_ggc_mx (T &) + // instead of picking up the gt_ggc_mx (T *) version. friend void gt_ggc_mx (int_range<1> *&); friend void gt_pch_nx (int_range<1> *&); @@ -335,39 +338,57 @@ range_includes_zero_p (const irange *vr) return vr->may_contain_p (build_zero_cst (vr->type ())); } -template inline void -gt_ggc_mx (int_range *x) +gt_ggc_mx (irange *x) { - for (unsigned i = 0; i < N; ++i) + for (unsigned i = 0; i < x->m_num_ranges; ++i) { - gt_ggc_mx (x->m_ranges[i * 2]); - gt_ggc_mx (x->m_ranges[i * 2 + 1]); + gt_ggc_mx (x->m_base[i * 2]); + gt_ggc_mx (x->m_base[i * 2 + 1]); } } -template inline void -gt_pch_nx (int_range *x) +gt_pch_nx (irange *x) { - for (unsigned i = 0; i < N; ++i) + for (unsigned i = 0; i < x->m_num_ranges; ++i) { - gt_pch_nx (x->m_ranges[i * 2]); - gt_pch_nx (x->m_ranges[i * 2 + 1]); + gt_pch_nx (x->m_base[i * 2]); + gt_pch_nx (x->m_base[i * 2 + 1]); } } -template inline void -gt_pch_nx (int_range *x, gt_pointer_operator op, void *cookie) +gt_pch_nx (irange *x, gt_pointer_operator op, void *cookie) { - for (unsigned i = 0; i < N; ++i) + for (unsigned i = 0; i < x->m_num_ranges; ++i) { - op (&x->m_ranges[i * 2], cookie); - op (&x->m_ranges[i * 2 + 1], cookie); + op (&x->m_base[i * 2], cookie); + op (&x->m_base[i * 2 + 1], cookie); } } +template +inline void +gt_ggc_mx (int_range *x) +{ + gt_ggc_mx ((irange *) x); +} + +template +inline void +gt_pch_nx (int_range *x) +{ + gt_pch_nx ((irange *) x); +} + +template +inline void +gt_pch_nx (int_range *x, gt_pointer_operator op, void *cookie) +{ + gt_pch_nx ((irange *) x, op, cookie); +} + // Constructors for irange inline