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 (QUIC)" X-Patchwork-Id: 189350 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp646328dyb; Thu, 18 Jan 2024 13:59:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IGzdbNxMhqM+YeLYYGS7j4NnP4H6ckgAaI3TB5ug2r69SRrP4hnOhKelcalx+KZS///EgPn X-Received: by 2002:ac8:5905:0:b0:429:bed4:8499 with SMTP id 5-20020ac85905000000b00429bed48499mr1604792qty.5.1705615142754; Thu, 18 Jan 2024 13:59:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705615142; cv=pass; d=google.com; s=arc-20160816; b=MMDFCjnw+qoNW1dIdU0njeC90DXtV5qIZmOSrpN4rOSqVdkzJjC3ZqNkqnLLVrwVvw AcwjSnh/2s651/TD8/ppgLVBgYz71Lt36yJdJuQ0C/GP78AitgoYbCy25KvZ1tzdlTRG nJdSjI0FO6xHyKUo7z5jYtmBWO9a4qMj9QRoa7DGO/tZ/wnqmSdkmoYNBTIoEQST5t8I o1h+pgcMtkLq0eZWGHw+3aBPf4HJanmhwjh2c1c0/9UmRGMjNS6P4zr3lujQxsYP04S1 Eg/IJ56kNKA5I6tIQU+w8zIsfLnTkfTeLM7l0wZGO2EHP9cem2Hn25DDLqyi39ipp53e iDHQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=VAV6FMyY+2iOjL+Wa+vhr5I3jQ3o7CNFPLXOL9tKKkE=; fh=o3CEdS3yGN/eIa89Zn0Kf01WYLxTE9IjKuSQGVPeOHI=; b=XzoXGBly8K/nls11TcRXyMHnhnIt+UN7CJeeFSxcOw3mvgVqrlH3ZvBgyEguMTELcj mbvRVom3CMtBvXPZKNiWHzEHIKsxjZpZVOdTVkteTHH+lupeDY5AiSj17Ff3dkV1TQuA dYRk1be1RkI3vlBSjKc9fP3h9i5B9zMb8q1de1IiF7roduTgplPXhHocGm6F+u9uvkqd ABL/HjQ5hjsK7t8liFPVZhblbhaJ5kPYGW4GYx+98/9DyldHYti5TKbNusThRdAZOT44 srEJ6csPZItT06i+LVVx5AUpGMThwNxqRMi6dk7LThD8ovM9IwC36jO3hhOtLiX2Uctd FSOg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=l6TfG6Hr; 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=quicinc.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id x1-20020a05622a000100b0042a12a1520bsi3626315qtw.602.2024.01.18.13.59.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 13:59:02 -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=@quicinc.com header.s=qcppdkim1 header.b=l6TfG6Hr; 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=quicinc.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B00C13858D1E for ; Thu, 18 Jan 2024 21:59:01 +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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788467104073812951 X-GMAIL-MSGID: 1788467104073812951 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); +}