From patchwork Wed Mar 20 07:10:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xi Ruoyao X-Patchwork-Id: 1913902 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=xry111.site header.i=@xry111.site header.a=rsa-sha256 header.s=default header.b=lmu4IYnC; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V00CT6q1zz23r9 for ; Wed, 20 Mar 2024 18:12:20 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 79B4B385842E for ; Wed, 20 Mar 2024 07:12:18 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from xry111.site (xry111.site [89.208.246.23]) by sourceware.org (Postfix) with ESMTPS id 41D9B3858CD1; Wed, 20 Mar 2024 07:12:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 41D9B3858CD1 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=xry111.site Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=xry111.site ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 41D9B3858CD1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=89.208.246.23 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710918722; cv=none; b=lW7aOmTv/70kh4zVCIJ1HV/OZPLIdnZBxdofn/yqHNoebiC3hFDPVqAw677PfUgHOxvIsyWuEgjduFMvT33W82mIdVW1qX3H78hpuiq+wIm5Czg54THO4KUM2QRJqWJLyMuU+vXu7Rx2HR9alaSOI2Doom9iDoAnbDsZM2PVlZA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710918722; c=relaxed/simple; bh=8wT4Nmgo3l+TKfIzDsXMzAS0/JjOT5yU/ZUm2u1ZN6M=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=BknaFif95Y+Kw1980AqDNequShgAJ8Kfb8xzS1XWU1slQgR3ZwgzBAWKzskHVzcQfDuNsbcu30gqTJ5BvrProIv5jPEeeelYMZG36nXzaILzIbwuNXKec+KMVgaiimtZKVwGe8BCYBQGEY3gh1+HsAczEpcozCMuj4wccmxdfNA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1710918718; bh=8wT4Nmgo3l+TKfIzDsXMzAS0/JjOT5yU/ZUm2u1ZN6M=; h=From:To:Cc:Subject:Date:From; b=lmu4IYnCxTJ5+FKems4UzchLz3xPBjhMivaVXqmM+LU6y1uVy68qkBTErUNBRuzpx 1Wm4Pwo8BRGs3XhuvAiGLhjQ55SjHUpw9w/QbW2qEgTAXHlWSYaaAUtW2k4oM/Q8Rq 77vs9JUdk+ZAdZ80aOEsEF8mL3RsnTj6k7TOD+fg= Received: from stargazer.. (unknown [IPv6:240e:358:1173:7000:dc73:854d:832e:6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 45EDC66B1F; Wed, 20 Mar 2024 03:11:55 -0400 (EDT) From: Xi Ruoyao To: gcc-patches@gcc.gnu.org Cc: YunQiang Su , Jeff Law , Xi Ruoyao Subject: [PATCH] mips: Fix C23 (...) functions returning large aggregates [PR114175] Date: Wed, 20 Mar 2024 15:10:59 +0800 Message-ID: <20240320071135.86306-1-xry111@xry111.site> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, LIKELY_SPAM_FROM, SPF_HELO_PASS, SPF_PASS, 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: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org We were assuming TYPE_NO_NAMED_ARGS_STDARG_P don't have any named arguments and there is nothing to advance, but that is not the case for (...) functions returning by hidden reference which have one such artificial argument. This is causing gcc.dg/c23-stdarg-{6,8,9}.c to fail. Fix the issue by checking if arg.type is NULL, as r14-9503 explains. gcc/ChangeLog: PR target/114175 * config/mips/mips.cc (mips_setup_incoming_varargs): Only skip mips_function_arg_advance for TYPE_NO_NAMED_ARGS_STDARG_P functions if arg.type is NULL. --- Bootstrapped and regtested on mips64el-linux-gnuabi64. Ok for trunk? gcc/config/mips/mips.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gcc/config/mips/mips.cc b/gcc/config/mips/mips.cc index 68e2ae8d8fa..ce764a5cb35 100644 --- a/gcc/config/mips/mips.cc +++ b/gcc/config/mips/mips.cc @@ -6834,7 +6834,13 @@ mips_setup_incoming_varargs (cumulative_args_t cum, argument. Advance a local copy of CUM past the last "real" named argument, to find out how many registers are left over. */ local_cum = *get_cumulative_args (cum); - if (!TYPE_NO_NAMED_ARGS_STDARG_P (TREE_TYPE (current_function_decl))) + + /* For a C23 variadic function w/o any named argument, and w/o an + artifical argument for large return value, skip advancing args. + There is such an artifical argument iff. arg.type is non-NULL + (PR 114175). */ + if (!TYPE_NO_NAMED_ARGS_STDARG_P (TREE_TYPE (current_function_decl)) + || arg.type != NULL_TREE) mips_function_arg_advance (pack_cumulative_args (&local_cum), arg); /* Found out how many registers we need to save. */