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 B03913858C31 for ; Thu, 29 Feb 2024 17:39:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B03913858C31 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 B03913858C31 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709228345; cv=none; b=SDLprRxpoqZWNJhmAGdvwdwBue4Fn5elS1w2WJJI27Fs/OlbWGDTWjNkbQ8fii3grUEUdlTqfNOvjxh6Kv1QNfHZwy7p4Qu+IffGttb1eTolLYvwRJtg+9LcGjJNd2J6cT0RO92a3WQIOaERY5jHjB3zu3NPewohwQT6dO3h5L0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709228345; c=relaxed/simple; bh=g75wlwmsf7o1g9Xmokv1X+dqOe0IJTldfXzmUkYEo70=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=Xt1yEOZExP9Z4yqSDqQH/sq2K5AMoJxY+YFjUMl4I0FkKLM9wrafF3qdlm2/GPXBziKjMmyqJOzotkoS7zIvv+90vflqFIVLWKX7zAZRiLr/Wzs0LuZXu6lZfp+JyC3hMFAIUCm8JVDdeYZY9akcYTZRZkCsgcAV9LQMHiIyLSI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709228343; 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=CjoFcwFMav4a/M/6heRei8fJNstWhB4OFJlr+lsre/M=; b=NluW/WF2uLPX/Z370KFQ+IYmI9vgOW5/SrdS2EfOIYcW65nT7/wNo38seo/6NcEA65iNfZ YYqcUlscirteJTRmcpDBrd62QNMIwLbTPF3tBs6+zQdyVDf+US40I0xksBLoGfEP2C2+w0 U/teJNBdHdj8sG6oMPMoBu/DiCn2LsQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-654-nhhV8PFVOLygXPsVpdMHcg-1; Thu, 29 Feb 2024 12:38:59 -0500 X-MC-Unique: nhhV8PFVOLygXPsVpdMHcg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7B35A185A780; Thu, 29 Feb 2024 17:38:59 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.226.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C9518492BC7; Thu, 29 Feb 2024 17:38:58 +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 41THctmv1822925 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 29 Feb 2024 18:38:55 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 41THcapU1822924; Thu, 29 Feb 2024 18:38:36 +0100 Date: Thu, 29 Feb 2024 18:38:36 +0100 From: Jakub Jelinek To: "Richard Earnshaw (lists)" Cc: "Joseph S. Myers" , Richard Biener , Jeff Law , gcc-patches@gcc.gnu.org, =?iso-8859-1?Q?Torbj=F6rn?= SVENSSON , oliva@adacore.com Subject: Re: [PATCH] calls: Further fixes for TYPE_NO_NAMED_ARGS_STDARG_P handling [PR107453] Message-ID: Reply-To: Jakub Jelinek References: <45ac2d54-21df-486c-a085-0a6c1f37a323@arm.com> <23c7c873-1954-43b2-80b8-714455eaaf2b@arm.com> <9b4f43f8-3807-432f-b1a2-e0515ab198ca@arm.com> MIME-Version: 1.0 In-Reply-To: <9b4f43f8-3807-432f-b1a2-e0515ab198ca@arm.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 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.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,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: On Thu, Feb 29, 2024 at 05:23:25PM +0000, Richard Earnshaw (lists) wrote: > On 29/02/2024 15:55, Jakub Jelinek wrote: > > On Thu, Feb 29, 2024 at 02:14:05PM +0000, Richard Earnshaw wrote: > >>> I tried the above on arm, aarch64 and x86_64 and that seems fine, > >>> including the new testcase you added. > >>> > >> > >> I should mention though, that INIT_CUMULATIVE_ARGS on arm ignores > >> n_named_args entirely, it doesn't need it (I don't think it even existed > >> when the AAPCS code was added). > > > > So far I've just checked that the new testcase passes not just on > > x86_64/i686-linux, but also on {powerpc64le,s390x,aarch64}-linux > > with vanilla trunk. > > Haven't posted this patch in patch form, plus while I'm not really sure > > whether setting n_named_args to 0 or not changing in the > > !pretend_outgoing_varargs_named is right, the setting to 0 feels more > > correct to me. If structure_value_addr_parm is 1, the function effectively > > has a single named argument and then ... args and if the target wants > > n_named_args to be number of named arguments except the last, then that > > should be 0 rather than 1. > > > > Thus, is the following patch ok for trunk then? > > The comment at the start of the section says > > /* Now possibly adjust the number of named args. > Normally, don't include the last named arg if anonymous args follow. > We do include the last named arg if > targetm.calls.strict_argument_naming() returns nonzero. > (If no anonymous args follow, the result of list_length is actually > one too large. This is harmless.) > > So in the case of strict_argument_naming perhaps it should return 1, but 0 for other cases. The TYPE_NO_NAMED_ARGS_STDARG_P (funtype) case is as if type_arg_types != 0 and list_length (type_arg_types) == 0, i.e. no user named arguments. As list_length (NULL) returns 0, perhaps it could be even handled just the by changing all the type_arg_types != 0 checks to type_arg_types != 0 || TYPE_NO_NAMED_ARGS_STDARG_P (funtype) There are just 2 cases I'm worried about, one is that I think rest of calls.cc nor the backends are prepared to see n_named_args -1 after the adjustments, I think it is better to use 0, and then the question is what the !strict_argument_naming && !pretend_outgoing_varargs_named case wants to do for the aggregate return. The patch as posted for void foo (...); void bar () { foo (1, 2, 3); } will set n_named_args initially to 0 (no named args) and with the adjustments for strict_argument_naming 0, otherwise for !pretend 0 as well, otherwise 3. For struct { char buf[4096]; } baz (...); void qux () { baz (1, 2, 3); } the patch sets n_named_args initially to 1 (the hidden return) and with the arguments for strict keep it at 1, for !pretend 0 and otherwise 3. So, which case do you think is handled incorrectly with that? Jakub