From patchwork Mon Mar 18 18:54:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Edwin Lu X-Patchwork-Id: 1913272 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=JAj8pkER; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; 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 [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4Tz3vc3YwRz1yWn for ; Tue, 19 Mar 2024 05:55:24 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 12D9B3858420 for ; Mon, 18 Mar 2024 18:55:22 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by sourceware.org (Postfix) with ESMTPS id 92C023858CD1 for ; Mon, 18 Mar 2024 18:55:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 92C023858CD1 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 92C023858CD1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::536 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710788102; cv=none; b=cqHB3G76uYKWbK6gTMUzB0ca+EpoByysWp+MDAJKzXZ2r2u7LYJFlXXSO377HXwukMaStmbs8P2kRkC9Uk10I7wMo4hkACnrJzpNx15Ki/dUkibPpfMFtpezzMkBnIfUo1X2AXOHl6rU8nU3bBUXP1oJRCy0Z5l4lviajKRgvS8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710788102; c=relaxed/simple; bh=dlBrNu7M/YgoE+4w9wlmAJkRHvwJpSqsnPen1y4kbHY=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=CZch2SRxGFtxcLiTZqHj/1rXjaLTSDzfOd3pjQ/yNYuYgWSL1gbjLQ2Yn4K1tdThNvmR7TXQ7jKIG1Uzp/RWIddwRo72IjdTqvdH5EP3viWvIcCUNBNfUI9tVgvyHP6n8UmqDz6iJ2KHNNUH+TzpeSbMAyERTy7UD2vwgMdz4k8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-5e152c757a5so2898126a12.2 for ; Mon, 18 Mar 2024 11:55:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1710788099; x=1711392899; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=gAJQWOSBQk9mE1sfgzahfzTvyp1WtHiQSwdSRaGCEiw=; b=JAj8pkER5gBnZjc4pFIil3LeKCcHlffHYrKr/eEdPXvvwUTwPXynAaxWKDe33nZduy noteBGs4wOaf9RapxYd6aHh48erJqh+pHdtKHaewPRKy7dWJAuPKxrJvdkpJi33WmDs2 kRP4xnmstOLg6yWzATwu23cQJq5cXlnJjhsi8QHorEFTsTd7tx8tnSRJ4zfG4Kae5VGU efjIKuNbsWXxdttijIn38UpkbAl2u+UpzbxMNXswv7he6BJ979J9fD09xap42fPPDXvy rMMd2Jbq976pUJPtBtsnkqbX1rhybneYHZ9NM5hbqBM3vgm9ae6CLfKizgOm1GaNKHXt D9IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710788099; x=1711392899; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gAJQWOSBQk9mE1sfgzahfzTvyp1WtHiQSwdSRaGCEiw=; b=DqnYYk2EPcDl1D7Qh3wuul0ObFoxoR4kiRI2LOR+bw4zu1McRR+rxkogwJ8NMXN5jg c+ut21aFh2sqe5OoJcBMcRxWZ+yNDS+bignjJvj3iZLLQ7TfLvUTw8+GfjGH5cQVhDLH O6DgCPhhH3NYI4+lI/uGQ2AuOgy5SudsmUbwO/oUCkN5Btd1I9xKkmFCQbI0173PgtXb xb8bpnFetxP6/3PmE+Yows08Q8lhC0cKRqqkcOuFNJxm6SYjm6QOc2/oquU1h/gF+F/3 FkboZWC1Iunz1IEtIB08CNRZLGoZelta1g6uj5logfjAZ2aLBgVmsliLvAkYR/SZAiyX PODA== X-Gm-Message-State: AOJu0Yx+bcEGYjid9n+WN5LGxJD1dfp3mAiZeFm+2tnK/6VD4gIX64fJ zU8uTj0A2tNNvwB2NfbiOjt0lRbeyDCMfilvXZODUMQ18kTjhSkJNOLzVvr36t8a2y6ulSAkkNL i X-Google-Smtp-Source: AGHT+IHpTLONoMKJ3lIiPuMyt8Zf/OlUd/TTbeaylIdAGe21w8QY+VpznIiXF+07wct6gDdvstKcWA== X-Received: by 2002:a17:903:1250:b0:1dc:d4f9:fd1b with SMTP id u16-20020a170903125000b001dcd4f9fd1bmr13395344plh.7.1710788099192; Mon, 18 Mar 2024 11:54:59 -0700 (PDT) Received: from ewlu.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id r11-20020a170903410b00b001ddb4df7f70sm9627609pld.304.2024.03.18.11.54.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 11:54:58 -0700 (PDT) From: Edwin Lu To: gcc-patches@gcc.gnu.org Cc: gnu-toolchain@rivosinc.com, Edwin Lu Subject: [PATCH] RISC-V: Fix C23 (...) functions returning large aggregates [PR114175] Date: Mon, 18 Mar 2024 11:54:54 -0700 Message-Id: <20240318185454.1314630-1-ewlu@rivosinc.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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 assume that 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 causes gcc.dg/c23-stdarg-[68].c to fail Fix the issue by checking if arg.type is NULL as r14-9503-g218d1749612 explains Tested on linux rv64gcv. gcc/ChangeLog: PR target/114175 * config/riscv/riscv.cc (riscv_setup_incoming_varargs): Only skip riscv_funciton_arg_advance for TYPE_NO_NAMED_ARGS_STDARG_P functions if arg.type is NULL --- gcc/config/riscv/riscv.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 680c4a728e9..1f5dc33796b 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -5378,7 +5378,8 @@ riscv_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) riscv_function_arg_advance (pack_cumulative_args (&local_cum), arg); /* Found out how many registers we need to save. */