From patchwork Thu May 23 20:53:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1938588 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=HdFJ64lP; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VlgRW1Yfcz20KL for ; Fri, 24 May 2024 06:55:19 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 516F93846459 for ; Thu, 23 May 2024 20:55:17 +0000 (GMT) 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 [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 6A7AA3849783 for ; Thu, 23 May 2024 20:53:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6A7AA3849783 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6A7AA3849783 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716497597; cv=none; b=p5joabIvoUjM9OmVeWYQa/NZHdzUyfbzz/kils8WjrISZBnu12TdyhP+2ktKLSFShevQnefkvh8q1TLtwg/AR3RsTVhQigiy86TctfUi0vyrj41cG9Yw4Dgl5N+a1nDR+IvQD9OMuk8+mWoltJzcBtlSsZ3+J8oicsw8ZN7zcB0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716497597; c=relaxed/simple; bh=0n6cI3n1VwJhxG5XAhMKBrugtKd/FsXD06OE5qMGeMU=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=mgPdxzcA4rxHjEtR0+b+41ODSDRPlhA8mLgiD+D4fcepvP+P1dqUhFaxy5N9HPoC9BP/2g/ea0iSoZwtmT6vaj7nM4CwXz3HL32O8yWq8Ty3SrFAJsaV9dviVdlvaR/ipW5tXP33RkCKdn1b3EdqwFeqrqo8hMuxzWnDSyvNFYY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716497595; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=25iQwKLg+aQ9orJqzFRZCEBsqZL+wR1Sgnk31K0KkC8=; b=HdFJ64lPlkNglAJzFw0uAfQq6KKHhU7fsDeQvI0tiwMpB0OHqSDiqGUasAs+8kCTdNazgP KwybHGqcbZCF254iFGb01V1DRU4t8P8W2w1xJVrvjrddliSJwf7FZHWQAgtHhOj++F4OiO AW/bf01p+93l2YXs/nwCqWkVS4ATkiI= Received: from mail-oi1-f197.google.com (mail-oi1-f197.google.com [209.85.167.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-592-eoQ83FYeP0qa2Bcv_FIrdg-1; Thu, 23 May 2024 16:53:13 -0400 X-MC-Unique: eoQ83FYeP0qa2Bcv_FIrdg-1 Received: by mail-oi1-f197.google.com with SMTP id 5614622812f47-3c9a403d9f4so1518803b6e.1 for ; Thu, 23 May 2024 13:53:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716497592; x=1717102392; h=subject:from:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Q/b+wv/LfUkRbFX3zJuWmr730zI3qcEqcjHzqiiYAcU=; b=K/LwnClIVWwYRwjFabERZZ9gmeIHTjBY6EHLoN3b4IzV8eIFP0mpKYLGz0yoAm+4Qw s5iBUOAesy5+RBmyaWFoe8ZotgPPO8ardCZl0c7h1PtiuzkVFHzSihbcsJmx/K+vBk1I x4BFmODqnU/Mq8cuEPfpgYh6kw2VFhBPyePaZ4j2jecsbj6dG/O0NNIEgtUENCZDu3xO gN/Qk7CS5MDP3UK5nG97m0R8cc1mcPlnnxJVVhQqAsTXXtl47GhgzmKzyDOR5SQv0p8Q O5gqkpg18SEyphUUU8B87PoWDww4vb/54kcx+UtQQCL6nIEAXsin/zctFKssD0dtC/w+ YcMg== X-Gm-Message-State: AOJu0Yy57e1vfPUtonI4uZIAjydU11HNF77YMQwQEIa2GyjGUCW3o2Tv vceXgTtiGI46Ka2kLuOJgmS35xzvYyOKA2OvIz9a0+cNFit5mbfmeBo8ougvCMk3P9Y04mSJoI2 WBH6CwenItO30JGuBuIXBRpsLNHATZtUmaqeJm3j3eIwom7y3+6ukhoNjnckEYcE+qaT7GGXMuR i0yfE7P0uYHHwYpBYcY1yzXXeYz25MQo+acOj8dQ4= X-Received: by 2002:a05:6808:1597:b0:3cf:e9d5:7078 with SMTP id 5614622812f47-3d1a5f247afmr714845b6e.33.1716497592485; Thu, 23 May 2024 13:53:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG7SoF6y7x02j0jI+stg9WWAxzf+Eih4XdwkWAaNmgqnn+1/DZD+Lm6EZ+rjsl8KQoKJE75EA== X-Received: by 2002:a05:6808:1597:b0:3cf:e9d5:7078 with SMTP id 5614622812f47-3d1a5f247afmr714812b6e.33.1716497591884; Thu, 23 May 2024 13:53:11 -0700 (PDT) Received: from [192.168.0.174] ([104.219.121.64]) by smtp.gmail.com with ESMTPSA id af79cd13be357-794abd48978sm202985a.132.2024.05.23.13.53.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 May 2024 13:53:11 -0700 (PDT) Message-ID: <593a9ac1-ecdc-42b9-ac63-88e31dc1ff2a@redhat.com> Date: Thu, 23 May 2024 16:53:10 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: gcc-patches Cc: "hernandez, aldy" From: Andrew MacLeod Subject: [COMMITTED 04/12] - Allow components to be shared among range-queries. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-11.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_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_WEB, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Ranger and ranger's cache are both range_query based, but they need to share some common components. The path ranger also needs to share the GORI component.   Up until now, they have simple copied pointers to share, but this patch provides a protected API to allow them to share without knowing what all components are involved. Bootstrapped on x86_64-pc-linux-gnu with no regressions.  Pushed. From ef99d19569a1c5fafa5784c2c2f7855b6e62ffd8 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Fri, 17 May 2024 10:44:27 -0400 Subject: [PATCH 04/12] Allow components to be shared among range-queries. Ranger and the ranger cache need to share components, this provides a blessed way to do so. * gimple-range.cc (gimple_ranger::gimple_ranger): Share the components from ranger_cache. (gimple_ranger::~gimple_ranger): Don't clear pointer. * value-query.cc (range_query::share_query): New. (range_query::range_query): Clear shared component flag. (range_query::~range_query): Don't free shared component copies. * value-query.h (share_query): New prototype. (m_shared_copy_p): New member. --- gcc/gimple-range.cc | 4 +--- gcc/value-query.cc | 11 +++++++++++ gcc/value-query.h | 5 +++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc index 9664300a80b..4326976fc2a 100644 --- a/gcc/gimple-range.cc +++ b/gcc/gimple-range.cc @@ -44,7 +44,7 @@ gimple_ranger::gimple_ranger (bool use_imm_uses) : current_bb (NULL) { // Share the oracle from the cache. - m_relation = &m_cache.relation (); + share_query (m_cache); if (dump_file && (param_ranger_debug & RANGER_DEBUG_TRACE)) tracer.enable_trace (); m_stmt_list.create (0); @@ -67,8 +67,6 @@ gimple_ranger::gimple_ranger (bool use_imm_uses) : gimple_ranger::~gimple_ranger () { - // Restore the original oracle. - m_relation = NULL; m_stmt_list.release (); } diff --git a/gcc/value-query.cc b/gcc/value-query.cc index db64a95a284..adcc59cadbf 100644 --- a/gcc/value-query.cc +++ b/gcc/value-query.cc @@ -211,13 +211,24 @@ range_query::destroy_relation_oracle () } } +void +range_query::share_query (range_query &q) +{ + m_relation = q.m_relation; + m_shared_copy_p = true; +} + range_query::range_query () { m_relation = &default_relation_oracle; + m_shared_copy_p = false; } range_query::~range_query () { + // Do not destroy anything if this is a shared copy. + if (m_shared_copy_p) + return; destroy_relation_oracle (); } diff --git a/gcc/value-query.h b/gcc/value-query.h index a8688a099fa..a5735902af0 100644 --- a/gcc/value-query.h +++ b/gcc/value-query.h @@ -88,6 +88,11 @@ protected: basic_block bbentry, basic_block bbexit); bool get_arith_expr_range (vrange &r, tree expr, gimple *stmt); relation_oracle *m_relation; + // When multiple related range queries wish to share oracles. + // This is an internal interface + void share_query (range_query &q); + bool m_shared_copy_p; + }; // Global ranges for SSA names using SSA_NAME_RANGE_INFO. -- 2.41.0