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 915593858C54 for ; Fri, 10 Mar 2023 09:03:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 915593858C54 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=1678439020; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=cMp34FZYcv1E1Mqrp/i4Q+RkBATt1I2JD2CYhKaBmXE=; b=gyCt/Hoedc/6m8G6ECqul5BAtDTv2gIHQDnKXjCH6S1o25ZR3zoGQErEflLZDzfWz/jHJp KJaqnTrslpEWKlgp7vcYzTB0Ia1x/xz1iSr95J56lBco3Jod2oOSI+jsUlPdQmRC8OJrOH BCeIDW2F7ovJf2cfwVUcYZagf+VC8mU= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-62-xt4hA0upPvmwBLKsn2gyjw-1; Fri, 10 Mar 2023 04:02:38 -0500 X-MC-Unique: xt4hA0upPvmwBLKsn2gyjw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7E0961C06EE2 for ; Fri, 10 Mar 2023 09:02:38 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 41E1F440E0; Fri, 10 Mar 2023 09:02:38 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 32A92amf844588 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 10 Mar 2023 10:02:36 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 32A92ZDx844587; Fri, 10 Mar 2023 10:02:35 +0100 Date: Fri, 10 Mar 2023 10:02:35 +0100 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: Patch ping: [PATCH] c++: Don't clear TREE_READONLY for -fmerge-all-constants for non-aggregates [PR107558] Message-ID: Reply-To: Jakub Jelinek References: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,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: Hi! I'd like to ping this patch: https://gcc.gnu.org/pipermail/gcc-patches/2022-November/607145.html - PR107558 - P2 - c++: Don't clear TREE_READONLY for -fmerge-all-constants for non-aggregates Thanks Jakub On Thu, Nov 24, 2022 at 10:13:55AM +0100, Jakub Jelinek via Gcc-patches wrote: > 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? > > 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 (); > +}