From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id D05233858C52 for ; Thu, 29 Feb 2024 17:23:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D05233858C52 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D05233858C52 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709227410; cv=none; b=cOod4A0XQXgFf7zBd8wi1byTy+pavzrI5H6UbLk8kPYNJjRtJxtmXTbAnCGsshkifrYeOqtgvLhYlVmvhT+mzRb/gseLdPVFfwloq3YvYh6kHidUCPJCSn1UtkL2QcUXmnObrZHFZkSSrXX96/JMoUE0epWucu/UahHzOXmw6TM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709227410; c=relaxed/simple; bh=qW1Z9k1pL4CSo/zxTRw34p0cbAq1Yzt6/sUo/OtTmoM=; h=Message-ID:Date:MIME-Version:Subject:To:From; b=YaclzXpyfUvPhI7METqeA/yHODEWTu4f6iT9S7pKkqExtO5wt1jOFg+Qu8UfmbbTb+83Ag6XZVToaVKaLF54SpAZvmLLMXWnI7+/9klujhyzNU9/iGW2Wz6vdOcFc001SUdlfk3Mx919HYHSvjX3TsPqH1Ywa/4gpQ6Deziny88= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 15E611FB; Thu, 29 Feb 2024 09:24:07 -0800 (PST) Received: from [10.2.78.54] (e120077-lin.cambridge.arm.com [10.2.78.54]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2E91E3F6C4; Thu, 29 Feb 2024 09:23:27 -0800 (PST) Message-ID: <9b4f43f8-3807-432f-b1a2-e0515ab198ca@arm.com> Date: Thu, 29 Feb 2024 17:23:25 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] calls: Further fixes for TYPE_NO_NAMED_ARGS_STDARG_P handling [PR107453] Content-Language: en-GB To: Jakub Jelinek , "Joseph S. Myers" , Richard Biener , Jeff Law Cc: gcc-patches@gcc.gnu.org, =?UTF-8?Q?Torbj=C3=B6rn_SVENSSON?= , oliva@adacore.com References: <45ac2d54-21df-486c-a085-0a6c1f37a323@arm.com> <23c7c873-1954-43b2-80b8-714455eaaf2b@arm.com> From: "Richard Earnshaw (lists)" In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3491.6 required=5.0 tests=BAYES_00,KAM_DMARC_NONE,KAM_DMARC_STATUS,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no 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 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. R. > > 2024-02-29 Jakub Jelinek > > PR target/107453 > * calls.cc (expand_call): For TYPE_NO_NAMED_ARGS_STDARG_P set > n_named_args initially before INIT_CUMULATIVE_ARGS to > structure_value_addr_parm rather than 0, after it don't modify > it if strict_argument_naming and clear only if > !pretend_outgoing_varargs_named. > > --- gcc/calls.cc.jj 2024-01-22 11:48:08.045847508 +0100 > +++ gcc/calls.cc 2024-02-29 16:24:47.799855912 +0100 > @@ -2938,7 +2938,7 @@ expand_call (tree exp, rtx target, int i > /* Count the struct value address, if it is passed as a parm. */ > + structure_value_addr_parm); > else if (TYPE_NO_NAMED_ARGS_STDARG_P (funtype)) > - n_named_args = 0; > + n_named_args = structure_value_addr_parm; > else > /* If we know nothing, treat all args as named. */ > n_named_args = num_actuals; > @@ -2970,14 +2970,15 @@ expand_call (tree exp, rtx target, int i > we do not have any reliable way to pass unnamed args in > registers, so we must force them into memory. */ > > - if (type_arg_types != 0 > + if ((type_arg_types != 0 || TYPE_NO_NAMED_ARGS_STDARG_P (funtype)) > && targetm.calls.strict_argument_naming (args_so_far)) > ; > else if (type_arg_types != 0 > && ! targetm.calls.pretend_outgoing_varargs_named (args_so_far)) > /* Don't include the last named arg. */ > --n_named_args; > - else if (TYPE_NO_NAMED_ARGS_STDARG_P (funtype)) > + else if (TYPE_NO_NAMED_ARGS_STDARG_P (funtype) > + && ! targetm.calls.pretend_outgoing_varargs_named (args_so_far)) > n_named_args = 0; > else > /* Treat all args as named. */ > > Jakub >