[compiler-rt] [scudo] Add support for LoongArch hardware CRC32 checksumming (PR #83113)
Xi Ruoyao via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 27 21:08:55 PST 2024
================
@@ -75,6 +77,15 @@ bool hasHardwareCRC32() {
return !!(getauxval(AT_HWCAP) & HWCAP_CRC32);
#endif // SCUDO_FUCHSIA
}
+#elif defined(__loongarch__)
+// Query HWCAP for platform capability, according to *Software Development and
+// Build Convention for LoongArch Architectures* v0.1, Section 9.1.
+//
+// Link:
+// https://github.com/loongson/la-softdev-convention/blob/v0.1/la-softdev-convention.adoc#kernel-development
+bool hasHardwareCRC32() {
+ return !!(getauxval(AT_HWCAP) & HWCAP_LOONGARCH_CRC32);
----------------
xry111 wrote:
> After `<asm/hwcap.h>` is included, I got this error:
>
> ```
> compiler-rt/lib/scudo/standalone/crc32_hw.cpp:23:49: error: implicit conversion changes signedness: 'u32' (aka 'unsigned int') to 'int' [-Werror,-Wsign-conversion]
> 23 | return static_cast<u32>(CRC32_INTRINSIC(Data, Crc));
> | ~~~~~~~~~~~~~~~ ^~~
> compiler-rt/lib/scudo/standalone/crc32_hw.cpp:23:43: error: implicit conversion changes signedness: 'uptr' (aka 'unsigned long') to 'long' [-Werror,-Wsign-conversion]
> 23 | return static_cast<u32>(CRC32_INTRINSIC(Data, Crc));
> | ~~~~~~~~~~~~~~~ ^~~~
> 2 errors generated.
> ```
>
> Note that I'm using clang-17 to build.
Yes, this is nasty. `__crc_w_d_w` etc. has signed argument and return value types. I had to add a lot of casts in my xz CRC32 optimization to silence the warning.
https://github.com/llvm/llvm-project/pull/83113
More information about the llvm-commits
mailing list