From 1b6ec5a95d3fd1ac858297fb7abbf3b5b4260b80 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Thu, 21 Sep 2023 19:54:33 -0700 Subject: [PATCH] [wpiutil] Upgrade to LLVM 17.0.1 (#5482) --- .../src/main/native/cpp/net3/WireDecoder3.cpp | 2 +- .../src/main/native/cpp/net3/WireEncoder3.cpp | 2 +- .../halsim_xrp/src/main/native/cpp/XRP.cpp | 36 +- .../0001-Fix-spelling-language-errors.patch | 22 - ...ove-StringRef-ArrayRef-and-Optional.patch} | 259 +++++++---- ...calls-in-parens-for-Windows-warning.patch} | 46 +- ...Change-unique_function-storage-size.patch} | 4 +- ...tes.patch => 0004-Threading-updates.patch} | 8 +- ...ty.patch => 0005-ifdef-guard-safety.patch} | 48 +-- ...td.patch => 0006-Explicitly-use-std.patch} | 10 +- ...atch => 0007-Remove-format_provider.patch} | 20 +- ...> 0008-Add-compiler-warning-pragmas.patch} | 28 +- ...tch => 0009-Remove-unused-functions.patch} | 8 +- ...> 0010-Detemplatize-SmallVectorBase.patch} | 6 +- ... => 0011-Add-vectors-to-raw_ostream.patch} | 4 +- ... => 0012-Extra-collections-features.patch} | 8 +- ...atch => 0013-EpochTracker-ABI-macro.patch} | 6 +- ...0014-Delete-numbers-from-MathExtras.patch} | 16 +- ...-sgn.patch => 0015-Add-lerp-and-sgn.patch} | 6 +- ...cludes.patch => 0016-Fixup-includes.patch} | 10 +- ...-std-is_trivially_copy_constructible.patch | 36 ++ ...pport.patch => 0018-Windows-support.patch} | 2 +- ...-fmtlib.patch => 0019-Prefer-fmtlib.patch} | 2 +- ...s.h.patch => 0020-Prefer-wpi-s-fs.h.patch} | 4 +- ...tch => 0021-Remove-unused-functions.patch} | 21 +- ...s.patch => 0022-OS-specific-changes.patch} | 2 +- ...-Use-SmallVector-for-UTF-conversion.patch} | 4 +- ...-use-static-pointers-in-raw_ostream.patch} | 2 +- ... => 0025-constexpr-endian-byte-swap.patch} | 2 +- ...from-STLExtras.h-into-PointerUnion..patch} | 4 +- ...Remove-StringMap-test-for-llvm-sort.patch} | 6 +- ...028-Unused-variable-in-release-mode.patch} | 4 +- ...r.patch => 0029-Use-C-20-bit-header.patch} | 243 +++++++---- ...0-Remove-DenseMap-GTest-printer-test.patch | 26 ++ ...ace-deprecated-std-aligned_storage_t.patch | 4 +- upstream_utils/update_llvm.py | 62 +-- .../src/netconsoleServer/native/cpp/main.cpp | 9 +- wpinet/src/netconsoleTee/native/cpp/main.cpp | 9 +- wpiutil/src/main/native/cpp/DataLog.cpp | 12 +- wpiutil/src/main/native/cpp/DataLogReader.cpp | 8 +- .../llvm/cpp/llvm/ConvertUTFWrapper.cpp | 4 +- .../thirdparty/llvm/cpp/llvm/StringMap.cpp | 11 +- .../thirdparty/llvm/cpp/llvm/xxhash.cpp | 407 ++++++++++++++++++ .../native/thirdparty/llvm/include/wpi/ADL.h | 103 +++++ .../llvm/include/wpi/AllocatorBase.h | 8 +- .../thirdparty/llvm/include/wpi/Casting.h | 13 +- .../thirdparty/llvm/include/wpi/Compiler.h | 20 +- .../native/thirdparty/llvm/include/wpi/DJB.h | 29 -- .../thirdparty/llvm/include/wpi/DenseMap.h | 34 +- .../llvm/include/wpi/DenseMapInfo.h | 40 +- .../llvm/include/wpi/DenseMapInfoVariant.h | 71 +++ .../llvm/include/wpi/EpochTracker.h | 6 + .../llvm/include/wpi/ErrorHandling.h | 2 +- .../llvm/include/wpi/FunctionExtras.h | 19 +- .../thirdparty/llvm/include/wpi/Hashing.h | 42 +- .../thirdparty/llvm/include/wpi/MapVector.h | 18 +- .../thirdparty/llvm/include/wpi/MathExtras.h | 146 +------ .../llvm/include/wpi/PointerIntPair.h | 42 +- .../llvm/include/wpi/PointerUnion.h | 6 +- .../llvm/include/wpi/ReverseIteration.h | 2 +- .../thirdparty/llvm/include/wpi/SmallPtrSet.h | 5 +- .../thirdparty/llvm/include/wpi/SmallSet.h | 2 + .../thirdparty/llvm/include/wpi/SmallVector.h | 11 +- .../thirdparty/llvm/include/wpi/StringMap.h | 24 +- .../llvm/include/wpi/SwapByteOrder.h | 12 +- .../llvm/include/wpi/iterator_range.h | 30 +- .../thirdparty/llvm/include/wpi/raw_ostream.h | 4 +- .../thirdparty/llvm/include/wpi/type_traits.h | 38 +- .../thirdparty/llvm/include/wpi/xxhash.h | 56 +++ .../src/test/native/cpp/json/unit-cbor.cpp | 5 +- .../test/native/cpp/json/unit-comparison.cpp | 4 +- .../native/cpp/json/unit-element_access2.cpp | 8 +- .../test/native/cpp/json/unit-iterators1.cpp | 20 +- .../src/test/native/cpp/llvm/DenseMapTest.cpp | 34 +- .../test/native/cpp/llvm/MapVectorTest.cpp | 2 + .../test/native/cpp/llvm/MathExtrasTest.cpp | 123 ------ .../native/cpp/llvm/PointerIntPairTest.cpp | 18 + .../test/native/cpp/llvm/PointerUnionTest.cpp | 76 ++-- .../test/native/cpp/llvm/SmallVectorTest.cpp | 5 + .../test/native/cpp/llvm/StringMapTest.cpp | 14 + .../native/cpp/llvm/SwapByteOrderTest.cpp | 10 - .../src/test/native/cpp/llvm/xxhashTest.cpp | 63 +++ 82 files changed, 1697 insertions(+), 901 deletions(-) delete mode 100644 upstream_utils/llvm_patches/0001-Fix-spelling-language-errors.patch rename upstream_utils/llvm_patches/{0002-Remove-StringRef-ArrayRef-and-Optional.patch => 0001-Remove-StringRef-ArrayRef-and-Optional.patch} (90%) rename upstream_utils/llvm_patches/{0003-Wrap-std-min-max-calls-in-parens-for-Windows-warning.patch => 0002-Wrap-std-min-max-calls-in-parens-for-Windows-warning.patch} (78%) rename upstream_utils/llvm_patches/{0004-Change-unique_function-storage-size.patch => 0003-Change-unique_function-storage-size.patch} (89%) rename upstream_utils/llvm_patches/{0005-Threading-updates.patch => 0004-Threading-updates.patch} (96%) rename upstream_utils/llvm_patches/{0006-ifdef-guard-safety.patch => 0005-ifdef-guard-safety.patch} (92%) rename upstream_utils/llvm_patches/{0007-Explicitly-use-std.patch => 0006-Explicitly-use-std.patch} (92%) rename upstream_utils/llvm_patches/{0008-Remove-format_provider.patch => 0007-Remove-format_provider.patch} (92%) rename upstream_utils/llvm_patches/{0009-Add-compiler-warning-pragmas.patch => 0008-Add-compiler-warning-pragmas.patch} (86%) rename upstream_utils/llvm_patches/{0010-Remove-unused-functions.patch => 0009-Remove-unused-functions.patch} (98%) rename upstream_utils/llvm_patches/{0011-Detemplatize-SmallVectorBase.patch => 0010-Detemplatize-SmallVectorBase.patch} (97%) rename upstream_utils/llvm_patches/{0012-Add-vectors-to-raw_ostream.patch => 0011-Add-vectors-to-raw_ostream.patch} (98%) rename upstream_utils/llvm_patches/{0013-Extra-collections-features.patch => 0012-Extra-collections-features.patch} (96%) rename upstream_utils/llvm_patches/{0014-EpochTracker-ABI-macro.patch => 0013-EpochTracker-ABI-macro.patch} (74%) rename upstream_utils/llvm_patches/{0015-Delete-numbers-from-MathExtras.patch => 0014-Delete-numbers-from-MathExtras.patch} (89%) rename upstream_utils/llvm_patches/{0016-Add-lerp-and-sgn.patch => 0015-Add-lerp-and-sgn.patch} (82%) rename upstream_utils/llvm_patches/{0017-Fixup-includes.patch => 0016-Fixup-includes.patch} (93%) create mode 100644 upstream_utils/llvm_patches/0017-Use-std-is_trivially_copy_constructible.patch rename upstream_utils/llvm_patches/{0019-Windows-support.patch => 0018-Windows-support.patch} (99%) rename upstream_utils/llvm_patches/{0020-Prefer-fmtlib.patch => 0019-Prefer-fmtlib.patch} (98%) rename upstream_utils/llvm_patches/{0021-Prefer-wpi-s-fs.h.patch => 0020-Prefer-wpi-s-fs.h.patch} (87%) rename upstream_utils/llvm_patches/{0022-Remove-unused-functions.patch => 0021-Remove-unused-functions.patch} (92%) rename upstream_utils/llvm_patches/{0023-OS-specific-changes.patch => 0022-OS-specific-changes.patch} (97%) rename upstream_utils/llvm_patches/{0024-Use-SmallVector-for-UTF-conversion.patch => 0023-Use-SmallVector-for-UTF-conversion.patch} (97%) rename upstream_utils/llvm_patches/{0025-Prefer-to-use-static-pointers-in-raw_ostream.patch => 0024-Prefer-to-use-static-pointers-in-raw_ostream.patch} (94%) rename upstream_utils/llvm_patches/{0026-constexpr-endian-byte-swap.patch => 0025-constexpr-endian-byte-swap.patch} (95%) rename upstream_utils/llvm_patches/{0027-Copy-type-traits-from-STLExtras.h-into-PointerUnion..patch => 0026-Copy-type-traits-from-STLExtras.h-into-PointerUnion..patch} (94%) rename upstream_utils/llvm_patches/{0028-Remove-StringMap-test-for-llvm-sort.patch => 0027-Remove-StringMap-test-for-llvm-sort.patch} (80%) rename upstream_utils/llvm_patches/{0029-Unused-variable-in-release-mode.patch => 0028-Unused-variable-in-release-mode.patch} (85%) rename upstream_utils/llvm_patches/{0030-Use-C-20-bit-header.patch => 0029-Use-C-20-bit-header.patch} (64%) create mode 100644 upstream_utils/llvm_patches/0030-Remove-DenseMap-GTest-printer-test.patch create mode 100644 wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/xxhash.cpp create mode 100644 wpiutil/src/main/native/thirdparty/llvm/include/wpi/ADL.h delete mode 100644 wpiutil/src/main/native/thirdparty/llvm/include/wpi/DJB.h create mode 100644 wpiutil/src/main/native/thirdparty/llvm/include/wpi/DenseMapInfoVariant.h create mode 100644 wpiutil/src/main/native/thirdparty/llvm/include/wpi/xxhash.h create mode 100644 wpiutil/src/test/native/cpp/llvm/xxhashTest.cpp diff --git a/ntcore/src/main/native/cpp/net3/WireDecoder3.cpp b/ntcore/src/main/native/cpp/net3/WireDecoder3.cpp index 04d79cd43b2..51180279b54 100644 --- a/ntcore/src/main/native/cpp/net3/WireDecoder3.cpp +++ b/ntcore/src/main/native/cpp/net3/WireDecoder3.cpp @@ -73,7 +73,7 @@ std::optional WireDecoder3::SimpleValueReader::Read64( std::optional WireDecoder3::SimpleValueReader::ReadDouble( std::span* in) { if (auto val = Read64(in)) { - return wpi::BitsToDouble(val.value()); + return wpi::bit_cast(val.value()); } else { return std::nullopt; } diff --git a/ntcore/src/main/native/cpp/net3/WireEncoder3.cpp b/ntcore/src/main/native/cpp/net3/WireEncoder3.cpp index 6bf3435f8df..d1e4c784358 100644 --- a/ntcore/src/main/native/cpp/net3/WireEncoder3.cpp +++ b/ntcore/src/main/native/cpp/net3/WireEncoder3.cpp @@ -32,7 +32,7 @@ static void Write32(wpi::raw_ostream& os, uint32_t val) { static void WriteDouble(wpi::raw_ostream& os, double val) { // The highest performance way to do this, albeit non-portable. - uint64_t v = wpi::DoubleToBits(val); + uint64_t v = wpi::bit_cast(val); os << std::span{{static_cast((v >> 56) & 0xff), static_cast((v >> 48) & 0xff), static_cast((v >> 40) & 0xff), diff --git a/simulation/halsim_xrp/src/main/native/cpp/XRP.cpp b/simulation/halsim_xrp/src/main/native/cpp/XRP.cpp index 33a49c4b91b..a0e61c2e209 100644 --- a/simulation/halsim_xrp/src/main/native/cpp/XRP.cpp +++ b/simulation/halsim_xrp/src/main/native/cpp/XRP.cpp @@ -241,7 +241,8 @@ void XRP::SetupMotorTag(wpi::raw_uv_ostream& buf) { << static_cast(motor.first); // Channel // Convert the value - wpi::support::endian::write32be(value, wpi::FloatToBits(motor.second)); + wpi::support::endian::write32be(value, + wpi::bit_cast(motor.second)); buf << value[0] << value[1] << value[2] << value[3]; } } @@ -256,7 +257,8 @@ void XRP::SetupServoTag(wpi::raw_uv_ostream& buf) { << static_cast(servo.first); // Channel // Convert the value - wpi::support::endian::write32be(value, wpi::FloatToBits(servo.second)); + wpi::support::endian::write32be(value, + wpi::bit_cast(servo.second)); buf << value[0] << value[1] << value[2] << value[3]; } } @@ -277,12 +279,18 @@ void XRP::ReadGyroTag(std::span packet) { } packet = packet.subspan(2); // Skip past the size and tag - float rate_x = wpi::BitsToFloat(wpi::support::endian::read32be(&packet[0])); - float rate_y = wpi::BitsToFloat(wpi::support::endian::read32be(&packet[4])); - float rate_z = wpi::BitsToFloat(wpi::support::endian::read32be(&packet[8])); - float angle_x = wpi::BitsToFloat(wpi::support::endian::read32be(&packet[12])); - float angle_y = wpi::BitsToFloat(wpi::support::endian::read32be(&packet[16])); - float angle_z = wpi::BitsToFloat(wpi::support::endian::read32be(&packet[20])); + float rate_x = + wpi::bit_cast(wpi::support::endian::read32be(&packet[0])); + float rate_y = + wpi::bit_cast(wpi::support::endian::read32be(&packet[4])); + float rate_z = + wpi::bit_cast(wpi::support::endian::read32be(&packet[8])); + float angle_x = + wpi::bit_cast(wpi::support::endian::read32be(&packet[12])); + float angle_y = + wpi::bit_cast(wpi::support::endian::read32be(&packet[16])); + float angle_z = + wpi::bit_cast(wpi::support::endian::read32be(&packet[20])); // Make the json object wpi::json gyroJson; @@ -302,9 +310,12 @@ void XRP::ReadAccelTag(std::span packet) { } packet = packet.subspan(2); // Skip past the size and tag - float accel_x = wpi::BitsToFloat(wpi::support::endian::read32be(&packet[0])); - float accel_y = wpi::BitsToFloat(wpi::support::endian::read32be(&packet[4])); - float accel_z = wpi::BitsToFloat(wpi::support::endian::read32be(&packet[8])); + float accel_x = + wpi::bit_cast(wpi::support::endian::read32be(&packet[0])); + float accel_y = + wpi::bit_cast(wpi::support::endian::read32be(&packet[4])); + float accel_z = + wpi::bit_cast(wpi::support::endian::read32be(&packet[8])); wpi::json accelJson; accelJson["type"] = "Accel"; @@ -362,7 +373,8 @@ void XRP::ReadAnalogTag(std::span packet) { uint8_t analogId = packet[2]; packet = packet.subspan(3); - float voltage = wpi::BitsToFloat(wpi::support::endian::read32be(&packet[0])); + float voltage = + wpi::bit_cast(wpi::support::endian::read32be(&packet[0])); wpi::json analogJson; analogJson["type"] = "AI"; diff --git a/upstream_utils/llvm_patches/0001-Fix-spelling-language-errors.patch b/upstream_utils/llvm_patches/0001-Fix-spelling-language-errors.patch deleted file mode 100644 index 7780f65138e..00000000000 --- a/upstream_utils/llvm_patches/0001-Fix-spelling-language-errors.patch +++ /dev/null @@ -1,22 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: PJ Reiniger -Date: Sat, 7 May 2022 20:50:26 -0400 -Subject: [PATCH 01/31] Fix spelling/language errors - ---- - llvm/include/llvm/Support/ErrorHandling.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/llvm/include/llvm/Support/ErrorHandling.h b/llvm/include/llvm/Support/ErrorHandling.h -index 9c8e3448f3a03e3540adb8b9dd730c77dd9b20ba..dd1384a63af71b50ba1ccbb5933a1e472f50a39b 100644 ---- a/llvm/include/llvm/Support/ErrorHandling.h -+++ b/llvm/include/llvm/Support/ErrorHandling.h -@@ -44,7 +44,7 @@ namespace llvm { - void install_fatal_error_handler(fatal_error_handler_t handler, - void *user_data = nullptr); - -- /// Restores default error handling behaviour. -+ /// Restores default error handling behavior. - void remove_fatal_error_handler(); - - /// ScopedFatalErrorHandler - This is a simple helper class which just diff --git a/upstream_utils/llvm_patches/0002-Remove-StringRef-ArrayRef-and-Optional.patch b/upstream_utils/llvm_patches/0001-Remove-StringRef-ArrayRef-and-Optional.patch similarity index 90% rename from upstream_utils/llvm_patches/0002-Remove-StringRef-ArrayRef-and-Optional.patch rename to upstream_utils/llvm_patches/0001-Remove-StringRef-ArrayRef-and-Optional.patch index dd72392d10a..48327f82173 100644 --- a/upstream_utils/llvm_patches/0002-Remove-StringRef-ArrayRef-and-Optional.patch +++ b/upstream_utils/llvm_patches/0001-Remove-StringRef-ArrayRef-and-Optional.patch @@ -1,30 +1,31 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 7 May 2022 22:09:18 -0400 -Subject: [PATCH 02/31] Remove StringRef, ArrayRef, and Optional +Subject: [PATCH 01/31] Remove StringRef, ArrayRef, and Optional --- llvm/include/llvm/ADT/PointerUnion.h | 1 - llvm/include/llvm/ADT/SmallSet.h | 2 +- llvm/include/llvm/ADT/SmallString.h | 77 ++++++++++--------- llvm/include/llvm/ADT/SmallVector.h | 7 +- - llvm/include/llvm/ADT/StringMap.h | 34 ++++---- + llvm/include/llvm/ADT/StringMap.h | 38 ++++----- llvm/include/llvm/ADT/StringMapEntry.h | 20 ++--- llvm/include/llvm/Support/Chrono.h | 10 +-- llvm/include/llvm/Support/Compiler.h | 2 +- llvm/include/llvm/Support/ConvertUTF.h | 31 ++++---- - llvm/include/llvm/Support/DJB.h | 6 +- llvm/include/llvm/Support/ErrorHandling.h | 9 +-- .../llvm/Support/SmallVectorMemoryBuffer.h | 6 +- llvm/include/llvm/Support/VersionTuple.h | 6 -- .../llvm/Support/Windows/WindowsSupport.h | 4 +- llvm/include/llvm/Support/raw_ostream.h | 46 ++++++----- + llvm/include/llvm/Support/xxhash.h | 16 ++-- llvm/lib/Support/ConvertUTFWrapper.cpp | 38 ++++----- llvm/lib/Support/ErrorHandling.cpp | 13 ++-- llvm/lib/Support/SmallVector.cpp | 5 +- llvm/lib/Support/StringMap.cpp | 12 +-- llvm/lib/Support/raw_ostream.cpp | 25 +++--- - llvm/unittests/ADT/DenseMapTest.cpp | 25 ------ + llvm/lib/Support/xxhash.cpp | 10 +-- + llvm/unittests/ADT/DenseMapTest.cpp | 29 +------ llvm/unittests/ADT/FunctionExtrasTest.cpp | 12 +-- llvm/unittests/ADT/HashingTest.cpp | 2 +- llvm/unittests/ADT/SmallPtrSetTest.cpp | 1 - @@ -32,10 +33,11 @@ Subject: [PATCH 02/31] Remove StringRef, ArrayRef, and Optional llvm/unittests/ADT/SmallVectorTest.cpp | 30 ++------ llvm/unittests/ADT/StringMapTest.cpp | 32 ++++---- llvm/unittests/Support/ConvertUTFTest.cpp | 41 +++++----- - 28 files changed, 247 insertions(+), 300 deletions(-) + llvm/unittests/Support/xxhashTest.cpp | 4 +- + 30 files changed, 264 insertions(+), 315 deletions(-) diff --git a/llvm/include/llvm/ADT/PointerUnion.h b/llvm/include/llvm/ADT/PointerUnion.h -index 061c4000fcb3532f8d24bf015dffd0e1f58120d2..6abec033a4008057f30d445d47ab22ebbb046a2f 100644 +index 7d4ed02b622626bb8043acb57b8ce7ed97a5f949..8ac68dbc0a791b8ac0e0ca865e69024cb642aa70 100644 --- a/llvm/include/llvm/ADT/PointerUnion.h +++ b/llvm/include/llvm/ADT/PointerUnion.h @@ -17,7 +17,6 @@ @@ -47,7 +49,7 @@ index 061c4000fcb3532f8d24bf015dffd0e1f58120d2..6abec033a4008057f30d445d47ab22eb #include "llvm/Support/PointerLikeTypeTraits.h" #include diff --git a/llvm/include/llvm/ADT/SmallSet.h b/llvm/include/llvm/ADT/SmallSet.h -index 5ac868d58314ce42476bee5aa08dee5c7a9d1c17..06bc9b5556dd76432552ee79aa916b850f829f4d 100644 +index a16e8ac6f07552d98250e808190b00ee270f12b3..aeee5f97799aea7e7588d7afba1e47b4fa3d8c7b 100644 --- a/llvm/include/llvm/ADT/SmallSet.h +++ b/llvm/include/llvm/ADT/SmallSet.h @@ -16,12 +16,12 @@ @@ -313,7 +315,7 @@ index 0052c86fb37b82dcdf577a7acf06e3a47f54da61..4d673cc8b1c49cf8a3f19653de53881c return *this; } diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h -index 98dce891688dac9530c968e99440e239148faece..92cccb130466a47127fbf8092286f9c5052dd26c 100644 +index 53a107b1574c6a35c66c7fe3c61deb2ffc84b991..4559864ed231206b098936dae4fc378bfa986371 100644 --- a/llvm/include/llvm/ADT/SmallVector.h +++ b/llvm/include/llvm/ADT/SmallVector.h @@ -27,13 +27,12 @@ @@ -340,7 +342,7 @@ index 98dce891688dac9530c968e99440e239148faece..92cccb130466a47127fbf8092286f9c5 /// to avoid unnecessarily requiring T to be complete. template class SmallVectorTemplateCommon -@@ -1228,7 +1227,7 @@ public: +@@ -1233,7 +1232,7 @@ public: template ::value>> @@ -350,7 +352,7 @@ index 98dce891688dac9530c968e99440e239148faece..92cccb130466a47127fbf8092286f9c5 } diff --git a/llvm/include/llvm/ADT/StringMap.h b/llvm/include/llvm/ADT/StringMap.h -index 0849bef53ba164dbe524972f6ca5a761c7c10603..1c8cda7ef0f8e2984f2d7960260f2a109a2986f7 100644 +index 466f95254d102e98343290b211f317f749d7692b..34dfbf83c681f4e81a9dadd9382ddca6ef8d6c1d 100644 --- a/llvm/include/llvm/ADT/StringMap.h +++ b/llvm/include/llvm/ADT/StringMap.h @@ -60,12 +60,12 @@ protected: @@ -377,7 +379,7 @@ index 0849bef53ba164dbe524972f6ca5a761c7c10603..1c8cda7ef0f8e2984f2d7960260f2a10 /// Allocate the table with the specified number of buckets and otherwise /// setup the map as empty. -@@ -126,7 +126,7 @@ public: +@@ -127,7 +127,7 @@ public: : StringMapImpl(InitialSize, static_cast(sizeof(MapEntryTy))), AllocTy(A) {} @@ -386,7 +388,7 @@ index 0849bef53ba164dbe524972f6ca5a761c7c10603..1c8cda7ef0f8e2984f2d7960260f2a10 : StringMapImpl(List.size(), static_cast(sizeof(MapEntryTy))) { insert(List); } -@@ -214,14 +214,14 @@ public: +@@ -215,14 +215,14 @@ public: StringMapKeyIterator(end())); } @@ -403,29 +405,42 @@ index 0849bef53ba164dbe524972f6ca5a761c7c10603..1c8cda7ef0f8e2984f2d7960260f2a10 int Bucket = FindKey(Key); if (Bucket == -1) return end(); -@@ -230,7 +230,7 @@ public: +@@ -231,7 +231,7 @@ public: /// lookup - Return the entry for the specified key, or a default /// constructed value if no such entry exists. - ValueTy lookup(StringRef Key) const { + ValueTy lookup(std::string_view Key) const { - const_iterator it = find(Key); - if (it != end()) - return it->second; -@@ -239,10 +239,10 @@ public: + const_iterator Iter = find(Key); + if (Iter != end()) + return Iter->second; +@@ -240,7 +240,7 @@ public: + + /// at - Return the entry for the specified key, or abort if no such + /// entry exists. +- const ValueTy &at(StringRef Val) const { ++ const ValueTy &at(std::string_view Val) const { + auto Iter = this->find(std::move(Val)); + assert(Iter != this->end() && "StringMap::at failed due to a missing key"); + return Iter->second; +@@ -248,13 +248,13 @@ public: /// Lookup the ValueTy for the \p Key, or create a default constructed value /// if the key is not in the map. - ValueTy &operator[](StringRef Key) { return try_emplace(Key).first->second; } + ValueTy &operator[](std::string_view Key) { return try_emplace(Key).first->second; } + /// contains - Return true if the element is in the map, false otherwise. +- bool contains(StringRef Key) const { return find(Key) != end(); } ++ bool contains(std::string_view Key) const { return find(Key) != end(); } + /// count - Return 1 if the element is in the map, 0 otherwise. -- size_type count(StringRef Key) const { return find(Key) == end() ? 0 : 1; } -+ size_type count(std::string_view Key) const { return find(Key) == end() ? 0 : 1; } +- size_type count(StringRef Key) const { return contains(Key) ? 1 : 0; } ++ size_type count(std::string_view Key) const { return contains(Key) ? 1 : 0; } template size_type count(const StringMapEntry &MapEntry) const { -@@ -292,7 +292,7 @@ public: +@@ -304,7 +304,7 @@ public: /// isn't already in the map. The bool component of the returned pair is true /// if and only if the insertion takes place, and the iterator component of /// the pair points to the element with key equivalent to the key of the pair. @@ -434,7 +449,7 @@ index 0849bef53ba164dbe524972f6ca5a761c7c10603..1c8cda7ef0f8e2984f2d7960260f2a10 return try_emplace(KV.first, std::move(KV.second)); } -@@ -307,14 +307,14 @@ public: +@@ -319,14 +319,14 @@ public: /// Inserts elements from initializer list ilist. If multiple elements in /// the range have keys that compare equivalent, it is unspecified which /// element is inserted @@ -451,7 +466,7 @@ index 0849bef53ba164dbe524972f6ca5a761c7c10603..1c8cda7ef0f8e2984f2d7960260f2a10 auto Ret = try_emplace(Key, std::forward(Val)); if (!Ret.second) Ret.first->second = std::forward(Val); -@@ -326,7 +326,7 @@ public: +@@ -338,7 +338,7 @@ public: /// if and only if the insertion takes place, and the iterator component of /// the pair points to the element with key equivalent to the key of the pair. template @@ -460,7 +475,7 @@ index 0849bef53ba164dbe524972f6ca5a761c7c10603..1c8cda7ef0f8e2984f2d7960260f2a10 unsigned BucketNo = LookupBucketFor(Key); StringMapEntryBase *&Bucket = TheTable[BucketNo]; if (Bucket && Bucket != getTombstoneVal()) -@@ -373,7 +373,7 @@ public: +@@ -385,7 +385,7 @@ public: V.Destroy(getAllocator()); } @@ -469,7 +484,7 @@ index 0849bef53ba164dbe524972f6ca5a761c7c10603..1c8cda7ef0f8e2984f2d7960260f2a10 iterator I = find(Key); if (I == end()) return false; -@@ -470,17 +470,17 @@ template +@@ -482,17 +482,17 @@ template class StringMapKeyIterator : public iterator_adaptor_base, StringMapConstIterator, @@ -604,10 +619,10 @@ index 9c2bd45d2803e56ed316d8552d899d87f2fbbb07..a7dea19d9193bcff4bc6b553b80a10b2 bool show_unit = consumeShowUnit(Style); diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h -index cf330662cf4b4d2ec759f1d8d253e20210602a95..4a54933031baa90c6f21138fb1f04c5da89878a4 100644 +index 10d5cec231a523c943c37a5464cb3943627239a9..92376629c607461061bc60597a47aed1e535af52 100644 --- a/llvm/include/llvm/Support/Compiler.h +++ b/llvm/include/llvm/Support/Compiler.h -@@ -288,7 +288,7 @@ +@@ -300,7 +300,7 @@ #endif /// LLVM_GSL_POINTER - Apply this to non-owning classes like @@ -728,29 +743,8 @@ index c892bb3c03cb569994429649bdbb96e4118dcef1..5c0e3009c25446a34882fb98329b1d95 std::error_code UTF16ToUTF8(const wchar_t *utf16, size_t utf16_len, SmallVectorImpl &utf8); /// Convert from UTF16 to the current code page used in the system -diff --git a/llvm/include/llvm/Support/DJB.h b/llvm/include/llvm/Support/DJB.h -index 8a04a324a5dc6cccaaa6af7b0e9b340f0755587e..8737cd144c37f9041a781a74e9f2b43384e85761 100644 ---- a/llvm/include/llvm/Support/DJB.h -+++ b/llvm/include/llvm/Support/DJB.h -@@ -13,13 +13,13 @@ - #ifndef LLVM_SUPPORT_DJB_H - #define LLVM_SUPPORT_DJB_H - --#include "llvm/ADT/StringRef.h" -+#include - - namespace llvm { - - /// The Bernstein hash function used by the DWARF accelerator tables. --inline uint32_t djbHash(StringRef Buffer, uint32_t H = 5381) { -- for (unsigned char C : Buffer.bytes()) -+inline uint32_t djbHash(std::string_view Buffer, uint32_t H = 5381) { -+ for (unsigned char C : Buffer) - H = (H << 5) + H + C; - return H; - } diff --git a/llvm/include/llvm/Support/ErrorHandling.h b/llvm/include/llvm/Support/ErrorHandling.h -index dd1384a63af71b50ba1ccbb5933a1e472f50a39b..67e889fe26ac5ba1f4f81dc407210b76d507a517 100644 +index 9c8e3448f3a03e3540adb8b9dd730c77dd9b20ba..68c27a8c67c4f378b92cfa726659ef7824b56dea 100644 --- a/llvm/include/llvm/Support/ErrorHandling.h +++ b/llvm/include/llvm/Support/ErrorHandling.h @@ -15,10 +15,10 @@ @@ -852,7 +846,7 @@ index d3aacd14b2097b1e7e13c1003987c1fd52e0cf76..aabdb2f14668a990329b57f5454a0d7d template diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h -index 7c42f355fd431791116226f6c6934213a130141c..c8a94f46fab18dabc123fd709974138c8b0b0beb 100644 +index 1e01eb9ea19c4187302a91457b6d34fbe5b67584..2463f1af612a78cafafe3c0e16d496e607cdc322 100644 --- a/llvm/include/llvm/Support/raw_ostream.h +++ b/llvm/include/llvm/Support/raw_ostream.h @@ -14,13 +14,12 @@ @@ -972,8 +966,38 @@ index 7c42f355fd431791116226f6c6934213a130141c..c8a94f46fab18dabc123fd709974138c std::function Write); raw_ostream &operator<<(raw_ostream &OS, std::nullopt_t); +diff --git a/llvm/include/llvm/Support/xxhash.h b/llvm/include/llvm/Support/xxhash.h +index 0cef3a54e50d70177a7401324f7a4daca83c6599..3e19ebabb7ad0ff437220d9fdfe59a313386762a 100644 +--- a/llvm/include/llvm/Support/xxhash.h ++++ b/llvm/include/llvm/Support/xxhash.h +@@ -38,16 +38,18 @@ + #ifndef LLVM_SUPPORT_XXHASH_H + #define LLVM_SUPPORT_XXHASH_H + +-#include "llvm/ADT/ArrayRef.h" +-#include "llvm/ADT/StringRef.h" ++#include ++ ++#include ++#include + + namespace llvm { +-uint64_t xxHash64(llvm::StringRef Data); +-uint64_t xxHash64(llvm::ArrayRef Data); ++uint64_t xxHash64(std::string_view Data); ++uint64_t xxHash64(span Data); + +-uint64_t xxh3_64bits(ArrayRef data); +-inline uint64_t xxh3_64bits(StringRef data) { +- return xxh3_64bits(ArrayRef(data.bytes_begin(), data.size())); ++uint64_t xxh3_64bits(span data); ++inline uint64_t xxh3_64bits(std::string_view data) { ++ return xxh3_64bits(span(reinterpret_cast(data.data()), data.size())); + } + } + diff --git a/llvm/lib/Support/ConvertUTFWrapper.cpp b/llvm/lib/Support/ConvertUTFWrapper.cpp -index 9bf3f8f8b897c4f2c49fa65d8036412675526369..bb5164ff9dce0271cafc5889a049b5d343530f8d 100644 +index 3fa7365e72d34a5db941d1cbe2b1beebad5c10e6..d53462e742e61d3476915d5b2c5aa63772e78a8a 100644 --- a/llvm/lib/Support/ConvertUTFWrapper.cpp +++ b/llvm/lib/Support/ConvertUTFWrapper.cpp @@ -6,24 +6,24 @@ @@ -1184,10 +1208,10 @@ index f7e7e80332cc337f6dfa388d1e218e6f3ec95cf2..6cefdff7c28060ca18b522acf5279af3 } diff --git a/llvm/lib/Support/StringMap.cpp b/llvm/lib/Support/StringMap.cpp -index 9b2f96fca2cd035963f88dc462c5d723b7adf164..3c790039bffbc11b2db28cbf13c248fdccec4383 100644 +index 67c05a87959cf0c243d17646ae2f28f6c9f0d708..7be219323f6d76f32a9a841115f2f146141cdbab 100644 --- a/llvm/lib/Support/StringMap.cpp +++ b/llvm/lib/Support/StringMap.cpp -@@ -80,7 +80,7 @@ void StringMapImpl::init(unsigned InitSize) { +@@ -81,7 +81,7 @@ void StringMapImpl::init(unsigned InitSize) { /// specified bucket will be non-null. Otherwise, it will be null. In either /// case, the FullHashValue field of the bucket will be set to the hash value /// of the string. @@ -1196,7 +1220,7 @@ index 9b2f96fca2cd035963f88dc462c5d723b7adf164..3c790039bffbc11b2db28cbf13c248fd // Hash table unallocated so far? if (NumBuckets == 0) init(16); -@@ -118,7 +118,7 @@ unsigned StringMapImpl::LookupBucketFor(StringRef Name) { +@@ -121,7 +121,7 @@ unsigned StringMapImpl::LookupBucketFor(StringRef Name) { // Do the comparison like this because Name isn't necessarily // null-terminated! char *ItemStr = (char *)BucketItem + ItemSize; @@ -1205,7 +1229,7 @@ index 9b2f96fca2cd035963f88dc462c5d723b7adf164..3c790039bffbc11b2db28cbf13c248fd // We found a match! return BucketNo; } -@@ -136,7 +136,7 @@ unsigned StringMapImpl::LookupBucketFor(StringRef Name) { +@@ -139,7 +139,7 @@ unsigned StringMapImpl::LookupBucketFor(StringRef Name) { /// FindKey - Look up the bucket that contains the specified key. If it exists /// in the map, return the bucket number of the key. Otherwise return -1. /// This does not modify the map. @@ -1213,8 +1237,8 @@ index 9b2f96fca2cd035963f88dc462c5d723b7adf164..3c790039bffbc11b2db28cbf13c248fd +int StringMapImpl::FindKey(std::string_view Key) const { if (NumBuckets == 0) return -1; // Really empty table? - unsigned FullHashValue = djbHash(Key, 0); -@@ -161,7 +161,7 @@ int StringMapImpl::FindKey(StringRef Key) const { + unsigned FullHashValue = xxh3_64bits(Key); +@@ -166,7 +166,7 @@ int StringMapImpl::FindKey(StringRef Key) const { // Do the comparison like this because NameStart isn't necessarily // null-terminated! char *ItemStr = (char *)BucketItem + ItemSize; @@ -1223,7 +1247,7 @@ index 9b2f96fca2cd035963f88dc462c5d723b7adf164..3c790039bffbc11b2db28cbf13c248fd // We found a match! return BucketNo; } -@@ -180,14 +180,14 @@ int StringMapImpl::FindKey(StringRef Key) const { +@@ -185,14 +185,14 @@ int StringMapImpl::FindKey(StringRef Key) const { /// delete it. This aborts if the value isn't in the table. void StringMapImpl::RemoveKey(StringMapEntryBase *V) { const char *VStr = (char *)V + ItemSize; @@ -1241,7 +1265,7 @@ index 9b2f96fca2cd035963f88dc462c5d723b7adf164..3c790039bffbc11b2db28cbf13c248fd if (Bucket == -1) return nullptr; diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp -index fae4a4308fd7fdc2126932a097d8c9a366d0840b..ce3ffa575995b9f00f8d569176c7aeae7892d30d 100644 +index a4fc605019c211f93dde009e89e7a79b07400aa3..9966a0056ae4f24a7a38346ee1c2f5d83ac20248 100644 --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp @@ -166,7 +166,7 @@ raw_ostream &raw_ostream::write_uuid(const uuid_t UUID) { @@ -1339,11 +1363,61 @@ index fae4a4308fd7fdc2126932a097d8c9a366d0840b..ce3ffa575995b9f00f8d569176c7aeae std::function Write) { if (OutputFileName == "-") return Write(outs()); +diff --git a/llvm/lib/Support/xxhash.cpp b/llvm/lib/Support/xxhash.cpp +index 577f14189caff7d74377f7b28d8332deef4c62c4..b9c15e885a1751eaca43317323bd7a85fa201073 100644 +--- a/llvm/lib/Support/xxhash.cpp ++++ b/llvm/lib/Support/xxhash.cpp +@@ -84,11 +84,11 @@ static uint64_t XXH64_avalanche(uint64_t hash) { + return hash; + } + +-uint64_t llvm::xxHash64(StringRef Data) { ++uint64_t llvm::xxHash64(std::string_view Data) { + size_t Len = Data.size(); + uint64_t Seed = 0; +- const unsigned char *P = Data.bytes_begin(); +- const unsigned char *const BEnd = Data.bytes_end(); ++ const unsigned char *P = reinterpret_cast(Data.data()); ++ const unsigned char *const BEnd = P + Data.size(); + uint64_t H64; + + if (Len >= 32) { +@@ -144,7 +144,7 @@ uint64_t llvm::xxHash64(StringRef Data) { + return XXH64_avalanche(H64); + } + +-uint64_t llvm::xxHash64(ArrayRef Data) { ++uint64_t llvm::xxHash64(span Data) { + return xxHash64({(const char *)Data.data(), Data.size()}); + } + +@@ -394,7 +394,7 @@ static uint64_t XXH3_hashLong_64b(const uint8_t *input, size_t len, + (uint64_t)len * PRIME64_1); + } + +-uint64_t llvm::xxh3_64bits(ArrayRef data) { ++uint64_t llvm::xxh3_64bits(span data) { + auto *in = data.data(); + size_t len = data.size(); + if (len <= 16) diff --git a/llvm/unittests/ADT/DenseMapTest.cpp b/llvm/unittests/ADT/DenseMapTest.cpp -index 2d01316e658b8dbb6b77b8158da11701fedb9e94..ab575dfe920e314489025bb68e6113f6227fe41f 100644 +index cc3244528f27e2bd7eaa385d8b7f49b2fbb7a3e6..b710ac07461ba58faa99cedeae7f209dc0f5902b 100644 --- a/llvm/unittests/ADT/DenseMapTest.cpp +++ b/llvm/unittests/ADT/DenseMapTest.cpp -@@ -486,31 +486,6 @@ TEST(DenseMapCustomTest, ReserveTest) { +@@ -9,11 +9,11 @@ + #include "llvm/ADT/DenseMap.h" + #include "llvm/ADT/DenseMapInfo.h" + #include "llvm/ADT/DenseMapInfoVariant.h" +-#include "llvm/ADT/StringRef.h" + #include "gmock/gmock.h" + #include "gtest/gtest.h" + #include + #include ++#include + #include + #include + +@@ -499,31 +499,6 @@ TEST(DenseMapCustomTest, ReserveTest) { } } @@ -1375,6 +1449,15 @@ index 2d01316e658b8dbb6b77b8158da11701fedb9e94..ab575dfe920e314489025bb68e6113f6 // Key traits that allows lookup with either an unsigned or char* key; // In the latter case, "a" == 0, "b" == 1 and so on. struct TestDenseMapInfo { +@@ -761,7 +736,7 @@ TEST(DenseMapCustomTest, VariantSupport) { + // Test that gTest prints map entries as pairs instead of opaque objects. + // See third-party/unittest/googletest/internal/custom/gtest-printers.h + TEST(DenseMapCustomTest, PairPrinting) { +- DenseMap Map = {{1, "one"}, {2, "two"}}; ++ DenseMap Map = {{1, "one"}, {2, "two"}}; + EXPECT_EQ(R"({ (1, "one"), (2, "two") })", ::testing::PrintToString(Map)); + } + diff --git a/llvm/unittests/ADT/FunctionExtrasTest.cpp b/llvm/unittests/ADT/FunctionExtrasTest.cpp index fc856a976946bf6decda9b6724cac66afc7bdcd6..aff9d61c7f0d48834123b04b74a2e4f7c86a56d8 100644 --- a/llvm/unittests/ADT/FunctionExtrasTest.cpp @@ -1574,7 +1657,7 @@ index 2f4df8afeafa592cb9616bb78feb4964187786f2..6cf14700b34739420cd3dc4ff8a4c16c theString = "hellx xello hell ello world foo bar hello"; EXPECT_EQ(36U, theString.find("hello")); diff --git a/llvm/unittests/ADT/SmallVectorTest.cpp b/llvm/unittests/ADT/SmallVectorTest.cpp -index fd3780a42ce50404216f248bedf79002e69d4070..e1090e6f605696f60a82d1708605ddd45f4e15f8 100644 +index 137dd43b473068eae34b39edc4b9b8b9633bab95..7029038d18d433cef987bedbfa4fda269b24fb8f 100644 --- a/llvm/unittests/ADT/SmallVectorTest.cpp +++ b/llvm/unittests/ADT/SmallVectorTest.cpp @@ -11,10 +11,10 @@ @@ -1589,7 +1672,7 @@ index fd3780a42ce50404216f248bedf79002e69d4070..e1090e6f605696f60a82d1708605ddd4 #include using namespace llvm; -@@ -247,11 +247,11 @@ TYPED_TEST(SmallVectorTest, ConstructorIterTest) { +@@ -252,11 +252,11 @@ TYPED_TEST(SmallVectorTest, ConstructorIterTest) { } // Constructor test. @@ -1604,7 +1687,7 @@ index fd3780a42ce50404216f248bedf79002e69d4070..e1090e6f605696f60a82d1708605ddd4 auto &V = this->theVector; V = SmallVector(Array); assertValuesInOrder(V, 3u, 1, 2, 3); -@@ -1124,24 +1124,6 @@ TEST(SmallVectorTest, DefaultInlinedElements) { +@@ -1129,24 +1129,6 @@ TEST(SmallVectorTest, DefaultInlinedElements) { EXPECT_EQ(NestedV[0][0][0], 42); } @@ -1629,7 +1712,7 @@ index fd3780a42ce50404216f248bedf79002e69d4070..e1090e6f605696f60a82d1708605ddd4 TEST(SmallVectorTest, ToVector) { { std::vector v = {'a', 'b', 'c'}; -@@ -1178,10 +1160,10 @@ private: +@@ -1183,10 +1165,10 @@ private: To T; }; @@ -1643,7 +1726,7 @@ index fd3780a42ce50404216f248bedf79002e69d4070..e1090e6f605696f60a82d1708605ddd4 llvm::SmallVector Vector(Array); diff --git a/llvm/unittests/ADT/StringMapTest.cpp b/llvm/unittests/ADT/StringMapTest.cpp -index f40f22ad140cbe7c2d2dd1ea6697cc2570ed51c3..ff68c66bd1eda0aa4fb78702875ff734557eb07d 100644 +index f9b138e9a472137139397d9cae76823711594211..7f10b3d7d3a8894b1ab0ac660268d94a8b89e082 100644 --- a/llvm/unittests/ADT/StringMapTest.cpp +++ b/llvm/unittests/ADT/StringMapTest.cpp @@ -7,8 +7,6 @@ @@ -1655,9 +1738,9 @@ index f40f22ad140cbe7c2d2dd1ea6697cc2570ed51c3..ff68c66bd1eda0aa4fb78702875ff734 #include "llvm/Support/DataTypes.h" #include "gtest/gtest.h" #include -@@ -42,10 +40,10 @@ protected: - +@@ -43,10 +41,10 @@ protected: // Lookup tests + EXPECT_FALSE(testMap.contains(testKey)); EXPECT_EQ(0u, testMap.count(testKey)); - EXPECT_EQ(0u, testMap.count(StringRef(testKeyFirst, testKeyLength))); + EXPECT_EQ(0u, testMap.count(std::string_view(testKeyFirst, testKeyLength))); @@ -1668,9 +1751,9 @@ index f40f22ad140cbe7c2d2dd1ea6697cc2570ed51c3..ff68c66bd1eda0aa4fb78702875ff734 testMap.end()); EXPECT_TRUE(testMap.find(testKeyStr) == testMap.end()); } -@@ -65,10 +63,10 @@ protected: - +@@ -67,10 +65,10 @@ protected: // Lookup tests + EXPECT_TRUE(testMap.contains(testKey)); EXPECT_EQ(1u, testMap.count(testKey)); - EXPECT_EQ(1u, testMap.count(StringRef(testKeyFirst, testKeyLength))); + EXPECT_EQ(1u, testMap.count(std::string_view(testKeyFirst, testKeyLength))); @@ -1681,7 +1764,7 @@ index f40f22ad140cbe7c2d2dd1ea6697cc2570ed51c3..ff68c66bd1eda0aa4fb78702875ff734 testMap.begin()); EXPECT_TRUE(testMap.find(testKeyStr) == testMap.begin()); } -@@ -106,10 +104,10 @@ TEST_F(StringMapTest, ConstEmptyMapTest) { +@@ -108,10 +106,10 @@ TEST_F(StringMapTest, ConstEmptyMapTest) { // Lookup tests EXPECT_EQ(0u, constTestMap.count(testKey)); @@ -1694,7 +1777,7 @@ index f40f22ad140cbe7c2d2dd1ea6697cc2570ed51c3..ff68c66bd1eda0aa4fb78702875ff734 constTestMap.end()); EXPECT_TRUE(constTestMap.find(testKeyStr) == constTestMap.end()); } -@@ -237,7 +235,7 @@ TEST_F(StringMapTest, StringMapEntryTest) { +@@ -251,7 +249,7 @@ TEST_F(StringMapTest, StringMapEntryTest) { MallocAllocator Allocator; StringMap::value_type *entry = StringMap::value_type::create( @@ -1703,7 +1786,7 @@ index f40f22ad140cbe7c2d2dd1ea6697cc2570ed51c3..ff68c66bd1eda0aa4fb78702875ff734 EXPECT_STREQ(testKey, entry->first().data()); EXPECT_EQ(1u, entry->second); entry->Destroy(Allocator); -@@ -247,7 +245,7 @@ TEST_F(StringMapTest, StringMapEntryTest) { +@@ -261,7 +259,7 @@ TEST_F(StringMapTest, StringMapEntryTest) { TEST_F(StringMapTest, InsertTest) { SCOPED_TRACE("InsertTest"); testMap.insert(StringMap::value_type::create( @@ -1712,7 +1795,7 @@ index f40f22ad140cbe7c2d2dd1ea6697cc2570ed51c3..ff68c66bd1eda0aa4fb78702875ff734 assertSingleItemMap(); } -@@ -316,10 +314,10 @@ TEST_F(StringMapTest, IterMapKeysVector) { +@@ -330,10 +328,10 @@ TEST_F(StringMapTest, IterMapKeysVector) { Map["C"] = 3; Map["D"] = 3; @@ -1725,7 +1808,7 @@ index f40f22ad140cbe7c2d2dd1ea6697cc2570ed51c3..ff68c66bd1eda0aa4fb78702875ff734 EXPECT_EQ(Expected, Keys); } -@@ -333,7 +331,7 @@ TEST_F(StringMapTest, IterMapKeysSmallVector) { +@@ -347,7 +345,7 @@ TEST_F(StringMapTest, IterMapKeysSmallVector) { auto Keys = to_vector<4>(Map.keys()); llvm::sort(Keys); @@ -1734,7 +1817,7 @@ index f40f22ad140cbe7c2d2dd1ea6697cc2570ed51c3..ff68c66bd1eda0aa4fb78702875ff734 EXPECT_EQ(Expected, Keys); } -@@ -375,13 +373,13 @@ private: +@@ -389,13 +387,13 @@ private: TEST_F(StringMapTest, MoveOnly) { StringMap t; t.insert(std::make_pair("Test", MoveOnly(42))); @@ -1750,7 +1833,7 @@ index f40f22ad140cbe7c2d2dd1ea6697cc2570ed51c3..ff68c66bd1eda0aa4fb78702875ff734 MallocAllocator Allocator; StringMapEntry::create(Key, Allocator, Immovable()) ->Destroy(Allocator); -@@ -566,7 +564,7 @@ TEST(StringMapCustomTest, InitialSizeTest) { +@@ -580,7 +578,7 @@ TEST(StringMapCustomTest, InitialSizeTest) { CountCtorCopyAndMove::Copy = 0; for (int i = 0; i < Size; ++i) Map.insert(std::pair( @@ -1759,7 +1842,7 @@ index f40f22ad140cbe7c2d2dd1ea6697cc2570ed51c3..ff68c66bd1eda0aa4fb78702875ff734 std::forward_as_tuple(i))); // After the initial move, the map will move the Elts in the Entry. EXPECT_EQ((unsigned)Size * 2, CountCtorCopyAndMove::Move); -@@ -635,7 +633,7 @@ TEST(StringMapCustomTest, StringMapEntrySize) { +@@ -649,7 +647,7 @@ TEST(StringMapCustomTest, StringMapEntrySize) { else LargeValue = std::numeric_limits::max() + 1ULL; StringMapEntry LargeEntry(LargeValue); @@ -1927,3 +2010,25 @@ index 6e75fbae0969ba1bf0a76c4d79a123e405a8dae7..3b07d344f15a555f11ad5f8177a0a65b // Overlong sequences of the above. EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars( +diff --git a/llvm/unittests/Support/xxhashTest.cpp b/llvm/unittests/Support/xxhashTest.cpp +index 7d78de6772b5159459572fe11633c76d04b86907..d61a5acd21f4d685ca631d3adb20c2649e050bc3 100644 +--- a/llvm/unittests/Support/xxhashTest.cpp ++++ b/llvm/unittests/Support/xxhashTest.cpp +@@ -12,7 +12,7 @@ + using namespace llvm; + + TEST(xxhashTest, Basic) { +- EXPECT_EQ(0xef46db3751d8e999U, xxHash64(StringRef())); ++ EXPECT_EQ(0xef46db3751d8e999U, xxHash64(std::string_view())); + EXPECT_EQ(0x33bf00a859c4ba3fU, xxHash64("foo")); + EXPECT_EQ(0x48a37c90ad27a659U, xxHash64("bar")); + EXPECT_EQ(0x69196c1b3af0bff9U, +@@ -31,7 +31,7 @@ TEST(xxhashTest, xxh3) { + } + + #define F(len, expected) \ +- EXPECT_EQ(uint64_t(expected), xxh3_64bits(ArrayRef(a, size_t(len)))) ++ EXPECT_EQ(uint64_t(expected), xxh3_64bits(span(a, size_t(len)))) + F(0, 0x2d06800538d394c2); + F(1, 0xd0d496e05c553485); + F(2, 0x84d625edb7055eac); diff --git a/upstream_utils/llvm_patches/0003-Wrap-std-min-max-calls-in-parens-for-Windows-warning.patch b/upstream_utils/llvm_patches/0002-Wrap-std-min-max-calls-in-parens-for-Windows-warning.patch similarity index 78% rename from upstream_utils/llvm_patches/0003-Wrap-std-min-max-calls-in-parens-for-Windows-warning.patch rename to upstream_utils/llvm_patches/0002-Wrap-std-min-max-calls-in-parens-for-Windows-warning.patch index 1fc7cdbf76e..fe5c48ef497 100644 --- a/upstream_utils/llvm_patches/0003-Wrap-std-min-max-calls-in-parens-for-Windows-warning.patch +++ b/upstream_utils/llvm_patches/0002-Wrap-std-min-max-calls-in-parens-for-Windows-warning.patch @@ -1,20 +1,20 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 7 May 2022 22:12:41 -0400 -Subject: [PATCH 03/31] Wrap std::min/max calls in parens, for Windows warnings +Subject: [PATCH 02/31] Wrap std::min/max calls in parens, for Windows warnings --- llvm/include/llvm/ADT/DenseMap.h | 4 ++-- llvm/include/llvm/ADT/SmallVector.h | 12 ++++++------ llvm/include/llvm/Support/ConvertUTF.h | 2 +- - llvm/include/llvm/Support/MathExtras.h | 22 +++++++++++----------- - 4 files changed, 20 insertions(+), 20 deletions(-) + llvm/include/llvm/Support/MathExtras.h | 18 +++++++++--------- + 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h -index 7adc6710cfa86db119446580246fc94a16dd9b3c..7f4ddc256a207289980b60385f02da69f7119578 100644 +index 3ef6a7cd1b4b587e61fcb9475d9f3516018bf2ee..108193f04486425f3b7f039cd9d2004be6facafb 100644 --- a/llvm/include/llvm/ADT/DenseMap.h +++ b/llvm/include/llvm/ADT/DenseMap.h -@@ -389,7 +389,7 @@ protected: +@@ -416,7 +416,7 @@ protected: return 0; // +1 is required because of the strict equality. // For example if NumEntries is 48, we need to return 401. @@ -23,7 +23,7 @@ index 7adc6710cfa86db119446580246fc94a16dd9b3c..7f4ddc256a207289980b60385f02da69 } void moveFromOldBuckets(BucketT *OldBucketsBegin, BucketT *OldBucketsEnd) { -@@ -825,7 +825,7 @@ public: +@@ -852,7 +852,7 @@ public: // Reduce the number of buckets. unsigned NewNumBuckets = 0; if (OldNumEntries) @@ -33,7 +33,7 @@ index 7adc6710cfa86db119446580246fc94a16dd9b3c..7f4ddc256a207289980b60385f02da69 this->BaseT::initEmpty(); return; diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h -index 92cccb130466a47127fbf8092286f9c5052dd26c..4a93f4c1d8102fc322ebde9c3c697877a1b9048a 100644 +index 4559864ed231206b098936dae4fc378bfa986371..84f4d0931a30f4be29549354c85cb4c0489e14c9 100644 --- a/llvm/include/llvm/ADT/SmallVector.h +++ b/llvm/include/llvm/ADT/SmallVector.h @@ -55,12 +55,12 @@ protected: @@ -101,28 +101,10 @@ index 5c0e3009c25446a34882fb98329b1d955231bb39..72321022beb373945f7935ed72944fd6 /* Some fundamental constants */ #define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h -index ff136ba2a8848e61fc85923e031fb3d60904a33d..45840976a09a733b69dee4070f2f9f8339455da2 100644 +index dc095941fdc8a9f2b3b822e6e014f0640676c0d3..0bd572d07fcbf2ff56998dbf366215068b62f527 100644 --- a/llvm/include/llvm/Support/MathExtras.h +++ b/llvm/include/llvm/Support/MathExtras.h -@@ -100,7 +100,7 @@ template unsigned countLeadingZeros(T Val) { - /// \param ZB the behavior on an input of 0. - template T findFirstSet(T Val, ZeroBehavior ZB = ZB_Max) { - if (ZB == ZB_Max && Val == 0) -- return std::numeric_limits::max(); -+ return (std::numeric_limits::max)(); - - return llvm::countr_zero(Val); - } -@@ -140,7 +140,7 @@ template T maskLeadingZeros(unsigned N) { - /// \param ZB the behavior on an input of 0. - template T findLastSet(T Val, ZeroBehavior ZB = ZB_Max) { - if (ZB == ZB_Max && Val == 0) -- return std::numeric_limits::max(); -+ return (std::numeric_limits::max)(); - - // Use ^ instead of - because both gcc and llvm can remove the associated ^ - // in the __builtin_clz intrinsic on x86. -@@ -407,26 +407,26 @@ template <> constexpr inline size_t CTLog2<1>() { return 0; } +@@ -311,26 +311,26 @@ template <> constexpr inline size_t CTLog2<1>() { return 0; } /// (32 bit edition.) /// Ex. Log2_32(32) == 5, Log2_32(1) == 0, Log2_32(0) == -1, Log2_32(6) == 2 inline unsigned Log2_32(uint32_t Value) { @@ -152,8 +134,8 @@ index ff136ba2a8848e61fc85923e031fb3d60904a33d..45840976a09a733b69dee4070f2f9f83 + return static_cast(64 - llvm::countl_zero(Value - 1)); } - /// This function takes a 64-bit integer and returns the bit equivalent double. -@@ -609,7 +609,7 @@ SaturatingAdd(T X, T Y, bool *ResultOverflowed = nullptr) { + /// A and B are either alignments or offsets. Return the minimum alignment that +@@ -479,7 +479,7 @@ SaturatingAdd(T X, T Y, bool *ResultOverflowed = nullptr) { T Z = X + Y; Overflowed = (Z < X || Z < Y); if (Overflowed) @@ -162,7 +144,7 @@ index ff136ba2a8848e61fc85923e031fb3d60904a33d..45840976a09a733b69dee4070f2f9f83 else return Z; } -@@ -622,7 +622,7 @@ std::enable_if_t, T> SaturatingAdd(T X, T Y, T Z, +@@ -492,7 +492,7 @@ std::enable_if_t, T> SaturatingAdd(T X, T Y, T Z, bool Overflowed = false; T XY = SaturatingAdd(X, Y, &Overflowed); if (Overflowed) @@ -171,7 +153,7 @@ index ff136ba2a8848e61fc85923e031fb3d60904a33d..45840976a09a733b69dee4070f2f9f83 return SaturatingAdd(XY, Z, Args...); } -@@ -646,7 +646,7 @@ SaturatingMultiply(T X, T Y, bool *ResultOverflowed = nullptr) { +@@ -516,7 +516,7 @@ SaturatingMultiply(T X, T Y, bool *ResultOverflowed = nullptr) { // Special case: if X or Y is 0, Log2_64 gives -1, and Log2Z // will necessarily be less than Log2Max as desired. int Log2Z = Log2_64(X) + Log2_64(Y); @@ -180,7 +162,7 @@ index ff136ba2a8848e61fc85923e031fb3d60904a33d..45840976a09a733b69dee4070f2f9f83 int Log2Max = Log2_64(Max); if (Log2Z < Log2Max) { return X * Y; -@@ -766,9 +766,9 @@ std::enable_if_t::value, T> MulOverflow(T X, T Y, T &Result) { +@@ -636,9 +636,9 @@ std::enable_if_t, T> MulOverflow(T X, T Y, T &Result) { // Check how the max allowed absolute value (2^n for negative, 2^(n-1) for // positive) divided by an argument compares to the other. if (IsNegative) diff --git a/upstream_utils/llvm_patches/0004-Change-unique_function-storage-size.patch b/upstream_utils/llvm_patches/0003-Change-unique_function-storage-size.patch similarity index 89% rename from upstream_utils/llvm_patches/0004-Change-unique_function-storage-size.patch rename to upstream_utils/llvm_patches/0003-Change-unique_function-storage-size.patch index 7eefcef62d0..c4e5176663b 100644 --- a/upstream_utils/llvm_patches/0004-Change-unique_function-storage-size.patch +++ b/upstream_utils/llvm_patches/0003-Change-unique_function-storage-size.patch @@ -1,14 +1,14 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 7 May 2022 22:13:55 -0400 -Subject: [PATCH 04/31] Change unique_function storage size +Subject: [PATCH 03/31] Change unique_function storage size --- llvm/include/llvm/ADT/FunctionExtras.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/include/llvm/ADT/FunctionExtras.h b/llvm/include/llvm/ADT/FunctionExtras.h -index 8f04277cdf0e5b3d3b0be4a307cf0e4fada810fd..ba145bf783775042ff4a2d4be4bb048f16db669d 100644 +index 4cf1de488c7bde2692d4878ccb4c4d60241e3a66..9d10b16e3cbe9c0df818a3254fcd3a6032d54b39 100644 --- a/llvm/include/llvm/ADT/FunctionExtras.h +++ b/llvm/include/llvm/ADT/FunctionExtras.h @@ -78,7 +78,7 @@ using EnableIfCallable = std::enable_if_t Date: Sat, 7 May 2022 22:17:19 -0400 -Subject: [PATCH 05/31] Threading updates +Subject: [PATCH 04/31] Threading updates - Remove guards for threads and exception - Prefer scope gaurd over lock gaurd @@ -12,10 +12,10 @@ Subject: [PATCH 05/31] Threading updates 3 files changed, 11 insertions(+), 43 deletions(-) diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h -index 4a54933031baa90c6f21138fb1f04c5da89878a4..ef9c0d1a73aec870b924faace3b4a32b187e197f 100644 +index 92376629c607461061bc60597a47aed1e535af52..2662839b27bf368cd5da0668099c4b44cbc6435d 100644 --- a/llvm/include/llvm/Support/Compiler.h +++ b/llvm/include/llvm/Support/Compiler.h -@@ -518,7 +518,6 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); +@@ -530,7 +530,6 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); /// initialize to some constant value. In almost all circumstances this is most /// appropriate for use with a pointer, integer, or small aggregation of /// pointers and integers. @@ -23,7 +23,7 @@ index 4a54933031baa90c6f21138fb1f04c5da89878a4..ef9c0d1a73aec870b924faace3b4a32b #if __has_feature(cxx_thread_local) || defined(_MSC_VER) #define LLVM_THREAD_LOCAL thread_local #else -@@ -526,11 +525,6 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); +@@ -538,11 +537,6 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); // we only need the restricted functionality that provides. #define LLVM_THREAD_LOCAL __thread #endif diff --git a/upstream_utils/llvm_patches/0006-ifdef-guard-safety.patch b/upstream_utils/llvm_patches/0005-ifdef-guard-safety.patch similarity index 92% rename from upstream_utils/llvm_patches/0006-ifdef-guard-safety.patch rename to upstream_utils/llvm_patches/0005-ifdef-guard-safety.patch index 1aee3b5a3bd..e74cf17593e 100644 --- a/upstream_utils/llvm_patches/0006-ifdef-guard-safety.patch +++ b/upstream_utils/llvm_patches/0005-ifdef-guard-safety.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 7 May 2022 22:28:13 -0400 -Subject: [PATCH 06/31] \#ifdef guard safety +Subject: [PATCH 05/31] \#ifdef guard safety Prevents redefinition if someone is pulling in real LLVM, since the macros are in global namespace --- @@ -9,7 +9,7 @@ Prevents redefinition if someone is pulling in real LLVM, since the macros are i 1 file changed, 42 insertions(+) diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h -index ef9c0d1a73aec870b924faace3b4a32b187e197f..53c272034ae8f735d02556ced5bae93a1c8644c4 100644 +index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e848519998685b 100644 --- a/llvm/include/llvm/Support/Compiler.h +++ b/llvm/include/llvm/Support/Compiler.h @@ -90,6 +90,7 @@ @@ -28,7 +28,7 @@ index ef9c0d1a73aec870b924faace3b4a32b187e197f..53c272034ae8f735d02556ced5bae93a /// LLVM_LIBRARY_VISIBILITY - If a class marked with this attribute is linked /// into a shared library, then the class should be private to the library and -@@ -127,17 +129,21 @@ +@@ -139,17 +141,21 @@ #define LLVM_EXTERNAL_VISIBILITY #endif @@ -50,7 +50,7 @@ index ef9c0d1a73aec870b924faace3b4a32b187e197f..53c272034ae8f735d02556ced5bae93a #if defined(__clang__) #define LLVM_DEPRECATED(MSG, FIX) __attribute__((deprecated(MSG, FIX))) -@@ -166,11 +172,13 @@ +@@ -178,11 +184,13 @@ // more portable solution: // (void)unused_var_name; // Prefer cast-to-void wherever it is sufficient. @@ -64,7 +64,7 @@ index ef9c0d1a73aec870b924faace3b4a32b187e197f..53c272034ae8f735d02556ced5bae93a // FIXME: Provide this for PE/COFF targets. #if __has_attribute(weak) && !defined(__MINGW32__) && !defined(__CYGWIN__) && \ -@@ -180,6 +188,7 @@ +@@ -192,6 +200,7 @@ #define LLVM_ATTRIBUTE_WEAK #endif @@ -72,7 +72,7 @@ index ef9c0d1a73aec870b924faace3b4a32b187e197f..53c272034ae8f735d02556ced5bae93a // Prior to clang 3.2, clang did not accept any spelling of // __has_attribute(const), so assume it is supported. #if defined(__clang__) || defined(__GNUC__) -@@ -188,13 +197,16 @@ +@@ -200,13 +209,16 @@ #else #define LLVM_READNONE #endif @@ -89,7 +89,7 @@ index ef9c0d1a73aec870b924faace3b4a32b187e197f..53c272034ae8f735d02556ced5bae93a #if __has_attribute(minsize) #define LLVM_ATTRIBUTE_MINSIZE __attribute__((minsize)) -@@ -202,6 +214,7 @@ +@@ -214,6 +226,7 @@ #define LLVM_ATTRIBUTE_MINSIZE #endif @@ -97,7 +97,7 @@ index ef9c0d1a73aec870b924faace3b4a32b187e197f..53c272034ae8f735d02556ced5bae93a #if __has_builtin(__builtin_expect) || defined(__GNUC__) #define LLVM_LIKELY(EXPR) __builtin_expect((bool)(EXPR), true) #define LLVM_UNLIKELY(EXPR) __builtin_expect((bool)(EXPR), false) -@@ -209,9 +222,11 @@ +@@ -221,9 +234,11 @@ #define LLVM_LIKELY(EXPR) (EXPR) #define LLVM_UNLIKELY(EXPR) (EXPR) #endif @@ -109,7 +109,7 @@ index ef9c0d1a73aec870b924faace3b4a32b187e197f..53c272034ae8f735d02556ced5bae93a #if __has_attribute(noinline) #define LLVM_ATTRIBUTE_NOINLINE __attribute__((noinline)) #elif defined(_MSC_VER) -@@ -219,9 +234,11 @@ +@@ -231,9 +246,11 @@ #else #define LLVM_ATTRIBUTE_NOINLINE #endif @@ -121,7 +121,7 @@ index ef9c0d1a73aec870b924faace3b4a32b187e197f..53c272034ae8f735d02556ced5bae93a #if __has_attribute(always_inline) #define LLVM_ATTRIBUTE_ALWAYS_INLINE inline __attribute__((always_inline)) #elif defined(_MSC_VER) -@@ -229,6 +246,7 @@ +@@ -241,6 +258,7 @@ #else #define LLVM_ATTRIBUTE_ALWAYS_INLINE inline #endif @@ -129,7 +129,7 @@ index ef9c0d1a73aec870b924faace3b4a32b187e197f..53c272034ae8f735d02556ced5bae93a /// LLVM_ATTRIBUTE_NO_DEBUG - On compilers where we have a directive to do /// so, mark a method "no debug" because debug info makes the debugger -@@ -239,6 +257,7 @@ +@@ -251,6 +269,7 @@ #define LLVM_ATTRIBUTE_NODEBUG #endif @@ -137,7 +137,7 @@ index ef9c0d1a73aec870b924faace3b4a32b187e197f..53c272034ae8f735d02556ced5bae93a #if __has_attribute(returns_nonnull) #define LLVM_ATTRIBUTE_RETURNS_NONNULL __attribute__((returns_nonnull)) #elif defined(_MSC_VER) -@@ -246,9 +265,11 @@ +@@ -258,9 +277,11 @@ #else #define LLVM_ATTRIBUTE_RETURNS_NONNULL #endif @@ -149,7 +149,7 @@ index ef9c0d1a73aec870b924faace3b4a32b187e197f..53c272034ae8f735d02556ced5bae93a #ifdef __GNUC__ #define LLVM_ATTRIBUTE_RETURNS_NOALIAS __attribute__((__malloc__)) #elif defined(_MSC_VER) -@@ -256,8 +277,10 @@ +@@ -268,8 +289,10 @@ #else #define LLVM_ATTRIBUTE_RETURNS_NOALIAS #endif @@ -160,7 +160,7 @@ index ef9c0d1a73aec870b924faace3b4a32b187e197f..53c272034ae8f735d02556ced5bae93a #if defined(__cplusplus) && __cplusplus > 201402L && LLVM_HAS_CPP_ATTRIBUTE(fallthrough) #define LLVM_FALLTHROUGH [[fallthrough]] #elif LLVM_HAS_CPP_ATTRIBUTE(gnu::fallthrough) -@@ -269,6 +292,7 @@ +@@ -281,6 +304,7 @@ #else #define LLVM_FALLTHROUGH #endif @@ -168,7 +168,7 @@ index ef9c0d1a73aec870b924faace3b4a32b187e197f..53c272034ae8f735d02556ced5bae93a /// LLVM_REQUIRE_CONSTANT_INITIALIZATION - Apply this to globals to ensure that /// they are constant initialized. -@@ -297,11 +321,13 @@ +@@ -309,11 +333,13 @@ /// LLVM_EXTENSION - Support compilers where we have a keyword to suppress /// pedantic diagnostics. @@ -182,7 +182,7 @@ index ef9c0d1a73aec870b924faace3b4a32b187e197f..53c272034ae8f735d02556ced5bae93a /// LLVM_BUILTIN_UNREACHABLE - On compilers which support it, expands /// to an expression which states that it is undefined behavior for the -@@ -310,14 +336,17 @@ +@@ -322,14 +348,17 @@ /// '#else' is intentionally left out so that other macro logic (e.g., /// LLVM_ASSUME_ALIGNED and llvm_unreachable()) can detect whether /// LLVM_BUILTIN_UNREACHABLE has a definition. @@ -200,7 +200,7 @@ index ef9c0d1a73aec870b924faace3b4a32b187e197f..53c272034ae8f735d02556ced5bae93a #if __has_builtin(__builtin_trap) || defined(__GNUC__) # define LLVM_BUILTIN_TRAP __builtin_trap() #elif defined(_MSC_VER) -@@ -329,10 +358,12 @@ +@@ -341,10 +370,12 @@ #else # define LLVM_BUILTIN_TRAP *(volatile int*)0x11 = 0 #endif @@ -213,7 +213,7 @@ index ef9c0d1a73aec870b924faace3b4a32b187e197f..53c272034ae8f735d02556ced5bae93a #if __has_builtin(__builtin_debugtrap) # define LLVM_BUILTIN_DEBUGTRAP __builtin_debugtrap() #elif defined(_MSC_VER) -@@ -346,9 +377,11 @@ +@@ -358,9 +389,11 @@ // program to abort if encountered. # define LLVM_BUILTIN_DEBUGTRAP #endif @@ -225,7 +225,7 @@ index ef9c0d1a73aec870b924faace3b4a32b187e197f..53c272034ae8f735d02556ced5bae93a #if __has_builtin(__builtin_assume_aligned) || defined(__GNUC__) # define LLVM_ASSUME_ALIGNED(p, a) __builtin_assume_aligned(p, a) #elif defined(LLVM_BUILTIN_UNREACHABLE) -@@ -357,6 +390,7 @@ +@@ -369,6 +402,7 @@ #else # define LLVM_ASSUME_ALIGNED(p, a) (p) #endif @@ -233,7 +233,7 @@ index ef9c0d1a73aec870b924faace3b4a32b187e197f..53c272034ae8f735d02556ced5bae93a /// \macro LLVM_PACKED /// Used to specify a packed structure. -@@ -376,6 +410,7 @@ +@@ -388,6 +422,7 @@ /// long long l; /// }; /// LLVM_PACKED_END @@ -241,7 +241,7 @@ index ef9c0d1a73aec870b924faace3b4a32b187e197f..53c272034ae8f735d02556ced5bae93a #ifdef _MSC_VER # define LLVM_PACKED(d) __pragma(pack(push, 1)) d __pragma(pack(pop)) # define LLVM_PACKED_START __pragma(pack(push, 1)) -@@ -385,6 +420,7 @@ +@@ -397,6 +432,7 @@ # define LLVM_PACKED_START _Pragma("pack(push, 1)") # define LLVM_PACKED_END _Pragma("pack(pop)") #endif @@ -249,7 +249,7 @@ index ef9c0d1a73aec870b924faace3b4a32b187e197f..53c272034ae8f735d02556ced5bae93a /// \macro LLVM_MEMORY_SANITIZER_BUILD /// Whether LLVM itself is built with MemorySanitizer instrumentation. -@@ -476,11 +512,13 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); +@@ -488,11 +524,13 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); /// \macro LLVM_NO_SANITIZE /// Disable a particular sanitizer for a function. @@ -263,7 +263,7 @@ index ef9c0d1a73aec870b924faace3b4a32b187e197f..53c272034ae8f735d02556ced5bae93a /// Mark debug helper function definitions like dump() that should not be /// stripped from debug builds. -@@ -488,17 +526,20 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); +@@ -500,17 +538,20 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); /// `#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)` so they do always /// get stripped in release builds. // FIXME: Move this to a private config.h as it's not usable in public headers. @@ -284,7 +284,7 @@ index ef9c0d1a73aec870b924faace3b4a32b187e197f..53c272034ae8f735d02556ced5bae93a #if defined(_MSC_VER) #define LLVM_PRETTY_FUNCTION __FUNCSIG__ #elif defined(__GNUC__) || defined(__clang__) -@@ -506,6 +547,7 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); +@@ -518,6 +559,7 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); #else #define LLVM_PRETTY_FUNCTION __func__ #endif diff --git a/upstream_utils/llvm_patches/0007-Explicitly-use-std.patch b/upstream_utils/llvm_patches/0006-Explicitly-use-std.patch similarity index 92% rename from upstream_utils/llvm_patches/0007-Explicitly-use-std.patch rename to upstream_utils/llvm_patches/0006-Explicitly-use-std.patch index 80c767c33ae..0d841d95c74 100644 --- a/upstream_utils/llvm_patches/0007-Explicitly-use-std.patch +++ b/upstream_utils/llvm_patches/0006-Explicitly-use-std.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 7 May 2022 22:37:34 -0400 -Subject: [PATCH 07/31] Explicitly use std:: +Subject: [PATCH 06/31] Explicitly use std:: --- llvm/include/llvm/ADT/SmallSet.h | 2 +- @@ -12,10 +12,10 @@ Subject: [PATCH 07/31] Explicitly use std:: 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/llvm/include/llvm/ADT/SmallSet.h b/llvm/include/llvm/ADT/SmallSet.h -index 06bc9b5556dd76432552ee79aa916b850f829f4d..630a79c21efeaed6822e7bcad85db0b0d5e42526 100644 +index aeee5f97799aea7e7588d7afba1e47b4fa3d8c7b..4969dfb0d61c2fad805c9cb7bc0184ea6d47bf23 100644 --- a/llvm/include/llvm/ADT/SmallSet.h +++ b/llvm/include/llvm/ADT/SmallSet.h -@@ -267,7 +267,7 @@ bool operator==(const SmallSet &LHS, const SmallSet &RHS) { +@@ -269,7 +269,7 @@ bool operator==(const SmallSet &LHS, const SmallSet &RHS) { return false; // All elements in LHS must also be in RHS @@ -101,10 +101,10 @@ index b50b368ae663614f050c220432c05b32c201db00..f9d84fa8a42a7feaaffa3aa080e84574 EXPECT_EQ("str 0", V[0]); EXPECT_EQ("str 1", V[1]); diff --git a/llvm/unittests/ADT/StringMapTest.cpp b/llvm/unittests/ADT/StringMapTest.cpp -index ff68c66bd1eda0aa4fb78702875ff734557eb07d..d12c585660ba8d00556c37bd1e5e41fbc953acc1 100644 +index 7f10b3d7d3a8894b1ab0ac660268d94a8b89e082..acd8b566f9c7a6efc2c9204624c01104dd34daf6 100644 --- a/llvm/unittests/ADT/StringMapTest.cpp +++ b/llvm/unittests/ADT/StringMapTest.cpp -@@ -329,7 +329,7 @@ TEST_F(StringMapTest, IterMapKeysSmallVector) { +@@ -343,7 +343,7 @@ TEST_F(StringMapTest, IterMapKeysSmallVector) { Map["D"] = 3; auto Keys = to_vector<4>(Map.keys()); diff --git a/upstream_utils/llvm_patches/0008-Remove-format_provider.patch b/upstream_utils/llvm_patches/0007-Remove-format_provider.patch similarity index 92% rename from upstream_utils/llvm_patches/0008-Remove-format_provider.patch rename to upstream_utils/llvm_patches/0007-Remove-format_provider.patch index 0cefeaf21c6..6495bb95935 100644 --- a/upstream_utils/llvm_patches/0008-Remove-format_provider.patch +++ b/upstream_utils/llvm_patches/0007-Remove-format_provider.patch @@ -1,13 +1,13 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 7 May 2022 22:53:50 -0400 -Subject: [PATCH 08/31] Remove format_provider +Subject: [PATCH 07/31] Remove format_provider --- llvm/include/llvm/Support/Chrono.h | 109 ------------------------ llvm/include/llvm/Support/raw_ostream.h | 6 -- - llvm/unittests/Support/Chrono.cpp | 61 ------------- - 3 files changed, 176 deletions(-) + llvm/unittests/Support/Chrono.cpp | 67 --------------- + 3 files changed, 182 deletions(-) diff --git a/llvm/include/llvm/Support/Chrono.h b/llvm/include/llvm/Support/Chrono.h index a7dea19d9193bcff4bc6b553b80a10b2bc7b64af..9f9a2b5cab270327898cee3f97d9ae7cf77eb564 100644 @@ -137,7 +137,7 @@ index a7dea19d9193bcff4bc6b553b80a10b2bc7b64af..9f9a2b5cab270327898cee3f97d9ae7c #endif // LLVM_SUPPORT_CHRONO_H diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h -index c8a94f46fab18dabc123fd709974138c8b0b0beb..0bf165c55921d7e09208a8fa8df7f9f5ad68d1e2 100644 +index 2463f1af612a78cafafe3c0e16d496e607cdc322..5d08596b4cf6bf9e9b8e2c2c1aef731bb8832da5 100644 --- a/llvm/include/llvm/Support/raw_ostream.h +++ b/llvm/include/llvm/Support/raw_ostream.h @@ -27,12 +27,6 @@ @@ -154,10 +154,10 @@ index c8a94f46fab18dabc123fd709974138c8b0b0beb..0bf165c55921d7e09208a8fa8df7f9f5 namespace sys { diff --git a/llvm/unittests/Support/Chrono.cpp b/llvm/unittests/Support/Chrono.cpp -index 9a08a5c1bfdff409c2240b7d15727d32d6339399..3c049de18c0a80465f4b0a8c054df2602d5e9b1c 100644 +index daf8a8a350f08c748ba05af44f43f3faca8e2c61..3c049de18c0a80465f4b0a8c054df2602d5e9b1c 100644 --- a/llvm/unittests/Support/Chrono.cpp +++ b/llvm/unittests/Support/Chrono.cpp -@@ -30,37 +30,6 @@ TEST(Chrono, TimeTConversion) { +@@ -30,43 +30,6 @@ TEST(Chrono, TimeTConversion) { EXPECT_EQ(TP, toTimePoint(toTimeT(TP))); } @@ -173,15 +173,21 @@ index 9a08a5c1bfdff409c2240b7d15727d32d6339399..3c049de18c0a80465f4b0a8c054df260 - TM.tm_isdst = -1; - TimePoint<> T = - system_clock::from_time_t(mktime(&TM)) + nanoseconds(123456789); +- TimePoint<> T2 = +- system_clock::from_time_t(mktime(&TM)) + nanoseconds(23456789); - - // operator<< uses the format YYYY-MM-DD HH:MM:SS.NNNNNNNNN - std::string S; - raw_string_ostream OS(S); - OS << T; - EXPECT_EQ("2006-01-02 15:04:05.123456789", OS.str()); +- S.clear(); +- OS << T2; +- EXPECT_EQ("2006-01-02 15:04:05.023456789", OS.str()); - - // formatv default style matches operator<<. - EXPECT_EQ("2006-01-02 15:04:05.123456789", formatv("{0}", T).str()); +- EXPECT_EQ("2006-01-02 15:04:05.023456789", formatv("{0}", T2).str()); - // formatv supports strftime-style format strings. - EXPECT_EQ("15:04:05", formatv("{0:%H:%M:%S}", T).str()); - // formatv supports our strftime extensions for sub-second precision. @@ -195,7 +201,7 @@ index 9a08a5c1bfdff409c2240b7d15727d32d6339399..3c049de18c0a80465f4b0a8c054df260 // Test that toTimePoint and toTimeT can be called with a arguments with varying // precisions. TEST(Chrono, ImplicitConversions) { -@@ -78,34 +47,4 @@ TEST(Chrono, ImplicitConversions) { +@@ -84,34 +47,4 @@ TEST(Chrono, ImplicitConversions) { EXPECT_EQ(TimeT, toTimeT(Nano)); } diff --git a/upstream_utils/llvm_patches/0009-Add-compiler-warning-pragmas.patch b/upstream_utils/llvm_patches/0008-Add-compiler-warning-pragmas.patch similarity index 86% rename from upstream_utils/llvm_patches/0009-Add-compiler-warning-pragmas.patch rename to upstream_utils/llvm_patches/0008-Add-compiler-warning-pragmas.patch index a086ba6133a..15442f172fc 100644 --- a/upstream_utils/llvm_patches/0009-Add-compiler-warning-pragmas.patch +++ b/upstream_utils/llvm_patches/0008-Add-compiler-warning-pragmas.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 13:34:07 -0400 -Subject: [PATCH 09/31] Add compiler warning pragmas +Subject: [PATCH 08/31] Add compiler warning pragmas --- llvm/include/llvm/ADT/FunctionExtras.h | 11 +++++++++++ @@ -17,7 +17,7 @@ Subject: [PATCH 09/31] Add compiler warning pragmas 10 files changed, 72 insertions(+), 4 deletions(-) diff --git a/llvm/include/llvm/ADT/FunctionExtras.h b/llvm/include/llvm/ADT/FunctionExtras.h -index ba145bf783775042ff4a2d4be4bb048f16db669d..07f9632bb871b1915b3016348d58938e738b3331 100644 +index 9d10b16e3cbe9c0df818a3254fcd3a6032d54b39..1daeae915eb506b32a2d1296d2f0fe4e6dab606e 100644 --- a/llvm/include/llvm/ADT/FunctionExtras.h +++ b/llvm/include/llvm/ADT/FunctionExtras.h @@ -55,6 +55,13 @@ namespace llvm { @@ -34,7 +34,7 @@ index ba145bf783775042ff4a2d4be4bb048f16db669d..07f9632bb871b1915b3016348d58938e namespace detail { template -@@ -410,6 +417,10 @@ public: +@@ -409,6 +416,10 @@ public: } }; @@ -46,7 +46,7 @@ index ba145bf783775042ff4a2d4be4bb048f16db669d..07f9632bb871b1915b3016348d58938e #endif // LLVM_ADT_FUNCTIONEXTRAS_H diff --git a/llvm/include/llvm/ADT/Hashing.h b/llvm/include/llvm/ADT/Hashing.h -index 463a8d572aa17c415b0ca160b7580862aa9ae197..13e79a12a4f8449c764c9fcf85194bcc2b52b74a 100644 +index ef983105c7bae67bb2ef832e4473939a0406e0df..781bdb7416392e3f60a1ac3a38fbcf5324b5395f 100644 --- a/llvm/include/llvm/ADT/Hashing.h +++ b/llvm/include/llvm/ADT/Hashing.h @@ -56,6 +56,11 @@ @@ -61,7 +61,7 @@ index 463a8d572aa17c415b0ca160b7580862aa9ae197..13e79a12a4f8449c764c9fcf85194bcc namespace llvm { template struct DenseMapInfo; -@@ -678,4 +683,8 @@ template <> struct DenseMapInfo { +@@ -683,4 +688,8 @@ template <> struct DenseMapInfo { } // namespace llvm @@ -71,7 +71,7 @@ index 463a8d572aa17c415b0ca160b7580862aa9ae197..13e79a12a4f8449c764c9fcf85194bcc + #endif diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h -index 4a93f4c1d8102fc322ebde9c3c697877a1b9048a..70c77618b307acfee816006d54eeddc422ab619b 100644 +index 84f4d0931a30f4be29549354c85cb4c0489e14c9..b42438a9b16c273f9ef5b5cce6192873c78cb964 100644 --- a/llvm/include/llvm/ADT/SmallVector.h +++ b/llvm/include/llvm/ADT/SmallVector.h @@ -14,6 +14,14 @@ @@ -90,10 +90,10 @@ index 4a93f4c1d8102fc322ebde9c3c697877a1b9048a..70c77618b307acfee816006d54eeddc4 #include "llvm/Support/type_traits.h" #include diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h -index 45840976a09a733b69dee4070f2f9f8339455da2..062ed2f4057820547cc6bfc4c91e7a13ceaa2f8a 100644 +index 0bd572d07fcbf2ff56998dbf366215068b62f527..cd5a64a746b2eb7491e9b6cf8570bdf436d94a6d 100644 --- a/llvm/include/llvm/Support/MathExtras.h +++ b/llvm/include/llvm/Support/MathExtras.h -@@ -268,6 +268,11 @@ inline uint64_t maxUIntN(uint64_t N) { +@@ -208,6 +208,11 @@ inline uint64_t maxUIntN(uint64_t N) { return UINT64_MAX >> (64 - N); } @@ -105,7 +105,7 @@ index 45840976a09a733b69dee4070f2f9f8339455da2..062ed2f4057820547cc6bfc4c91e7a13 /// Gets the minimum value for a N-bit signed integer. inline int64_t minIntN(int64_t N) { assert(N > 0 && N <= 64 && "integer width out of range"); -@@ -275,6 +280,10 @@ inline int64_t minIntN(int64_t N) { +@@ -215,6 +220,10 @@ inline int64_t minIntN(int64_t N) { return UINT64_C(1) + ~(UINT64_C(1) << (N - 1)); } @@ -146,7 +146,7 @@ index d6012bd5a6985d8405136039aa85931605cd8a40..01007deb89bba625b1b3ad3e703d0c16 + #endif diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp -index ce3ffa575995b9f00f8d569176c7aeae7892d30d..a2778407119ccd73031b22a5a091e21923905aa9 100644 +index 9966a0056ae4f24a7a38346ee1c2f5d83ac20248..a23f567a37abdc199363607446f33f29e021d7ad 100644 --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp @@ -10,6 +10,10 @@ @@ -161,7 +161,7 @@ index ce3ffa575995b9f00f8d569176c7aeae7892d30d..a2778407119ccd73031b22a5a091e219 #include "llvm/ADT/StringExtras.h" #include "llvm/Config/config.h" diff --git a/llvm/unittests/ADT/DenseMapTest.cpp b/llvm/unittests/ADT/DenseMapTest.cpp -index ab575dfe920e314489025bb68e6113f6227fe41f..d83ba0009c8a70e64a4e3a43a7f3b58663711b87 100644 +index b710ac07461ba58faa99cedeae7f209dc0f5902b..1f232d3046292c0da940ba4bef7d50604556e4c2 100644 --- a/llvm/unittests/ADT/DenseMapTest.cpp +++ b/llvm/unittests/ADT/DenseMapTest.cpp @@ -6,6 +6,10 @@ @@ -174,9 +174,9 @@ index ab575dfe920e314489025bb68e6113f6227fe41f..d83ba0009c8a70e64a4e3a43a7f3b586 + #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseMapInfo.h" - #include "gmock/gmock.h" + #include "llvm/ADT/DenseMapInfoVariant.h" diff --git a/llvm/unittests/ADT/MapVectorTest.cpp b/llvm/unittests/ADT/MapVectorTest.cpp -index 552f9956bdc2c6148f2e338b02074b7c479994a9..20ebcd753bcce0112f6a2d96ea23ccb6662996bb 100644 +index 1a371cbfba81e8ea4b57c4077ca94c86c3db8991..62fafcaf04a67d4c67b98b8f42d837ccca245fe9 100644 --- a/llvm/unittests/ADT/MapVectorTest.cpp +++ b/llvm/unittests/ADT/MapVectorTest.cpp @@ -6,6 +6,13 @@ @@ -194,7 +194,7 @@ index 552f9956bdc2c6148f2e338b02074b7c479994a9..20ebcd753bcce0112f6a2d96ea23ccb6 #include "llvm/ADT/iterator_range.h" #include "gtest/gtest.h" diff --git a/llvm/unittests/ADT/SmallVectorTest.cpp b/llvm/unittests/ADT/SmallVectorTest.cpp -index e1090e6f605696f60a82d1708605ddd45f4e15f8..26ef3aee0bebf351c148a3ce9eaada24d365f603 100644 +index 7029038d18d433cef987bedbfa4fda269b24fb8f..f8c37820ef9fdfe0af067f5aa8d2297ed15e73bc 100644 --- a/llvm/unittests/ADT/SmallVectorTest.cpp +++ b/llvm/unittests/ADT/SmallVectorTest.cpp @@ -17,6 +17,10 @@ diff --git a/upstream_utils/llvm_patches/0010-Remove-unused-functions.patch b/upstream_utils/llvm_patches/0009-Remove-unused-functions.patch similarity index 98% rename from upstream_utils/llvm_patches/0010-Remove-unused-functions.patch rename to upstream_utils/llvm_patches/0009-Remove-unused-functions.patch index ff19f0d6851..13bec69dc9f 100644 --- a/upstream_utils/llvm_patches/0010-Remove-unused-functions.patch +++ b/upstream_utils/llvm_patches/0009-Remove-unused-functions.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 13:43:50 -0400 -Subject: [PATCH 10/31] Remove unused functions +Subject: [PATCH 09/31] Remove unused functions --- llvm/include/llvm/ADT/SmallString.h | 85 +----- @@ -189,7 +189,7 @@ index 953b40701dc934c1a356b5413c9c6c692d5f5679..30cf717973fb15ff65a47a2d80795c35 } // end namespace llvm diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h -index 0bf165c55921d7e09208a8fa8df7f9f5ad68d1e2..429d1dca24942d16e5c3a551035c0d459e7c5c00 100644 +index 5d08596b4cf6bf9e9b8e2c2c1aef731bb8832da5..95019180a9deb406ed4f2991c664a4cc4e956dac 100644 --- a/llvm/include/llvm/Support/raw_ostream.h +++ b/llvm/include/llvm/Support/raw_ostream.h @@ -261,32 +261,6 @@ public: @@ -388,7 +388,7 @@ index 0bf165c55921d7e09208a8fa8df7f9f5ad68d1e2..429d1dca24942d16e5c3a551035c0d45 #endif // LLVM_SUPPORT_RAW_OSTREAM_H diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp -index a2778407119ccd73031b22a5a091e21923905aa9..76c32155b4296fbbf3f4b164cd58d63f472ccd5e 100644 +index a23f567a37abdc199363607446f33f29e021d7ad..76c32155b4296fbbf3f4b164cd58d63f472ccd5e 100644 --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp @@ -18,7 +18,6 @@ @@ -751,7 +751,7 @@ index a2778407119ccd73031b22a5a091e21923905aa9..76c32155b4296fbbf3f4b164cd58d63f - return Write(Out); - } - -- unsigned Mode = sys::fs::all_read | sys::fs::all_write | sys::fs::all_exe; +- unsigned Mode = sys::fs::all_read | sys::fs::all_write; - Expected Temp = - sys::fs::TempFile::create(OutputFileName + ".temp-stream-%%%%%%", Mode); - if (!Temp) diff --git a/upstream_utils/llvm_patches/0011-Detemplatize-SmallVectorBase.patch b/upstream_utils/llvm_patches/0010-Detemplatize-SmallVectorBase.patch similarity index 97% rename from upstream_utils/llvm_patches/0011-Detemplatize-SmallVectorBase.patch rename to upstream_utils/llvm_patches/0010-Detemplatize-SmallVectorBase.patch index fd421c42fc2..8d28e0fadea 100644 --- a/upstream_utils/llvm_patches/0011-Detemplatize-SmallVectorBase.patch +++ b/upstream_utils/llvm_patches/0010-Detemplatize-SmallVectorBase.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Thu, 5 May 2022 23:18:34 -0400 -Subject: [PATCH 11/31] Detemplatize SmallVectorBase +Subject: [PATCH 10/31] Detemplatize SmallVectorBase --- llvm/include/llvm/ADT/SmallVector.h | 27 +++++++-------------- @@ -9,7 +9,7 @@ Subject: [PATCH 11/31] Detemplatize SmallVectorBase 2 files changed, 14 insertions(+), 50 deletions(-) diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h -index 70c77618b307acfee816006d54eeddc422ab619b..3c523c969bd6ee0cc2f19c923231e55787879df9 100644 +index b42438a9b16c273f9ef5b5cce6192873c78cb964..7775ed7e8e083908f033529c30b1e4beae91b10a 100644 --- a/llvm/include/llvm/ADT/SmallVector.h +++ b/llvm/include/llvm/ADT/SmallVector.h @@ -56,14 +56,14 @@ using EnableIfConvertibleToInputIterator = std::enable_if_tgetFirstEl(), MinSize, sizeof(T), NewCapacity)); } -@@ -1319,12 +1314,6 @@ template SmallVector to_vector_of(R &&Range) { +@@ -1324,12 +1319,6 @@ template SmallVector to_vector_of(R &&Range) { return {std::begin(Range), std::end(Range)}; } diff --git a/upstream_utils/llvm_patches/0012-Add-vectors-to-raw_ostream.patch b/upstream_utils/llvm_patches/0011-Add-vectors-to-raw_ostream.patch similarity index 98% rename from upstream_utils/llvm_patches/0012-Add-vectors-to-raw_ostream.patch rename to upstream_utils/llvm_patches/0011-Add-vectors-to-raw_ostream.patch index e7acf3d7ade..cba909f2990 100644 --- a/upstream_utils/llvm_patches/0012-Add-vectors-to-raw_ostream.patch +++ b/upstream_utils/llvm_patches/0011-Add-vectors-to-raw_ostream.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 13:48:59 -0400 -Subject: [PATCH 12/31] Add vectors to raw_ostream +Subject: [PATCH 11/31] Add vectors to raw_ostream --- llvm/include/llvm/Support/raw_ostream.h | 115 ++++++++++++++++++++++++ @@ -9,7 +9,7 @@ Subject: [PATCH 12/31] Add vectors to raw_ostream 2 files changed, 162 insertions(+) diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h -index 429d1dca24942d16e5c3a551035c0d459e7c5c00..d656123867f331b32463f2da9e637892e0e39930 100644 +index 95019180a9deb406ed4f2991c664a4cc4e956dac..e7526e016a858ad728feb7cf1c5014b9691759d4 100644 --- a/llvm/include/llvm/Support/raw_ostream.h +++ b/llvm/include/llvm/Support/raw_ostream.h @@ -24,6 +24,7 @@ diff --git a/upstream_utils/llvm_patches/0013-Extra-collections-features.patch b/upstream_utils/llvm_patches/0012-Extra-collections-features.patch similarity index 96% rename from upstream_utils/llvm_patches/0013-Extra-collections-features.patch rename to upstream_utils/llvm_patches/0012-Extra-collections-features.patch index a1016cc2d40..7da2c106a64 100644 --- a/upstream_utils/llvm_patches/0013-Extra-collections-features.patch +++ b/upstream_utils/llvm_patches/0012-Extra-collections-features.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Tue, 3 May 2022 22:16:10 -0400 -Subject: [PATCH 13/31] Extra collections features +Subject: [PATCH 12/31] Extra collections features --- llvm/include/llvm/ADT/StringMap.h | 103 +++++++++++++++++++++++++++++- @@ -9,7 +9,7 @@ Subject: [PATCH 13/31] Extra collections features 2 files changed, 110 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/ADT/StringMap.h b/llvm/include/llvm/ADT/StringMap.h -index 1c8cda7ef0f8e2984f2d7960260f2a109a2986f7..99a183772f909ed9eab8c8e0c0fc87f183d2c98d 100644 +index 34dfbf83c681f4e81a9dadd9382ddca6ef8d6c1d..c133e84f9b2e3a225cdac782c011fadbf07adab2 100644 --- a/llvm/include/llvm/ADT/StringMap.h +++ b/llvm/include/llvm/ADT/StringMap.h @@ -42,7 +42,7 @@ protected: @@ -21,7 +21,7 @@ index 1c8cda7ef0f8e2984f2d7960260f2a109a2986f7..99a183772f909ed9eab8c8e0c0fc87f1 : TheTable(RHS.TheTable), NumBuckets(RHS.NumBuckets), NumItems(RHS.NumItems), NumTombstones(RHS.NumTombstones), ItemSize(RHS.ItemSize) { -@@ -420,11 +420,27 @@ public: +@@ -432,11 +432,27 @@ public: return Tmp; } @@ -49,7 +49,7 @@ index 1c8cda7ef0f8e2984f2d7960260f2a109a2986f7..99a183772f909ed9eab8c8e0c0fc87f1 }; template -@@ -483,6 +499,91 @@ public: +@@ -495,6 +511,91 @@ public: std::string_view operator*() const { return this->wrapped()->getKey(); } }; diff --git a/upstream_utils/llvm_patches/0014-EpochTracker-ABI-macro.patch b/upstream_utils/llvm_patches/0013-EpochTracker-ABI-macro.patch similarity index 74% rename from upstream_utils/llvm_patches/0014-EpochTracker-ABI-macro.patch rename to upstream_utils/llvm_patches/0013-EpochTracker-ABI-macro.patch index 0cec9ca5cc7..a280defac3f 100644 --- a/upstream_utils/llvm_patches/0014-EpochTracker-ABI-macro.patch +++ b/upstream_utils/llvm_patches/0013-EpochTracker-ABI-macro.patch @@ -1,14 +1,14 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Wed, 4 May 2022 00:01:00 -0400 -Subject: [PATCH 14/31] EpochTracker ABI macro +Subject: [PATCH 13/31] EpochTracker ABI macro --- llvm/include/llvm/ADT/EpochTracker.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/include/llvm/ADT/EpochTracker.h b/llvm/include/llvm/ADT/EpochTracker.h -index a639d1b5b3ec4a18d3666ee62d83a9a382075d93..6fb2199ca3b9d7bb636a3e46e18b71f15bfa0494 100644 +index fc41d6f2c92d2f9876c741067b5645a74663db04..56d0acda2c1a0e390cfed086fa298b650c4a561f 100644 --- a/llvm/include/llvm/ADT/EpochTracker.h +++ b/llvm/include/llvm/ADT/EpochTracker.h @@ -22,7 +22,7 @@ @@ -17,6 +17,6 @@ index a639d1b5b3ec4a18d3666ee62d83a9a382075d93..6fb2199ca3b9d7bb636a3e46e18b71f1 -#if LLVM_ENABLE_ABI_BREAKING_CHECKS +#ifndef NDEBUG //ifndef LLVM_ENABLE_ABI_BREAKING_CHECKS + #define LLVM_DEBUGEPOCHBASE_HANDLEBASE_EMPTYBASE /// A base class for data structure classes wishing to make iterators - /// ("handles") pointing into themselves fail-fast. When building without diff --git a/upstream_utils/llvm_patches/0015-Delete-numbers-from-MathExtras.patch b/upstream_utils/llvm_patches/0014-Delete-numbers-from-MathExtras.patch similarity index 89% rename from upstream_utils/llvm_patches/0015-Delete-numbers-from-MathExtras.patch rename to upstream_utils/llvm_patches/0014-Delete-numbers-from-MathExtras.patch index 5e8e8b5c694..ea27672b2e4 100644 --- a/upstream_utils/llvm_patches/0015-Delete-numbers-from-MathExtras.patch +++ b/upstream_utils/llvm_patches/0014-Delete-numbers-from-MathExtras.patch @@ -1,19 +1,19 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Thu, 5 May 2022 18:09:45 -0400 -Subject: [PATCH 15/31] Delete numbers from MathExtras +Subject: [PATCH 14/31] Delete numbers from MathExtras --- llvm/include/llvm/Support/MathExtras.h | 36 -------------------------- 1 file changed, 36 deletions(-) diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h -index 062ed2f4057820547cc6bfc4c91e7a13ceaa2f8a..cc0c1cbd1c8bb523bce720b9783afad7f602c88c 100644 +index cd5a64a746b2eb7491e9b6cf8570bdf436d94a6d..cdf859ccfaca22a04b08a351d7c2c9789a70627e 100644 --- a/llvm/include/llvm/Support/MathExtras.h +++ b/llvm/include/llvm/Support/MathExtras.h -@@ -32,42 +32,6 @@ enum ZeroBehavior { - ZB_Max - }; +@@ -24,42 +24,6 @@ + + namespace llvm { -/// Mathematical constants. -namespace numbers { @@ -51,6 +51,6 @@ index 062ed2f4057820547cc6bfc4c91e7a13ceaa2f8a..cc0c1cbd1c8bb523bce720b9783afad7 - phif = 1.61803399F; // (0x1.9e377aP+0) https://oeis.org/A001622 -} // namespace numbers - - /// Count number of 0's from the least significant bit to the most - /// stopping at the first 1. - /// + /// Create a bitmask with the N right-most bits set to 1, and all other + /// bits set to 0. Only unsigned types are allowed. + template T maskTrailingOnes(unsigned N) { diff --git a/upstream_utils/llvm_patches/0016-Add-lerp-and-sgn.patch b/upstream_utils/llvm_patches/0015-Add-lerp-and-sgn.patch similarity index 82% rename from upstream_utils/llvm_patches/0016-Add-lerp-and-sgn.patch rename to upstream_utils/llvm_patches/0015-Add-lerp-and-sgn.patch index 37f792ace48..c2fe9ed6430 100644 --- a/upstream_utils/llvm_patches/0016-Add-lerp-and-sgn.patch +++ b/upstream_utils/llvm_patches/0015-Add-lerp-and-sgn.patch @@ -1,17 +1,17 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Tue, 3 May 2022 22:50:24 -0400 -Subject: [PATCH 16/31] Add lerp and sgn +Subject: [PATCH 15/31] Add lerp and sgn --- llvm/include/llvm/Support/MathExtras.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h -index cc0c1cbd1c8bb523bce720b9783afad7f602c88c..fe9c5136f9f2f687577a0b1ecce69262568a9c3c 100644 +index cdf859ccfaca22a04b08a351d7c2c9789a70627e..b82d9883c41008dcbbd933709c6e854ad74c5b58 100644 --- a/llvm/include/llvm/Support/MathExtras.h +++ b/llvm/include/llvm/Support/MathExtras.h -@@ -744,6 +744,26 @@ std::enable_if_t::value, T> MulOverflow(T X, T Y, T &Result) { +@@ -614,6 +614,26 @@ std::enable_if_t, T> MulOverflow(T X, T Y, T &Result) { return UX > (static_cast((std::numeric_limits::max)())) / UY; } diff --git a/upstream_utils/llvm_patches/0017-Fixup-includes.patch b/upstream_utils/llvm_patches/0016-Fixup-includes.patch similarity index 93% rename from upstream_utils/llvm_patches/0017-Fixup-includes.patch rename to upstream_utils/llvm_patches/0016-Fixup-includes.patch index def27cfbeb3..6d32c22203b 100644 --- a/upstream_utils/llvm_patches/0017-Fixup-includes.patch +++ b/upstream_utils/llvm_patches/0016-Fixup-includes.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 16:38:11 -0400 -Subject: [PATCH 17/31] Fixup includes +Subject: [PATCH 16/31] Fixup includes --- llvm/include/llvm/ADT/StringMap.h | 4 ++++ @@ -17,7 +17,7 @@ Subject: [PATCH 17/31] Fixup includes 10 files changed, 25 insertions(+), 9 deletions(-) diff --git a/llvm/include/llvm/ADT/StringMap.h b/llvm/include/llvm/ADT/StringMap.h -index 99a183772f909ed9eab8c8e0c0fc87f183d2c98d..2605dcd3dfd60a93d714caf8bc8058e3c983dbde 100644 +index c133e84f9b2e3a225cdac782c011fadbf07adab2..2173a4159111e7fea70325de82dbfce628ae3ea8 100644 --- a/llvm/include/llvm/ADT/StringMap.h +++ b/llvm/include/llvm/ADT/StringMap.h @@ -17,6 +17,10 @@ @@ -59,7 +59,7 @@ index 1b15f930bd87d97d51824af5e62ea5f222a6b4c9..acadd5e89a1651cfbad67a5b1b0933d1 namespace llvm { diff --git a/llvm/lib/Support/ConvertUTFWrapper.cpp b/llvm/lib/Support/ConvertUTFWrapper.cpp -index bb5164ff9dce0271cafc5889a049b5d343530f8d..195071cc697070af2a75207fced50d49bae46c23 100644 +index d53462e742e61d3476915d5b2c5aa63772e78a8a..34054140489e4d536ace4650207c783d669d850e 100644 --- a/llvm/lib/Support/ConvertUTFWrapper.cpp +++ b/llvm/lib/Support/ConvertUTFWrapper.cpp @@ -7,6 +7,7 @@ @@ -142,7 +142,7 @@ index 531f81ab5b3fc1dcff731230f3cb7649cb90aedf..3db8b6e37d31a0a3cc304da8fc4cbbe1 TEST(SmallPtrSetTest, Assignment) { diff --git a/llvm/unittests/ADT/SmallVectorTest.cpp b/llvm/unittests/ADT/SmallVectorTest.cpp -index 26ef3aee0bebf351c148a3ce9eaada24d365f603..adb0755988c67ecd126931425296d32d833da561 100644 +index f8c37820ef9fdfe0af067f5aa8d2297ed15e73bc..5e91f71bc9ac0e499a64dd1591e581d0707417f6 100644 --- a/llvm/unittests/ADT/SmallVectorTest.cpp +++ b/llvm/unittests/ADT/SmallVectorTest.cpp @@ -13,6 +13,7 @@ @@ -154,7 +154,7 @@ index 26ef3aee0bebf351c148a3ce9eaada24d365f603..adb0755988c67ecd126931425296d32d #include #include diff --git a/llvm/unittests/ADT/StringMapTest.cpp b/llvm/unittests/ADT/StringMapTest.cpp -index d12c585660ba8d00556c37bd1e5e41fbc953acc1..a45dde69f833900fa1d7c5a1984edee3d501111d 100644 +index acd8b566f9c7a6efc2c9204624c01104dd34daf6..6b6cf564909f329c220eb225f3b7af6c35301029 100644 --- a/llvm/unittests/ADT/StringMapTest.cpp +++ b/llvm/unittests/ADT/StringMapTest.cpp @@ -9,6 +9,7 @@ diff --git a/upstream_utils/llvm_patches/0017-Use-std-is_trivially_copy_constructible.patch b/upstream_utils/llvm_patches/0017-Use-std-is_trivially_copy_constructible.patch new file mode 100644 index 00000000000..c78fd427756 --- /dev/null +++ b/upstream_utils/llvm_patches/0017-Use-std-is_trivially_copy_constructible.patch @@ -0,0 +1,36 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: PJ Reiniger +Date: Sun, 8 May 2022 16:42:09 -0400 +Subject: [PATCH 17/31] Use std::is_trivially_copy_constructible + +--- + llvm/include/llvm/Support/type_traits.h | 16 ---------------- + 1 file changed, 16 deletions(-) + +diff --git a/llvm/include/llvm/Support/type_traits.h b/llvm/include/llvm/Support/type_traits.h +index 3fd158def34d7256a736f8fb0b30dadea2177864..3171af93fa7ffe4707c03289270cf5951e3db7c5 100644 +--- a/llvm/include/llvm/Support/type_traits.h ++++ b/llvm/include/llvm/Support/type_traits.h +@@ -76,22 +76,6 @@ union trivial_helper { + + } // end namespace detail + +-template +-struct is_copy_assignable { +- template +- static auto get(F*) -> decltype(std::declval() = std::declval(), std::true_type{}); +- static std::false_type get(...); +- static constexpr bool value = decltype(get((T*)nullptr))::value; +-}; +- +-template +-struct is_move_assignable { +- template +- static auto get(F*) -> decltype(std::declval() = std::declval(), std::true_type{}); +- static std::false_type get(...); +- static constexpr bool value = decltype(get((T*)nullptr))::value; +-}; +- + } // end namespace llvm + + #endif // LLVM_SUPPORT_TYPE_TRAITS_H diff --git a/upstream_utils/llvm_patches/0019-Windows-support.patch b/upstream_utils/llvm_patches/0018-Windows-support.patch similarity index 99% rename from upstream_utils/llvm_patches/0019-Windows-support.patch rename to upstream_utils/llvm_patches/0018-Windows-support.patch index e9ddcac8df7..43e0a071f72 100644 --- a/upstream_utils/llvm_patches/0019-Windows-support.patch +++ b/upstream_utils/llvm_patches/0018-Windows-support.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Tue, 3 May 2022 20:22:38 -0400 -Subject: [PATCH 19/31] Windows support +Subject: [PATCH 18/31] Windows support --- .../llvm/Support/Windows/WindowsSupport.h | 45 +++++---- diff --git a/upstream_utils/llvm_patches/0020-Prefer-fmtlib.patch b/upstream_utils/llvm_patches/0019-Prefer-fmtlib.patch similarity index 98% rename from upstream_utils/llvm_patches/0020-Prefer-fmtlib.patch rename to upstream_utils/llvm_patches/0019-Prefer-fmtlib.patch index cc733d9bdcf..4d5b81c3cc9 100644 --- a/upstream_utils/llvm_patches/0020-Prefer-fmtlib.patch +++ b/upstream_utils/llvm_patches/0019-Prefer-fmtlib.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 16:46:20 -0400 -Subject: [PATCH 20/31] Prefer fmtlib +Subject: [PATCH 19/31] Prefer fmtlib --- llvm/lib/Support/ErrorHandling.cpp | 20 ++++++-------------- diff --git a/upstream_utils/llvm_patches/0021-Prefer-wpi-s-fs.h.patch b/upstream_utils/llvm_patches/0020-Prefer-wpi-s-fs.h.patch similarity index 87% rename from upstream_utils/llvm_patches/0021-Prefer-wpi-s-fs.h.patch rename to upstream_utils/llvm_patches/0020-Prefer-wpi-s-fs.h.patch index 6b317cd23c0..18ae0e7b8c4 100644 --- a/upstream_utils/llvm_patches/0021-Prefer-wpi-s-fs.h.patch +++ b/upstream_utils/llvm_patches/0020-Prefer-wpi-s-fs.h.patch @@ -1,14 +1,14 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 16:49:36 -0400 -Subject: [PATCH 21/31] Prefer wpi's fs.h +Subject: [PATCH 20/31] Prefer wpi's fs.h --- llvm/include/llvm/Support/raw_ostream.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h -index d656123867f331b32463f2da9e637892e0e39930..582b731b0495ad2a38911ef1f9fe6d2aec58aea1 100644 +index e7526e016a858ad728feb7cf1c5014b9691759d4..d56999186f719f8d91f3a047a19960caf62a066c 100644 --- a/llvm/include/llvm/Support/raw_ostream.h +++ b/llvm/include/llvm/Support/raw_ostream.h @@ -26,18 +26,15 @@ diff --git a/upstream_utils/llvm_patches/0022-Remove-unused-functions.patch b/upstream_utils/llvm_patches/0021-Remove-unused-functions.patch similarity index 92% rename from upstream_utils/llvm_patches/0022-Remove-unused-functions.patch rename to upstream_utils/llvm_patches/0021-Remove-unused-functions.patch index 144858875fb..4f6ba93fffa 100644 --- a/upstream_utils/llvm_patches/0022-Remove-unused-functions.patch +++ b/upstream_utils/llvm_patches/0021-Remove-unused-functions.patch @@ -1,32 +1,17 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 19:16:51 -0400 -Subject: [PATCH 22/31] Remove unused functions +Subject: [PATCH 21/31] Remove unused functions --- - llvm/include/llvm/Support/DJB.h | 3 - llvm/include/llvm/Support/raw_ostream.h | 5 +- llvm/lib/Support/ErrorHandling.cpp | 16 ----- llvm/lib/Support/raw_ostream.cpp | 47 +++++++------- llvm/unittests/ADT/SmallStringTest.cpp | 81 ------------------------- - 5 files changed, 23 insertions(+), 129 deletions(-) + 4 files changed, 23 insertions(+), 126 deletions(-) -diff --git a/llvm/include/llvm/Support/DJB.h b/llvm/include/llvm/Support/DJB.h -index 8737cd144c37f9041a781a74e9f2b43384e85761..67b0ae91b4b1401374d7d39d859daaf30da17ee2 100644 ---- a/llvm/include/llvm/Support/DJB.h -+++ b/llvm/include/llvm/Support/DJB.h -@@ -24,9 +24,6 @@ inline uint32_t djbHash(std::string_view Buffer, uint32_t H = 5381) { - return H; - } - --/// Computes the Bernstein hash after folding the input according to the Dwarf 5 --/// standard case folding rules. --uint32_t caseFoldingDjbHash(StringRef Buffer, uint32_t H = 5381); - } // namespace llvm - - #endif // LLVM_SUPPORT_DJB_H diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h -index 582b731b0495ad2a38911ef1f9fe6d2aec58aea1..3edc33b9dcc94a2ef68d52bc0af178121447acaa 100644 +index d56999186f719f8d91f3a047a19960caf62a066c..9a9a1f688313a5784a58a70f2cb4cc0d6ec70e79 100644 --- a/llvm/include/llvm/Support/raw_ostream.h +++ b/llvm/include/llvm/Support/raw_ostream.h @@ -70,7 +70,6 @@ private: diff --git a/upstream_utils/llvm_patches/0023-OS-specific-changes.patch b/upstream_utils/llvm_patches/0022-OS-specific-changes.patch similarity index 97% rename from upstream_utils/llvm_patches/0023-OS-specific-changes.patch rename to upstream_utils/llvm_patches/0022-OS-specific-changes.patch index d5da63a1659..4b3b3b7e25e 100644 --- a/upstream_utils/llvm_patches/0023-OS-specific-changes.patch +++ b/upstream_utils/llvm_patches/0022-OS-specific-changes.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 19:30:43 -0400 -Subject: [PATCH 23/31] OS-specific changes +Subject: [PATCH 22/31] OS-specific changes --- llvm/lib/Support/ErrorHandling.cpp | 16 +++++++--------- diff --git a/upstream_utils/llvm_patches/0024-Use-SmallVector-for-UTF-conversion.patch b/upstream_utils/llvm_patches/0023-Use-SmallVector-for-UTF-conversion.patch similarity index 97% rename from upstream_utils/llvm_patches/0024-Use-SmallVector-for-UTF-conversion.patch rename to upstream_utils/llvm_patches/0023-Use-SmallVector-for-UTF-conversion.patch index a5155c7c123..d04e93b476e 100644 --- a/upstream_utils/llvm_patches/0024-Use-SmallVector-for-UTF-conversion.patch +++ b/upstream_utils/llvm_patches/0023-Use-SmallVector-for-UTF-conversion.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Mon, 9 May 2022 00:04:30 -0400 -Subject: [PATCH 24/31] Use SmallVector for UTF conversion +Subject: [PATCH 23/31] Use SmallVector for UTF conversion --- llvm/include/llvm/Support/ConvertUTF.h | 6 +++--- @@ -41,7 +41,7 @@ index 72321022beb373945f7935ed72944fd68eb7d02f..5c8b966ce296699a0315d72cdfdcdb5a /** * Converts a stream of raw bytes assumed to be UTF32 into a UTF8 std::string. diff --git a/llvm/lib/Support/ConvertUTFWrapper.cpp b/llvm/lib/Support/ConvertUTFWrapper.cpp -index 195071cc697070af2a75207fced50d49bae46c23..d13d876d6c5c830bede6ed90ff2cfa6236a79504 100644 +index 34054140489e4d536ace4650207c783d669d850e..0b62315e3461ff60a8313e73b4142b1f83e36ca7 100644 --- a/llvm/lib/Support/ConvertUTFWrapper.cpp +++ b/llvm/lib/Support/ConvertUTFWrapper.cpp @@ -82,7 +82,7 @@ bool hasUTF16ByteOrderMark(span S) { diff --git a/upstream_utils/llvm_patches/0025-Prefer-to-use-static-pointers-in-raw_ostream.patch b/upstream_utils/llvm_patches/0024-Prefer-to-use-static-pointers-in-raw_ostream.patch similarity index 94% rename from upstream_utils/llvm_patches/0025-Prefer-to-use-static-pointers-in-raw_ostream.patch rename to upstream_utils/llvm_patches/0024-Prefer-to-use-static-pointers-in-raw_ostream.patch index 027b21a2dfa..f5dce6b5230 100644 --- a/upstream_utils/llvm_patches/0025-Prefer-to-use-static-pointers-in-raw_ostream.patch +++ b/upstream_utils/llvm_patches/0024-Prefer-to-use-static-pointers-in-raw_ostream.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Thu, 19 May 2022 00:58:36 -0400 -Subject: [PATCH 25/31] Prefer to use static pointers in raw_ostream +Subject: [PATCH 24/31] Prefer to use static pointers in raw_ostream See #1401 --- diff --git a/upstream_utils/llvm_patches/0026-constexpr-endian-byte-swap.patch b/upstream_utils/llvm_patches/0025-constexpr-endian-byte-swap.patch similarity index 95% rename from upstream_utils/llvm_patches/0026-constexpr-endian-byte-swap.patch rename to upstream_utils/llvm_patches/0025-constexpr-endian-byte-swap.patch index c27e8208833..acbded14803 100644 --- a/upstream_utils/llvm_patches/0026-constexpr-endian-byte-swap.patch +++ b/upstream_utils/llvm_patches/0025-constexpr-endian-byte-swap.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Thu, 19 May 2022 01:12:41 -0400 -Subject: [PATCH 26/31] constexpr endian byte swap +Subject: [PATCH 25/31] constexpr endian byte swap --- llvm/include/llvm/Support/Endian.h | 4 +++- diff --git a/upstream_utils/llvm_patches/0027-Copy-type-traits-from-STLExtras.h-into-PointerUnion..patch b/upstream_utils/llvm_patches/0026-Copy-type-traits-from-STLExtras.h-into-PointerUnion..patch similarity index 94% rename from upstream_utils/llvm_patches/0027-Copy-type-traits-from-STLExtras.h-into-PointerUnion..patch rename to upstream_utils/llvm_patches/0026-Copy-type-traits-from-STLExtras.h-into-PointerUnion..patch index f1c1f6106bb..efa9e6cc338 100644 --- a/upstream_utils/llvm_patches/0027-Copy-type-traits-from-STLExtras.h-into-PointerUnion..patch +++ b/upstream_utils/llvm_patches/0026-Copy-type-traits-from-STLExtras.h-into-PointerUnion..patch @@ -1,14 +1,14 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Wed, 10 Aug 2022 17:07:52 -0700 -Subject: [PATCH 27/31] Copy type traits from STLExtras.h into PointerUnion.h +Subject: [PATCH 26/31] Copy type traits from STLExtras.h into PointerUnion.h --- llvm/include/llvm/ADT/PointerUnion.h | 46 ++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/llvm/include/llvm/ADT/PointerUnion.h b/llvm/include/llvm/ADT/PointerUnion.h -index 6abec033a4008057f30d445d47ab22ebbb046a2f..7303694ef3d0cb833db3cb9f86bd155ab6136511 100644 +index 8ac68dbc0a791b8ac0e0ca865e69024cb642aa70..273ba02934bd405ea4f1b911ebb58f7080837ff0 100644 --- a/llvm/include/llvm/ADT/PointerUnion.h +++ b/llvm/include/llvm/ADT/PointerUnion.h @@ -23,9 +23,55 @@ diff --git a/upstream_utils/llvm_patches/0028-Remove-StringMap-test-for-llvm-sort.patch b/upstream_utils/llvm_patches/0027-Remove-StringMap-test-for-llvm-sort.patch similarity index 80% rename from upstream_utils/llvm_patches/0028-Remove-StringMap-test-for-llvm-sort.patch rename to upstream_utils/llvm_patches/0027-Remove-StringMap-test-for-llvm-sort.patch index 704f751d607..977dff33838 100644 --- a/upstream_utils/llvm_patches/0028-Remove-StringMap-test-for-llvm-sort.patch +++ b/upstream_utils/llvm_patches/0027-Remove-StringMap-test-for-llvm-sort.patch @@ -1,17 +1,17 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Wed, 10 Aug 2022 22:35:00 -0700 -Subject: [PATCH 28/31] Remove StringMap test for llvm::sort() +Subject: [PATCH 27/31] Remove StringMap test for llvm::sort() --- llvm/unittests/ADT/StringMapTest.cpp | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/llvm/unittests/ADT/StringMapTest.cpp b/llvm/unittests/ADT/StringMapTest.cpp -index a45dde69f833900fa1d7c5a1984edee3d501111d..d232c61e84a93fdc4d4c3a77b1f6124269d1fc05 100644 +index 6b6cf564909f329c220eb225f3b7af6c35301029..0d83669a580408e925ec6308410ebe7c01b48b12 100644 --- a/llvm/unittests/ADT/StringMapTest.cpp +++ b/llvm/unittests/ADT/StringMapTest.cpp -@@ -308,20 +308,6 @@ TEST_F(StringMapTest, InsertOrAssignTest) { +@@ -322,20 +322,6 @@ TEST_F(StringMapTest, InsertOrAssignTest) { EXPECT_EQ(0, try1.first->second.copy); } diff --git a/upstream_utils/llvm_patches/0029-Unused-variable-in-release-mode.patch b/upstream_utils/llvm_patches/0028-Unused-variable-in-release-mode.patch similarity index 85% rename from upstream_utils/llvm_patches/0029-Unused-variable-in-release-mode.patch rename to upstream_utils/llvm_patches/0028-Unused-variable-in-release-mode.patch index 9a45046c2b0..2492883e8b9 100644 --- a/upstream_utils/llvm_patches/0029-Unused-variable-in-release-mode.patch +++ b/upstream_utils/llvm_patches/0028-Unused-variable-in-release-mode.patch @@ -1,14 +1,14 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Leander Schulten Date: Mon, 10 Jul 2023 00:53:43 +0200 -Subject: [PATCH 29/31] Unused variable in release mode +Subject: [PATCH 28/31] Unused variable in release mode --- llvm/include/llvm/ADT/DenseMap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h -index 7f4ddc256a207289980b60385f02da69f7119578..838a9b88648c7ce57b9ef4894573ddc25c74340a 100644 +index 108193f04486425f3b7f039cd9d2004be6facafb..e9bd3bfa4a6fe0fa26ff20069bbadc816c8baa65 100644 --- a/llvm/include/llvm/ADT/DenseMap.h +++ b/llvm/include/llvm/ADT/DenseMap.h @@ -124,7 +124,7 @@ public: diff --git a/upstream_utils/llvm_patches/0030-Use-C-20-bit-header.patch b/upstream_utils/llvm_patches/0029-Use-C-20-bit-header.patch similarity index 64% rename from upstream_utils/llvm_patches/0030-Use-C-20-bit-header.patch rename to upstream_utils/llvm_patches/0029-Use-C-20-bit-header.patch index d3fae626bfe..fad61d3e39a 100644 --- a/upstream_utils/llvm_patches/0030-Use-C-20-bit-header.patch +++ b/upstream_utils/llvm_patches/0029-Use-C-20-bit-header.patch @@ -1,15 +1,129 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Tue, 11 Jul 2023 22:56:09 -0700 -Subject: [PATCH 30/31] Use C++20 header +Subject: [PATCH 29/31] Use C++20 header --- - llvm/include/llvm/ADT/bit.h | 256 ------------------------- - llvm/include/llvm/Support/MathExtras.h | 37 ++-- - 2 files changed, 19 insertions(+), 274 deletions(-) + llvm/include/llvm/ADT/DenseMap.h | 3 +- + llvm/include/llvm/ADT/Hashing.h | 35 +-- + llvm/include/llvm/ADT/bit.h | 287 ------------------------- + llvm/include/llvm/Support/MathExtras.h | 21 +- + 4 files changed, 31 insertions(+), 315 deletions(-) +diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h +index e9bd3bfa4a6fe0fa26ff20069bbadc816c8baa65..93b50c9e53af4ea3af5fd0329a8a03bdce659e9d 100644 +--- a/llvm/include/llvm/ADT/DenseMap.h ++++ b/llvm/include/llvm/ADT/DenseMap.h +@@ -23,6 +23,7 @@ + #include "llvm/Support/ReverseIteration.h" + #include "llvm/Support/type_traits.h" + #include ++#include + #include + #include + #include +@@ -933,7 +934,7 @@ class SmallDenseMap + public: + explicit SmallDenseMap(unsigned NumInitBuckets = 0) { + if (NumInitBuckets > InlineBuckets) +- NumInitBuckets = llvm::bit_ceil(NumInitBuckets); ++ NumInitBuckets = std::bit_ceil(NumInitBuckets); + init(NumInitBuckets); + } + +diff --git a/llvm/include/llvm/ADT/Hashing.h b/llvm/include/llvm/ADT/Hashing.h +index 781bdb7416392e3f60a1ac3a38fbcf5324b5395f..28934add722f518ae1e9cb9c4a23d2212a47cbdf 100644 +--- a/llvm/include/llvm/ADT/Hashing.h ++++ b/llvm/include/llvm/ADT/Hashing.h +@@ -49,6 +49,7 @@ + #include "llvm/Support/SwapByteOrder.h" + #include "llvm/Support/type_traits.h" + #include ++#include + #include + #include + #include +@@ -224,30 +225,30 @@ inline uint64_t hash_17to32_bytes(const char *s, size_t len, uint64_t seed) { + uint64_t b = fetch64(s + 8); + uint64_t c = fetch64(s + len - 8) * k2; + uint64_t d = fetch64(s + len - 16) * k0; +- return hash_16_bytes(llvm::rotr(a - b, 43) + +- llvm::rotr(c ^ seed, 30) + d, +- a + llvm::rotr(b ^ k3, 20) - c + len + seed); ++ return hash_16_bytes(std::rotr(a - b, 43) + ++ std::rotr(c ^ seed, 30) + d, ++ a + std::rotr(b ^ k3, 20) - c + len + seed); + } + + inline uint64_t hash_33to64_bytes(const char *s, size_t len, uint64_t seed) { + uint64_t z = fetch64(s + 24); + uint64_t a = fetch64(s) + (len + fetch64(s + len - 16)) * k0; +- uint64_t b = llvm::rotr(a + z, 52); +- uint64_t c = llvm::rotr(a, 37); ++ uint64_t b = std::rotr(a + z, 52); ++ uint64_t c = std::rotr(a, 37); + a += fetch64(s + 8); +- c += llvm::rotr(a, 7); ++ c += std::rotr(a, 7); + a += fetch64(s + 16); + uint64_t vf = a + z; +- uint64_t vs = b + llvm::rotr(a, 31) + c; ++ uint64_t vs = b + std::rotr(a, 31) + c; + a = fetch64(s + 16) + fetch64(s + len - 32); + z = fetch64(s + len - 8); +- b = llvm::rotr(a + z, 52); +- c = llvm::rotr(a, 37); ++ b = std::rotr(a + z, 52); ++ c = std::rotr(a, 37); + a += fetch64(s + len - 24); +- c += llvm::rotr(a, 7); ++ c += std::rotr(a, 7); + a += fetch64(s + len - 16); + uint64_t wf = a + z; +- uint64_t ws = b + llvm::rotr(a, 31) + c; ++ uint64_t ws = b + std::rotr(a, 31) + c; + uint64_t r = shift_mix((vf + ws) * k2 + (wf + vs) * k0); + return shift_mix((seed ^ (r * k0)) + vs) * k2; + } +@@ -280,7 +281,7 @@ struct hash_state { + hash_state state = {0, + seed, + hash_16_bytes(seed, k1), +- llvm::rotr(seed ^ k1, 49), ++ std::rotr(seed ^ k1, 49), + seed * k1, + shift_mix(seed), + 0}; +@@ -294,10 +295,10 @@ struct hash_state { + static void mix_32_bytes(const char *s, uint64_t &a, uint64_t &b) { + a += fetch64(s); + uint64_t c = fetch64(s + 24); +- b = llvm::rotr(b + a + c, 21); ++ b = std::rotr(b + a + c, 21); + uint64_t d = a; + a += fetch64(s + 8) + fetch64(s + 16); +- b += llvm::rotr(a, 44) + d; ++ b += std::rotr(a, 44) + d; + a += c; + } + +@@ -305,11 +306,11 @@ struct hash_state { + /// We mix all 64 bytes even when the chunk length is smaller, but we + /// record the actual length. + void mix(const char *s) { +- h0 = llvm::rotr(h0 + h1 + h3 + fetch64(s + 8), 37) * k1; +- h1 = llvm::rotr(h1 + h4 + fetch64(s + 48), 42) * k1; ++ h0 = std::rotr(h0 + h1 + h3 + fetch64(s + 8), 37) * k1; ++ h1 = std::rotr(h1 + h4 + fetch64(s + 48), 42) * k1; + h0 ^= h6; + h1 += h3 + fetch64(s + 40); +- h2 = llvm::rotr(h2 + h5, 33) * k1; ++ h2 = std::rotr(h2 + h5, 33) * k1; + h3 = h4 * k1; + h4 = h0 + h5; + mix_32_bytes(s, h3, h4); diff --git a/llvm/include/llvm/ADT/bit.h b/llvm/include/llvm/ADT/bit.h -index d93023d88b4efe962f425d0b8fe98fc25394f1fe..0a4a3634820efbc0a8ca675e3ad7c98469260d0b 100644 +index 2840c5f608d3ea896e1867dd4710685da9572f2d..0a4a3634820efbc0a8ca675e3ad7c98469260d0b 100644 --- a/llvm/include/llvm/ADT/bit.h +++ b/llvm/include/llvm/ADT/bit.h @@ -27,18 +27,6 @@ @@ -31,7 +145,7 @@ index d93023d88b4efe962f425d0b8fe98fc25394f1fe..0a4a3634820efbc0a8ca675e3ad7c984 namespace llvm { // This implementation of bit_cast is different from the C++20 one in two ways: -@@ -106,250 +94,6 @@ template >> +@@ -106,281 +94,6 @@ template >> } } @@ -226,7 +340,7 @@ index d93023d88b4efe962f425d0b8fe98fc25394f1fe..0a4a3634820efbc0a8ca675e3ad7c984 -} - -/// Returns the smallest integral power of two no smaller than Value if Value is --/// nonzero. Returns 0 otherwise. +-/// nonzero. Returns 1 otherwise. -/// -/// Ex. bit_ceil(5) == 8. -/// @@ -278,12 +392,43 @@ index d93023d88b4efe962f425d0b8fe98fc25394f1fe..0a4a3634820efbc0a8ca675e3ad7c984 -[[nodiscard]] inline int popcount(T Value) noexcept { - return detail::PopulationCounter::count(Value); -} +- +-// Forward-declare rotr so that rotl can use it. +-template >> +-[[nodiscard]] constexpr T rotr(T V, int R); +- +-template >> +-[[nodiscard]] constexpr T rotl(T V, int R) { +- unsigned N = std::numeric_limits::digits; +- +- R = R % N; +- if (!R) +- return V; +- +- if (R < 0) +- return llvm::rotr(V, -R); +- +- return (V << R) | (V >> (N - R)); +-} +- +-template [[nodiscard]] constexpr T rotr(T V, int R) { +- unsigned N = std::numeric_limits::digits; +- +- R = R % N; +- if (!R) +- return V; +- +- if (R < 0) +- return llvm::rotl(V, -R); +- +- return (V >> R) | (V << (N - R)); +-} - } // namespace llvm #endif diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h -index fe9c5136f9f2f687577a0b1ecce69262568a9c3c..c269839c309e92d92ff8835127dcd2dfc0dd2c23 100644 +index b82d9883c41008dcbbd933709c6e854ad74c5b58..5f034b694989d8ef24e0b249abd12a5c20146b97 100644 --- a/llvm/include/llvm/Support/MathExtras.h +++ b/llvm/include/llvm/Support/MathExtras.h @@ -15,6 +15,7 @@ @@ -294,43 +439,7 @@ index fe9c5136f9f2f687577a0b1ecce69262568a9c3c..c269839c309e92d92ff8835127dcd2df #include #include #include -@@ -41,7 +42,7 @@ enum ZeroBehavior { - template unsigned countTrailingZeros(T Val) { - static_assert(std::is_unsigned_v, - "Only unsigned integral types are allowed."); -- return llvm::countr_zero(Val); -+ return std::countr_zero(Val); - } - - /// Count number of 0's from the most significant bit to the least -@@ -53,7 +54,7 @@ template unsigned countTrailingZeros(T Val) { - template unsigned countLeadingZeros(T Val) { - static_assert(std::is_unsigned_v, - "Only unsigned integral types are allowed."); -- return llvm::countl_zero(Val); -+ return std::countl_zero(Val); - } - - /// Get the index of the first set bit starting from the least -@@ -66,7 +67,7 @@ template T findFirstSet(T Val, ZeroBehavior ZB = ZB_Max) { - if (ZB == ZB_Max && Val == 0) - return (std::numeric_limits::max)(); - -- return llvm::countr_zero(Val); -+ return std::countr_zero(Val); - } - - /// Create a bitmask with the N right-most bits set to 1, and all other -@@ -108,7 +109,7 @@ template T findLastSet(T Val, ZeroBehavior ZB = ZB_Max) { - - // Use ^ instead of - because both gcc and llvm can remove the associated ^ - // in the __builtin_clz intrinsic on x86. -- return llvm::countl_zero(Val) ^ (std::numeric_limits::digits - 1); -+ return std::countl_zero(Val) ^ (std::numeric_limits::digits - 1); - } - - /// Macro compressed bit reversal table for 256 bits. -@@ -295,12 +296,12 @@ constexpr inline bool isShiftedMask_64(uint64_t Value) { +@@ -235,12 +236,12 @@ constexpr inline bool isShiftedMask_64(uint64_t Value) { /// Return true if the argument is a power of two > 0. /// Ex. isPowerOf2_32(0x00100000U) == true (32 bit edition.) constexpr inline bool isPowerOf2_32(uint32_t Value) { @@ -344,35 +453,8 @@ index fe9c5136f9f2f687577a0b1ecce69262568a9c3c..c269839c309e92d92ff8835127dcd2df + return std::has_single_bit(Value); } - /// Count the number of ones from the most significant bit to the first -@@ -313,7 +314,7 @@ constexpr inline bool isPowerOf2_64(uint64_t Value) { - template unsigned countLeadingOnes(T Value) { - static_assert(std::is_unsigned_v, - "Only unsigned integral types are allowed."); -- return llvm::countl_one(Value); -+ return std::countl_one(Value); - } - - /// Count the number of ones from the least significant bit to the first -@@ -326,7 +327,7 @@ template unsigned countLeadingOnes(T Value) { - template unsigned countTrailingOnes(T Value) { - static_assert(std::is_unsigned_v, - "Only unsigned integral types are allowed."); -- return llvm::countr_one(Value); -+ return std::countr_one(Value); - } - - /// Count the number of set bits in a value. -@@ -336,7 +337,7 @@ template - inline unsigned countPopulation(T Value) { - static_assert(std::is_unsigned_v, - "Only unsigned integral types are allowed."); -- return (unsigned)llvm::popcount(Value); -+ return (unsigned)std::popcount(Value); - } - /// Return true if the argument contains a non-empty sequence of ones with the -@@ -348,8 +349,8 @@ inline bool isShiftedMask_32(uint32_t Value, unsigned &MaskIdx, +@@ -252,8 +253,8 @@ inline bool isShiftedMask_32(uint32_t Value, unsigned &MaskIdx, unsigned &MaskLen) { if (!isShiftedMask_32(Value)) return false; @@ -383,7 +465,7 @@ index fe9c5136f9f2f687577a0b1ecce69262568a9c3c..c269839c309e92d92ff8835127dcd2df return true; } -@@ -361,8 +362,8 @@ inline bool isShiftedMask_64(uint64_t Value, unsigned &MaskIdx, +@@ -265,8 +266,8 @@ inline bool isShiftedMask_64(uint64_t Value, unsigned &MaskIdx, unsigned &MaskLen) { if (!isShiftedMask_64(Value)) return false; @@ -394,7 +476,7 @@ index fe9c5136f9f2f687577a0b1ecce69262568a9c3c..c269839c309e92d92ff8835127dcd2df return true; } -@@ -380,26 +381,26 @@ template <> constexpr inline size_t CTLog2<1>() { return 0; } +@@ -284,26 +285,26 @@ template <> constexpr inline size_t CTLog2<1>() { return 0; } /// (32 bit edition.) /// Ex. Log2_32(32) == 5, Log2_32(1) == 0, Log2_32(0) == -1, Log2_32(6) == 2 inline unsigned Log2_32(uint32_t Value) { @@ -424,13 +506,4 @@ index fe9c5136f9f2f687577a0b1ecce69262568a9c3c..c269839c309e92d92ff8835127dcd2df + return static_cast(64 - std::countl_zero(Value - 1)); } - /// This function takes a 64-bit integer and returns the bit equivalent double. -@@ -456,7 +457,7 @@ constexpr inline uint64_t NextPowerOf2(uint64_t A) { - /// Returns the power of two which is less than or equal to the given value. - /// Essentially, it is a floor operation across the domain of powers of two. - inline uint64_t PowerOf2Floor(uint64_t A) { -- return llvm::bit_floor(A); -+ return std::bit_floor(A); - } - - /// Returns the power of two which is greater than or equal to the given value. + /// A and B are either alignments or offsets. Return the minimum alignment that diff --git a/upstream_utils/llvm_patches/0030-Remove-DenseMap-GTest-printer-test.patch b/upstream_utils/llvm_patches/0030-Remove-DenseMap-GTest-printer-test.patch new file mode 100644 index 00000000000..8ee47b8fff8 --- /dev/null +++ b/upstream_utils/llvm_patches/0030-Remove-DenseMap-GTest-printer-test.patch @@ -0,0 +1,26 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tyler Veness +Date: Sun, 30 Jul 2023 14:17:37 -0700 +Subject: [PATCH 30/31] Remove DenseMap GTest printer test + +LLVM modifies internal GTest headers to support it, which we can't do. +--- + llvm/unittests/ADT/DenseMapTest.cpp | 7 ------- + 1 file changed, 7 deletions(-) + +diff --git a/llvm/unittests/ADT/DenseMapTest.cpp b/llvm/unittests/ADT/DenseMapTest.cpp +index 1f232d3046292c0da940ba4bef7d50604556e4c2..8d90d5afea79c619590cc32539e5124d02b1349c 100644 +--- a/llvm/unittests/ADT/DenseMapTest.cpp ++++ b/llvm/unittests/ADT/DenseMapTest.cpp +@@ -737,11 +737,4 @@ TEST(DenseMapCustomTest, VariantSupport) { + EXPECT_FALSE(DenseMapInfo::isEqual(Keys[2], Keys[2])); + } + +-// Test that gTest prints map entries as pairs instead of opaque objects. +-// See third-party/unittest/googletest/internal/custom/gtest-printers.h +-TEST(DenseMapCustomTest, PairPrinting) { +- DenseMap Map = {{1, "one"}, {2, "two"}}; +- EXPECT_EQ(R"({ (1, "one"), (2, "two") })", ::testing::PrintToString(Map)); +-} +- + } // namespace diff --git a/upstream_utils/llvm_patches/0031-Replace-deprecated-std-aligned_storage_t.patch b/upstream_utils/llvm_patches/0031-Replace-deprecated-std-aligned_storage_t.patch index 96d4ae1f49c..e074f273b66 100644 --- a/upstream_utils/llvm_patches/0031-Replace-deprecated-std-aligned_storage_t.patch +++ b/upstream_utils/llvm_patches/0031-Replace-deprecated-std-aligned_storage_t.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Tyler Veness -Date: Fri, 15 Sep 2023 18:16:50 -0700 +Date: Fri, 15 Sep 2023 18:26:50 -0700 Subject: [PATCH 31/31] Replace deprecated std::aligned_storage_t --- @@ -8,7 +8,7 @@ Subject: [PATCH 31/31] Replace deprecated std::aligned_storage_t 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/include/llvm/ADT/FunctionExtras.h b/llvm/include/llvm/ADT/FunctionExtras.h -index 07f9632bb871b1915b3016348d58938e738b3331..f6c04fe0209c4d9b64d7e23ff4dbbd15455dcac0 100644 +index 1daeae915eb506b32a2d1296d2f0fe4e6dab606e..2e60e34d69914bd9b2197fc0a0e75a8e025674b2 100644 --- a/llvm/include/llvm/ADT/FunctionExtras.h +++ b/llvm/include/llvm/ADT/FunctionExtras.h @@ -37,6 +37,7 @@ diff --git a/upstream_utils/update_llvm.py b/upstream_utils/update_llvm.py index 6d4d606097b..3a816a27fd4 100755 --- a/upstream_utils/update_llvm.py +++ b/upstream_utils/update_llvm.py @@ -171,43 +171,43 @@ def overwrite_tests(wpiutil_root, llvm_root): def main(): - upstream_root = clone_repo("https://github.com/llvm/llvm-project", "llvmorg-16.0.6") + upstream_root = clone_repo("https://github.com/llvm/llvm-project", "llvmorg-17.0.1") wpilib_root = get_repo_root() wpiutil = os.path.join(wpilib_root, "wpiutil") # Apply patches to upstream Git repo os.chdir(upstream_root) for f in [ - "0001-Fix-spelling-language-errors.patch", - "0002-Remove-StringRef-ArrayRef-and-Optional.patch", - "0003-Wrap-std-min-max-calls-in-parens-for-Windows-warning.patch", - "0004-Change-unique_function-storage-size.patch", - "0005-Threading-updates.patch", - "0006-ifdef-guard-safety.patch", - "0007-Explicitly-use-std.patch", - "0008-Remove-format_provider.patch", - "0009-Add-compiler-warning-pragmas.patch", - "0010-Remove-unused-functions.patch", - "0011-Detemplatize-SmallVectorBase.patch", - "0012-Add-vectors-to-raw_ostream.patch", - "0013-Extra-collections-features.patch", - "0014-EpochTracker-ABI-macro.patch", - "0015-Delete-numbers-from-MathExtras.patch", - "0016-Add-lerp-and-sgn.patch", - "0017-Fixup-includes.patch", - "0018-Use-std-is_trivially_copy_constructible.patch", - "0019-Windows-support.patch", - "0020-Prefer-fmtlib.patch", - "0021-Prefer-wpi-s-fs.h.patch", - "0022-Remove-unused-functions.patch", - "0023-OS-specific-changes.patch", - "0024-Use-SmallVector-for-UTF-conversion.patch", - "0025-Prefer-to-use-static-pointers-in-raw_ostream.patch", - "0026-constexpr-endian-byte-swap.patch", - "0027-Copy-type-traits-from-STLExtras.h-into-PointerUnion..patch", - "0028-Remove-StringMap-test-for-llvm-sort.patch", - "0029-Unused-variable-in-release-mode.patch", - "0030-Use-C-20-bit-header.patch", + "0001-Remove-StringRef-ArrayRef-and-Optional.patch", + "0002-Wrap-std-min-max-calls-in-parens-for-Windows-warning.patch", + "0003-Change-unique_function-storage-size.patch", + "0004-Threading-updates.patch", + "0005-ifdef-guard-safety.patch", + "0006-Explicitly-use-std.patch", + "0007-Remove-format_provider.patch", + "0008-Add-compiler-warning-pragmas.patch", + "0009-Remove-unused-functions.patch", + "0010-Detemplatize-SmallVectorBase.patch", + "0011-Add-vectors-to-raw_ostream.patch", + "0012-Extra-collections-features.patch", + "0013-EpochTracker-ABI-macro.patch", + "0014-Delete-numbers-from-MathExtras.patch", + "0015-Add-lerp-and-sgn.patch", + "0016-Fixup-includes.patch", + "0017-Use-std-is_trivially_copy_constructible.patch", + "0018-Windows-support.patch", + "0019-Prefer-fmtlib.patch", + "0020-Prefer-wpi-s-fs.h.patch", + "0021-Remove-unused-functions.patch", + "0022-OS-specific-changes.patch", + "0023-Use-SmallVector-for-UTF-conversion.patch", + "0024-Prefer-to-use-static-pointers-in-raw_ostream.patch", + "0025-constexpr-endian-byte-swap.patch", + "0026-Copy-type-traits-from-STLExtras.h-into-PointerUnion..patch", + "0027-Remove-StringMap-test-for-llvm-sort.patch", + "0028-Unused-variable-in-release-mode.patch", + "0029-Use-C-20-bit-header.patch", + "0030-Remove-DenseMap-GTest-printer-test.patch", "0031-Replace-deprecated-std-aligned_storage_t.patch", ]: git_am( diff --git a/wpinet/src/netconsoleServer/native/cpp/main.cpp b/wpinet/src/netconsoleServer/native/cpp/main.cpp index 0271e36482f..29c1491586b 100644 --- a/wpinet/src/netconsoleServer/native/cpp/main.cpp +++ b/wpinet/src/netconsoleServer/native/cpp/main.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include "wpinet/raw_uv_ostream.h" @@ -47,7 +48,8 @@ static bool NewlineBuffer(std::string& rem, uv::Buffer& buf, size_t len, std::string_view toCopy = wpi::slice(str, 0, idx + 1); if (tcp) { // Header is 2 byte len, 1 byte type, 4 byte timestamp, 2 byte sequence num - uint32_t ts = wpi::FloatToBits((wpi::Now() - startTime) * 1.0e-6); + uint32_t ts = + wpi::bit_cast((wpi::Now() - startTime) * 1.0e-6); uint16_t len = rem.size() + toCopy.size() + 1 + 4 + 2; const uint8_t header[] = {static_cast((len >> 8) & 0xff), static_cast(len & 0xff), @@ -67,6 +69,10 @@ static bool NewlineBuffer(std::string& rem, uv::Buffer& buf, size_t len, return true; } +// FIXME: clang-tidy reports a false positive for leaking a captured shared_ptr +// (clang-analyzer-cplusplus.NewDeleteLeaks) + +// NOLINTBEGIN static void CopyUdp(uv::Stream& in, std::shared_ptr out, bool broadcast) { sockaddr_in addr; @@ -131,6 +137,7 @@ static void CopyStream(uv::Stream& in, std::shared_ptr out) { }); }); } +// NOLINTEND int main(int argc, char* argv[]) { // parse arguments diff --git a/wpinet/src/netconsoleTee/native/cpp/main.cpp b/wpinet/src/netconsoleTee/native/cpp/main.cpp index a6bdff44401..1028992063b 100644 --- a/wpinet/src/netconsoleTee/native/cpp/main.cpp +++ b/wpinet/src/netconsoleTee/native/cpp/main.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "wpinet/raw_uv_ostream.h" @@ -38,7 +39,8 @@ static bool NewlineBuffer(std::string& rem, uv::Buffer& buf, size_t len, std::string_view toCopy = wpi::slice(str, 0, idx + 1); if (tcp) { // Header is 2 byte len, 1 byte type, 4 byte timestamp, 2 byte sequence num - uint32_t ts = wpi::FloatToBits((wpi::Now() - startTime) * 1.0e-6); + uint32_t ts = + wpi::bit_cast((wpi::Now() - startTime) * 1.0e-6); uint16_t len = rem.size() + toCopy.size() + 1 + 4 + 2; const uint8_t header[] = {static_cast((len >> 8) & 0xff), static_cast(len & 0xff), @@ -58,6 +60,10 @@ static bool NewlineBuffer(std::string& rem, uv::Buffer& buf, size_t len, return true; } +// FIXME: clang-tidy reports a false positive for leaking a captured shared_ptr +// (clang-analyzer-cplusplus.NewDeleteLeaks) + +// NOLINTBEGIN static void CopyUdp(uv::Stream& in, std::shared_ptr out, int port, bool broadcast) { sockaddr_in addr; @@ -110,6 +116,7 @@ static void CopyTcp(uv::Stream& in, std::shared_ptr out) { }, out); } +// NOLINTEND static void CopyStream(uv::Stream& in, std::shared_ptr out) { in.data.connect([out](uv::Buffer& buf, size_t len) { diff --git a/wpiutil/src/main/native/cpp/DataLog.cpp b/wpiutil/src/main/native/cpp/DataLog.cpp index 19a718f27dd..50effcfea94 100644 --- a/wpiutil/src/main/native/cpp/DataLog.cpp +++ b/wpiutil/src/main/native/cpp/DataLog.cpp @@ -596,7 +596,7 @@ void DataLog::AppendFloat(int entry, float value, int64_t timestamp) { wpi::support::little) { std::memcpy(buf, &value, 4); } else { - wpi::support::endian::write32le(buf, wpi::FloatToBits(value)); + wpi::support::endian::write32le(buf, wpi::bit_cast(value)); } } @@ -613,7 +613,7 @@ void DataLog::AppendDouble(int entry, double value, int64_t timestamp) { wpi::support::little) { std::memcpy(buf, &value, 8); } else { - wpi::support::endian::write64le(buf, wpi::DoubleToBits(value)); + wpi::support::endian::write64le(buf, wpi::bit_cast(value)); } } @@ -730,14 +730,14 @@ void DataLog::AppendFloatArray(int entry, std::span arr, while ((arr.size() * 4) > kBlockSize) { buf = Reserve(kBlockSize); for (auto val : arr.subspan(0, kBlockSize / 4)) { - wpi::support::endian::write32le(buf, wpi::FloatToBits(val)); + wpi::support::endian::write32le(buf, wpi::bit_cast(val)); buf += 4; } arr = arr.subspan(kBlockSize / 4); } buf = Reserve(arr.size() * 4); for (auto val : arr) { - wpi::support::endian::write32le(buf, wpi::FloatToBits(val)); + wpi::support::endian::write32le(buf, wpi::bit_cast(val)); buf += 4; } } @@ -763,14 +763,14 @@ void DataLog::AppendDoubleArray(int entry, std::span arr, while ((arr.size() * 8) > kBlockSize) { buf = Reserve(kBlockSize); for (auto val : arr.subspan(0, kBlockSize / 8)) { - wpi::support::endian::write64le(buf, wpi::DoubleToBits(val)); + wpi::support::endian::write64le(buf, wpi::bit_cast(val)); buf += 8; } arr = arr.subspan(kBlockSize / 8); } buf = Reserve(arr.size() * 8); for (auto val : arr) { - wpi::support::endian::write64le(buf, wpi::DoubleToBits(val)); + wpi::support::endian::write64le(buf, wpi::bit_cast(val)); buf += 8; } } diff --git a/wpiutil/src/main/native/cpp/DataLogReader.cpp b/wpiutil/src/main/native/cpp/DataLogReader.cpp index 96f66893638..c2e1192e14a 100644 --- a/wpiutil/src/main/native/cpp/DataLogReader.cpp +++ b/wpiutil/src/main/native/cpp/DataLogReader.cpp @@ -95,7 +95,7 @@ bool DataLogRecord::GetFloat(float* value) const { if (m_data.size() != 4) { return false; } - *value = wpi::BitsToFloat(wpi::support::endian::read32le(m_data.data())); + *value = wpi::bit_cast(wpi::support::endian::read32le(m_data.data())); return true; } @@ -103,7 +103,7 @@ bool DataLogRecord::GetDouble(double* value) const { if (m_data.size() != 8) { return false; } - *value = wpi::BitsToDouble(wpi::support::endian::read64le(m_data.data())); + *value = wpi::bit_cast(wpi::support::endian::read64le(m_data.data())); return true; } @@ -141,7 +141,7 @@ bool DataLogRecord::GetFloatArray(std::vector* arr) const { arr->reserve(m_data.size() / 4); for (size_t pos = 0; pos < m_data.size(); pos += 4) { arr->push_back( - wpi::BitsToFloat(wpi::support::endian::read32le(&m_data[pos]))); + wpi::bit_cast(wpi::support::endian::read32le(&m_data[pos]))); } return true; } @@ -154,7 +154,7 @@ bool DataLogRecord::GetDoubleArray(std::vector* arr) const { arr->reserve(m_data.size() / 8); for (size_t pos = 0; pos < m_data.size(); pos += 8) { arr->push_back( - wpi::BitsToDouble(wpi::support::endian::read64le(&m_data[pos]))); + wpi::bit_cast(wpi::support::endian::read64le(&m_data[pos]))); } return true; } diff --git a/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/ConvertUTFWrapper.cpp b/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/ConvertUTFWrapper.cpp index 1ab937da407..10267efa3ea 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/ConvertUTFWrapper.cpp +++ b/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/ConvertUTFWrapper.cpp @@ -103,7 +103,7 @@ bool convertUTF16ToUTF8String(std::span SrcBytes, SmallVectorImpl(I); Src = &ByteSwapped[0]; SrcEnd = &ByteSwapped[ByteSwapped.size() - 1] + 1; } @@ -161,7 +161,7 @@ bool convertUTF32ToUTF8String(std::span SrcBytes, std::string &Out) if (Src[0] == UNI_UTF32_BYTE_ORDER_MARK_SWAPPED) { ByteSwapped.insert(ByteSwapped.end(), Src, SrcEnd); for (UTF32 &I : ByteSwapped) - I = wpi::ByteSwap_32(I); + I = wpi::byteswap(I); Src = &ByteSwapped[0]; SrcEnd = &ByteSwapped[ByteSwapped.size() - 1] + 1; } diff --git a/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/StringMap.cpp b/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/StringMap.cpp index 101bf323971..de41aeac09c 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/StringMap.cpp +++ b/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/StringMap.cpp @@ -11,8 +11,9 @@ //===----------------------------------------------------------------------===// #include "wpi/StringMap.h" -#include "wpi/DJB.h" #include "wpi/MathExtras.h" +#include "wpi/ReverseIteration.h" +#include "wpi/xxhash.h" using namespace wpi; @@ -84,7 +85,9 @@ unsigned StringMapImpl::LookupBucketFor(std::string_view Name) { // Hash table unallocated so far? if (NumBuckets == 0) init(16); - unsigned FullHashValue = djbHash(Name, 0); + unsigned FullHashValue = xxh3_64bits(Name); + if (shouldReverseIterate()) + FullHashValue = ~FullHashValue; unsigned BucketNo = FullHashValue & (NumBuckets - 1); unsigned *HashTable = getHashTable(TheTable, NumBuckets); @@ -139,7 +142,9 @@ unsigned StringMapImpl::LookupBucketFor(std::string_view Name) { int StringMapImpl::FindKey(std::string_view Key) const { if (NumBuckets == 0) return -1; // Really empty table? - unsigned FullHashValue = djbHash(Key, 0); + unsigned FullHashValue = xxh3_64bits(Key); + if (shouldReverseIterate()) + FullHashValue = ~FullHashValue; unsigned BucketNo = FullHashValue & (NumBuckets - 1); unsigned *HashTable = getHashTable(TheTable, NumBuckets); diff --git a/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/xxhash.cpp b/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/xxhash.cpp new file mode 100644 index 00000000000..323e8354dde --- /dev/null +++ b/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/xxhash.cpp @@ -0,0 +1,407 @@ +/* +* xxHash - Fast Hash algorithm +* Copyright (C) 2012-2021, Yann Collet +* +* BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are +* met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above +* copyright notice, this list of conditions and the following disclaimer +* in the documentation and/or other materials provided with the +* distribution. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* You can contact the author at : +* - xxHash homepage: http://www.xxhash.com +* - xxHash source repository : https://github.com/Cyan4973/xxHash +*/ + +// xxhash64 is based on commit d2df04efcbef7d7f6886d345861e5dfda4edacc1. Removed +// everything but a simple interface for computing xxh64. + +// xxh3_64bits is based on commit d5891596637d21366b9b1dcf2c0007a3edb26a9e (July +// 2023). + +#include "wpi/xxhash.h" +#include "wpi/Compiler.h" +#include "wpi/Endian.h" + +#include + +using namespace wpi; +using namespace support; + +static uint64_t rotl64(uint64_t X, size_t R) { + return (X << R) | (X >> (64 - R)); +} + +constexpr uint32_t PRIME32_1 = 0x9E3779B1; +constexpr uint32_t PRIME32_2 = 0x85EBCA77; +constexpr uint32_t PRIME32_3 = 0xC2B2AE3D; + +static const uint64_t PRIME64_1 = 11400714785074694791ULL; +static const uint64_t PRIME64_2 = 14029467366897019727ULL; +static const uint64_t PRIME64_3 = 1609587929392839161ULL; +static const uint64_t PRIME64_4 = 9650029242287828579ULL; +static const uint64_t PRIME64_5 = 2870177450012600261ULL; + +static uint64_t round(uint64_t Acc, uint64_t Input) { + Acc += Input * PRIME64_2; + Acc = rotl64(Acc, 31); + Acc *= PRIME64_1; + return Acc; +} + +static uint64_t mergeRound(uint64_t Acc, uint64_t Val) { + Val = round(0, Val); + Acc ^= Val; + Acc = Acc * PRIME64_1 + PRIME64_4; + return Acc; +} + +static uint64_t XXH64_avalanche(uint64_t hash) { + hash ^= hash >> 33; + hash *= PRIME64_2; + hash ^= hash >> 29; + hash *= PRIME64_3; + hash ^= hash >> 32; + return hash; +} + +uint64_t wpi::xxHash64(std::string_view Data) { + size_t Len = Data.size(); + uint64_t Seed = 0; + const unsigned char *P = reinterpret_cast(Data.data()); + const unsigned char *const BEnd = P + Data.size(); + uint64_t H64; + + if (Len >= 32) { + const unsigned char *const Limit = BEnd - 32; + uint64_t V1 = Seed + PRIME64_1 + PRIME64_2; + uint64_t V2 = Seed + PRIME64_2; + uint64_t V3 = Seed + 0; + uint64_t V4 = Seed - PRIME64_1; + + do { + V1 = round(V1, endian::read64le(P)); + P += 8; + V2 = round(V2, endian::read64le(P)); + P += 8; + V3 = round(V3, endian::read64le(P)); + P += 8; + V4 = round(V4, endian::read64le(P)); + P += 8; + } while (P <= Limit); + + H64 = rotl64(V1, 1) + rotl64(V2, 7) + rotl64(V3, 12) + rotl64(V4, 18); + H64 = mergeRound(H64, V1); + H64 = mergeRound(H64, V2); + H64 = mergeRound(H64, V3); + H64 = mergeRound(H64, V4); + + } else { + H64 = Seed + PRIME64_5; + } + + H64 += (uint64_t)Len; + + while (reinterpret_cast(P) + 8 <= + reinterpret_cast(BEnd)) { + uint64_t const K1 = round(0, endian::read64le(P)); + H64 ^= K1; + H64 = rotl64(H64, 27) * PRIME64_1 + PRIME64_4; + P += 8; + } + + if (reinterpret_cast(P) + 4 <= reinterpret_cast(BEnd)) { + H64 ^= (uint64_t)(endian::read32le(P)) * PRIME64_1; + H64 = rotl64(H64, 23) * PRIME64_2 + PRIME64_3; + P += 4; + } + + while (P < BEnd) { + H64 ^= (*P) * PRIME64_5; + H64 = rotl64(H64, 11) * PRIME64_1; + P++; + } + + return XXH64_avalanche(H64); +} + +uint64_t wpi::xxHash64(std::span Data) { + return xxHash64({(const char *)Data.data(), Data.size()}); +} + +constexpr size_t XXH3_SECRETSIZE_MIN = 136; +constexpr size_t XXH_SECRET_DEFAULT_SIZE = 192; + +/* Pseudorandom data taken directly from FARSH */ +// clang-format off +constexpr uint8_t kSecret[XXH_SECRET_DEFAULT_SIZE] = { + 0xb8, 0xfe, 0x6c, 0x39, 0x23, 0xa4, 0x4b, 0xbe, 0x7c, 0x01, 0x81, 0x2c, 0xf7, 0x21, 0xad, 0x1c, + 0xde, 0xd4, 0x6d, 0xe9, 0x83, 0x90, 0x97, 0xdb, 0x72, 0x40, 0xa4, 0xa4, 0xb7, 0xb3, 0x67, 0x1f, + 0xcb, 0x79, 0xe6, 0x4e, 0xcc, 0xc0, 0xe5, 0x78, 0x82, 0x5a, 0xd0, 0x7d, 0xcc, 0xff, 0x72, 0x21, + 0xb8, 0x08, 0x46, 0x74, 0xf7, 0x43, 0x24, 0x8e, 0xe0, 0x35, 0x90, 0xe6, 0x81, 0x3a, 0x26, 0x4c, + 0x3c, 0x28, 0x52, 0xbb, 0x91, 0xc3, 0x00, 0xcb, 0x88, 0xd0, 0x65, 0x8b, 0x1b, 0x53, 0x2e, 0xa3, + 0x71, 0x64, 0x48, 0x97, 0xa2, 0x0d, 0xf9, 0x4e, 0x38, 0x19, 0xef, 0x46, 0xa9, 0xde, 0xac, 0xd8, + 0xa8, 0xfa, 0x76, 0x3f, 0xe3, 0x9c, 0x34, 0x3f, 0xf9, 0xdc, 0xbb, 0xc7, 0xc7, 0x0b, 0x4f, 0x1d, + 0x8a, 0x51, 0xe0, 0x4b, 0xcd, 0xb4, 0x59, 0x31, 0xc8, 0x9f, 0x7e, 0xc9, 0xd9, 0x78, 0x73, 0x64, + 0xea, 0xc5, 0xac, 0x83, 0x34, 0xd3, 0xeb, 0xc3, 0xc5, 0x81, 0xa0, 0xff, 0xfa, 0x13, 0x63, 0xeb, + 0x17, 0x0d, 0xdd, 0x51, 0xb7, 0xf0, 0xda, 0x49, 0xd3, 0x16, 0x55, 0x26, 0x29, 0xd4, 0x68, 0x9e, + 0x2b, 0x16, 0xbe, 0x58, 0x7d, 0x47, 0xa1, 0xfc, 0x8f, 0xf8, 0xb8, 0xd1, 0x7a, 0xd0, 0x31, 0xce, + 0x45, 0xcb, 0x3a, 0x8f, 0x95, 0x16, 0x04, 0x28, 0xaf, 0xd7, 0xfb, 0xca, 0xbb, 0x4b, 0x40, 0x7e, +}; +// clang-format on + +constexpr uint64_t PRIME_MX1 = 0x165667919E3779F9; +constexpr uint64_t PRIME_MX2 = 0x9FB21C651E98DF25; + +// Calculates a 64-bit to 128-bit multiply, then XOR folds it. +static uint64_t XXH3_mul128_fold64(uint64_t lhs, uint64_t rhs) { +#if defined(__SIZEOF_INT128__) || \ + (defined(_INTEGRAL_MAX_BITS) && _INTEGRAL_MAX_BITS >= 128) + __uint128_t product = (__uint128_t)lhs * (__uint128_t)rhs; + return uint64_t(product) ^ uint64_t(product >> 64); + +#else + /* First calculate all of the cross products. */ + const uint64_t lo_lo = (lhs & 0xFFFFFFFF) * (rhs & 0xFFFFFFFF); + const uint64_t hi_lo = (lhs >> 32) * (rhs & 0xFFFFFFFF); + const uint64_t lo_hi = (lhs & 0xFFFFFFFF) * (rhs >> 32); + const uint64_t hi_hi = (lhs >> 32) * (rhs >> 32); + + /* Now add the products together. These will never overflow. */ + const uint64_t cross = (lo_lo >> 32) + (hi_lo & 0xFFFFFFFF) + lo_hi; + const uint64_t upper = (hi_lo >> 32) + (cross >> 32) + hi_hi; + const uint64_t lower = (cross << 32) | (lo_lo & 0xFFFFFFFF); + + return upper ^ lower; +#endif +} + +constexpr size_t XXH_STRIPE_LEN = 64; +constexpr size_t XXH_SECRET_CONSUME_RATE = 8; +constexpr size_t XXH_ACC_NB = XXH_STRIPE_LEN / sizeof(uint64_t); + +static uint64_t XXH3_avalanche(uint64_t hash) { + hash ^= hash >> 37; + hash *= PRIME_MX1; + hash ^= hash >> 32; + return hash; +} + +static uint64_t XXH3_len_1to3_64b(const uint8_t *input, size_t len, + const uint8_t *secret, uint64_t seed) { + const uint8_t c1 = input[0]; + const uint8_t c2 = input[len >> 1]; + const uint8_t c3 = input[len - 1]; + uint32_t combined = ((uint32_t)c1 << 16) | ((uint32_t)c2 << 24) | + ((uint32_t)c3 << 0) | ((uint32_t)len << 8); + uint64_t bitflip = + (uint64_t)(endian::read32le(secret) ^ endian::read32le(secret + 4)) + + seed; + return XXH64_avalanche(uint64_t(combined) ^ bitflip); +} + +static uint64_t XXH3_len_4to8_64b(const uint8_t *input, size_t len, + const uint8_t *secret, uint64_t seed) { + seed ^= (uint64_t)byteswap(uint32_t(seed)) << 32; + const uint32_t input1 = endian::read32le(input); + const uint32_t input2 = endian::read32le(input + len - 4); + uint64_t acc = + (endian::read64le(secret + 8) ^ endian::read64le(secret + 16)) - seed; + const uint64_t input64 = (uint64_t)input2 | ((uint64_t)input1 << 32); + acc ^= input64; + // XXH3_rrmxmx(acc, len) + acc ^= rotl64(acc, 49) ^ rotl64(acc, 24); + acc *= PRIME_MX2; + acc ^= (acc >> 35) + (uint64_t)len; + acc *= PRIME_MX2; + return acc ^ (acc >> 28); +} + +static uint64_t XXH3_len_9to16_64b(const uint8_t *input, size_t len, + const uint8_t *secret, uint64_t const seed) { + uint64_t input_lo = + (endian::read64le(secret + 24) ^ endian::read64le(secret + 32)) + seed; + uint64_t input_hi = + (endian::read64le(secret + 40) ^ endian::read64le(secret + 48)) - seed; + input_lo ^= endian::read64le(input); + input_hi ^= endian::read64le(input + len - 8); + uint64_t acc = uint64_t(len) + byteswap(input_lo) + input_hi + + XXH3_mul128_fold64(input_lo, input_hi); + return XXH3_avalanche(acc); +} + +LLVM_ATTRIBUTE_ALWAYS_INLINE +static uint64_t XXH3_len_0to16_64b(const uint8_t *input, size_t len, + const uint8_t *secret, uint64_t const seed) { + if (LLVM_LIKELY(len > 8)) + return XXH3_len_9to16_64b(input, len, secret, seed); + if (LLVM_LIKELY(len >= 4)) + return XXH3_len_4to8_64b(input, len, secret, seed); + if (len != 0) + return XXH3_len_1to3_64b(input, len, secret, seed); + return XXH64_avalanche(seed ^ endian::read64le(secret + 56) ^ + endian::read64le(secret + 64)); +} + +static uint64_t XXH3_mix16B(const uint8_t *input, uint8_t const *secret, + uint64_t seed) { + uint64_t lhs = seed; + uint64_t rhs = 0U - seed; + lhs += endian::read64le(secret); + rhs += endian::read64le(secret + 8); + lhs ^= endian::read64le(input); + rhs ^= endian::read64le(input + 8); + return XXH3_mul128_fold64(lhs, rhs); +} + +/* For mid range keys, XXH3 uses a Mum-hash variant. */ +LLVM_ATTRIBUTE_ALWAYS_INLINE +static uint64_t XXH3_len_17to128_64b(const uint8_t *input, size_t len, + const uint8_t *secret, + uint64_t const seed) { + uint64_t acc = len * PRIME64_1, acc_end; + acc += XXH3_mix16B(input + 0, secret + 0, seed); + acc_end = XXH3_mix16B(input + len - 16, secret + 16, seed); + if (len > 32) { + acc += XXH3_mix16B(input + 16, secret + 32, seed); + acc_end += XXH3_mix16B(input + len - 32, secret + 48, seed); + if (len > 64) { + acc += XXH3_mix16B(input + 32, secret + 64, seed); + acc_end += XXH3_mix16B(input + len - 48, secret + 80, seed); + if (len > 96) { + acc += XXH3_mix16B(input + 48, secret + 96, seed); + acc_end += XXH3_mix16B(input + len - 64, secret + 112, seed); + } + } + } + return XXH3_avalanche(acc + acc_end); +} + +constexpr size_t XXH3_MIDSIZE_MAX = 240; + +LLVM_ATTRIBUTE_NOINLINE +static uint64_t XXH3_len_129to240_64b(const uint8_t *input, size_t len, + const uint8_t *secret, uint64_t seed) { + constexpr size_t XXH3_MIDSIZE_STARTOFFSET = 3; + constexpr size_t XXH3_MIDSIZE_LASTOFFSET = 17; + uint64_t acc = (uint64_t)len * PRIME64_1; + const unsigned nbRounds = len / 16; + for (unsigned i = 0; i < 8; ++i) + acc += XXH3_mix16B(input + 16 * i, secret + 16 * i, seed); + acc = XXH3_avalanche(acc); + + for (unsigned i = 8; i < nbRounds; ++i) { + acc += XXH3_mix16B(input + 16 * i, + secret + 16 * (i - 8) + XXH3_MIDSIZE_STARTOFFSET, seed); + } + /* last bytes */ + acc += + XXH3_mix16B(input + len - 16, + secret + XXH3_SECRETSIZE_MIN - XXH3_MIDSIZE_LASTOFFSET, seed); + return XXH3_avalanche(acc); +} + +LLVM_ATTRIBUTE_ALWAYS_INLINE +static void XXH3_accumulate_512_scalar(uint64_t *acc, const uint8_t *input, + const uint8_t *secret) { + for (size_t i = 0; i < XXH_ACC_NB; ++i) { + uint64_t data_val = endian::read64le(input + 8 * i); + uint64_t data_key = data_val ^ endian::read64le(secret + 8 * i); + acc[i ^ 1] += data_val; + acc[i] += uint32_t(data_key) * (data_key >> 32); + } +} + +LLVM_ATTRIBUTE_ALWAYS_INLINE +static void XXH3_accumulate_scalar(uint64_t *acc, const uint8_t *input, + const uint8_t *secret, size_t nbStripes) { + for (size_t n = 0; n < nbStripes; ++n) + XXH3_accumulate_512_scalar(acc, input + n * XXH_STRIPE_LEN, + secret + n * XXH_SECRET_CONSUME_RATE); +} + +static void XXH3_scrambleAcc(uint64_t *acc, const uint8_t *secret) { + for (size_t i = 0; i < XXH_ACC_NB; ++i) { + acc[i] ^= acc[i] >> 47; + acc[i] ^= endian::read64le(secret + 8 * i); + acc[i] *= PRIME32_1; + } +} + +static uint64_t XXH3_mix2Accs(const uint64_t *acc, const uint8_t *secret) { + return XXH3_mul128_fold64(acc[0] ^ endian::read64le(secret), + acc[1] ^ endian::read64le(secret + 8)); +} + +static uint64_t XXH3_mergeAccs(const uint64_t *acc, const uint8_t *key, + uint64_t start) { + uint64_t result64 = start; + for (size_t i = 0; i < 4; ++i) + result64 += XXH3_mix2Accs(acc + 2 * i, key + 16 * i); + return XXH3_avalanche(result64); +} + +LLVM_ATTRIBUTE_NOINLINE +static uint64_t XXH3_hashLong_64b(const uint8_t *input, size_t len, + const uint8_t *secret, size_t secretSize) { + const size_t nbStripesPerBlock = + (secretSize - XXH_STRIPE_LEN) / XXH_SECRET_CONSUME_RATE; + const size_t block_len = XXH_STRIPE_LEN * nbStripesPerBlock; + const size_t nb_blocks = (len - 1) / block_len; + alignas(16) uint64_t acc[XXH_ACC_NB] = { + PRIME32_3, PRIME64_1, PRIME64_2, PRIME64_3, + PRIME64_4, PRIME32_2, PRIME64_5, PRIME32_1, + }; + for (size_t n = 0; n < nb_blocks; ++n) { + XXH3_accumulate_scalar(acc, input + n * block_len, secret, + nbStripesPerBlock); + XXH3_scrambleAcc(acc, secret + secretSize - XXH_STRIPE_LEN); + } + + /* last partial block */ + const size_t nbStripes = (len - 1 - (block_len * nb_blocks)) / XXH_STRIPE_LEN; + assert(nbStripes <= secretSize / XXH_SECRET_CONSUME_RATE); + XXH3_accumulate_scalar(acc, input + nb_blocks * block_len, secret, nbStripes); + + /* last stripe */ + constexpr size_t XXH_SECRET_LASTACC_START = 7; + XXH3_accumulate_512_scalar(acc, input + len - XXH_STRIPE_LEN, + secret + secretSize - XXH_STRIPE_LEN - + XXH_SECRET_LASTACC_START); + + /* converge into final hash */ + constexpr size_t XXH_SECRET_MERGEACCS_START = 11; + return XXH3_mergeAccs(acc, secret + XXH_SECRET_MERGEACCS_START, + (uint64_t)len * PRIME64_1); +} + +uint64_t wpi::xxh3_64bits(std::span data) { + auto *in = data.data(); + size_t len = data.size(); + if (len <= 16) + return XXH3_len_0to16_64b(in, len, kSecret, 0); + if (len <= 128) + return XXH3_len_17to128_64b(in, len, kSecret, 0); + if (len <= XXH3_MIDSIZE_MAX) + return XXH3_len_129to240_64b(in, len, kSecret, 0); + return XXH3_hashLong_64b(in, len, kSecret, sizeof(kSecret)); +} diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/ADL.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/ADL.h new file mode 100644 index 00000000000..3be8691d4f7 --- /dev/null +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/ADL.h @@ -0,0 +1,103 @@ +//===- llvm/ADT/ADL.h - Argument dependent lookup utilities -----*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef WPIUTIL_WPI_ADL_H +#define WPIUTIL_WPI_ADL_H + +#include +#include +#include + +namespace wpi { + +// Only used by compiler if both template types are the same. Useful when +// using SFINAE to test for the existence of member functions. +template struct SameType; + +namespace adl_detail { + +using std::begin; + +template +constexpr auto begin_impl(RangeT &&range) + -> decltype(begin(std::forward(range))) { + return begin(std::forward(range)); +} + +using std::end; + +template +constexpr auto end_impl(RangeT &&range) + -> decltype(end(std::forward(range))) { + return end(std::forward(range)); +} + +using std::swap; + +template +constexpr void swap_impl(T &&lhs, + T &&rhs) noexcept(noexcept(swap(std::declval(), + std::declval()))) { + swap(std::forward(lhs), std::forward(rhs)); +} + +using std::size; + +template +constexpr auto size_impl(RangeT &&range) + -> decltype(size(std::forward(range))) { + return size(std::forward(range)); +} + +} // end namespace adl_detail + +/// Returns the begin iterator to \p range using `std::begin` and +/// function found through Argument-Dependent Lookup (ADL). +template +constexpr auto adl_begin(RangeT &&range) + -> decltype(adl_detail::begin_impl(std::forward(range))) { + return adl_detail::begin_impl(std::forward(range)); +} + +/// Returns the end iterator to \p range using `std::end` and +/// functions found through Argument-Dependent Lookup (ADL). +template +constexpr auto adl_end(RangeT &&range) + -> decltype(adl_detail::end_impl(std::forward(range))) { + return adl_detail::end_impl(std::forward(range)); +} + +/// Swaps \p lhs with \p rhs using `std::swap` and functions found through +/// Argument-Dependent Lookup (ADL). +template +constexpr void adl_swap(T &&lhs, T &&rhs) noexcept( + noexcept(adl_detail::swap_impl(std::declval(), std::declval()))) { + adl_detail::swap_impl(std::forward(lhs), std::forward(rhs)); +} + +/// Returns the size of \p range using `std::size` and functions found through +/// Argument-Dependent Lookup (ADL). +template +constexpr auto adl_size(RangeT &&range) + -> decltype(adl_detail::size_impl(std::forward(range))) { + return adl_detail::size_impl(std::forward(range)); +} + +namespace detail { + +template +using IterOfRange = decltype(adl_begin(std::declval())); + +template +using ValueOfRange = + std::remove_reference_t()))>; + +} // namespace detail +} // namespace wpi + +#endif // WPIUTIL_WPI_ADL_H diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/AllocatorBase.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/AllocatorBase.h index dc1d004584b..97a2f488a72 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/AllocatorBase.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/AllocatorBase.h @@ -19,6 +19,12 @@ #ifndef WPIUTIL_WPI_ALLOCATORBASE_H #define WPIUTIL_WPI_ALLOCATORBASE_H +#ifdef _MSC_VER +#define LLVM_ALLOCATORHOLDER_EMPTYBASE __declspec(empty_bases) +#else +#define LLVM_ALLOCATORHOLDER_EMPTYBASE +#endif // _MSC_VER + #include "wpi/Compiler.h" #include "wpi/MemAlloc.h" #include @@ -72,7 +78,7 @@ template class AllocatorBase { /// Deallocate space for a sequence of objects without constructing them. template - std::enable_if_t, void>::value, void> + std::enable_if_t, void>, void> Deallocate(T *Ptr, size_t Num = 1) { Deallocate(static_cast(Ptr), Num * sizeof(T), alignof(T)); } diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Casting.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Casting.h index b85cd8566bc..c91f1b772a9 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Casting.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Casting.h @@ -66,7 +66,7 @@ template struct isa_impl { // Always allow upcasts, and perform no dynamic check for them. template -struct isa_impl::value>> { +struct isa_impl>> { static inline bool doit(const From &) { return true; } }; @@ -231,7 +231,7 @@ struct cast_convert_val { template struct is_simple_type { static const bool value = - std::is_same::SimpleType>::value; + std::is_same_v::SimpleType>; }; // } // namespace detail @@ -275,8 +275,7 @@ struct CastIsPossible> { /// Upcasting (from derived to base) and casting from a type to itself should /// always be possible. template -struct CastIsPossible::value>> { +struct CastIsPossible>> { static inline bool isPossible(const From &f) { return true; } }; @@ -319,7 +318,7 @@ namespace detail { /// A helper to derive the type to use with `Self` for cast traits, when the /// provided CRTP derived type is allowed to be void. template -using SelfType = std::conditional_t::value, +using SelfType = std::conditional_t, Default, OptionalDerived>; } // namespace detail @@ -390,8 +389,8 @@ struct ConstStrippingForwardingCast { // Remove the pointer if it exists, then we can get rid of consts/volatiles. using DecayedFrom = std::remove_cv_t>; // Now if it's a pointer, add it back. Otherwise, we want a ref. - using NonConstFrom = std::conditional_t::value, - DecayedFrom *, DecayedFrom &>; + using NonConstFrom = + std::conditional_t, DecayedFrom *, DecayedFrom &>; static inline bool isPossible(const From &f) { return ForwardTo::isPossible(const_cast(f)); diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Compiler.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Compiler.h index 87a1f203a28..121ed5416d7 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Compiler.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Compiler.h @@ -114,12 +114,24 @@ /// LLVM_EXTERNAL_VISIBILITY - classes, functions, and variables marked with /// this attribute will be made public and visible outside of any shared library /// they are linked in to. -#if __has_attribute(visibility) && \ - (!(defined(_WIN32) || defined(__CYGWIN__)) || \ + +#if LLVM_HAS_CPP_ATTRIBUTE(gnu::visibility) +#define LLVM_ATTRIBUTE_VISIBILITY_HIDDEN [[gnu::visibility("hidden")]] +#define LLVM_ATTRIBUTE_VISIBILITY_DEFAULT [[gnu::visibility("default")]] +#elif __has_attribute(visibility) +#define LLVM_ATTRIBUTE_VISIBILITY_HIDDEN __attribute__((visibility("hidden"))) +#define LLVM_ATTRIBUTE_VISIBILITY_DEFAULT __attribute__((visibility("default"))) +#else +#define LLVM_ATTRIBUTE_VISIBILITY_HIDDEN +#define LLVM_ATTRIBUTE_VISIBILITY_DEFAULT +#endif + + +#if (!(defined(_WIN32) || defined(__CYGWIN__)) || \ (defined(__MINGW32__) && defined(__clang__))) -#define LLVM_LIBRARY_VISIBILITY __attribute__ ((visibility("hidden"))) +#define LLVM_LIBRARY_VISIBILITY LLVM_ATTRIBUTE_VISIBILITY_HIDDEN #if defined(LLVM_BUILD_LLVM_DYLIB) || defined(LLVM_BUILD_SHARED_LIBS) -#define LLVM_EXTERNAL_VISIBILITY __attribute__((visibility("default"))) +#define LLVM_EXTERNAL_VISIBILITY LLVM_ATTRIBUTE_VISIBILITY_DEFAULT #else #define LLVM_EXTERNAL_VISIBILITY #endif diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/DJB.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/DJB.h deleted file mode 100644 index 2615bba4bdb..00000000000 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/DJB.h +++ /dev/null @@ -1,29 +0,0 @@ -//===-- llvm/Support/DJB.h ---DJB Hash --------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// This file contains support for the DJ Bernstein hash function. -// -//===----------------------------------------------------------------------===// - -#ifndef WPIUTIL_WPI_DJB_H -#define WPIUTIL_WPI_DJB_H - -#include - -namespace wpi { - -/// The Bernstein hash function used by the DWARF accelerator tables. -inline uint32_t djbHash(std::string_view Buffer, uint32_t H = 5381) { - for (unsigned char C : Buffer) - H = (H << 5) + H + C; - return H; -} - -} // namespace wpi - -#endif // WPIUTIL_WPI_DJB_H diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/DenseMap.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/DenseMap.h index fbd1644cc9b..2b872de732d 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/DenseMap.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/DenseMap.h @@ -23,6 +23,7 @@ #include "wpi/ReverseIteration.h" #include "wpi/type_traits.h" #include +#include #include #include #include @@ -141,10 +142,15 @@ class DenseMapBase : public DebugEpochBase { setNumTombstones(0); } + /// Return true if the specified key is in the map, false otherwise. + bool contains(const_arg_type_t Val) const { + const BucketT *TheBucket; + return LookupBucketFor(Val, TheBucket); + } + /// Return 1 if the specified key is in the map, 0 otherwise. size_type count(const_arg_type_t Val) const { - const BucketT *TheBucket; - return LookupBucketFor(Val, TheBucket) ? 1 : 0; + return contains(Val) ? 1 : 0; } iterator find(const_arg_type_t Val) { @@ -201,6 +207,14 @@ class DenseMapBase : public DebugEpochBase { return ValueT(); } + /// at - Return the entry for the specified key, or abort if no such + /// entry exists. + const ValueT &at(const_arg_type_t Val) const { + auto Iter = this->find(std::move(Val)); + assert(Iter != this->end() && "DenseMap::at failed due to a missing key"); + return Iter->second; + } + // Inserts key,value pair into the map if the key isn't already in the map. // If the key is already in the map, it returns false and doesn't update the // value. @@ -299,6 +313,20 @@ class DenseMapBase : public DebugEpochBase { insert(*I); } + /// Returns the value associated to the key in the map if it exists. If it + /// does not exist, emplace a default value for the key and returns a + /// reference to the newly created value. + ValueT &getOrInsertDefault(KeyT &&Key) { + return try_emplace(Key).first->second; + } + + /// Returns the value associated to the key in the map if it exists. If it + /// does not exist, emplace a default value for the key and returns a + /// reference to the newly created value. + ValueT &getOrInsertDefault(const KeyT &Key) { + return try_emplace(Key).first->second; + } + bool erase(const KeyT &Val) { BucketT *TheBucket; if (!LookupBucketFor(Val, TheBucket)) @@ -906,7 +934,7 @@ class SmallDenseMap public: explicit SmallDenseMap(unsigned NumInitBuckets = 0) { if (NumInitBuckets > InlineBuckets) - NumInitBuckets = NextPowerOf2(NumInitBuckets - 1); + NumInitBuckets = std::bit_ceil(NumInitBuckets); init(NumInitBuckets); } diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/DenseMapInfo.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/DenseMapInfo.h index f207359f184..9e939effb51 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/DenseMapInfo.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/DenseMapInfo.h @@ -20,7 +20,6 @@ #include #include #include -#include namespace wpi { @@ -234,6 +233,14 @@ struct DenseMapInfo> { SecondInfo::getHashValue(PairVal.second)); } + // Expose an additional function intended to be used by other + // specializations of DenseMapInfo without needing to know how + // to combine hash values manually + static unsigned getHashValuePiecewise(const T &First, const U &Second) { + return detail::combineHashValue(FirstInfo::getHashValue(First), + SecondInfo::getHashValue(Second)); + } + static bool isEqual(const Pair &LHS, const Pair &RHS) { return FirstInfo::isEqual(LHS.first, RHS.first) && SecondInfo::isEqual(LHS.second, RHS.second); @@ -290,37 +297,6 @@ template struct DenseMapInfo> { } }; -// Provide DenseMapInfo for variants whose all alternatives have DenseMapInfo. -template struct DenseMapInfo> { - using Variant = std::variant; - using FirstT = std::variant_alternative_t<0, Variant>; - - static inline Variant getEmptyKey() { - return Variant(std::in_place_index<0>, DenseMapInfo::getEmptyKey()); - } - - static inline Variant getTombstoneKey() { - return Variant(std::in_place_index<0>, - DenseMapInfo::getTombstoneKey()); - } - - static unsigned getHashValue(const Variant &Val) { - return std::visit( - [&Val](auto &&Alternative) { - using T = std::decay_t; - // Include index in hash to make sure same value as different - // alternatives don't collide. - return detail::combineHashValue( - DenseMapInfo::getHashValue(Val.index()), - DenseMapInfo::getHashValue(Alternative)); - }, - Val); - } - - static bool isEqual(const Variant &LHS, const Variant &RHS) { - return LHS == RHS; - } -}; } // end namespace wpi #endif // WPIUTIL_WPI_DENSEMAPINFO_H diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/DenseMapInfoVariant.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/DenseMapInfoVariant.h new file mode 100644 index 00000000000..b2d9739f0b2 --- /dev/null +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/DenseMapInfoVariant.h @@ -0,0 +1,71 @@ +//===- DenseMapInfoVariant.h - Type traits for DenseMap *- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// This file defines DenseMapInfo traits for DenseMap>. +/// +//===----------------------------------------------------------------------===// + +#ifndef WPIUTIL_WPI_DENSEMAPINFOVARIANT_H +#define WPIUTIL_WPI_DENSEMAPINFOVARIANT_H + +#include "wpi/DenseMapInfo.h" +#include +#include + +namespace wpi { + +// Provide DenseMapInfo for variants whose all alternatives have DenseMapInfo. +template struct DenseMapInfo> { + using Variant = std::variant; + using FirstT = std::variant_alternative_t<0, Variant>; + + static inline Variant getEmptyKey() { + return Variant(std::in_place_index<0>, DenseMapInfo::getEmptyKey()); + } + + static inline Variant getTombstoneKey() { + return Variant(std::in_place_index<0>, + DenseMapInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const Variant &Val) { + return std::visit( + [&Val](auto &&Alternative) { + using T = std::decay_t; + // Include index in hash to make sure same value as different + // alternatives don't collide. + return DenseMapInfo>::getHashValuePiecewise( + Val.index(), Alternative); + }, + Val); + } + + static bool isEqual(const Variant &LHS, const Variant &RHS) { + if (LHS.index() != RHS.index()) + return false; + if (LHS.valueless_by_exception()) + return true; + // We want to dispatch to DenseMapInfo::isEqual(LHS.get(I), RHS.get(I)) + // We know the types are the same, but std::visit(V, LHS, RHS) doesn't. + // We erase the type held in LHS to void*, and dispatch over RHS. + const void *ErasedLHS = + std::visit([](const auto &LHS) -> const void * { return &LHS; }, LHS); + return std::visit( + [&](const auto &RHS) -> bool { + using T = std::remove_cv_t>; + return DenseMapInfo::isEqual(*static_cast(ErasedLHS), + RHS); + }, + RHS); + } +}; + +} // end namespace wpi + +#endif // WPIUTIL_WPI_DENSEMAPINFOVARIANT_H diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/EpochTracker.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/EpochTracker.h index 14a32f16998..8cb122a7d57 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/EpochTracker.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/EpochTracker.h @@ -22,6 +22,7 @@ namespace wpi { #ifndef NDEBUG //ifndef LLVM_ENABLE_ABI_BREAKING_CHECKS +#define LLVM_DEBUGEPOCHBASE_HANDLEBASE_EMPTYBASE /// A base class for data structure classes wishing to make iterators /// ("handles") pointing into themselves fail-fast. When building without @@ -77,6 +78,11 @@ class DebugEpochBase { }; #else +#ifdef _MSC_VER +#define LLVM_DEBUGEPOCHBASE_HANDLEBASE_EMPTYBASE __declspec(empty_bases) +#else +#define LLVM_DEBUGEPOCHBASE_HANDLEBASE_EMPTYBASE +#endif // _MSC_VER class DebugEpochBase { public: diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/ErrorHandling.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/ErrorHandling.h index f3cf658fe6b..abc9d7dc39a 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/ErrorHandling.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/ErrorHandling.h @@ -44,7 +44,7 @@ namespace wpi { void install_fatal_error_handler(fatal_error_handler_t handler, void *user_data = nullptr); - /// Restores default error handling behavior. + /// Restores default error handling behaviour. void remove_fatal_error_handler(); /// ScopedFatalErrorHandler - This is a simple helper class which just diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/FunctionExtras.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/FunctionExtras.h index e7c5a17f0e0..8c6d8472a2e 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/FunctionExtras.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/FunctionExtras.h @@ -67,7 +67,7 @@ namespace detail { template using EnableIfTrivial = - std::enable_if_t::value && + std::enable_if_t::value && std::is_trivially_destructible::value>; template using EnableUnlessSameType = @@ -107,11 +107,11 @@ template class UniqueFunctionBase { template struct AdjustedParamTBase { static_assert(!std::is_reference::value, "references should be handled by template specialization"); - using type = std::conditional_t< - wpi::is_trivially_copy_constructible::value && - wpi::is_trivially_move_constructible::value && - IsSizeLessThanThresholdT::value, - T, T &>; + using type = + std::conditional_t::value && + std::is_trivially_move_constructible::value && + IsSizeLessThanThresholdT::value, + T, T &>; }; // This specialization ensures that 'AdjustedParam&>' or @@ -179,16 +179,15 @@ template class UniqueFunctionBase { bool isInlineStorage() const { return CallbackAndInlineFlag.getInt(); } bool isTrivialCallback() const { - return CallbackAndInlineFlag.getPointer().template is(); + return isa(CallbackAndInlineFlag.getPointer()); } CallPtrT getTrivialCallback() const { - return CallbackAndInlineFlag.getPointer().template get()->CallPtr; + return cast(CallbackAndInlineFlag.getPointer())->CallPtr; } NonTrivialCallbacks *getNonTrivialCallbacks() const { - return CallbackAndInlineFlag.getPointer() - .template get(); + return cast(CallbackAndInlineFlag.getPointer()); } CallPtrT getCallPtr() const { diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Hashing.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Hashing.h index 0f5c224352f..bdb439c2172 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Hashing.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Hashing.h @@ -48,6 +48,7 @@ #include "wpi/SwapByteOrder.h" #include "wpi/type_traits.h" #include +#include #include #include #include @@ -223,29 +224,30 @@ inline uint64_t hash_17to32_bytes(const char *s, size_t len, uint64_t seed) { uint64_t b = fetch64(s + 8); uint64_t c = fetch64(s + len - 8) * k2; uint64_t d = fetch64(s + len - 16) * k0; - return hash_16_bytes(rotate(a - b, 43) + rotate(c ^ seed, 30) + d, - a + rotate(b ^ k3, 20) - c + len + seed); + return hash_16_bytes(std::rotr(a - b, 43) + + std::rotr(c ^ seed, 30) + d, + a + std::rotr(b ^ k3, 20) - c + len + seed); } inline uint64_t hash_33to64_bytes(const char *s, size_t len, uint64_t seed) { uint64_t z = fetch64(s + 24); uint64_t a = fetch64(s) + (len + fetch64(s + len - 16)) * k0; - uint64_t b = rotate(a + z, 52); - uint64_t c = rotate(a, 37); + uint64_t b = std::rotr(a + z, 52); + uint64_t c = std::rotr(a, 37); a += fetch64(s + 8); - c += rotate(a, 7); + c += std::rotr(a, 7); a += fetch64(s + 16); uint64_t vf = a + z; - uint64_t vs = b + rotate(a, 31) + c; + uint64_t vs = b + std::rotr(a, 31) + c; a = fetch64(s + 16) + fetch64(s + len - 32); z = fetch64(s + len - 8); - b = rotate(a + z, 52); - c = rotate(a, 37); + b = std::rotr(a + z, 52); + c = std::rotr(a, 37); a += fetch64(s + len - 24); - c += rotate(a, 7); + c += std::rotr(a, 7); a += fetch64(s + len - 16); uint64_t wf = a + z; - uint64_t ws = b + rotate(a, 31) + c; + uint64_t ws = b + std::rotr(a, 31) + c; uint64_t r = shift_mix((vf + ws) * k2 + (wf + vs) * k0); return shift_mix((seed ^ (r * k0)) + vs) * k2; } @@ -275,9 +277,13 @@ struct hash_state { /// seed and the first 64-byte chunk. /// This effectively performs the initial mix. static hash_state create(const char *s, uint64_t seed) { - hash_state state = { - 0, seed, hash_16_bytes(seed, k1), rotate(seed ^ k1, 49), - seed * k1, shift_mix(seed), 0 }; + hash_state state = {0, + seed, + hash_16_bytes(seed, k1), + std::rotr(seed ^ k1, 49), + seed * k1, + shift_mix(seed), + 0}; state.h6 = hash_16_bytes(state.h4, state.h5); state.mix(s); return state; @@ -288,10 +294,10 @@ struct hash_state { static void mix_32_bytes(const char *s, uint64_t &a, uint64_t &b) { a += fetch64(s); uint64_t c = fetch64(s + 24); - b = rotate(b + a + c, 21); + b = std::rotr(b + a + c, 21); uint64_t d = a; a += fetch64(s + 8) + fetch64(s + 16); - b += rotate(a, 44) + d; + b += std::rotr(a, 44) + d; a += c; } @@ -299,11 +305,11 @@ struct hash_state { /// We mix all 64 bytes even when the chunk length is smaller, but we /// record the actual length. void mix(const char *s) { - h0 = rotate(h0 + h1 + h3 + fetch64(s + 8), 37) * k1; - h1 = rotate(h1 + h4 + fetch64(s + 48), 42) * k1; + h0 = std::rotr(h0 + h1 + h3 + fetch64(s + 8), 37) * k1; + h1 = std::rotr(h1 + h4 + fetch64(s + 48), 42) * k1; h0 ^= h6; h1 += h3 + fetch64(s + 40); - h2 = rotate(h2 + h5, 33) * k1; + h2 = std::rotr(h2 + h5, 33) * k1; h3 = h4 * k1; h4 = h0 + h5; mix_32_bytes(s, h3, h4); diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/MapVector.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/MapVector.h index 26db80038de..ce6fe78702f 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/MapVector.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/MapVector.h @@ -10,7 +10,7 @@ /// This file implements a map that provides insertion order iteration. The /// interface is purposefully minimal. The key is assumed to be cheap to copy /// and 2 copies are kept, one for indexing in a DenseMap, one for iteration in -/// a std::vector. +/// a SmallVector. /// //===----------------------------------------------------------------------===// @@ -24,16 +24,15 @@ #include #include #include -#include namespace wpi { /// This class implements a map that also provides access to all stored values -/// in a deterministic order. The values are kept in a std::vector and the +/// in a deterministic order. The values are kept in a SmallVector<*, 0> and the /// mapping is done with DenseMap from Keys to indexes in that vector. -template, - typename VectorType = std::vector>> +template , + typename VectorType = SmallVector, 0>> class MapVector { MapType Map; VectorType Vector; @@ -140,10 +139,9 @@ class MapVector { return std::make_pair(begin() + I, false); } - size_type count(const KeyT &Key) const { - typename MapType::const_iterator Pos = Map.find(Key); - return Pos == Map.end()? 0 : 1; - } + bool contains(const KeyT &Key) const { return Map.find(Key) != Map.end(); } + + size_type count(const KeyT &Key) const { return contains(Key) ? 1 : 0; } iterator find(const KeyT &Key) { typename MapType::const_iterator Pos = Map.find(Key); diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/MathExtras.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/MathExtras.h index af3727ba64b..b77cce7bd9d 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/MathExtras.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/MathExtras.h @@ -25,55 +25,10 @@ namespace wpi { -/// The behavior an operation has on an input of 0. -enum ZeroBehavior { - /// The returned value is undefined. - ZB_Undefined, - /// The returned value is numeric_limits::max() - ZB_Max -}; - -/// Count number of 0's from the least significant bit to the most -/// stopping at the first 1. -/// -/// Only unsigned integral types are allowed. -/// -/// Returns std::numeric_limits::digits on an input of 0. -template unsigned countTrailingZeros(T Val) { - static_assert(std::is_unsigned_v, - "Only unsigned integral types are allowed."); - return std::countr_zero(Val); -} - -/// Count number of 0's from the most significant bit to the least -/// stopping at the first 1. -/// -/// Only unsigned integral types are allowed. -/// -/// Returns std::numeric_limits::digits on an input of 0. -template unsigned countLeadingZeros(T Val) { - static_assert(std::is_unsigned_v, - "Only unsigned integral types are allowed."); - return std::countl_zero(Val); -} - -/// Get the index of the first set bit starting from the least -/// significant bit. -/// -/// Only unsigned integral types are allowed. -/// -/// \param ZB the behavior on an input of 0. -template T findFirstSet(T Val, ZeroBehavior ZB = ZB_Max) { - if (ZB == ZB_Max && Val == 0) - return (std::numeric_limits::max)(); - - return std::countr_zero(Val); -} - /// Create a bitmask with the N right-most bits set to 1, and all other /// bits set to 0. Only unsigned types are allowed. template T maskTrailingOnes(unsigned N) { - static_assert(std::is_unsigned::value, "Invalid type!"); + static_assert(std::is_unsigned_v, "Invalid type!"); const unsigned Bits = CHAR_BIT * sizeof(T); assert(N <= Bits && "Invalid bit index"); return N == 0 ? 0 : (T(-1) >> (Bits - N)); @@ -97,21 +52,6 @@ template T maskLeadingZeros(unsigned N) { return maskTrailingOnes(CHAR_BIT * sizeof(T) - N); } -/// Get the index of the last set bit starting from the least -/// significant bit. -/// -/// Only unsigned integral types are allowed. -/// -/// \param ZB the behavior on an input of 0. -template T findLastSet(T Val, ZeroBehavior ZB = ZB_Max) { - if (ZB == ZB_Max && Val == 0) - return (std::numeric_limits::max)(); - - // Use ^ instead of - because both gcc and llvm can remove the associated ^ - // in the __builtin_clz intrinsic on x86. - return std::countl_zero(Val) ^ (std::numeric_limits::digits - 1); -} - /// Macro compressed bit reversal table for 256 bits. /// /// http://graphics.stanford.edu/~seander/bithacks.html#BitReverseTable @@ -304,42 +244,6 @@ constexpr inline bool isPowerOf2_64(uint64_t Value) { return std::has_single_bit(Value); } -/// Count the number of ones from the most significant bit to the first -/// zero bit. -/// -/// Ex. countLeadingOnes(0xFF0FFF00) == 8. -/// Only unsigned integral types are allowed. -/// -/// Returns std::numeric_limits::digits on an input of all ones. -template unsigned countLeadingOnes(T Value) { - static_assert(std::is_unsigned_v, - "Only unsigned integral types are allowed."); - return std::countl_one(Value); -} - -/// Count the number of ones from the least significant bit to the first -/// zero bit. -/// -/// Ex. countTrailingOnes(0x00FF00FF) == 8. -/// Only unsigned integral types are allowed. -/// -/// Returns std::numeric_limits::digits on an input of all ones. -template unsigned countTrailingOnes(T Value) { - static_assert(std::is_unsigned_v, - "Only unsigned integral types are allowed."); - return std::countr_one(Value); -} - -/// Count the number of set bits in a value. -/// Ex. countPopulation(0xF000F000) = 8 -/// Returns 0 if the word is zero. -template -inline unsigned countPopulation(T Value) { - static_assert(std::is_unsigned_v, - "Only unsigned integral types are allowed."); - return (unsigned)std::popcount(Value); -} - /// Return true if the argument contains a non-empty sequence of ones with the /// remainder zero (32 bit version.) Ex. isShiftedMask_32(0x0000FF00U) == true. /// If true, \p MaskIdx will specify the index of the lowest set bit and \p @@ -403,34 +307,6 @@ inline unsigned Log2_64_Ceil(uint64_t Value) { return static_cast(64 - std::countl_zero(Value - 1)); } -/// This function takes a 64-bit integer and returns the bit equivalent double. -inline double BitsToDouble(uint64_t Bits) { - static_assert(sizeof(uint64_t) == sizeof(double), "Unexpected type sizes"); - return wpi::bit_cast(Bits); -} - -/// This function takes a 32-bit integer and returns the bit equivalent float. -inline float BitsToFloat(uint32_t Bits) { - static_assert(sizeof(uint32_t) == sizeof(float), "Unexpected type sizes"); - return wpi::bit_cast(Bits); -} - -/// This function takes a double and returns the bit equivalent 64-bit integer. -/// Note that copying doubles around changes the bits of NaNs on some hosts, -/// notably x86, so this routine cannot be used if these bits are needed. -inline uint64_t DoubleToBits(double Double) { - static_assert(sizeof(uint64_t) == sizeof(double), "Unexpected type sizes"); - return wpi::bit_cast(Double); -} - -/// This function takes a float and returns the bit equivalent 32-bit integer. -/// Note that copying floats around changes the bits of NaNs on some hosts, -/// notably x86, so this routine cannot be used if these bits are needed. -inline uint32_t FloatToBits(float Float) { - static_assert(sizeof(uint32_t) == sizeof(float), "Unexpected type sizes"); - return wpi::bit_cast(Float); -} - /// A and B are either alignments or offsets. Return the minimum alignment that /// may be assumed after adding the two together. constexpr inline uint64_t MinAlign(uint64_t A, uint64_t B) { @@ -454,12 +330,6 @@ constexpr inline uint64_t NextPowerOf2(uint64_t A) { return A + 1; } -/// Returns the power of two which is less than or equal to the given value. -/// Essentially, it is a floor operation across the domain of powers of two. -inline uint64_t PowerOf2Floor(uint64_t A) { - return std::bit_floor(A); -} - /// Returns the power of two which is greater than or equal to the given value. /// Essentially, it is a ceil operation across the domain of powers of two. inline uint64_t PowerOf2Ceil(uint64_t A) { @@ -567,7 +437,7 @@ inline int64_t SignExtend64(uint64_t X, unsigned B) { /// Subtract two unsigned integers, X and Y, of type T and return the absolute /// value of the result. template -std::enable_if_t::value, T> AbsoluteDifference(T X, T Y) { +std::enable_if_t, T> AbsoluteDifference(T X, T Y) { return X > Y ? (X - Y) : (Y - X); } @@ -575,7 +445,7 @@ std::enable_if_t::value, T> AbsoluteDifference(T X, T Y) { /// maximum representable value of T on overflow. ResultOverflowed indicates if /// the result is larger than the maximum representable value of type T. template -std::enable_if_t::value, T> +std::enable_if_t, T> SaturatingAdd(T X, T Y, bool *ResultOverflowed = nullptr) { bool Dummy; bool &Overflowed = ResultOverflowed ? *ResultOverflowed : Dummy; @@ -604,7 +474,7 @@ std::enable_if_t, T> SaturatingAdd(T X, T Y, T Z, /// maximum representable value of T on overflow. ResultOverflowed indicates if /// the result is larger than the maximum representable value of type T. template -std::enable_if_t::value, T> +std::enable_if_t, T> SaturatingMultiply(T X, T Y, bool *ResultOverflowed = nullptr) { bool Dummy; bool &Overflowed = ResultOverflowed ? *ResultOverflowed : Dummy; @@ -650,7 +520,7 @@ SaturatingMultiply(T X, T Y, bool *ResultOverflowed = nullptr) { /// overflow. ResultOverflowed indicates if the result is larger than the /// maximum representable value of type T. template -std::enable_if_t::value, T> +std::enable_if_t, T> SaturatingMultiplyAdd(T X, T Y, T A, bool *ResultOverflowed = nullptr) { bool Dummy; bool &Overflowed = ResultOverflowed ? *ResultOverflowed : Dummy; @@ -669,7 +539,7 @@ extern const float huge_valf; /// Add two signed integers, computing the two's complement truncated result, /// returning true if overflow occurred. template -std::enable_if_t::value, T> AddOverflow(T X, T Y, T &Result) { +std::enable_if_t, T> AddOverflow(T X, T Y, T &Result) { #if __has_builtin(__builtin_add_overflow) return __builtin_add_overflow(X, Y, &Result); #else @@ -695,7 +565,7 @@ std::enable_if_t::value, T> AddOverflow(T X, T Y, T &Result) { /// Subtract two signed integers, computing the two's complement truncated /// result, returning true if an overflow ocurred. template -std::enable_if_t::value, T> SubOverflow(T X, T Y, T &Result) { +std::enable_if_t, T> SubOverflow(T X, T Y, T &Result) { #if __has_builtin(__builtin_sub_overflow) return __builtin_sub_overflow(X, Y, &Result); #else @@ -721,7 +591,7 @@ std::enable_if_t::value, T> SubOverflow(T X, T Y, T &Result) { /// Multiply two signed integers, computing the two's complement truncated /// result, returning true if an overflow ocurred. template -std::enable_if_t::value, T> MulOverflow(T X, T Y, T &Result) { +std::enable_if_t, T> MulOverflow(T X, T Y, T &Result) { // Perform the unsigned multiplication on absolute values. using U = std::make_unsigned_t; const U UX = X < 0 ? (0 - static_cast(X)) : static_cast(X); diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/PointerIntPair.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/PointerIntPair.h index 2344001e9b4..22205c9a719 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/PointerIntPair.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/PointerIntPair.h @@ -19,10 +19,44 @@ #include "wpi/type_traits.h" #include #include +#include #include namespace wpi { +namespace detail { +template struct PunnedPointer { + static_assert(sizeof(Ptr) == sizeof(intptr_t), ""); + + // Asserts that allow us to let the compiler implement the destructor and + // copy/move constructors + static_assert(std::is_trivially_destructible::value, ""); + static_assert(std::is_trivially_copy_constructible::value, ""); + static_assert(std::is_trivially_move_constructible::value, ""); + + explicit constexpr PunnedPointer(intptr_t i = 0) { *this = i; } + + constexpr intptr_t asInt() const { + intptr_t R = 0; + std::memcpy(&R, Data, sizeof(R)); + return R; + } + + constexpr operator intptr_t() const { return asInt(); } + + constexpr PunnedPointer &operator=(intptr_t V) { + std::memcpy(Data, &V, sizeof(Data)); + return *this; + } + + Ptr *getPointerAddress() { return reinterpret_cast(Data); } + const Ptr *getPointerAddress() const { return reinterpret_cast(Data); } + +private: + alignas(Ptr) unsigned char Data[sizeof(Ptr)]; +}; +} // namespace detail + template struct DenseMapInfo; template struct PointerIntPairInfo; @@ -46,7 +80,7 @@ template Value; public: constexpr PointerIntPair() = default; @@ -86,10 +120,12 @@ class PointerIntPair { assert(Value == reinterpret_cast(getPointer()) && "Can only return the address if IntBits is cleared and " "PtrTraits doesn't change the pointer"); - return reinterpret_cast(&Value); + return Value.getPointerAddress(); } - void *getOpaqueValue() const { return reinterpret_cast(Value); } + void *getOpaqueValue() const { + return reinterpret_cast(Value.asInt()); + } void setFromOpaqueValue(void *Val) & { Value = reinterpret_cast(Val); diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/PointerUnion.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/PointerUnion.h index f0ed39223ac..5053a5fcc37 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/PointerUnion.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/PointerUnion.h @@ -217,9 +217,9 @@ class PointerUnion /// If the union is set to the first pointer type get an address pointing to /// it. First *getAddrOfPtr1() { - assert(is() && "Val is not the first pointer"); + assert(isa(*this) && "Val is not the first pointer"); assert( - PointerLikeTypeTraits::getAsVoidPointer(get()) == + PointerLikeTypeTraits::getAsVoidPointer(cast(*this)) == this->Val.getPointer() && "Can't get the address because PointerLikeTypeTraits changes the ptr"); return const_cast( @@ -276,7 +276,7 @@ template struct CastInfoPointerUnionImpl { } template static To doCast(From &F) { - assert(isPossible(F) && "cast to an incompatible type !"); + assert(isPossible(F) && "cast to an incompatible type!"); return PointerLikeTypeTraits::getFromVoidPointer(F.Val.getPointer()); } }; diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/ReverseIteration.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/ReverseIteration.h index f46d38dda48..5425cd95701 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/ReverseIteration.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/ReverseIteration.h @@ -14,5 +14,5 @@ bool shouldReverseIterate() { #endif } -} +} // namespace wpi #endif diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallPtrSet.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallPtrSet.h index 824518d61b4..db2b471509d 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallPtrSet.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallPtrSet.h @@ -264,8 +264,9 @@ class SmallPtrSetIteratorImpl { /// SmallPtrSetIterator - This implements a const_iterator for SmallPtrSet. template -class SmallPtrSetIterator : public SmallPtrSetIteratorImpl, - DebugEpochBase::HandleBase { +class LLVM_DEBUGEPOCHBASE_HANDLEBASE_EMPTYBASE SmallPtrSetIterator + : public SmallPtrSetIteratorImpl, + DebugEpochBase::HandleBase { using PtrTraits = PointerLikeTypeTraits; public: diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallSet.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallSet.h index 26796429657..699be241e2b 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallSet.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallSet.h @@ -149,7 +149,9 @@ class SmallSet { static_assert(N <= 32, "N should be small"); public: + using key_type = T; using size_type = size_t; + using value_type = T; using const_iterator = SmallSetIterator; SmallSet() = default; diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallVector.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallVector.h index 8f7af89b0d6..3b4b890db54 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallVector.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallVector.h @@ -328,8 +328,8 @@ class SmallVectorTemplateCommon /// copy these types with memcpy, there is no way for the type to observe this. /// This catches the important case of std::pair, which is not /// trivially assignable. -template ::value) && - (is_trivially_move_constructible::value) && +template ::value) && + (std::is_trivially_move_constructible::value) && std::is_trivially_destructible::value> class SmallVectorTemplateBase : public SmallVectorTemplateCommon { friend class SmallVectorTemplateCommon; @@ -1208,7 +1208,12 @@ class LLVM_GSL_OWNER SmallVector : public SmallVectorImpl, this->destroy_range(this->begin(), this->end()); } - explicit SmallVector(size_t Size, const T &Value = T()) + explicit SmallVector(size_t Size) + : SmallVectorImpl(N) { + this->resize(Size); + } + + SmallVector(size_t Size, const T &Value) : SmallVectorImpl(N) { this->assign(Size, Value); } diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/StringMap.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/StringMap.h index 8b1d66a8dca..323d22e7442 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/StringMap.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/StringMap.h @@ -111,8 +111,9 @@ class StringMapImpl { /// funky memory allocation and hashing things to make it extremely efficient, /// storing the string data *after* the value in the map. template -class StringMap : public StringMapImpl, - private detail::AllocatorHolder { +class LLVM_ALLOCATORHOLDER_EMPTYBASE StringMap + : public StringMapImpl, + private detail::AllocatorHolder { using AllocTy = detail::AllocatorHolder; public: @@ -235,18 +236,29 @@ class StringMap : public StringMapImpl, /// lookup - Return the entry for the specified key, or a default /// constructed value if no such entry exists. ValueTy lookup(std::string_view Key) const { - const_iterator it = find(Key); - if (it != end()) - return it->second; + const_iterator Iter = find(Key); + if (Iter != end()) + return Iter->second; return ValueTy(); } + /// at - Return the entry for the specified key, or abort if no such + /// entry exists. + const ValueTy &at(std::string_view Val) const { + auto Iter = this->find(std::move(Val)); + assert(Iter != this->end() && "StringMap::at failed due to a missing key"); + return Iter->second; + } + /// Lookup the ValueTy for the \p Key, or create a default constructed value /// if the key is not in the map. ValueTy &operator[](std::string_view Key) { return try_emplace(Key).first->second; } + /// contains - Return true if the element is in the map, false otherwise. + bool contains(std::string_view Key) const { return find(Key) != end(); } + /// count - Return 1 if the element is in the map, 0 otherwise. - size_type count(std::string_view Key) const { return find(Key) == end() ? 0 : 1; } + size_type count(std::string_view Key) const { return contains(Key) ? 1 : 0; } template size_type count(const StringMapEntry &MapEntry) const { diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SwapByteOrder.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SwapByteOrder.h index 47706cf6ab9..af7fcf9eb88 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SwapByteOrder.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SwapByteOrder.h @@ -46,16 +46,6 @@ namespace wpi { -/// ByteSwap_16 - This function returns a byte-swapped representation of -/// the 16-bit argument. -inline uint16_t ByteSwap_16(uint16_t value) { return wpi::byteswap(value); } - -/// This function returns a byte-swapped representation of the 32-bit argument. -inline uint32_t ByteSwap_32(uint32_t value) { return wpi::byteswap(value); } - -/// This function returns a byte-swapped representation of the 64-bit argument. -inline uint64_t ByteSwap_64(uint64_t value) { return wpi::byteswap(value); } - namespace sys { #if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN @@ -103,7 +93,7 @@ inline double getSwappedBytes(double C) { } template -inline std::enable_if_t::value, T> getSwappedBytes(T C) { +inline std::enable_if_t, T> getSwappedBytes(T C) { return static_cast( wpi::byteswap(static_cast>(C))); } diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/iterator_range.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/iterator_range.h index ce0e4ee7ef1..afb73436365 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/iterator_range.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/iterator_range.h @@ -18,10 +18,22 @@ #ifndef WPIUTIL_WPI_ITERATOR_RANGE_H #define WPIUTIL_WPI_ITERATOR_RANGE_H +#include "wpi/ADL.h" +#include #include namespace wpi { +template +struct explicitly_convertible : std::false_type {}; + +template +struct explicitly_convertible< + From, To, + std::void_t( + std::declval>()))>> : std::true_type { +}; + /// A range adaptor for a pair of iterators. /// /// This just wraps two iterators into a range-compatible interface. Nothing @@ -31,12 +43,19 @@ class iterator_range { IteratorT begin_iterator, end_iterator; public: - //TODO: Add SFINAE to test that the Container's iterators match the range's - // iterators. +#if __GNUC__ == 7 + // Be careful no to break gcc-7 on the mlir target. + // See https://github.com/llvm/llvm-project/issues/63843 template +#else + template , IteratorT>::value> * = nullptr> +#endif iterator_range(Container &&c) - //TODO: Consider ADL/non-member begin/end calls. - : begin_iterator(c.begin()), end_iterator(c.end()) {} + : begin_iterator(adl_begin(std::forward(c))), + end_iterator(adl_end(std::forward(c))) { + } iterator_range(IteratorT begin_iterator, IteratorT end_iterator) : begin_iterator(std::move(begin_iterator)), end_iterator(std::move(end_iterator)) {} @@ -46,6 +65,9 @@ class iterator_range { bool empty() const { return begin_iterator == end_iterator; } }; +template +iterator_range(Container &&) -> iterator_range>; + /// Convenience function for iterating over sub-ranges. /// /// This provides a bit of syntactic sugar to make using sub-ranges diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/raw_ostream.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/raw_ostream.h index 49fb44d8736..7a804d53fe2 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/raw_ostream.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/raw_ostream.h @@ -387,8 +387,8 @@ class raw_ostream { /// Call the appropriate insertion operator, given an rvalue reference to a /// raw_ostream object and return a stream of the same type as the argument. template -std::enable_if_t::value && - std::is_base_of::value, +std::enable_if_t && + std::is_base_of_v, OStream &&> operator<<(OStream &&OS, const T &Value) { OS << Value; diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/type_traits.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/type_traits.h index 7fe78660b65..d74fd0fa616 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/type_traits.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/type_traits.h @@ -32,11 +32,11 @@ template class is_integral_or_enum { public: static const bool value = - !std::is_class::value && // Filter conversion operators. - !std::is_pointer::value && - !std::is_floating_point::value && - (std::is_enum::value || - std::is_convertible::value); + !std::is_class_v && // Filter conversion operators. + !std::is_pointer_v && + !std::is_floating_point_v && + (std::is_enum_v || + std::is_convertible_v); }; /// If T is a pointer, just return it. If it is not, return T&. @@ -45,7 +45,7 @@ struct add_lvalue_reference_if_not_pointer { using type = T &; }; template struct add_lvalue_reference_if_not_pointer< - T, std::enable_if_t::value>> { + T, std::enable_if_t>> { using type = T; }; @@ -55,7 +55,7 @@ template struct add_const_past_pointer { using type = const T; }; template -struct add_const_past_pointer::value>> { +struct add_const_past_pointer>> { using type = const std::remove_pointer_t *; }; @@ -64,27 +64,11 @@ struct const_pointer_or_const_ref { using type = const T &; }; template -struct const_pointer_or_const_ref::value>> { +struct const_pointer_or_const_ref>> { using type = typename add_const_past_pointer::type; }; namespace detail { -/// Internal utility to detect trivial copy construction. -template union copy_construction_triviality_helper { - T t; - copy_construction_triviality_helper() = default; - copy_construction_triviality_helper(const copy_construction_triviality_helper&) = default; - ~copy_construction_triviality_helper() = default; -}; -/// Internal utility to detect trivial move construction. -template union move_construction_triviality_helper { - T t; - move_construction_triviality_helper() = default; - move_construction_triviality_helper(move_construction_triviality_helper&&) = default; - ~move_construction_triviality_helper() = default; -}; - template union trivial_helper { T t; @@ -92,12 +76,6 @@ union trivial_helper { } // end namespace detail -template -using is_trivially_move_constructible = std::is_trivially_move_constructible; - -template -using is_trivially_copy_constructible = std::is_trivially_copy_constructible; - } // end namespace wpi #endif // WPIUTIL_WPI_TYPE_TRAITS_H diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/xxhash.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/xxhash.h new file mode 100644 index 00000000000..e0284bc523f --- /dev/null +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/xxhash.h @@ -0,0 +1,56 @@ +/* + xxHash - Extremely Fast Hash algorithm + Header File + Copyright (C) 2012-2016, Yann Collet. + + BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + You can contact the author at : + - xxHash source repository : https://github.com/Cyan4973/xxHash +*/ + +/* based on revision d2df04efcbef7d7f6886d345861e5dfda4edacc1 Removed + * everything but a simple interface for computing XXh64. */ + +#ifndef WPIUTIL_WPI_XXHASH_H +#define WPIUTIL_WPI_XXHASH_H + +#include + +#include +#include + +namespace wpi { +uint64_t xxHash64(std::string_view Data); +uint64_t xxHash64(std::span Data); + +uint64_t xxh3_64bits(std::span data); +inline uint64_t xxh3_64bits(std::string_view data) { + return xxh3_64bits(std::span(reinterpret_cast(data.data()), data.size())); +} +} + +#endif diff --git a/wpiutil/src/test/native/cpp/json/unit-cbor.cpp b/wpiutil/src/test/native/cpp/json/unit-cbor.cpp index f96ff522ac8..f39302c0580 100644 --- a/wpiutil/src/test/native/cpp/json/unit-cbor.cpp +++ b/wpiutil/src/test/native/cpp/json/unit-cbor.cpp @@ -1699,5 +1699,8 @@ static const internal::CborRoundtripTestParam rfc7049_appendix_a_objects[] = { {"{\"Fun\": true, \"Amt\": -2}", {0xbf,0x63,0x46,0x75,0x6e,0xf5,0x63,0x41,0x6d,0x74,0x21,0xff}, false}, }; -INSTANTIATE_TEST_SUITE_P(CborRfc7049AppendixAObjectTests, CborRoundtripTest, +// Disabled because serialization order isn't guaranteed by the underlying map +// container +INSTANTIATE_TEST_SUITE_P(DISABLED_CborRfc7049AppendixAObjectTests, + CborRoundtripTest, ::testing::ValuesIn(rfc7049_appendix_a_objects)); diff --git a/wpiutil/src/test/native/cpp/json/unit-comparison.cpp b/wpiutil/src/test/native/cpp/json/unit-comparison.cpp index be1c90215a4..041a8d0f595 100644 --- a/wpiutil/src/test/native/cpp/json/unit-comparison.cpp +++ b/wpiutil/src/test/native/cpp/json/unit-comparison.cpp @@ -164,7 +164,9 @@ TEST_F(JsonComparisonValuesTest, NotEqual) EXPECT_EQ(nullptr != j_null, !(nullptr == j_null)); } -TEST_F(JsonComparisonValuesTest, Less) +// Disabled because serialization order isn't guaranteed by the underlying map +// container +TEST_F(JsonComparisonValuesTest, DISABLED_Less) { static const std::vector> expected = { diff --git a/wpiutil/src/test/native/cpp/json/unit-element_access2.cpp b/wpiutil/src/test/native/cpp/json/unit-element_access2.cpp index 495e855e10d..24065a1bbbc 100644 --- a/wpiutil/src/test/native/cpp/json/unit-element_access2.cpp +++ b/wpiutil/src/test/native/cpp/json/unit-element_access2.cpp @@ -568,14 +568,18 @@ TEST_F(JsonElementObjectRemoveTest, Key) } // erase(begin()) -TEST_F(JsonElementObjectRemoveTest, Begin) +// Disabled because iteration order isn't guaranteed by the underlying map +// container +TEST_F(JsonElementObjectRemoveTest, DISABLED_Begin) { json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}}; jobject.erase(jobject.begin()); EXPECT_EQ(jobject, json({{"b", 1}, {"c", 17u}})); } -TEST_F(JsonElementObjectRemoveTest, BeginConst) +// Disabled because iteration order isn't guaranteed by the underlying map +// container +TEST_F(JsonElementObjectRemoveTest, DISABLED_BeginConst) { json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}}; jobject.erase(jobject.cbegin()); diff --git a/wpiutil/src/test/native/cpp/json/unit-iterators1.cpp b/wpiutil/src/test/native/cpp/json/unit-iterators1.cpp index dda884fa569..c6924a39fa8 100644 --- a/wpiutil/src/test/native/cpp/json/unit-iterators1.cpp +++ b/wpiutil/src/test/native/cpp/json/unit-iterators1.cpp @@ -662,7 +662,9 @@ class JsonIteratorObjectTest : public ::testing::Test { json j_const; }; -TEST_F(JsonIteratorObjectTest, BeginEnd) +// Disabled because iteration order isn't guaranteed by the underlying map +// container +TEST_F(JsonIteratorObjectTest, DISABLED_BeginEnd) { json::iterator it_begin = j.begin(); json::iterator it_end = j.end(); @@ -686,7 +688,9 @@ TEST_F(JsonIteratorObjectTest, BeginEnd) EXPECT_EQ(it, it_end); } -TEST_F(JsonIteratorObjectTest, ConstBeginEnd) +// Disabled because iteration order isn't guaranteed by the underlying map +// container +TEST_F(JsonIteratorObjectTest, DISABLED_ConstBeginEnd) { json::const_iterator it_begin = j_const.begin(); json::const_iterator it_end = j_const.end(); @@ -710,7 +714,9 @@ TEST_F(JsonIteratorObjectTest, ConstBeginEnd) EXPECT_EQ(it, it_end); } -TEST_F(JsonIteratorObjectTest, CBeginEnd) +// Disabled because iteration order isn't guaranteed by the underlying map +// container +TEST_F(JsonIteratorObjectTest, DISABLED_CBeginEnd) { json::const_iterator it_begin = j.cbegin(); json::const_iterator it_end = j.cend(); @@ -734,7 +740,9 @@ TEST_F(JsonIteratorObjectTest, CBeginEnd) EXPECT_EQ(it, it_end); } -TEST_F(JsonIteratorObjectTest, ConstCBeginEnd) +// Disabled because iteration order isn't guaranteed by the underlying map +// container +TEST_F(JsonIteratorObjectTest, DISABLED_ConstCBeginEnd) { json::const_iterator it_begin = j_const.cbegin(); json::const_iterator it_end = j_const.cend(); @@ -831,7 +839,9 @@ TEST_F(JsonIteratorObjectTest, ConstCRBeginEnd) } #endif -TEST_F(JsonIteratorObjectTest, KeyValue) +// Disabled because iteration order isn't guaranteed by the underlying map +// container +TEST_F(JsonIteratorObjectTest, DISABLED_KeyValue) { auto it = j.begin(); auto cit = j_const.cbegin(); diff --git a/wpiutil/src/test/native/cpp/llvm/DenseMapTest.cpp b/wpiutil/src/test/native/cpp/llvm/DenseMapTest.cpp index fa339d18516..22e535e837d 100644 --- a/wpiutil/src/test/native/cpp/llvm/DenseMapTest.cpp +++ b/wpiutil/src/test/native/cpp/llvm/DenseMapTest.cpp @@ -12,10 +12,12 @@ #include "wpi/DenseMap.h" #include "wpi/DenseMapInfo.h" +#include "wpi/DenseMapInfoVariant.h" #include "gmock/gmock.h" #include "gtest/gtest.h" #include #include +#include #include #include @@ -126,6 +128,7 @@ TYPED_TEST(DenseMapTest, EmptyIntMapTest) { // Lookup tests EXPECT_FALSE(this->Map.count(this->getKey())); + EXPECT_FALSE(this->Map.contains(this->getKey())); EXPECT_TRUE(this->Map.find(this->getKey()) == this->Map.end()); EXPECT_EQ(typename TypeParam::mapped_type(), this->Map.lookup(this->getKey())); @@ -157,11 +160,21 @@ TYPED_TEST(DenseMapTest, SingleEntryMapTest) { // Lookup tests EXPECT_TRUE(this->Map.count(this->getKey())); + EXPECT_TRUE(this->Map.contains(this->getKey())); EXPECT_TRUE(this->Map.find(this->getKey()) == this->Map.begin()); EXPECT_EQ(this->getValue(), this->Map.lookup(this->getKey())); EXPECT_EQ(this->getValue(), this->Map[this->getKey()]); } +TYPED_TEST(DenseMapTest, AtTest) { + this->Map[this->getKey(0)] = this->getValue(0); + this->Map[this->getKey(1)] = this->getValue(1); + this->Map[this->getKey(2)] = this->getValue(2); + EXPECT_EQ(this->getValue(0), this->Map.at(this->getKey(0))); + EXPECT_EQ(this->getValue(1), this->Map.at(this->getKey(1))); + EXPECT_EQ(this->getValue(2), this->Map.at(this->getKey(2))); +} + // Test clear() method TYPED_TEST(DenseMapTest, ClearTest) { this->Map[this->getKey()] = this->getValue(); @@ -658,6 +671,10 @@ struct A { struct B : public A { using A::A; }; + +struct AlwaysEqType { + bool operator==(const AlwaysEqType &RHS) const { return true; } +}; } // namespace namespace wpi { @@ -670,6 +687,16 @@ struct DenseMapInfo>> { return LHS.value == RHS.value; } }; + +template <> struct DenseMapInfo { + using T = AlwaysEqType; + static inline T getEmptyKey() { return {}; } + static inline T getTombstoneKey() { return {}; } + static unsigned getHashValue(const T &Val) { return 0; } + static bool isEqual(const T &LHS, const T &RHS) { + return false; + } +}; } // namespace wpi namespace { @@ -693,16 +720,21 @@ TEST(DenseMapCustomTest, SFINAEMapInfo) { } TEST(DenseMapCustomTest, VariantSupport) { - using variant = std::variant; + using variant = std::variant; DenseMap Map; variant Keys[] = { variant(std::in_place_index<0>, 1), variant(std::in_place_index<1>, 1), + variant(std::in_place_index<2>), }; Map.try_emplace(Keys[0], 0); Map.try_emplace(Keys[1], 1); EXPECT_THAT(Map, testing::SizeIs(2)); EXPECT_NE(DenseMapInfo::getHashValue(Keys[0]), DenseMapInfo::getHashValue(Keys[1])); + // Check that isEqual dispatches to isEqual of underlying type, and not to + // operator==. + EXPECT_FALSE(DenseMapInfo::isEqual(Keys[2], Keys[2])); } + } // namespace diff --git a/wpiutil/src/test/native/cpp/llvm/MapVectorTest.cpp b/wpiutil/src/test/native/cpp/llvm/MapVectorTest.cpp index 99bda8ad274..4bfa6b2040c 100644 --- a/wpiutil/src/test/native/cpp/llvm/MapVectorTest.cpp +++ b/wpiutil/src/test/native/cpp/llvm/MapVectorTest.cpp @@ -94,8 +94,10 @@ TEST(MapVectorTest, erase) { MV.insert(std::make_pair(5, 6)); ASSERT_EQ(MV.size(), 3u); + ASSERT_TRUE(MV.contains(1)); MV.erase(MV.find(1)); ASSERT_EQ(MV.size(), 2u); + ASSERT_FALSE(MV.contains(1)); ASSERT_EQ(MV.find(1), MV.end()); ASSERT_EQ(MV[3], 4); ASSERT_EQ(MV[5], 6); diff --git a/wpiutil/src/test/native/cpp/llvm/MathExtrasTest.cpp b/wpiutil/src/test/native/cpp/llvm/MathExtrasTest.cpp index 0026711d987..eab7ba15d12 100644 --- a/wpiutil/src/test/native/cpp/llvm/MathExtrasTest.cpp +++ b/wpiutil/src/test/native/cpp/llvm/MathExtrasTest.cpp @@ -13,58 +13,6 @@ using namespace wpi; namespace { -TEST(MathExtras, countTrailingZeros) { - uint8_t Z8 = 0; - uint16_t Z16 = 0; - uint32_t Z32 = 0; - uint64_t Z64 = 0; - EXPECT_EQ(8u, countTrailingZeros(Z8)); - EXPECT_EQ(16u, countTrailingZeros(Z16)); - EXPECT_EQ(32u, countTrailingZeros(Z32)); - EXPECT_EQ(64u, countTrailingZeros(Z64)); - - uint8_t NZ8 = 42; - uint16_t NZ16 = 42; - uint32_t NZ32 = 42; - uint64_t NZ64 = 42; - EXPECT_EQ(1u, countTrailingZeros(NZ8)); - EXPECT_EQ(1u, countTrailingZeros(NZ16)); - EXPECT_EQ(1u, countTrailingZeros(NZ32)); - EXPECT_EQ(1u, countTrailingZeros(NZ64)); -} - -TEST(MathExtras, countLeadingZeros) { - uint8_t Z8 = 0; - uint16_t Z16 = 0; - uint32_t Z32 = 0; - uint64_t Z64 = 0; - EXPECT_EQ(8u, countLeadingZeros(Z8)); - EXPECT_EQ(16u, countLeadingZeros(Z16)); - EXPECT_EQ(32u, countLeadingZeros(Z32)); - EXPECT_EQ(64u, countLeadingZeros(Z64)); - - uint8_t NZ8 = 42; - uint16_t NZ16 = 42; - uint32_t NZ32 = 42; - uint64_t NZ64 = 42; - EXPECT_EQ(2u, countLeadingZeros(NZ8)); - EXPECT_EQ(10u, countLeadingZeros(NZ16)); - EXPECT_EQ(26u, countLeadingZeros(NZ32)); - EXPECT_EQ(58u, countLeadingZeros(NZ64)); - - EXPECT_EQ(8u, countLeadingZeros(0x00F000FFu)); - EXPECT_EQ(8u, countLeadingZeros(0x00F12345u)); - for (unsigned i = 0; i <= 30; ++i) { - EXPECT_EQ(31 - i, countLeadingZeros(1u << i)); - } - - EXPECT_EQ(8u, countLeadingZeros(0x00F1234500F12345ULL)); - EXPECT_EQ(1u, countLeadingZeros(1ULL << 62)); - for (unsigned i = 0; i <= 62; ++i) { - EXPECT_EQ(63 - i, countLeadingZeros(1ULL << i)); - } -} - TEST(MathExtras, onesMask) { EXPECT_EQ(0U, maskLeadingOnes(0)); EXPECT_EQ(0U, maskTrailingOnes(0)); @@ -90,46 +38,6 @@ TEST(MathExtras, onesMask) { EXPECT_EQ(0xFFFFFFFFFFFF0000ULL, maskLeadingOnes(48U)); } -TEST(MathExtras, findFirstSet) { - uint8_t Z8 = 0; - uint16_t Z16 = 0; - uint32_t Z32 = 0; - uint64_t Z64 = 0; - EXPECT_EQ(0xFFULL, findFirstSet(Z8)); - EXPECT_EQ(0xFFFFULL, findFirstSet(Z16)); - EXPECT_EQ(0xFFFFFFFFULL, findFirstSet(Z32)); - EXPECT_EQ(0xFFFFFFFFFFFFFFFFULL, findFirstSet(Z64)); - - uint8_t NZ8 = 42; - uint16_t NZ16 = 42; - uint32_t NZ32 = 42; - uint64_t NZ64 = 42; - EXPECT_EQ(1u, findFirstSet(NZ8)); - EXPECT_EQ(1u, findFirstSet(NZ16)); - EXPECT_EQ(1u, findFirstSet(NZ32)); - EXPECT_EQ(1u, findFirstSet(NZ64)); -} - -TEST(MathExtras, findLastSet) { - uint8_t Z8 = 0; - uint16_t Z16 = 0; - uint32_t Z32 = 0; - uint64_t Z64 = 0; - EXPECT_EQ(0xFFULL, findLastSet(Z8)); - EXPECT_EQ(0xFFFFULL, findLastSet(Z16)); - EXPECT_EQ(0xFFFFFFFFULL, findLastSet(Z32)); - EXPECT_EQ(0xFFFFFFFFFFFFFFFFULL, findLastSet(Z64)); - - uint8_t NZ8 = 42; - uint16_t NZ16 = 42; - uint32_t NZ32 = 42; - uint64_t NZ64 = 42; - EXPECT_EQ(5u, findLastSet(NZ8)); - EXPECT_EQ(5u, findLastSet(NZ16)); - EXPECT_EQ(5u, findLastSet(NZ32)); - EXPECT_EQ(5u, findLastSet(NZ64)); -} - TEST(MathExtras, isIntN) { EXPECT_TRUE(isIntN(16, 32767)); EXPECT_FALSE(isIntN(16, 32768)); @@ -235,12 +143,6 @@ TEST(MathExtras, PowerOf2Ceil) { EXPECT_EQ(8U, PowerOf2Ceil(7U)); } -TEST(MathExtras, PowerOf2Floor) { - EXPECT_EQ(0U, PowerOf2Floor(0U)); - EXPECT_EQ(8U, PowerOf2Floor(8U)); - EXPECT_EQ(4U, PowerOf2Floor(7U)); -} - TEST(MathExtras, CTLog2) { EXPECT_EQ(CTLog2<1ULL << 0>(), 0U); EXPECT_EQ(CTLog2<1ULL << 1>(), 1U); @@ -260,31 +162,6 @@ TEST(MathExtras, CTLog2) { EXPECT_EQ(CTLog2<1ULL << 15>(), 15U); } -TEST(MathExtras, countLeadingOnes) { - for (int i = 30; i >= 0; --i) { - // Start with all ones and unset some bit. - EXPECT_EQ(31u - i, countLeadingOnes(0xFFFFFFFF ^ (1 << i))); - } - for (int i = 62; i >= 0; --i) { - // Start with all ones and unset some bit. - EXPECT_EQ(63u - i, countLeadingOnes(0xFFFFFFFFFFFFFFFFULL ^ (1LL << i))); - } - for (int i = 30; i >= 0; --i) { - // Start with all ones and unset some bit. - EXPECT_EQ(31u - i, countLeadingOnes(0xFFFFFFFF ^ (1 << i))); - } -} - -TEST(MathExtras, FloatBits) { - static const float kValue = 5632.34f; - EXPECT_FLOAT_EQ(kValue, BitsToFloat(FloatToBits(kValue))); -} - -TEST(MathExtras, DoubleBits) { - static const double kValue = 87987234.983498; - EXPECT_DOUBLE_EQ(kValue, BitsToDouble(DoubleToBits(kValue))); -} - TEST(MathExtras, MinAlign) { EXPECT_EQ(1u, MinAlign(2, 3)); EXPECT_EQ(2u, MinAlign(2, 4)); diff --git a/wpiutil/src/test/native/cpp/llvm/PointerIntPairTest.cpp b/wpiutil/src/test/native/cpp/llvm/PointerIntPairTest.cpp index a13e7bca223..03e22e1fba8 100644 --- a/wpiutil/src/test/native/cpp/llvm/PointerIntPairTest.cpp +++ b/wpiutil/src/test/native/cpp/llvm/PointerIntPairTest.cpp @@ -109,4 +109,22 @@ TEST(PointerIntPairTest, ManyUnusedBits) { "trivially copyable"); } +TEST(PointerIntPairTest, TypePunning) { + int I = 0; + int *IntPtr = &I; + + int **IntPtrBegin = &IntPtr; + int **IntPtrEnd = IntPtrBegin + 1; + + PointerIntPair Pair; + int **PairAddr = Pair.getAddrOfPointer(); + + while (IntPtrBegin != IntPtrEnd) { + *PairAddr = *IntPtrBegin; + ++PairAddr; + ++IntPtrBegin; + } + EXPECT_EQ(Pair.getPointer(), IntPtr); +} + } // end anonymous namespace diff --git a/wpiutil/src/test/native/cpp/llvm/PointerUnionTest.cpp b/wpiutil/src/test/native/cpp/llvm/PointerUnionTest.cpp index bf02aef987f..1bc20338959 100644 --- a/wpiutil/src/test/native/cpp/llvm/PointerUnionTest.cpp +++ b/wpiutil/src/test/native/cpp/llvm/PointerUnionTest.cpp @@ -89,29 +89,29 @@ TEST_F(PointerUnionTest, Null) { } TEST_F(PointerUnionTest, Is) { - EXPECT_FALSE(a.is()); - EXPECT_TRUE(a.is()); - EXPECT_TRUE(b.is()); - EXPECT_FALSE(b.is()); - EXPECT_TRUE(n.is()); - EXPECT_FALSE(n.is()); - EXPECT_TRUE(i3.is()); - EXPECT_TRUE(f3.is()); - EXPECT_TRUE(l3.is()); - EXPECT_TRUE(i4.is()); - EXPECT_TRUE(f4.is()); - EXPECT_TRUE(l4.is()); - EXPECT_TRUE(d4.is()); - EXPECT_TRUE(i4null.is()); - EXPECT_TRUE(f4null.is()); - EXPECT_TRUE(l4null.is()); - EXPECT_TRUE(d4null.is()); + EXPECT_FALSE(isa(a)); + EXPECT_TRUE(isa(a)); + EXPECT_TRUE(isa(b)); + EXPECT_FALSE(isa(b)); + EXPECT_TRUE(isa(n)); + EXPECT_FALSE(isa(n)); + EXPECT_TRUE(isa(i3)); + EXPECT_TRUE(isa(f3)); + EXPECT_TRUE(isa(l3)); + EXPECT_TRUE(isa(i4)); + EXPECT_TRUE(isa(f4)); + EXPECT_TRUE(isa(l4)); + EXPECT_TRUE(isa(d4)); + EXPECT_TRUE(isa(i4null)); + EXPECT_TRUE(isa(f4null)); + EXPECT_TRUE(isa(l4null)); + EXPECT_TRUE(isa(d4null)); } TEST_F(PointerUnionTest, Get) { - EXPECT_EQ(a.get(), &f); - EXPECT_EQ(b.get(), &i); - EXPECT_EQ(n.get(), (int *)nullptr); + EXPECT_EQ(cast(a), &f); + EXPECT_EQ(cast(b), &i); + EXPECT_EQ(cast(n), (int *)nullptr); } template struct alignas(8) Aligned {}; @@ -125,27 +125,27 @@ TEST_F(PointerUnionTest, ManyElements) { Aligned<7> a7; PU8 a = &a0; - EXPECT_TRUE(a.is*>()); - EXPECT_FALSE(a.is*>()); - EXPECT_FALSE(a.is*>()); - EXPECT_FALSE(a.is*>()); - EXPECT_FALSE(a.is*>()); - EXPECT_FALSE(a.is*>()); - EXPECT_FALSE(a.is*>()); - EXPECT_FALSE(a.is*>()); - EXPECT_EQ(a.dyn_cast*>(), &a0); + EXPECT_TRUE(isa *>(a)); + EXPECT_FALSE(isa *>(a)); + EXPECT_FALSE(isa *>(a)); + EXPECT_FALSE(isa *>(a)); + EXPECT_FALSE(isa *>(a)); + EXPECT_FALSE(isa *>(a)); + EXPECT_FALSE(isa *>(a)); + EXPECT_FALSE(isa *>(a)); + EXPECT_EQ(dyn_cast_if_present *>(a), &a0); EXPECT_EQ(*a.getAddrOfPtr1(), &a0); a = &a7; - EXPECT_FALSE(a.is*>()); - EXPECT_FALSE(a.is*>()); - EXPECT_FALSE(a.is*>()); - EXPECT_FALSE(a.is*>()); - EXPECT_FALSE(a.is*>()); - EXPECT_FALSE(a.is*>()); - EXPECT_FALSE(a.is*>()); - EXPECT_TRUE(a.is*>()); - EXPECT_EQ(a.dyn_cast*>(), &a7); + EXPECT_FALSE(isa *>(a)); + EXPECT_FALSE(isa *>(a)); + EXPECT_FALSE(isa *>(a)); + EXPECT_FALSE(isa *>(a)); + EXPECT_FALSE(isa *>(a)); + EXPECT_FALSE(isa *>(a)); + EXPECT_FALSE(isa *>(a)); + EXPECT_TRUE(isa *>(a)); + EXPECT_EQ(dyn_cast_if_present *>(a), &a7); EXPECT_TRUE(a == PU8(&a7)); EXPECT_TRUE(a != PU8(&a0)); diff --git a/wpiutil/src/test/native/cpp/llvm/SmallVectorTest.cpp b/wpiutil/src/test/native/cpp/llvm/SmallVectorTest.cpp index d097c2b6abf..53a941ccc58 100644 --- a/wpiutil/src/test/native/cpp/llvm/SmallVectorTest.cpp +++ b/wpiutil/src/test/native/cpp/llvm/SmallVectorTest.cpp @@ -176,6 +176,11 @@ LLVM_ATTRIBUTE_USED void CompileTest() { V.resize(42); } +TEST(SmallVectorTest, ConstructNonCopyableTest) { + SmallVector V(42); + EXPECT_EQ(V.size(), (size_t)42); +} + // Assert that v contains the specified values, in order. template void assertValuesInOrder(VectorT &v, size_t size, ...) { diff --git a/wpiutil/src/test/native/cpp/llvm/StringMapTest.cpp b/wpiutil/src/test/native/cpp/llvm/StringMapTest.cpp index 1fa206b4ed1..760749846c9 100644 --- a/wpiutil/src/test/native/cpp/llvm/StringMapTest.cpp +++ b/wpiutil/src/test/native/cpp/llvm/StringMapTest.cpp @@ -39,6 +39,7 @@ class StringMapTest : public testing::Test { EXPECT_TRUE(testMap.begin() == testMap.end()); // Lookup tests + EXPECT_FALSE(testMap.contains(testKey)); EXPECT_EQ(0u, testMap.count(testKey)); EXPECT_EQ(0u, testMap.count(std::string_view(testKeyFirst, testKeyLength))); EXPECT_EQ(0u, testMap.count(testKeyStr)); @@ -62,6 +63,7 @@ class StringMapTest : public testing::Test { EXPECT_TRUE(it == testMap.end()); // Lookup tests + EXPECT_TRUE(testMap.contains(testKey)); EXPECT_EQ(1u, testMap.count(testKey)); EXPECT_EQ(1u, testMap.count(std::string_view(testKeyFirst, testKeyLength))); EXPECT_EQ(1u, testMap.count(testKeyStr)); @@ -203,6 +205,18 @@ TEST_F(StringMapTest, CopyCtorTest) { EXPECT_EQ(5, Map2.lookup("funf")); } +TEST_F(StringMapTest, AtTest) { + wpi::StringMap Map; + + // keys both found and not found on non-empty map + Map["a"] = 1; + Map["b"] = 2; + Map["c"] = 3; + EXPECT_EQ(1, Map.at("a")); + EXPECT_EQ(2, Map.at("b")); + EXPECT_EQ(3, Map.at("c")); +} + // A more complex iteration test. TEST_F(StringMapTest, IterationTest) { bool visited[100]; diff --git a/wpiutil/src/test/native/cpp/llvm/SwapByteOrderTest.cpp b/wpiutil/src/test/native/cpp/llvm/SwapByteOrderTest.cpp index abacef7ed19..23ad2aba7ed 100644 --- a/wpiutil/src/test/native/cpp/llvm/SwapByteOrderTest.cpp +++ b/wpiutil/src/test/native/cpp/llvm/SwapByteOrderTest.cpp @@ -16,16 +16,6 @@ using namespace wpi; namespace { -TEST(ByteSwap, Swap_32) { - EXPECT_EQ(0x44332211u, ByteSwap_32(0x11223344)); - EXPECT_EQ(0xDDCCBBAAu, ByteSwap_32(0xAABBCCDD)); -} - -TEST(ByteSwap, Swap_64) { - EXPECT_EQ(0x8877665544332211ULL, ByteSwap_64(0x1122334455667788LL)); - EXPECT_EQ(0x1100FFEEDDCCBBAAULL, ByteSwap_64(0xAABBCCDDEEFF0011LL)); -} - // In these first two tests all of the original_uintx values are truncated // except for 64. We could avoid this, but there's really no point. diff --git a/wpiutil/src/test/native/cpp/llvm/xxhashTest.cpp b/wpiutil/src/test/native/cpp/llvm/xxhashTest.cpp new file mode 100644 index 00000000000..133c5426ff4 --- /dev/null +++ b/wpiutil/src/test/native/cpp/llvm/xxhashTest.cpp @@ -0,0 +1,63 @@ +//===- llvm/unittest/Support/xxhashTest.cpp -------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "wpi/xxhash.h" +#include "gtest/gtest.h" + +using namespace wpi; + +TEST(xxhashTest, Basic) { + EXPECT_EQ(0xef46db3751d8e999U, xxHash64(std::string_view())); + EXPECT_EQ(0x33bf00a859c4ba3fU, xxHash64("foo")); + EXPECT_EQ(0x48a37c90ad27a659U, xxHash64("bar")); + EXPECT_EQ(0x69196c1b3af0bff9U, + xxHash64("0123456789abcdefghijklmnopqrstuvwxyz")); +} + +TEST(xxhashTest, xxh3) { + constexpr size_t size = 2243; + uint8_t a[size]; + uint64_t x = 1; + for (size_t i = 0; i < size; ++i) { + x ^= x << 13; + x ^= x >> 7; + x ^= x << 17; + a[i] = uint8_t(x); + } + +#define F(len, expected) \ + EXPECT_EQ(uint64_t(expected), xxh3_64bits(std::span(a, size_t(len)))) + F(0, 0x2d06800538d394c2); + F(1, 0xd0d496e05c553485); + F(2, 0x84d625edb7055eac); + F(3, 0x6ea2d59aca5c3778); + F(4, 0xbf65290914e80242); + F(5, 0xc01fd099ad4fc8e4); + F(6, 0x9e3ea8187399caa5); + F(7, 0x9da8b60540644f5a); + F(8, 0xabc1413da6cd0209); + F(9, 0x8bc89400bfed51f6); + F(16, 0x7e46916754d7c9b8); + F(17, 0xed4be912ba5f836d); + F(32, 0xf59b59b58c304fd1); + F(33, 0x9013fb74ca603e0c); + F(64, 0xfa5271fcce0db1c3); + F(65, 0x79c42431727f1012); + F(96, 0x591ee0ddf9c9ccd1); + F(97, 0x8ffc6a3111fe19da); + F(128, 0x06a146ee9a2da378); + F(129, 0xbc7138129bf065da); + F(403, 0xcefeb3ffa532ad8c); + F(512, 0xcdfa6b6268e3650f); + F(513, 0x4bb5d42742f9765f); + F(2048, 0x330ce110cbb79eae); + F(2049, 0x3ba6afa0249fef9a); + F(2240, 0xd61d4d2a94e926a8); + F(2243, 0x0979f786a24edde7); +#undef F +}