From patchwork Mon Mar 18 09:34:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xi Ruoyao X-Patchwork-Id: 87304 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 83C833858C5F for ; Mon, 18 Mar 2024 09:36:22 +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 025353858D1E for ; Mon, 18 Mar 2024 09:35:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 025353858D1E 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 025353858D1E 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=1710754546; cv=none; b=lo+1sJgwacIjOSLPh1hz2y8f/Bm/wpitc3W8n7A/iCADNuwit+L3Z6nTTqqpW+UmH0KH5vam7jjRfxJZtxBeV7qDpSNOaDrWmnuZH0uKaneeAs3KDDD0r74yVDiAYY47i7W3x9bHVfz6ZVNP7meWz3/yCVhrHOwxgsZaZF6RhIM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710754546; c=relaxed/simple; bh=uqyoEcCI9MFyO8tMzgTelk+MAoSp2s1HXE2r/GxcrXk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=CJRNMI7/TJssGL/G47Mc+PHHcoS/9sSZVj9QBnj5iGvlH+qxFlBwvbqyF01jvZIavO4YdimuAPTqvOs1RC6+TJuFMLLX9uwD7zygDq3tm2dmEbAvQV4jHiyzJgZ3HQUGy07J0ogMKGft0/DK7tRbkRl0ElP8kZdR6MOTe68PcLA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1710754528; bh=uqyoEcCI9MFyO8tMzgTelk+MAoSp2s1HXE2r/GxcrXk=; h=From:To:Cc:Subject:Date:From; b=ZasngjYtkve1VniVOp6XuMaVj31bW405JbmO1gu3QJLmT8wsQ6MUTnL9IlNar8Idg SXHVlU6t/0dVLCORxIkGrfqbYlCTDXdD+j/cmLsPQQ0D+KeCB18wVvqNqt+Lh1S3Nq BPgApxn4kdq8PnLNkFKI8IKR1TRMBDtLZdlmgfQ8= Received: from stargazer.. (unknown [IPv6:240e:358:1170:d100:dc73:854d:832e:8]) (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 6815466DEC; Mon, 18 Mar 2024 05:35:26 -0400 (EDT) From: Xi Ruoyao To: gcc-patches@gcc.gnu.org Cc: chenglulu , i@xen0n.name, xuchenghua@loongson.cn, Xi Ruoyao Subject: [PATCH] LoongArch: Fix C23 (...) functions returning large aggregates [PR114175] Date: Mon, 18 Mar 2024 17:34:27 +0800 Message-ID: <20240318093510.9520-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+patchwork=sourceware.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.c and gcc.dg/c23-stdarg-8.c to fail. Fix the issue by checking if arg.type is NULL, as r14-9503 explains. gcc/ChangeLog: PR target/114175 * config/loongarch/loongarch.cc (loongarch_setup_incoming_varargs): Only skip loongarch_function_arg_advance for TYPE_NO_NAMED_ARGS_STDARG_P functions if arg.type is NULL. --- Bootstrapped and regtested on loongarch64-linux-gnu. Ok for trunk? gcc/config/loongarch/loongarch.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc index 70e31bb831c..57de8ef7d20 100644 --- a/gcc/config/loongarch/loongarch.cc +++ b/gcc/config/loongarch/loongarch.cc @@ -767,7 +767,8 @@ loongarch_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))) + if (!TYPE_NO_NAMED_ARGS_STDARG_P (TREE_TYPE (current_function_decl)) + || arg.type != NULL_TREE) loongarch_function_arg_advance (pack_cumulative_args (&local_cum), arg); /* Found out how many registers we need to save. */