From nobody Mon May 29 14:28:58 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QVHvv10pCz4XrpG; Mon, 29 May 2023 14:28:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QVHvv0Lffz3QXH; Mon, 29 May 2023 14:28:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685370539; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/5ffxU6LUJ7cPDJydTqxpANmS4Ocqe4VhlGB6727pxk=; b=bNzHHpxirNs7vfJRFvtge0XKcp9dZKU8ufzGYCs8M1vmQkosM62Lb30AVhpu8/gaQDQpgL 2WYG5420+FKKgp0K9Y7jBfDlyzeCdc9kJQ+hFubnb+s0kha7cCydM6bB060CXbWrRfXos+ dz47xkDvb4MxWhgIvAJ8+APkcNOdsUfOfTfaphvPGtAbQEImemiDh23TOeRV+diG5PJrjC DUz9MlWNFOHoBRYPlm01Vf7qEV0xK/ZGydm+/0XnPb7EOR4Ozg7TD0KXixnTRZiYNsDbt2 pWhmpZWHtMVrblCR7zopYKZ9Vj0tXFn9r71qGYJEtWjls6kUvyNxdcEo0QyzxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685370539; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/5ffxU6LUJ7cPDJydTqxpANmS4Ocqe4VhlGB6727pxk=; b=a15E6a8qWuM+kTLm9M1jR2NYezJ5Jj6Iu8xRmQyT8toLrdh4B9RklTBRAgmSlvih2vJfis kKYeIESEE706m3vEkjINa9G7IMEwY/xZz7ZCvMVBMKIrPK+h3pOAdedtd4oz6WKMFYx850 lgG9jJvrg8khniG5WitScn8rZB44W2oEuU1IL7xjzWsFkW9MCV9vft/Irhzdo3zALYUmwj 1sCK4+Uc1yeCloim5Cuqqcrry4l9pjGdOJIM/cMq3lA3MKecfgSiV6jKNUTez+L93+0J32 ijIy1K8sjrmYmcn1kEqgG2hIXUoJP17VTgfqGMklI77WaRoVOe5NSruxHd6mEA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1685370539; a=rsa-sha256; cv=none; b=fAZDRx1L54OCqUQsiXunuHfKUv738RnUblposQrYwE9BeC5vTqEffoVEz1jlrd/TFXtZxz EK+buaJM7M15jRQm5mfUmYmkN5Wz40qwjZBftsfkx4rdBETaCW2HwjwuQ/OmjYM5U+rCd8 hiRv8+EPR8Ga7WdUxDjZUSDE7XNYfZmIriK9k13Hj7/vGoUko9QYta45vI1zR88gF8cNZH czwKVsY3HRCzC3xSyk+9UBUB35QPH+Dw0uUgcRoNKKKmZNUqZ7AwSzTV42Nd4rphudHWFt iT7CQiMnaaketB+DNs4zIY4i/Fc0Oo4lBuhuhRGpKCtP541V0tA9nZDoyDJI1Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QVHvt6XX6zFjP; Mon, 29 May 2023 14:28:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 34TESwVe073403; Mon, 29 May 2023 14:28:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 34TESw0L073402; Mon, 29 May 2023 14:28:58 GMT (envelope-from git) Date: Mon, 29 May 2023 14:28:58 GMT Message-Id: <202305291428.34TESw0L073402@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dimitry Andric Subject: git: 8792c03886d9 - main - Apply clang fixes for crashes compiling ARM/AArch64 CRC intrinsics List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8792c03886d9e6df10fbac825819603dc059c7ea Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=8792c03886d9e6df10fbac825819603dc059c7ea commit 8792c03886d9e6df10fbac825819603dc059c7ea Author: Dimitry Andric AuthorDate: 2023-05-29 14:27:58 +0000 Commit: Dimitry Andric CommitDate: 2023-05-29 14:28:18 +0000 Apply clang fixes for crashes compiling ARM/AArch64 CRC intrinsics Merge commit 069ecd0c6e2c from llvm-project (by Fangrui Song): [ARM] Check target feature support for __builtin_arm_crc* `__builtin_arm_crc*` requires the target feature crc which is available on armv8 and above. Calling the fuctions for armv7 leads to a SelectionDAG crash. ``` % clang -c --target=armv7-unknown-linux-gnueabi -c a.c fatal error: error in backend: Cannot select: intrinsic %llvm.arm.crc32b PLEASE submit a bug report to ... ``` Add `TARGET_BUILTIN` and define required features for these builtins to report an error in `CodeGenFunction::checkTargetFeatures`. The problem is quite widespread. I will add `TARGET_BUILTIN` for more builtins later. Fix https://github.com/llvm/llvm-project/issues/57802 Differential Revision: https://reviews.llvm.org/D134127 Merge commit b2d7a0dcf1ff from llvm-project (by Fangrui Song): [AArch64] Check target feature support for __builtin_arm_crc* This is the AArch64 counterpart of D134127. Daniel Kiss will change more `BUILTIN` to `TARGET_BUILTIN`. Fix #57802 Note that programs attempting to use ARM/AArch64 CRC intrinsics, when they are not supported by the targeted CPU, will still receive a regular compilation error (instead of a fatal backend error) similar to: 7zCrc.c:4:10: error: '__builtin_arm_crc32b' needs target feature crc return __builtin_arm_crc32b(a, b); ^ Reported by: Alastair Hogge PR: 271624 MFC after: 3 days --- .../clang/include/clang/Basic/BuiltinsAArch64.def | 20 ++++++++++++-------- .../clang/include/clang/Basic/BuiltinsARM.def | 20 ++++++++++++-------- .../llvm-project/clang/lib/Basic/Targets/AArch64.cpp | 2 ++ contrib/llvm-project/clang/lib/Basic/Targets/ARM.cpp | 2 ++ 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/contrib/llvm-project/clang/include/clang/Basic/BuiltinsAArch64.def b/contrib/llvm-project/clang/include/clang/Basic/BuiltinsAArch64.def index 65ab4fcced9a..3c0a5f12681d 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/BuiltinsAArch64.def +++ b/contrib/llvm-project/clang/include/clang/Basic/BuiltinsAArch64.def @@ -17,6 +17,10 @@ # define LANGBUILTIN(ID, TYPE, ATTRS, BUILTIN_LANG) BUILTIN(ID, TYPE, ATTRS) #endif +#if defined(BUILTIN) && !defined(TARGET_BUILTIN) +# define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS) +#endif + #if defined(BUILTIN) && !defined(TARGET_HEADER_BUILTIN) # define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANG, FEATURE) BUILTIN(ID, TYPE, ATTRS) #endif @@ -45,14 +49,14 @@ BUILTIN(__builtin_arm_sev, "v", "") BUILTIN(__builtin_arm_sevl, "v", "") // CRC32 -BUILTIN(__builtin_arm_crc32b, "UiUiUc", "nc") -BUILTIN(__builtin_arm_crc32cb, "UiUiUc", "nc") -BUILTIN(__builtin_arm_crc32h, "UiUiUs", "nc") -BUILTIN(__builtin_arm_crc32ch, "UiUiUs", "nc") -BUILTIN(__builtin_arm_crc32w, "UiUiUi", "nc") -BUILTIN(__builtin_arm_crc32cw, "UiUiUi", "nc") -BUILTIN(__builtin_arm_crc32d, "UiUiWUi", "nc") -BUILTIN(__builtin_arm_crc32cd, "UiUiWUi", "nc") +TARGET_BUILTIN(__builtin_arm_crc32b, "UiUiUc", "nc", "crc") +TARGET_BUILTIN(__builtin_arm_crc32cb, "UiUiUc", "nc", "crc") +TARGET_BUILTIN(__builtin_arm_crc32h, "UiUiUs", "nc", "crc") +TARGET_BUILTIN(__builtin_arm_crc32ch, "UiUiUs", "nc", "crc") +TARGET_BUILTIN(__builtin_arm_crc32w, "UiUiUi", "nc", "crc") +TARGET_BUILTIN(__builtin_arm_crc32cw, "UiUiUi", "nc", "crc") +TARGET_BUILTIN(__builtin_arm_crc32d, "UiUiWUi", "nc", "crc") +TARGET_BUILTIN(__builtin_arm_crc32cd, "UiUiWUi", "nc", "crc") // Memory Tagging Extensions (MTE) BUILTIN(__builtin_arm_irg, "v*v*Ui", "t") diff --git a/contrib/llvm-project/clang/include/clang/Basic/BuiltinsARM.def b/contrib/llvm-project/clang/include/clang/Basic/BuiltinsARM.def index 0cea0a9051e5..53fe64c317d1 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/BuiltinsARM.def +++ b/contrib/llvm-project/clang/include/clang/Basic/BuiltinsARM.def @@ -17,6 +17,10 @@ # define LANGBUILTIN(ID, TYPE, ATTRS, BUILTIN_LANG) BUILTIN(ID, TYPE, ATTRS) #endif +#if defined(BUILTIN) && !defined(TARGET_BUILTIN) +# define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS) +#endif + #if defined(BUILTIN) && !defined(TARGET_HEADER_BUILTIN) # define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANG, FEATURE) BUILTIN(ID, TYPE, ATTRS) #endif @@ -157,14 +161,14 @@ BUILTIN(__builtin_arm_mrrc, "LLUiUIiUIiUIi", "") BUILTIN(__builtin_arm_mrrc2, "LLUiUIiUIiUIi", "") // CRC32 -BUILTIN(__builtin_arm_crc32b, "UiUiUc", "nc") -BUILTIN(__builtin_arm_crc32cb, "UiUiUc", "nc") -BUILTIN(__builtin_arm_crc32h, "UiUiUs", "nc") -BUILTIN(__builtin_arm_crc32ch, "UiUiUs", "nc") -BUILTIN(__builtin_arm_crc32w, "UiUiUi", "nc") -BUILTIN(__builtin_arm_crc32cw, "UiUiUi", "nc") -BUILTIN(__builtin_arm_crc32d, "UiUiLLUi", "nc") -BUILTIN(__builtin_arm_crc32cd, "UiUiLLUi", "nc") +TARGET_BUILTIN(__builtin_arm_crc32b, "UiUiUc", "nc", "crc") +TARGET_BUILTIN(__builtin_arm_crc32cb, "UiUiUc", "nc", "crc") +TARGET_BUILTIN(__builtin_arm_crc32h, "UiUiUs", "nc", "crc") +TARGET_BUILTIN(__builtin_arm_crc32ch, "UiUiUs", "nc", "crc") +TARGET_BUILTIN(__builtin_arm_crc32w, "UiUiUi", "nc", "crc") +TARGET_BUILTIN(__builtin_arm_crc32cw, "UiUiUi", "nc", "crc") +TARGET_BUILTIN(__builtin_arm_crc32d, "UiUiLLUi", "nc", "crc") +TARGET_BUILTIN(__builtin_arm_crc32cd, "UiUiLLUi", "nc", "crc") // ARMv8-M Security Extensions a.k.a CMSE BUILTIN(__builtin_arm_cmse_TT, "Uiv*", "n") diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/AArch64.cpp b/contrib/llvm-project/clang/lib/Basic/Targets/AArch64.cpp index 8d8972c1613a..22b7cf4d0c7e 100644 --- a/contrib/llvm-project/clang/lib/Basic/Targets/AArch64.cpp +++ b/contrib/llvm-project/clang/lib/Basic/Targets/AArch64.cpp @@ -35,6 +35,8 @@ const Builtin::Info AArch64TargetInfo::BuiltinInfo[] = { {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr}, #define LANGBUILTIN(ID, TYPE, ATTRS, LANG) \ {#ID, TYPE, ATTRS, nullptr, LANG, nullptr}, +#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ + {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, FEATURE}, #define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANGS, FEATURE) \ {#ID, TYPE, ATTRS, HEADER, LANGS, FEATURE}, #include "clang/Basic/BuiltinsAArch64.def" diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/ARM.cpp b/contrib/llvm-project/clang/lib/Basic/Targets/ARM.cpp index b2f61cff81c9..159b00dea5bb 100644 --- a/contrib/llvm-project/clang/lib/Basic/Targets/ARM.cpp +++ b/contrib/llvm-project/clang/lib/Basic/Targets/ARM.cpp @@ -979,6 +979,8 @@ const Builtin::Info ARMTargetInfo::BuiltinInfo[] = { {#ID, TYPE, ATTRS, nullptr, LANG, nullptr}, #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \ {#ID, TYPE, ATTRS, HEADER, ALL_LANGUAGES, nullptr}, +#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ + {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, FEATURE}, #define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANGS, FEATURE) \ {#ID, TYPE, ATTRS, HEADER, LANGS, FEATURE}, #include "clang/Basic/BuiltinsARM.def"