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.133.124]) by sourceware.org (Postfix) with ESMTPS id 4A1133858D32 for ; Fri, 10 Mar 2023 18:36:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4A1133858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678473386; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=brgUEdrlXXLNmAml/4C8KtSLNPmP6yM5pqKhnhumY4g=; b=DLDFtFzliAz3OSLqMSMVHnJS7uvgeEZG1gbM5FZLyGDi/GwODPstscU9yKYXDrWRZoEmao 7gORZ65ZOmmG4PiUgYgP9GC+bUWFB5uQG6K+gTHbrTWNtT3IG3krxnv99WbjiKEj+AoBky wDG1OlPxXNqAMKlyxMMH0rdRcU4mOBY= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-282-d2-tLzfEPk2nPemg1wTrpw-1; Fri, 10 Mar 2023 13:36:24 -0500 X-MC-Unique: d2-tLzfEPk2nPemg1wTrpw-1 Received: by mail-qt1-f198.google.com with SMTP id g11-20020ac8774b000000b003bfa92f56cbso3357346qtu.3 for ; Fri, 10 Mar 2023 10:36:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678473383; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=brgUEdrlXXLNmAml/4C8KtSLNPmP6yM5pqKhnhumY4g=; b=ePfo9yEtPSpiMVYKgdr+T11MasynhYHUlUtsEQM2VuItOAe72tiOgNc5tfsWnFp4sd bHrqrk05cDz/1GuhZg7GkhR9SROCqLmSwfpC3QQWxi6lBJbYICsT8PMjYNNHrJvkhhwT io6TuDLKYx0XzgsbcwMoK7s5twX8NZLz+UbdnM1Zl6tzpQxbJNZK03FCgwjd4lDeCNlS WBo1xL7nZE07Ic/PF5r4VEATs12tFmYjtLbjTMXjA6GZCQiCq93T8/EaKJZn+0f00gIc yrVWOrrETMCtAOOT9IBYziF5ofvJ//mimiF62d9rLEIOsXJNq/tGmLlKumLF3GlZsoHy iLVw== X-Gm-Message-State: AO0yUKUMZxu5kbmtUcqkFC8NV2mvF2HwIc6OYbjWy1pOZkRN8TBJIUnS 8DyNpO9EplGixi9J9ZNKXxh6iqrGQp6FaUrGlnhBFjTS7yBmYvvXx0i5JsMMVVF9A+g3y5CqFiI Pw2oBhsJ4edZccVbmUaMfFhOUpg== X-Received: by 2002:a05:6214:29eb:b0:56e:9f05:6265 with SMTP id jv11-20020a05621429eb00b0056e9f056265mr42769235qvb.39.1678473383391; Fri, 10 Mar 2023 10:36:23 -0800 (PST) X-Google-Smtp-Source: AK7set+4ck5ozTuiC9ak/YYpg2vh8MwkSpmGSpi4DS1NtSErbTvCd8bNycb+Mg8h1R4TcuZWsDKizA== X-Received: by 2002:a05:6214:29eb:b0:56e:9f05:6265 with SMTP id jv11-20020a05621429eb00b0056e9f056265mr42769212qvb.39.1678473383113; Fri, 10 Mar 2023 10:36:23 -0800 (PST) Received: from [192.168.1.108] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id t132-20020a37aa8a000000b00742709bc5edsm299114qke.5.2023.03.10.10.36.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 10 Mar 2023 10:36:22 -0800 (PST) Message-ID: <5fd1c3c7-48ac-ee67-82f3-6ca0e2d7241f@redhat.com> Date: Fri, 10 Mar 2023 13:36:20 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH] c++: Don't clear TREE_READONLY for -fmerge-all-constants for non-aggregates [PR107558] To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org References: From: Jason Merrill In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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 List-Id: On 11/24/22 04:13, Jakub Jelinek wrote: > Hi! > > The following testcase ICEs, because OpenMP lowering for shared clause > on l variable with REFERENCE_TYPE creates POINTER_TYPE to REFERENCE_TYPE. > The reason is that the automatic variable has non-trivial construction > (reference to a lambda) and -fmerge-all-constants is on and so TREE_READONLY > isn't set - omp-low will handle automatic TREE_READONLY vars in shared > specially and only copy to the construct and not back, while !TREE_READONLY > are assumed to be changeable. > The PR91529 change rationale was that the gimplification can change > some non-addressable automatic variables to TREE_STATIC with > -fmerge-all-constants and therefore TREE_READONLY on them is undesirable. > But, the gimplifier does that only for aggregate variables: > switch (TREE_CODE (type)) > { > case RECORD_TYPE: > case UNION_TYPE: > case QUAL_UNION_TYPE: > case ARRAY_TYPE: > and not for anything else. So, I think clearing TREE_READONLY for > automatic integral or reference or pointer etc. vars for > -fmerge-all-constants only is unnecessary. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? OK. > 2022-11-24 Jakub Jelinek > > PR c++/107558 > * decl.cc (cp_finish_decl): Don't clear TREE_READONLY on > automatic non-aggregate variables just because of > -fmerge-all-constants. > > * g++.dg/gomp/pr107558.C: New test. > > --- gcc/cp/decl.cc.jj 2022-11-19 09:21:14.662439877 +0100 > +++ gcc/cp/decl.cc 2022-11-23 13:12:31.866553152 +0100 > @@ -8679,8 +8679,10 @@ cp_finish_decl (tree decl, tree init, bo > > if (var_definition_p > /* With -fmerge-all-constants, gimplify_init_constructor > - might add TREE_STATIC to the variable. */ > - && (TREE_STATIC (decl) || flag_merge_constants >= 2)) > + might add TREE_STATIC to aggregate variables. */ > + && (TREE_STATIC (decl) > + || (flag_merge_constants >= 2 > + && AGGREGATE_TYPE_P (type)))) > { > /* If a TREE_READONLY variable needs initialization > at runtime, it is no longer readonly and we need to > --- gcc/testsuite/g++.dg/gomp/pr107558.C.jj 2022-11-23 13:13:27.260736525 +0100 > +++ gcc/testsuite/g++.dg/gomp/pr107558.C 2022-11-23 13:15:22.271041005 +0100 > @@ -0,0 +1,14 @@ > +// PR c++/107558 > +// { dg-do compile { target c++11 } } > +// { dg-additional-options "-fmerge-all-constants" } > +// { dg-additional-options "-flto" { target lto } } > + > +int a = 15; > + > +void > +foo () > +{ > + auto &&l = [&]() { return a; }; > +#pragma omp target parallel > + l (); > +} > > Jakub >