From patchwork Tue Nov 9 18:29:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1553098 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=qsHo1adK; dkim-atps=neutral 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+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4Hpc2r0kynz9s0r for ; Wed, 10 Nov 2021 05:29:38 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5FEF83858022 for ; Tue, 9 Nov 2021 18:29:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5FEF83858022 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1636482576; bh=Lm0jAaXts8gocldixhRxJXXczuVnHXSa28MweXTRQt8=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=qsHo1adKWfaXGDlq8aORV/7gwSjWHdvbu5uo2nnXQ0kp8mSD5GfQ/Ujro3IHfpenG d15bdmbfanbyZPVE0h3o19p0KwbRCMv+1SaPZ836U0O+xooHDkkAS57K9L6WXDRdnC wHUOrClbOZ4MWcnrfKuSuftNQ6FOXEz2zlUdeEtk= 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 0BEA43858404 for ; Tue, 9 Nov 2021 18:29:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0BEA43858404 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-54-304fyQLqM5O6R6k0lQ5Bgw-1; Tue, 09 Nov 2021 13:29:11 -0500 X-MC-Unique: 304fyQLqM5O6R6k0lQ5Bgw-1 Received: by mail-qk1-f199.google.com with SMTP id v14-20020a05620a0f0e00b0043355ed67d1so7077qkl.7 for ; Tue, 09 Nov 2021 10:29:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=Lm0jAaXts8gocldixhRxJXXczuVnHXSa28MweXTRQt8=; b=b86sAOEjwcUw3/2lMzNGbYs3zi2SSFCSU81/A3hPl5jyQQxU3FLwpQlBdyCQw6oNW8 Sg5yn1R5axodRSkfqyRHllkPuNniwNT2R2NzgLuvK9TNNdu8CQuHqaxC/kdUFBLfYTIT XkqIAAYQYd0AW1GuLtgNqYwK6K0DPnq4LKnv/XzLNslouCppU34EX6epHeIT3ydUFgOF xHhHan9k8IrE2B5K+AnIH2t5GWuguu2EdXn9D6U0rGcR55dO6UEozVrcdABon3lnOv8Z 916DNr5ue2WVYIzTHAowhONYR4BpPQakzp6yHO9Fb1KUi+kq4Lwih7XR84LfgJtQUkHl ZWhQ== X-Gm-Message-State: AOAM533kjW8iCfZEh9HilfdyiC7ye0Y3vDdbzdoRu8EYObcRKm/tZmHy SIbxLqWXWOIH9LPRBYTcLOqf52iN1tm+Ulep58CrQQjgXVwyif6l5IbCtoDiys4HSScKlryq8Ry fpq+lObQ/xT95t5jbkQ== X-Received: by 2002:a05:6214:301b:: with SMTP id ke27mr9275305qvb.43.1636482550970; Tue, 09 Nov 2021 10:29:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJwrqS7FkBNzJNAsNy7LgIHFkGR/TMJJOvwUnpD2BozFF9xgtrHrRpv5bZ/BqavfQIftcT3A5w== X-Received: by 2002:a05:6214:301b:: with SMTP id ke27mr9275281qvb.43.1636482550750; Tue, 09 Nov 2021 10:29:10 -0800 (PST) Received: from [192.168.0.102] ([104.219.122.240]) by smtp.gmail.com with ESMTPSA id h3sm12087873qkn.73.2021.11.09.10.29.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Nov 2021 10:29:09 -0800 (PST) Subject: [COMMITTED] Keep x_range_query NULL for global ranges. To: Jakub Jelinek References: <20211108114604.GI2710@tucnak> <20211108194807.GJ2710@tucnak> <6n83494-274o-4r5r-552n-8195p08748o7@fhfr.qr> <20211109094445.GN2710@tucnak> <20211109113208.GP2710@tucnak> <56823174-1nn6-5613-q640-p01pqn63q24q@fhfr.qr> <20211109122910.GR2710@tucnak> <20211109145847.GS2710@tucnak> <60f47e3b-a522-34d7-ea3e-5ed77b5c8fd8@redhat.com> <20211109152829.GV2710@tucnak> Message-ID: <2cd06d10-767c-fc3c-8225-4736a7a3dd52@redhat.com> Date: Tue, 9 Nov 2021 13:29:08 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <20211109152829.GV2710@tucnak> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-CA X-Spam-Status: No, score=-12.7 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_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Andrew MacLeod via Gcc-patches From: Andrew MacLeod Reply-To: Andrew MacLeod Cc: Iain Sandoe , gcc-patches@gcc.gnu.org, Richard Biener , John David Anglin Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" On 11/9/21 10:28 AM, Jakub Jelinek wrote: > On Tue, Nov 09, 2021 at 10:23:19AM -0500, Andrew MacLeod wrote: >> yeah, that doesnt work because range_query is a pure virtual. However, there >> also does not seem to be any reason why we need to jump thru hoops since >> get_range_query() doesn't need to be in function.h..   If I relocate it to >> value-query.h like so it seems to work quite well...   How about this? > Ah, ok. Indeed while one can extern global_range_query global_ranges; > with incomplete global_range_query type, inheritance will not be known. > >> --- a/gcc/value-query.h >> +++ b/gcc/value-query.h >> @@ -127,6 +127,17 @@ public: >> }; >> >> extern global_range_query global_ranges; >> +inline range_query *get_global_range_query () { return &global_ranges; } > Formatting, there should be empty line after global_ranges, and > inline range_query * > get_global_range_entry () > { > return &global_ranges; > } > >> + >> +/* Returns the currently active range access class. When there is no active >> + range class, global ranges are used. Never returns null. */ >> + >> +ATTRIBUTE_RETURNS_NONNULL inline range_query * >> +get_range_query (const struct function *fun) >> +{ >> + return fun->x_range_query ? fun->x_range_query : &global_ranges; >> +} >> + >> extern value_range gimple_range_global (tree name); >> extern bool update_global_range (irange &r, tree name); >> > Ok for trunk with the above nits fixed if it passes bootstrap/regtest, > thanks. > > Jakub > Bootstraps on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew commit 56af35de3d11960100996b96034dc9ccd7c75ca3 Author: Andrew MacLeod Date: Tue Nov 9 09:29:23 2021 -0500 Keep x_range_query NULL for global ranges. Instead of x_range_query always pointing to an object, have it default to NULL and return a pointer to the global query in that case. * function.c (allocate_struct_function): Don't set x_range_query. * function.h (get_range_query): Move to value-query.h. * gimple-range.cc (enable_ranger): Check that query is currently NULL. (disable_ranger): Clear function current query field. * value-query.cc (get_global_range_query): Relocate to: * value-query.h (get_global_range_query): Here and inline. (get_range_query): Relocate here from function.h. diff --git a/gcc/function.c b/gcc/function.c index af3d57b32a3..61b3bd036b8 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -4873,8 +4873,6 @@ allocate_struct_function (tree fndecl, bool abstract_p) binding annotations among them. */ cfun->debug_nonbind_markers = lang_hooks.emits_begin_stmt && MAY_HAVE_DEBUG_MARKER_STMTS; - - cfun->x_range_query = &global_ranges; } /* This is like allocate_struct_function, but pushes a new cfun for FNDECL diff --git a/gcc/function.h b/gcc/function.h index 36003e7576a..899430833ce 100644 --- a/gcc/function.h +++ b/gcc/function.h @@ -719,15 +719,4 @@ extern const char *current_function_name (void); extern void used_types_insert (tree); -/* Returns the currently active range access class. When there is no active - range class, global ranges are used. Never returns null. */ - -ATTRIBUTE_RETURNS_NONNULL inline range_query * -get_range_query (const struct function *fun) -{ - return fun->x_range_query; -} - -extern range_query *get_global_range_query (); - #endif /* GCC_FUNCTION_H */ diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc index 87dba6e81d8..a2b68b2bc80 100644 --- a/gcc/gimple-range.cc +++ b/gcc/gimple-range.cc @@ -467,6 +467,7 @@ enable_ranger (struct function *fun) { gimple_ranger *r; + gcc_checking_assert (!fun->x_range_query); r = new gimple_ranger; fun->x_range_query = r; @@ -479,7 +480,7 @@ enable_ranger (struct function *fun) void disable_ranger (struct function *fun) { + gcc_checking_assert (fun->x_range_query); delete fun->x_range_query; - - fun->x_range_query = &global_ranges; + fun->x_range_query = NULL; } diff --git a/gcc/value-query.cc b/gcc/value-query.cc index 17ebd86ce5f..b7d9e6653b1 100644 --- a/gcc/value-query.cc +++ b/gcc/value-query.cc @@ -435,14 +435,6 @@ gimple_range_global (tree name) global_range_query global_ranges; -// Like get_range_query, but for accessing global ranges. - -range_query * -get_global_range_query () -{ - return &global_ranges; -} - bool global_range_query::range_of_expr (irange &r, tree expr, gimple *stmt) { diff --git a/gcc/value-query.h b/gcc/value-query.h index 5161d23714b..38e23bb357b 100644 --- a/gcc/value-query.h +++ b/gcc/value-query.h @@ -127,6 +127,22 @@ public: }; extern global_range_query global_ranges; + +inline range_query * +get_global_range_query () +{ + return &global_ranges; +} + +/* Returns the currently active range access class. When there is no active + range class, global ranges are used. Never returns null. */ + +ATTRIBUTE_RETURNS_NONNULL inline range_query * +get_range_query (const struct function *fun) +{ + return fun->x_range_query ? fun->x_range_query : &global_ranges; +} + extern value_range gimple_range_global (tree name); extern bool update_global_range (irange &r, tree name);