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 821B53858C41 for ; Tue, 27 Feb 2024 17:25:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 821B53858C41 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 821B53858C41 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=1709054734; cv=none; b=aQOnIEqj43PK+zVvgCRzhy6ZHdnvePeJ6e8aZVy6twyu/2FwdMlNs/57dwRwKXbQjXYYpHIQ43pKt04VTg/9ACDpCBxTlV2euS9SLivD6W77hqhFbpBs2zEANMfN+GTPt6odvWh99CUyx4rFu30O6dRUf6cIcz2XI403kLNYNPk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709054734; c=relaxed/simple; bh=rsUk5wNDE8ic8znvdYiaAv2dVlTUpAdZVom1WklTJG4=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=hYygETss/wO/G2U1h13DsJmMZ/Zi636xsYYDcumHhPdHxFVreNxg0yqHhL46agGvo8k2rgjxzH3C2/QbGV8lIKHoRmK7sH9gPUmyoum4mni6y14fKB/AaL0aoA2J3L7dCwqZcJ4solJysrJnU+OhOUrvd4fi8jN7fExjvDgKqso= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709054733; 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=H+spBYj8vWTIksg2Offrl1WC1k/uMQ8lzIC+9yrdsgE=; b=eQ1gRQvZtsn9bIj+M7urgHdH7uu06tdkTokW1vO1qCyGPKZA3MonzmpW0cakcg3YCufP13 3Fgn5UOQxHoCiH/vqopUsjYN4dXW+rrWH9hytHMPcHV+Xvq9Et6j7wf7T94slp0pJTP8zJ ahp6klKL77dTP35ACyka9R8mXZpUVRs= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-548-SG9Gc-ocPle2Canicv4dsw-1; Tue, 27 Feb 2024 12:25:29 -0500 X-MC-Unique: SG9Gc-ocPle2Canicv4dsw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 4AC893C14951; Tue, 27 Feb 2024 17:25:29 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EBF1C40153A7; Tue, 27 Feb 2024 17:25:28 +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 41RHPPNm118828 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 27 Feb 2024 18:25:25 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 41RHPMQQ118827; Tue, 27 Feb 2024 18:25:22 +0100 Date: Tue, 27 Feb 2024 18:25:21 +0100 From: Jakub Jelinek To: Richard Earnshaw Cc: "Joseph S. Myers" , Richard Biener , Jeff Law , gcc-patches@gcc.gnu.org, Alexandre Ferreira , =?iso-8859-1?Q?Torbj=F6rn?= SVENSSON Subject: Re: [PATCH] calls: Fix up TYPE_NO_NAMED_ARGS_STDARG_P handling [PR107453] Message-ID: Reply-To: Jakub Jelinek References: <45ac2d54-21df-486c-a085-0a6c1f37a323@arm.com> MIME-Version: 1.0 In-Reply-To: <45ac2d54-21df-486c-a085-0a6c1f37a323@arm.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 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.7 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 Tue, Feb 27, 2024 at 04:41:32PM +0000, Richard Earnshaw wrote: > > 2023-01-09 Jakub Jelinek > > > > PR target/107453 > > * calls.cc (expand_call): For calls with > > TYPE_NO_NAMED_ARGS_STDARG_P (funtype) use zero for n_named_args. > > Formatting fix. > > This one has been festering for a while; both Alexandre and Torbjorn have attempted to fix it recently, but I'm not sure either is really right... > > On Arm this is causing all anonymous arguments to be passed on the stack, > which is incorrect per the ABI. On a target that uses > 'pretend_outgoing_vararg_named', why is it correct to set n_named_args to > zero? Is it enough to guard both the statements you've added with > !targetm.calls.pretend_outgoing_args_named? I'm afraid I haven't heard of that target hook before. All I was doing with that change was fixing a regression reported in the PR for ppc64le/sparc/nvptx/loongarch at least. The TYPE_NO_NAMED_ARGS_STDARG_P functions (C23 fns like void foo (...) {}) have NULL type_arg_types, so the list_length (type_arg_types) isn't done for it, but it should be handled as if it was non-NULL but list length was 0. So, for the if (type_arg_types != 0) n_named_args = (list_length (type_arg_types) /* 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; else /* If we know nothing, treat all args as named. */ n_named_args = num_actuals; case, I think guarding it by any target hooks is wrong, although I guess it should have been n_named_args = structure_value_addr_parm; instead of n_named_args = 0; For the second if (type_arg_types != 0 && 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)) n_named_args = 0; else /* Treat all args as named. */ n_named_args = num_actuals; bet (but no testing done, don't even know which targets return what for those hooks) we should treat those as if type_arg_types was non-NULL with 0 elements in the list, except the --n_named_args doesn't make sense because that would decrease it to -1. So perhaps 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) && ! targetm.calls.pretend_outgoing_varargs_named (args_so_far))) ; else /* Treat all args as named. */ n_named_args = num_actuals; (or n_named_args = 0; instead of ; before the final else? Dunno). I guess we need some testsuite coverage for caller/callee ABI match of struct S { char p[64]; }; struct S foo (...); Jakub