From patchwork Thu Feb 29 15:55:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 86598 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8D05E385840E for ; Thu, 29 Feb 2024 15:56:58 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id ECD653858C98 for ; Thu, 29 Feb 2024 15:56:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ECD653858C98 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 ECD653858C98 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709222195; cv=none; b=R6LELZ/HKFwpzkvLmD0i0/2V+JM1QpsTmayr26vffrSSY7/Tm5T6xlP98DpbgFfahsSBPor5S0mK3h/d2hN76MQLZAQv+KV170j7G3nYMdSklAQxLvnxc4sJeNoNPgxEcrRObIdKj330OCNiUFt8EaDNHLTv7rJ/ELUO5jnZAQw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709222195; c=relaxed/simple; bh=5xoKgWWWIRhC6xh7iq+xcUwXLX0qM9te+unDIlzD7tI=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=F1DcKCDKXlZKA7PU71xz45GxT7kh/DYXkCjqaOv667FNSrEsH5Rt4QZ0NWSdrWE8Db90opD2ceWSYnQRDK2beRrMDiJvGWB/ut7zPgqXQOfHKVRP4kf8fHNom61ufRz1Zse10+tb+mUtsPn4P8hVgrNyQ4I4yUBpZDAJlTTXRuw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709222192; 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=5up4gdcob8ytsO+yxrS+f7bVBi5jhF84i8voQDPjkrg=; b=a7uQYFf3oLqj6PXv9UPsZ1hJcBGEzCYpGBl78WJAg+kK4tuhIz9wQo+ganIRfd9AKNfGs1 +lz4/mZviUp6tWZrUWzhx/kwRKmoMTj+i8SsEY9cOpx4t1kLzZFOhBu50JWgoJFz2zsxvv Q99YkcpxhpXO7gChG7aDqTvNbzBYbOk= 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-93-AodHvSA2PsaVKCKwAuagTw-1; Thu, 29 Feb 2024 10:56:29 -0500 X-MC-Unique: AodHvSA2PsaVKCKwAuagTw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 A2CFD185A788; Thu, 29 Feb 2024 15:56:28 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.226.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4AB00C185C0; Thu, 29 Feb 2024 15:56: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 41TFu3X01817895 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 29 Feb 2024 16:56:03 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 41TFtla41817876; Thu, 29 Feb 2024 16:55:47 +0100 Date: Thu, 29 Feb 2024 16:55:46 +0100 From: Jakub Jelinek To: Richard Earnshaw , "Joseph S. Myers" , Richard Biener , Jeff Law Cc: gcc-patches@gcc.gnu.org, =?iso-8859-1?q?Torbj=F6rn?= SVENSSON , oliva@adacore.com Subject: [PATCH] calls: Further fixes for TYPE_NO_NAMED_ARGS_STDARG_P handling [PR107453] Message-ID: References: <45ac2d54-21df-486c-a085-0a6c1f37a323@arm.com> <23c7c873-1954-43b2-80b8-714455eaaf2b@arm.com> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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_H2, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org 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? 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. Jakub --- 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. */