From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 464673850413 for ; Fri, 26 Aug 2022 20:05:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 464673850413 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 38F971F937; Fri, 26 Aug 2022 20:05:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1661544335; h=from:from:reply-to: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=B6Xk863qCR1nUzN+oiMSpAbeXFet/BRWyDfgDgife/s=; b=PWYoJU4pjpZv5td+MGbASGCflduDPjo+lh4c5ZnlFKgzUPwd+DmLOIAl+lGAgzNH4L3zUo xfz/rLMoRCcL6JzEmrLRC13voLCuQPxT74j/4MG8FYdSSfoSdO5r3AOvgf15+8d6JcsS0E N7FvRYqmHaZqpNyOdq56xaIFbQajmMg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1661544335; h=from:from:reply-to: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=B6Xk863qCR1nUzN+oiMSpAbeXFet/BRWyDfgDgife/s=; b=UNyGF4YFEjcVTviBhH1vCz9yMtSijRVyxSWeDLQMdpws/jwpwgLtkWYxQXSSkZYF2sEUny osNPmrsQCNIYXQAw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2914B13A7E; Fri, 26 Aug 2022 20:05:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id V0j3CY8nCWPQOQAAMHmgww (envelope-from ); Fri, 26 Aug 2022 20:05:35 +0000 From: Martin Jambor To: Richard Biener Cc: GCC Patches , Richard Sandiford Subject: Re: [PATCH 1/2] vec: Add array_slice constructors from non-const and gc vectors In-Reply-To: References: User-Agent: Notmuch/0.35 (https://notmuchmail.org) Emacs/28.1 (x86_64-suse-linux-gnu) Date: Fri, 26 Aug 2022 22:05:34 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_SOFTFAIL,TXREP,T_SCC_BODY_TEXT_LINE 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, On Fri, Aug 26 2022, Richard Biener wrote: >> Am 26.08.2022 um 18:39 schrieb Martin Jambor : >> >> =EF=BB=BFHi, >> >> This patch adds constructors of array_slice that are required to >> create them from non-const (heap or auto) vectors or from GC vectors. >> >> The use of non-const array_slices is somewhat limited, as creating one >> from const vec still leads to array_slice, >> so I eventually also only resorted to having read-only array_slices. >> But I do need the constructor from the gc vector. >> >> Bootstrapped and tested along code that actually uses it on >> x86_64-linux. OK for trunk? >> >> Thanks, >> >> Martin >> >> >> gcc/ChangeLog: >> >> 2022-08-08 Martin Jambor >> >> * vec.h (array_slice): Add constructors for non-const reference to >> heap vector and pointers to heap vectors. >> --- >> gcc/vec.h | 12 ++++++++++++ >> 1 file changed, 12 insertions(+) >> >> diff --git a/gcc/vec.h b/gcc/vec.h >> index eed075addc9..b0477e1044c 100644 >> --- a/gcc/vec.h >> +++ b/gcc/vec.h >> @@ -2264,6 +2264,18 @@ public: >> array_slice (const vec &v) >> : m_base (v.address ()), m_size (v.length ()) {} >> >> + template >> + array_slice (vec &v) >> + : m_base (v.address ()), m_size (v.length ()) {} >> + >> + template >> + array_slice (const vec *v) >> + : m_base (v ? v->address () : nullptr), m_size (v ? v->length () : = 0) {} >> + >> + template >> + array_slice (vec *v) >> + : m_base (v ? v->address () : nullptr), m_size (v ? v->length () : = 0) {} >> + > > I don=E2=80=99t quite understand why the generic ctor doesn=E2=80=99t cov= er the GC case. It looks more like reference vs pointer? > If you think that this should work: vec *heh =3D cfun->local_decls; array_slice arr_slice (*heh); then it does not: /home/mjambor/gcc/mine/src/gcc/ipa-cp.cc:6693:36: error: no matching func= tion for call to =E2=80=98array_slice::array_slice(vec&)=E2=80=99 6693 | array_slice arr_slice (*heh); | ^ In file included from /home/mjambor/gcc/mine/src/gcc/hash-table.h:248, from /home/mjambor/gcc/mine/src/gcc/coretypes.h:486, from /home/mjambor/gcc/mine/src/gcc/ipa-cp.cc:105: /home/mjambor/gcc/mine/src/gcc/vec.h:2264:3: note: candidate: =E2=80=98te= mplate array_slice::array_slice(const vec&) [with = T =3D tree_node*]=E2=80=99 2264 | array_slice (const vec &v) | ^~~~~~~~~~~ /home/mjambor/gcc/mine/src/gcc/vec.h:2264:3: note: template argument de= duction/substitution failed: /home/mjambor/gcc/mine/src/gcc/ipa-cp.cc:6693:36: note: mismatched type= s =E2=80=98va_heap=E2=80=99 and =E2=80=98va_gc=E2=80=99 6693 | array_slice arr_slice (*heh); | ^ [... I trimmed notes about all other candidates...] Or did you mean something else? Thanks, Martin