From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id EBA03382C435 for ; Wed, 30 Jun 2021 09:29:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EBA03382C435 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 00C8022452; Wed, 30 Jun 2021 09:29:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1625045386; h=from:from:reply-to: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=ddqU+H9w3fpLWfdBD6P7LTOmExPKJa0AvK8NgRozpK8=; b=HPHN4jQ2AqQ+EOdpSqvxGqL9MSPUHOKIi/Kma0GVkvwVqMUgo1vnm1grZ0RqOe7ZduWioc 8qjcKv8c4VZ0uXRyKI8XHVHYcqWumVAIJ/SivPmsWJ+zWhoUcOXO1qwpMcZLUt1EeYHHK4 Da95Y+7c5KYeWAYhchXJ9lWtSoDpAuA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1625045386; h=from:from:reply-to: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=ddqU+H9w3fpLWfdBD6P7LTOmExPKJa0AvK8NgRozpK8=; b=Hnoco5a7ILUKhUjaNDXSxmmjQvWSHHcWRc5BCv/DNFcMtQZ3sfISVMaS15V2KK6Upn+wOo CpjC+RmFdBk8XiDQ== Received: from suse.cz (virgil.suse.cz [10.100.13.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id E1FE5A3B85; Wed, 30 Jun 2021 09:29:45 +0000 (UTC) From: Martin Jambor To: Richard Biener , Martin Sebor Cc: Jason Merrill , gcc-patches , Jonathan Wakely Subject: Re: [PATCH] define auto_vec copy ctor and assignment (PR 90904) In-Reply-To: References: <91545a73-12af-33b2-c6e7-119b5a21de60@gmail.com> <4d503394-4e82-1d36-41ca-34315042775b@redhat.com> <49569f1d-9856-55c7-b9e9-578bbd7c7b7a@gmail.com> <390c6652-0a1f-e8c4-d70d-56ced2f7b0fb@gmail.com> User-Agent: Notmuch/0.32 (https://notmuchmail.org) Emacs/27.2 (x86_64-suse-linux-gnu) Date: Wed, 30 Jun 2021 11:29:45 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Wed, 30 Jun 2021 09:29:48 -0000 Hi, On Wed, Jun 30 2021, Richard Biener wrote: > On Wed, Jun 30, 2021 at 3:46 AM Martin Sebor wrote: >> On 6/29/21 4:58 AM, Richard Biener wrote: [...] >> > >> > But I wonder if since you now identified them they could be massaged >> > prior to doing the change. >> > >> > I do hope we end up not needing .to_vec () after all, if no users remain ;) >> >> I'd be happy to if none remained. I see how to eliminate those in >> calls to functions like c_parser_declaration_or_fndef() (done in >> the attached revision of the patch), but no easy way to get rid >> of those that replace other implicit conversions, like all those >> assignments to the vec members of the ipa_call_arg_values ctor. >> If it's appropriate to std::move those then that would get rid >> of the .to_vec () call. I'm not familiar with the code but I >> have the impression it might be meant more as a reference to >> some "remote" object (an instance of ipa_auto_call_arg_values?) >> If that's right then making the vec members auto_vec references >> (or pointers) would be one way to "fix" this. > > I think ipa_call_arg_values is just a temporary container used to > pass a collection of vec<>s along API boundaries. I'm not sure > whether it's default CTOR is ever used but it's definitely an > optimization avoiding extra indirection (when changing the vec<> > members to vec<> * or references, in case the default CTOR is > not used). It _might_ be that the vecs are all just read and never > written to in the APIs using this abstract type No, IPA-CP does add and then remove extra context-specific values in the auto version of the container, ipa_auto_call_arg_values, but I do not think that consumers of ipa_call_arg_values do. The caching mechanism can make a (partial) copy. > but then it's > likely the vector are always appropriately pre-allocated. They are, they should never be reallocated. > Maybe using array_slice instead of vec<> members would work, > but they'd pack less efficient (but I guess not an issue for this > aggregate which should be only used temporarily for argument > passing). I need to educate myself more about array_slice to to comment on that. But note that apart from reducing the number of parameters, there is also an ipa_call_arg_values field in ipa_call_context and especially ipa_cached_call_context. Martin