From 9a4f1f434b006d20ad1815abf8faee64e4657f01 Mon Sep 17 00:00:00 2001 From: Ben Niu Date: Mon, 8 Mar 2021 10:53:04 -0800 Subject: [PATCH] Disable x64-specific optimizations for ARM64EC ReadInt64 (#6506) ARM64EC is a new ARM64 ABI designed by Microsoft to support x64 application emulation on ARM64 CPUs. When compiling for ARM64EC, both the _M_X64 and _M_ARM64EC macros are defined. However, that causes problem in compiling this file, because the __movsb intrinsic, which is lowered to rep movsb, is not supported on ARM64, so the optimization for native x64 should be disabled for ARM64EC. --- include/flatbuffers/flexbuffers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/flatbuffers/flexbuffers.h b/include/flatbuffers/flexbuffers.h index f2088b31b..c71928e8a 100644 --- a/include/flatbuffers/flexbuffers.h +++ b/include/flatbuffers/flexbuffers.h @@ -155,7 +155,7 @@ inline uint64_t ReadUInt64(const uint8_t *data, uint8_t byte_width) { // constant, which here it isn't. Test if memcpy is still faster than // the conditionals in ReadSizedScalar. Can also use inline asm. // clang-format off - #if defined(_MSC_VER) && (defined(_M_X64) || defined _M_IX86) + #if defined(_MSC_VER) && ((defined(_M_X64) && !defined(_M_ARM64EC)) || defined _M_IX86) uint64_t u = 0; __movsb(reinterpret_cast(&u), reinterpret_cast(data), byte_width);