From patchwork Thu Jan 18 21:57:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 1888256 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=quicinc.com header.i=@quicinc.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=l6TfG6Hr; 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 4TGGpq2NScz1yPJ for ; Fri, 19 Jan 2024 08:58:41 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 290833858D33 for ; Thu, 18 Jan 2024 21:58:38 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by sourceware.org (Postfix) with ESMTPS id B7E4C3858D1E for ; Thu, 18 Jan 2024 21:58:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B7E4C3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=quicinc.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B7E4C3858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705615099; cv=none; b=Ul833691qE+XOjufIW9B2nw6OmgxRU2nBKzzezCjA/wvlGlwITVA+dDqK1m3kdPZjJV+ki1NckW1FLjRYACumUz/LBEyoI4rG253nVSwcbdsb0gM80xzYFxD1m0GCN4mynzRcMRRXmOszjnrI5Z84I/UogIMNIl3nZKECKgYWGA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705615099; c=relaxed/simple; bh=b9vTulayEEuF2Zi2klku61fufp1fgGS84E+rCFceX4E=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=AGPwmALcHGzK444OxdWBOHxMMa15+KHz8wtBdv9dMzvsCP2pw5hu0KW7hY9nfqGxP9XB+6Qf6wWcq8MVcoYMScOfG0jObcLpvrJfXYT4ySRHD9AWAqpdwqgxwC9Ii61N27hMgpCEszS4pMmzZsG+O6m5KGgTl73I89G7RXVq8xo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40ILVlgc025951 for ; Thu, 18 Jan 2024 21:58:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding:content-type; s=qcppdkim1; bh=VAV6FMy Y+2iOjL+Wa+vhr5I3jQ3o7CNFPLXOL9tKKkE=; b=l6TfG6Hry8O20jHqf8GHiji vhE+rX7GKzILQlpANCeQhqS4URnPv9CVDQ2BDmUg1JiLNJmd91cHKEIzhDGv55to DjPYa/KT8i1Jm5m+AqluGLEoTBGXP7jVwf07gFuUrjjsZpS6d+zpXtmTgo+deJ5I loTLk/JbTFPT3zElw56WanZohbcXb2tvCulrp+JjTyGzHUaeGfW7qI4I04USuvU+ pmFgWPABcDyY/3BBps/e89yguIgOWnObFJKNs1yH5T0TQaHy76FuGPpAYrZw1/fe Wg4U59hoifapy35m51S1QVKgeOkAhtAwJwHVBsmOHihDK91YdIAwP0KRvf+QNpQ= = Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vq6ub8t1b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 18 Jan 2024 21:58:14 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 40ILvfiE028266 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 18 Jan 2024 21:57:41 GMT Received: from hu-apinski-lv.qualcomm.com (10.49.16.6) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 18 Jan 2024 13:57:41 -0800 From: Andrew Pinski To: CC: Andrew Pinski Subject: [PATCH] aarch64: Fix __builtin_apply with -mgeneral-regs-only [PR113486] Date: Thu, 18 Jan 2024 13:57:30 -0800 Message-ID: <20240118215730.1012858-1-quic_apinski@quicinc.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01a.na.qualcomm.com (10.47.209.196) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: LgfxhwYA4jewXAJtN9NbrkVrG9KhU-zm X-Proofpoint-GUID: LgfxhwYA4jewXAJtN9NbrkVrG9KhU-zm X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-18_10,2024-01-17_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 suspectscore=0 clxscore=1015 adultscore=0 malwarescore=0 mlxlogscore=486 phishscore=0 lowpriorityscore=0 mlxscore=0 spamscore=0 bulkscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2401180152 X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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 The problem here is the builtin apply mechanism thinks the FP registers are to be used due to get_raw_arg_mode not returning VOIDmode. This fixes that oversight and the backend now returns VOIDmode for non-general-regs if TARGET_GENERAL_REGS_ONLY is true. Built and tested for aarch64-linux-gnu with no regressions. PR target/113486 gcc/ChangeLog: * config/aarch64/aarch64.cc (aarch64_get_reg_raw_mode): For TARGET_GENERAL_REGS_ONLY, return VOIDmode for non-GP_REGNUM_P regno. gcc/testsuite/ChangeLog: * gcc.target/aarch64/builtin_apply-1.c: New test. Signed-off-by: Andrew Pinski --- gcc/config/aarch64/aarch64.cc | 4 ++++ gcc/testsuite/gcc.target/aarch64/builtin_apply-1.c | 12 ++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 gcc/testsuite/gcc.target/aarch64/builtin_apply-1.c diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index e6bd3fd0bb4..a838cbba51d 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -7221,6 +7221,10 @@ aarch64_function_arg_boundary (machine_mode mode, const_tree type) static fixed_size_mode aarch64_get_reg_raw_mode (int regno) { + /* Don't use any non GP registers for __builtin_apply and + __builtin_return if general registers only mode is requested. */ + if (TARGET_GENERAL_REGS_ONLY && !GP_REGNUM_P (regno)) + return as_a (VOIDmode); if (TARGET_SVE && FP_REGNUM_P (regno)) /* Don't use the SVE part of the register for __builtin_apply and __builtin_return. The SVE registers aren't used by the normal PCS, diff --git a/gcc/testsuite/gcc.target/aarch64/builtin_apply-1.c b/gcc/testsuite/gcc.target/aarch64/builtin_apply-1.c new file mode 100644 index 00000000000..d70abe037d2 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/builtin_apply-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-mgeneral-regs-only" } */ +/* PR target/113486 */ + + +/* __builtin_apply should not use FP registers if + general registers only mode is requested. */ +void +foo (void) +{ + __builtin_apply (foo, 0, 0); +}