From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Fri, 1 Mar 2024 11:56:17 -0800 Subject: [PATCH 26/37] constexpr endian byte swap --- llvm/include/llvm/Support/Endian.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/Support/Endian.h b/llvm/include/llvm/Support/Endian.h index 5831fe66a1f7b71f26aac179c4e2c904d0ad4255..62e19c04e5dc565dd94c5c38f7c6b141fbcb56a3 100644 --- a/llvm/include/llvm/Support/Endian.h +++ b/llvm/include/llvm/Support/Endian.h @@ -50,7 +50,9 @@ template /// Swap the bytes of value to match the given endianness. template [[nodiscard]] inline value_type byte_swap(value_type value) { - return byte_swap(value, endian); + if constexpr (endian != llvm::endianness::native) + sys::swapByteOrder(value); + return value; } /// Read a value of a particular endianness from memory.