]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Apply clang fixes for crashes compiling ARM/AArch64 CRC intrinsics
authorDimitry Andric <dim@FreeBSD.org>
Mon, 29 May 2023 14:27:58 +0000 (16:27 +0200)
committerDimitry Andric <dim@FreeBSD.org>
Thu, 1 Jun 2023 19:15:31 +0000 (21:15 +0200)
commit3cc4f10db0feca9d54bbfc615328b317a5c6b4c8
treead3c8b6dd688f54b2d6e5f165816060cfa3cf0fb
parent9058186bc1fa513a264fe949375f25f0061528eb
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 <agh@riseup.net>
PR: 271624
MFC after: 3 days

(cherry picked from commit 8792c03886d9e6df10fbac825819603dc059c7ea)
contrib/llvm-project/clang/include/clang/Basic/BuiltinsAArch64.def
contrib/llvm-project/clang/include/clang/Basic/BuiltinsARM.def
contrib/llvm-project/clang/lib/Basic/Targets/AArch64.cpp
contrib/llvm-project/clang/lib/Basic/Targets/ARM.cpp