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 2D9ED3858D20 for ; Mon, 11 Mar 2024 14:36:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2D9ED3858D20 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 2D9ED3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710167775; cv=none; b=pSERg0GxBOoHNE1+JHWboGx7ycx6UraqdiX+7csYsFwI/ie+G3CINxSLoGnSBcKVurEyhe9ROrTdKzcrEpFH34q1COkfA3WBlPwgNi+YlIWsF/yq3TSQDXJ9/LBlPYXIBvSQHnSELiOoOv+skM8XOPAzMaYK3BVOMHP0eobF5+I= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710167775; c=relaxed/simple; bh=odyyMMPfBus3R2lSO02QbMZ4085cuVOYyvHPxegkPeY=; h=DKIM-Signature:From:Date:To:Subject:Message-ID:MIME-Version; b=nTmVHAVFRqKTefLiT6kNnQJ6h7SMyP/XtZWMB/2jQ60M5nsqmOSLVGCggR1FVm2nR/EZK7+puNkMpew3zPnbY4IA8LE7iajwzA1Q9gVUc8/dYgWYQLJYncAlkyzlGmkQ4AQ0cga7MEboG3zqP9vHHmhCe93eA0gbYsoTxP0rTV4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710167772; 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: in-reply-to:in-reply-to:references:references; bh=uShXgevjTGx4ewxTw/HlDqyoKg0A2G2WEVZ3GVAPdSI=; b=Gi+NPxzxt4DDeoRJv5gxYap8orFxq5v0e4/41bbj66fkZ59EJFcWacXbX2vrHYThPpmZKu MLAbs4ONnvtjr270z/bdDHar7HQrU4m184Bt08Kxszx+cWz8n1rrwHeNAEbA7VBxCZGstv REqudIGFRbVWQXqIbx32cRiu5rgijhI= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-1-iRdPYmfrMxSwt_B1rcNndg-1; Mon, 11 Mar 2024 10:36:09 -0400 X-MC-Unique: iRdPYmfrMxSwt_B1rcNndg-1 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-42f01892811so45006101cf.2 for ; Mon, 11 Mar 2024 07:36:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710167769; x=1710772569; h=mime-version:references:message-id:in-reply-to:subject:cc:to:date :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uShXgevjTGx4ewxTw/HlDqyoKg0A2G2WEVZ3GVAPdSI=; b=bOs95f6ovv+ATY75Js8jPu8AdBorj/0EN5Z0jXHvSYJJXgwz2cQbnMeM6Vu/MH+Wf6 x9UxwGbkO+azn9eU7LxHJHODmNLuILz17+3BL/TnCq/KrMlCygkfwNdCqe1h+z599Vy8 FyNuALAsBoSU6uFOEY1FiHeSpLgRVuqjvSY93sSqXh4xsKcWm4q7KYLA/hTBzt6E9Z4U DCOWHPLKr4/Ssy8NXHErigYQhMp0hmndEC5SWCysBjk+6Te5IJbLwiPIDbaPEbskR5ub tgaqJmT27buNj+e28mRD/ytTg7NbvUhm9VL01q0Y8N8rtIPtOQwA+lH7pExCaHf+lst4 JUfA== X-Gm-Message-State: AOJu0YyTGGWIgpG9SniiijEH7HHYWP+DAHzP7yCkCN7FK2ARxwHp88Ct Oo2pmLt8i92W4XeeHhQzE39TyT7/EOKt4lyEVwt+74uB9tzgSwqCwyiOxb4l5V1Le5UaFGSJsIc 3FmHwUm8PyV8nzdYipxZkiUlOK0ikmjJxSDmQYa6c0Fprpl5zcktl0tE= X-Received: by 2002:ac8:5a91:0:b0:42e:60ba:14 with SMTP id c17-20020ac85a91000000b0042e60ba0014mr9938449qtc.44.1710167768847; Mon, 11 Mar 2024 07:36:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHxnhk+wi4LEbNjt1wjGaFIY5eBiEtG/0naZMfCtM3vrG2oJ30DBkHl5qMUq4NT8GbMZedOZg== X-Received: by 2002:ac8:5a91:0:b0:42e:60ba:14 with SMTP id c17-20020ac85a91000000b0042e60ba0014mr9938415qtc.44.1710167768337; Mon, 11 Mar 2024 07:36:08 -0700 (PDT) Received: from [192.168.1.130] (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id bj40-20020a05620a192800b007884db6b2absm2755370qkb.10.2024.03.11.07.36.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 07:36:07 -0700 (PDT) From: Patrick Palka X-Google-Original-From: Patrick Palka Date: Mon, 11 Mar 2024 10:36:06 -0400 (EDT) To: Nathaniel Shead cc: gcc-patches@gcc.gnu.org, Jason Merrill , Nathan Sidwell , Patrick Palka Subject: Re: [PATCH] c++/modules: Support target-specific nodes with streaming [PR111224] In-Reply-To: <65ed9f0f.170a0220.64a2e.2144@mx.google.com> Message-ID: References: <65ed9f0f.170a0220.64a2e.2144@mx.google.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII 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_NONE,RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE,URIBL_BLACK 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 Sun, 10 Mar 2024, Nathaniel Shead wrote: > Bootstrapped and regtested on x86_64-pc-linux-gnu and > aarch64-unknown-linux-gnu, OK for trunk? > > It's worth noting that the AArch64 machines I had available to test with > didn't have a new enough glibc to reproduce the ICEs in the PR, but this > patch will be necessary (albeit possibly not sufficient) to fix it. > > -- >8 -- > > Some targets make use of POLY_INT_CSTs and other custom builtin types, > which currently violate some assumptions when streaming. This patch adds > support for them, specifically AArch64 SVE types like __fp16. It seems other built-in types are handled by adding them to the fixed_trees vector in init_modules (and then we install them first during streaming). Could we just add all the target-specific types to fixed_trees too? > > This patch doesn't provide "full" support of AArch64 SVE, however, since > for that we would need to support 'target' nodes (tracked in PR108080). > > PR c++/111224 > > gcc/cp/ChangeLog: > > * module.cc (enum tree_tag): Add new tag for builtin types. > (trees_out::start): POLY_INT_CSTs can be emitted. > (trees_in::start): Likewise. > (trees_out::core_vals): Stream POLY_INT_CSTs. > (trees_in::core_vals): Likewise. > (trees_out::type_node): Handle target-specific builtin types, > and vectors with NUM_POLY_INT_COEFFS > 1. > (trees_in::tree_node): Likewise. > > gcc/testsuite/ChangeLog: > > * g++.dg/modules/pr111224_a.C: New test. > * g++.dg/modules/pr111224_b.C: New test. > > Signed-off-by: Nathaniel Shead > --- > gcc/cp/module.cc | 70 +++++++++++++++++++---- > gcc/testsuite/g++.dg/modules/pr111224_a.C | 17 ++++++ > gcc/testsuite/g++.dg/modules/pr111224_b.C | 13 +++++ > 3 files changed, 90 insertions(+), 10 deletions(-) > create mode 100644 gcc/testsuite/g++.dg/modules/pr111224_a.C > create mode 100644 gcc/testsuite/g++.dg/modules/pr111224_b.C > > diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc > index 99055523d91..0b5e2e67053 100644 > --- a/gcc/cp/module.cc > +++ b/gcc/cp/module.cc > @@ -2718,6 +2718,7 @@ enum tree_tag { > tt_typedef_type, /* A (possibly implicit) typedefed type. */ > tt_derived_type, /* A type derived from another type. */ > tt_variant_type, /* A variant of another type. */ > + tt_builtin_type, /* A custom builtin type. */ > > tt_tinfo_var, /* Typeinfo object. */ > tt_tinfo_typedef, /* Typeinfo typedef. */ > @@ -2732,7 +2733,7 @@ enum tree_tag { > tt_binfo, /* A BINFO. */ > tt_vtable, /* A vtable. */ > tt_thunk, /* A thunk. */ > - tt_clone_ref, > + tt_clone_ref, /* A cloned function. */ > > tt_entity, /* A extra-cluster entity. */ > > @@ -5173,7 +5174,6 @@ trees_out::start (tree t, bool code_streamed) > break; > > case FIXED_CST: > - case POLY_INT_CST: > gcc_unreachable (); /* Not supported in C++. */ > break; > > @@ -5259,7 +5259,6 @@ trees_in::start (unsigned code) > > case FIXED_CST: > case IDENTIFIER_NODE: > - case POLY_INT_CST: > case SSA_NAME: > case TARGET_MEM_REF: > case TRANSLATION_UNIT_DECL: > @@ -6106,7 +6105,10 @@ trees_out::core_vals (tree t) > break; > > case POLY_INT_CST: > - gcc_unreachable (); /* Not supported in C++. */ > + if (streaming_p ()) > + for (unsigned ix = 0; ix != NUM_POLY_INT_COEFFS; ix++) > + WT (POLY_INT_CST_COEFF (t, ix)); > + break; > > case REAL_CST: > if (streaming_p ()) > @@ -6615,8 +6617,9 @@ trees_in::core_vals (tree t) > break; > > case POLY_INT_CST: > - /* Not suported in C++. */ > - return false; > + for (unsigned ix = 0; ix != NUM_POLY_INT_COEFFS; ix++) > + RT (POLY_INT_CST_COEFF (t, ix)); > + break; > > case REAL_CST: > if (const void *bytes = buf (sizeof (real_value))) > @@ -8930,6 +8933,32 @@ trees_out::type_node (tree type) > return; > } > > + if (tree name = TYPE_NAME (type)) > + if (TREE_CODE (name) == TYPE_DECL && DECL_ARTIFICIAL (name)) > + { > + /* Potentially a custom machine- or OS-specific builtin type. */ > + bool found = false; > + unsigned ix = 0; > + for (tree t = registered_builtin_types; t; t = TREE_CHAIN (t), ix++) > + if (TREE_VALUE (t) == type) > + { > + found = true; > + break; > + } > + if (found) > + { > + int type_tag = insert (type); > + if (streaming_p ()) > + { > + i (tt_builtin_type); > + u (ix); > + dump (dumper::TREE) > + && dump ("Wrote:%d builtin type %N", type_tag, name); > + } > + return; > + } > + } > + > if (streaming_p ()) > { > u (tt_derived_type); > @@ -9068,8 +9097,8 @@ trees_out::type_node (tree type) > if (streaming_p ()) > { > poly_uint64 nunits = TYPE_VECTOR_SUBPARTS (type); > - /* to_constant asserts that only coeff[0] is of interest. */ > - wu (static_cast (nunits.to_constant ())); > + for (unsigned ix = 0; ix != NUM_POLY_INT_COEFFS; ix++) > + wu (nunits.coeffs[ix]); > } > break; > } > @@ -9630,9 +9659,11 @@ trees_in::tree_node (bool is_use) > > case VECTOR_TYPE: > { > - unsigned HOST_WIDE_INT nunits = wu (); > + poly_uint64 nunits; > + for (unsigned ix = 0; ix != NUM_POLY_INT_COEFFS; ix++) > + nunits.coeffs[ix] = wu (); > if (!get_overrun ()) > - res = build_vector_type (res, static_cast (nunits)); > + res = build_vector_type (res, nunits); > } > break; > } > @@ -9700,6 +9731,25 @@ trees_in::tree_node (bool is_use) > } > break; > > + case tt_builtin_type: > + /* A machine- or OS-specific builtin type. */ > + { > + unsigned ix = u (); > + res = registered_builtin_types; > + for (; ix && res; res = TREE_CHAIN (res)) > + ix--; > + if (!res) > + set_overrun (); > + if (!get_overrun ()) > + { > + res = TREE_VALUE (res); > + int type_tag = insert (res); > + dump (dumper::TREE) > + && dump ("Read:%d builtin type %N", type_tag, res); > + } > + } > + break; > + > case tt_tinfo_var: > case tt_tinfo_typedef: > /* A tinfo var or typedef. */ > diff --git a/gcc/testsuite/g++.dg/modules/pr111224_a.C b/gcc/testsuite/g++.dg/modules/pr111224_a.C > new file mode 100644 > index 00000000000..6c699053cdc > --- /dev/null > +++ b/gcc/testsuite/g++.dg/modules/pr111224_a.C > @@ -0,0 +1,17 @@ > +// PR c++/111224 > +// { dg-do compile { target aarch64*-*-* } } > +// { dg-require-effective-target aarch64_asm_sve_ok } > +// { dg-additional-options "-fmodules-ts -march=armv8.2-a+sve" } > + > +module; > + > +// We can't do a header unit of this right now because this > +// uses target attributes, that we don't yet support. > +// See also PR c++/108080. > +#include > + > +export module M; > + > +export inline void foo(svbool_t x, svfloat16_t f) { > + svabs_f16_x(x, f); > +} > diff --git a/gcc/testsuite/g++.dg/modules/pr111224_b.C b/gcc/testsuite/g++.dg/modules/pr111224_b.C > new file mode 100644 > index 00000000000..c18691dcf8a > --- /dev/null > +++ b/gcc/testsuite/g++.dg/modules/pr111224_b.C > @@ -0,0 +1,13 @@ > +// PR c++/111224 > +// { dg-module-do link { target aarch64*-*-* } } > +// { dg-require-effective-target aarch64_asm_sve_ok } > +// { dg-additional-options "-fmodules-ts -fno-module-lazy -march=armv8.2-a+sve" } > + > +#include > +import M; > + > +int main() { > + svbool_t x = svptrue_b8 (); > + svfloat16_t f = svdup_n_f16(1.0); > + foo(x, f); > +} > -- > 2.43.2 > >