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: 208402 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp493898dyb; Thu, 29 Feb 2024 07:57:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXFETHNOdFyP/S6kKNFP0nk6qT7w9CoCMXebhuqKqgKbLsosUJBocXHsgS1Gi9fL/lkk0/0bMhfbIV9VGcy5TlKuFAvrg== X-Google-Smtp-Source: AGHT+IGk3UhjcCsXGrE9o1cWY4Q/TkxlGNQaEfaO28pMjrm32AM2Gp0eXkFTgWu3IDBmM5OKWLt8 X-Received: by 2002:a05:6870:4728:b0:21e:635c:a5b9 with SMTP id b40-20020a056870472800b0021e635ca5b9mr2281639oaq.52.1709222231745; Thu, 29 Feb 2024 07:57:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709222231; cv=pass; d=google.com; s=arc-20160816; b=kk94WfPAYwU+HN4ZHQyLtSuqJv90l+xD4xTDPwknDaHrZKl81zZ3IGa+bxTCwoPqBn 0yg+H5gXAuniLG8zThivLmw2xFCzQtlsQh0FysMWUxpBuT0JlBmxEO0CbwEZsAE1agz3 UnrlFYrk+WSM1jUHfdqLakO2vG7Isc82Q0FGvFgKH68pRLzlRCPeX+ol/hVieihtLXDA YQZZGe+tu0J6JERo7yX28uytlaVAVAvIznnDtSTx9469EE65E59A+5k0pdpo/glaO7jp By1H4YJLZlMETgZtu4632zADMrQQ9pSI4nbGCvL43GZU1rLZ+9V8Od2oNsuq9maO7RXa UtuA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:reply-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-disposition:in-reply-to :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=5up4gdcob8ytsO+yxrS+f7bVBi5jhF84i8voQDPjkrg=; fh=/37ZHSAgmhTCemu1J5XrUBHIrABEQ4LY3f+uw+jieoc=; b=SLpyM3CoPPDLrfiCazfDEdTqsZKAp1JXOxwDRNwqifHFQKplkl9MOqlwU1SrY4b7tw 8C09Y54KjHP8gZRpwC5AdHxEYwnPxTMDs8+U268KPURo18D6IJsKz0QHCGRB8axAlWci pTb/rFMwm+nqMlGYJNZ61X4lDulQXOnIwgCSUf+nKT75HStKM7bpOI6iWjNcS9ithxod 0J6AMCYy+LMB5IAvH53KvPCFae51/T1rmWYpqIVPbzQHDSEtV9Vdi9jthYSfKJ3jp4vN aM8Omn9xwakkPoV5OdJFRIFVhd6o7TnbGFx/bRZbzBqam1TlPSuiQ6DwMonry0P8nbf5 l5QA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=a7uQYFf3; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id d2-20020a05621421c200b0068cb0f6bc39si1649367qvh.431.2024.02.29.07.57.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 07:57:11 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=a7uQYFf3; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6E4DF3858402 for ; Thu, 29 Feb 2024 15:57:11 +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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792249410897359845 X-GMAIL-MSGID: 1792249410897359845 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. */