From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 1E20D385843D for ; Tue, 9 Nov 2021 14:41:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1E20D385843D Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-67-K2h2t99pOuuRUHA7ta89tg-1; Tue, 09 Nov 2021 09:41:16 -0500 X-MC-Unique: K2h2t99pOuuRUHA7ta89tg-1 Received: by mail-qv1-f71.google.com with SMTP id jn10-20020ad45dea000000b003bd74c93df4so17581592qvb.15 for ; Tue, 09 Nov 2021 06:41:16 -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=0UemIYfO8QimvT6Gygp9iCEuEZxQ4hdBxPufe/rJIas=; b=58BNYfLENBomZnI0pEzOtGZpmQckxjRWPr7YSrKDV6OOP+IluLGnbX+Kpk/N5ToX/N TN3k2N1xjWw7+POzo14qmAvOJwuzdqcnvM6Oo0qvOtThBqH92oFcZ1L5kUSebK9y2aAx fXzpFEj4ybCrjZDbfl1VcOKII+Y9qKrsLxdZEql+9AZlzC+/rsJ2cyCeBKYOMeSQ2OYj CttQID3DOOJdDyR9uLeO6LMgAj7e5NFvBtlfcOnEwJgxtrhavRPzxZAdbHPxezRxsgrk yT23PpiUOgvYMM1LnNQbWaUUhzpQuGKPEcdGNvO4+OI3qZvUIpf+sc1yhuo3zpRryD40 pYzQ== X-Gm-Message-State: AOAM5308ddzTErzmfgY9gMx2gU2PyZP9BE8Hw5FiM7B9eQUsxWEiOEeU fGB/vNp4/v24efADfLiJ5SpIPQdOU7Kai+f8BIX/XN0w8InzEDiFcRgP837vNv3OvK5/G0dcHf4 PjFA5FE5ug4quh5DfBw== X-Received: by 2002:a05:620a:f07:: with SMTP id v7mr6148761qkl.289.1636468875754; Tue, 09 Nov 2021 06:41:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJysC3WCzj96DhaXipyRXzVyj9Jxo972aObe5K6Z3dtV0tcBzC5nRYNAg1oKiVm20d91E2jc7Q== X-Received: by 2002:a05:620a:f07:: with SMTP id v7mr6148746qkl.289.1636468875555; Tue, 09 Nov 2021 06:41:15 -0800 (PST) Received: from [192.168.0.102] ([104.219.122.240]) by smtp.gmail.com with ESMTPSA id bq30sm11711446qkb.6.2021.11.09.06.41.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Nov 2021 06:41:10 -0800 (PST) Subject: Re: [PATCH] pch: Add support for PCH for relocatable executables To: Jakub Jelinek , Richard Biener , Aldy Hernandez Cc: gcc-patches@gcc.gnu.org, John David Anglin , Iain Sandoe References: <20211105095411.GG304296@tucnak> <20211105152515.GK304296@tucnak> <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> From: Andrew MacLeod Message-ID: Date: Tue, 9 Nov 2021 09:41: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: <20211109122910.GR2710@tucnak> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="------------3E10E375C21937D3987E18FD" Content-Language: en-CA X-Spam-Status: No, score=-14.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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-List-Received-Date: Tue, 09 Nov 2021 14:41:20 -0000 This is a multi-part message in MIME format. --------------3E10E375C21937D3987E18FD Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 11/9/21 7:29 AM, Jakub Jelinek wrote: > On Tue, Nov 09, 2021 at 01:03:38PM +0100, Richard Biener wrote: >>> Apparently the range_of_expr can handle some tree cases through >>> range_query::get_tree_range, like INTEGER_CSTs, ADDR_EXPRs, >>> and some binary and unary ops. >> But that shouldn't need a range query object ... this was all >> available pre-ranger and just got stuffed there for no good reason? resolving the binary ops requires calls back into range_of_expr to resolve operands.  It could be split out if needed/desired. > That is for Andrew/Aldy to answer. > All I can say is that get_tree_range is a non-static member function > of range_query and therefore it needs non-NULL query object. > > But I must say I wonder if all this pain is worth it, if it wouldn't > be easier to keep cfun->x_range_query NULL most of the time and use > ATTRIBUTE_RETURNS_NONNULL inline range_query * > get_range_query (const struct function *fun) > { > return fun->x_range_query ? fun->x_range_query : &global_ranges; > } > > (of course, the function then would need to be in some header > where global_ranges is declared). > > Jakub > Yeah, Im not particular about how we do this...  I think thats perfectly reasonable.   Would something like the following solve this issue? It creates a global-range class pointer, initializes it to point to the global query, and we can simply hide its existence and refer to it directly from function.h if you thinks thats reasonable and will work OK for this.   Then we dont have any inclusion issues. Let me know and I'll run it thru the gauntlet. Andrew --------------3E10E375C21937D3987E18FD Content-Type: text/x-patch; charset=UTF-8; name="query.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="query.diff" commit 17a5b03c95549b5488bc8dd2af4f6e2cc9ddf098 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 alwasy 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): Set x_range_query to NULL. * function.h (get_range_query): Return context query or global. * gimple-range.cc (enable_ranger): Check current query is NULL. (disable_ranger): Clear function current query field. * value_query.cc (global_range_query_ptr): New. * value-query.h (global_ranges): Remove. diff --git a/gcc/function.c b/gcc/function.c index af3d57b32a3..8768c5fcf22 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -4874,7 +4874,7 @@ allocate_struct_function (tree fndecl, bool abstract_p) cfun->debug_nonbind_markers = lang_hooks.emits_begin_stmt && MAY_HAVE_DEBUG_MARKER_STMTS; - cfun->x_range_query = &global_ranges; + cfun->x_range_query = NULL; } /* 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..3c1b2aa2b90 100644 --- a/gcc/function.h +++ b/gcc/function.h @@ -725,7 +725,9 @@ extern void used_types_insert (tree); ATTRIBUTE_RETURNS_NONNULL inline range_query * get_range_query (const struct function *fun) { - return fun->x_range_query; + // From value-query.h + extern range_query *global_range_query_ptr; + return fun->x_range_query ? fun->x_range_query : global_range_query_ptr; } extern range_query *get_global_range_query (); 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..8d1b27d9bfb 100644 --- a/gcc/value-query.cc +++ b/gcc/value-query.cc @@ -433,7 +433,9 @@ gimple_range_global (tree name) // ---------------------------------------------- // global_range_query implementation. +// This is utlized by function.h get_range_query() only. global_range_query global_ranges; +range_query *global_range_query_ptr = &global_ranges; // Like get_range_query, but for accessing global ranges. diff --git a/gcc/value-query.h b/gcc/value-query.h index 5161d23714b..f56abc4777c 100644 --- a/gcc/value-query.h +++ b/gcc/value-query.h @@ -126,7 +126,6 @@ public: bool range_of_expr (irange &r, tree expr, gimple * = NULL) OVERRIDE; }; -extern global_range_query global_ranges; extern value_range gimple_range_global (tree name); extern bool update_global_range (irange &r, tree name); --------------3E10E375C21937D3987E18FD--