summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@moritz.systems>2022-04-19 01:05:34 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-04-19 01:05:34 +0000
commit20ca2dc226a7780a7e73d9a32307aff6f07d4901 (patch)
tree4b38033d0130f157bbe58b0ba04b50ade7b8dcdf
parent154ac1ef98464a359c2b4aecaa173e8025c1cb94 (diff)
parent195a29847a3c8afc6dc49d9895fe4d77e485a86a (diff)
downloadscudo-20ca2dc226a7780a7e73d9a32307aff6f07d4901.tar.gz
[compiler-rt] [scudo] Use -mcrc32 on x86 when available am: 47318d28f4 am: a060512444 am: 195a29847a
Original change: https://android-review.googlesource.com/c/platform/external/scudo/+/2063221 Change-Id: I6fb17c6132916eebf6b479ea36ac66d110d2f8d4 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--standalone/checksum.h5
-rw-r--r--standalone/chunk.h4
-rw-r--r--standalone/crc32_hw.cpp4
3 files changed, 7 insertions, 6 deletions
diff --git a/standalone/checksum.h b/standalone/checksum.h
index a63b1b4f064..df3299543ae 100644
--- a/standalone/checksum.h
+++ b/standalone/checksum.h
@@ -12,12 +12,13 @@
#include "internal_defs.h"
// Hardware CRC32 is supported at compilation via the following:
-// - for i386 & x86_64: -msse4.2
+// - for i386 & x86_64: -mcrc32 (earlier: -msse4.2)
// - for ARM & AArch64: -march=armv8-a+crc or -mcrc
// An additional check must be performed at runtime as well to make sure the
// emitted instructions are valid on the target host.
-#ifdef __SSE4_2__
+#if defined(__CRC32__) || defined(__SSE4_2__)
+// NB: clang has <crc32intrin.h> but GCC does not
#include <smmintrin.h>
#define CRC32_INTRINSIC FIRST_32_SECOND_64(_mm_crc32_u32, _mm_crc32_u64)
#endif
diff --git a/standalone/chunk.h b/standalone/chunk.h
index 69b8e1b12a9..0581420dfc9 100644
--- a/standalone/chunk.h
+++ b/standalone/chunk.h
@@ -25,7 +25,7 @@ inline u16 computeChecksum(u32 Seed, uptr Value, uptr *Array, uptr ArraySize) {
// as opposed to only for crc32_hw.cpp. This means that other hardware
// specific instructions were likely emitted at other places, and as a result
// there is no reason to not use it here.
-#if defined(__SSE4_2__) || defined(__ARM_FEATURE_CRC32)
+#if defined(__CRC32__) || defined(__SSE4_2__) || defined(__ARM_FEATURE_CRC32)
u32 Crc = static_cast<u32>(CRC32_INTRINSIC(Seed, Value));
for (uptr I = 0; I < ArraySize; I++)
Crc = static_cast<u32>(CRC32_INTRINSIC(Crc, Array[I]));
@@ -42,7 +42,7 @@ inline u16 computeChecksum(u32 Seed, uptr Value, uptr *Array, uptr ArraySize) {
Checksum = computeBSDChecksum(Checksum, Array[I]);
return Checksum;
}
-#endif // defined(__SSE4_2__) || defined(__ARM_FEATURE_CRC32)
+#endif // defined(__CRC32__) || defined(__SSE4_2__) || defined(__ARM_FEATURE_CRC32)
}
namespace Chunk {
diff --git a/standalone/crc32_hw.cpp b/standalone/crc32_hw.cpp
index 62841ba5101..d13c615498f 100644
--- a/standalone/crc32_hw.cpp
+++ b/standalone/crc32_hw.cpp
@@ -10,10 +10,10 @@
namespace scudo {
-#if defined(__SSE4_2__) || defined(__ARM_FEATURE_CRC32)
+#if defined(__CRC32__) || defined(__SSE4_2__) || defined(__ARM_FEATURE_CRC32)
u32 computeHardwareCRC32(u32 Crc, uptr Data) {
return static_cast<u32>(CRC32_INTRINSIC(Crc, Data));
}
-#endif // defined(__SSE4_2__) || defined(__ARM_FEATURE_CRC32)
+#endif // defined(__CRC32__) || defined(__SSE4_2__) || defined(__ARM_FEATURE_CRC32)
} // namespace scudo