diff --git a/upstream_utils/llvm_patches/0001-Fix-spelling-language-errors.patch b/upstream_utils/llvm_patches/0001-Fix-spelling-language-errors.patch index 960285a55a..f3ae6fc92e 100644 --- a/upstream_utils/llvm_patches/0001-Fix-spelling-language-errors.patch +++ b/upstream_utils/llvm_patches/0001-Fix-spelling-language-errors.patch @@ -1,7 +1,7 @@ -From 4f34f83152a851ce675c876f3bd0e53322110d04 Mon Sep 17 00:00:00 2001 +From e5c61a18376a34b94bf1761f30e017a741e52b0b 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 +Subject: [PATCH 01/27] Fix spelling / language errors --- llvm/include/llvm/Support/Chrono.h | 2 +- diff --git a/upstream_utils/llvm_patches/0002-Remove-StringRef-ArrayRef-and-Optional.patch b/upstream_utils/llvm_patches/0002-Remove-StringRef-ArrayRef-and-Optional.patch index 4d0301f312..6f49762d55 100644 --- a/upstream_utils/llvm_patches/0002-Remove-StringRef-ArrayRef-and-Optional.patch +++ b/upstream_utils/llvm_patches/0002-Remove-StringRef-ArrayRef-and-Optional.patch @@ -1,7 +1,7 @@ -From 3b9d1af2e3a1b031554e3f3b9d0eda4aa55d8b15 Mon Sep 17 00:00:00 2001 +From 8799ad77758b93e742394699451009a8d3fc7bb7 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 02/27] Remove StringRef, ArrayRef, and Optional --- llvm/include/llvm/ADT/SmallSet.h | 12 +-- @@ -11,6 +11,7 @@ Subject: [PATCH 02/31] Remove StringRef, ArrayRef, and Optional llvm/include/llvm/Support/Chrono.h | 10 +-- llvm/include/llvm/Support/Compiler.h | 2 +- llvm/include/llvm/Support/ConvertUTF.h | 25 +++--- + llvm/include/llvm/Support/DJB.h | 6 +- llvm/include/llvm/Support/ErrorHandling.h | 7 +- .../llvm/Support/SmallVectorMemoryBuffer.h | 6 +- llvm/include/llvm/Support/VersionTuple.h | 20 ++--- @@ -27,7 +28,7 @@ Subject: [PATCH 02/31] Remove StringRef, ArrayRef, and Optional llvm/unittests/ADT/SmallVectorTest.cpp | 20 +---- llvm/unittests/ADT/StringMapTest.cpp | 27 ++++--- llvm/unittests/Support/ConvertUTFTest.cpp | 37 +++++---- - 23 files changed, 234 insertions(+), 285 deletions(-) + 24 files changed, 237 insertions(+), 288 deletions(-) diff --git a/llvm/include/llvm/ADT/SmallSet.h b/llvm/include/llvm/ADT/SmallSet.h index 0600e528ee69..e4c209c5f2a9 100644 @@ -689,6 +690,27 @@ index 1add185330fa..7f1527f51cdf 100644 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 8a04a324a5dc..8737cd144c37 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 dd85a5892e01..411c78a81b24 100644 --- a/llvm/include/llvm/Support/ErrorHandling.h @@ -1506,7 +1528,7 @@ index 06b98efe66ef..1914f38fac6c 100644 class SmallVectorReferenceInvalidationTest : public SmallVectorTestBase { protected: diff --git a/llvm/unittests/ADT/StringMapTest.cpp b/llvm/unittests/ADT/StringMapTest.cpp -index 98fbd6e1df5a..4c4aec2184b7 100644 +index 98fbd6e1df5a..18beb3878067 100644 --- a/llvm/unittests/ADT/StringMapTest.cpp +++ b/llvm/unittests/ADT/StringMapTest.cpp @@ -7,7 +7,6 @@ @@ -1561,7 +1583,7 @@ index 98fbd6e1df5a..4c4aec2184b7 100644 StringMap::value_type *entry = StringMap::value_type::Create( - StringRef(testKeyFirst, testKeyLength), Allocator, 1u); -+ std::string_view(testKeyFirst, testKeyLength), 1u); ++ std::string_view(testKeyFirst, testKeyLength), Allocator, 1u); EXPECT_STREQ(testKey, entry->first().data()); EXPECT_EQ(1u, entry->second); entry->Destroy(Allocator); diff --git a/upstream_utils/llvm_patches/0003-Wrap-std-min-max-calls-in-parens-for-windows-warning.patch b/upstream_utils/llvm_patches/0003-Wrap-std-min-max-calls-in-parens-for-windows-warning.patch index c233dacf6c..364ef91ff2 100644 --- a/upstream_utils/llvm_patches/0003-Wrap-std-min-max-calls-in-parens-for-windows-warning.patch +++ b/upstream_utils/llvm_patches/0003-Wrap-std-min-max-calls-in-parens-for-windows-warning.patch @@ -1,7 +1,7 @@ -From 81df3d81b0bffd848890d7c01d946e65744fb649 Mon Sep 17 00:00:00 2001 +From 48f55e6aa592d66f46f392330317e4efe0502faf 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 03/27] Wrap std::min/max calls in parens, for windows warnings --- llvm/include/llvm/ADT/DenseMap.h | 4 ++-- diff --git a/upstream_utils/llvm_patches/0004-Change-uniqe_function-storage-size.patch b/upstream_utils/llvm_patches/0004-Change-uniqe_function-storage-size.patch index 15f8c982c8..1070a240aa 100644 --- a/upstream_utils/llvm_patches/0004-Change-uniqe_function-storage-size.patch +++ b/upstream_utils/llvm_patches/0004-Change-uniqe_function-storage-size.patch @@ -1,7 +1,7 @@ -From 086a4a7ee635c68d81b85044c9f8f4317b2b164c Mon Sep 17 00:00:00 2001 +From 1c61002f2933aedbcc64ff52de7f69666479e55a Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 7 May 2022 22:13:55 -0400 -Subject: [PATCH 04/31] Change uniqe_function storage size +Subject: [PATCH 04/27] Change uniqe_function storage size --- llvm/include/llvm/ADT/FunctionExtras.h | 4 ++-- diff --git a/upstream_utils/llvm_patches/0005-Threading-updates.patch b/upstream_utils/llvm_patches/0005-Threading-updates.patch index 7ad3cde3cc..c20986d5d8 100644 --- a/upstream_utils/llvm_patches/0005-Threading-updates.patch +++ b/upstream_utils/llvm_patches/0005-Threading-updates.patch @@ -1,7 +1,7 @@ -From a53483a33c8d5778e5594a49376b5bafe742d126 Mon Sep 17 00:00:00 2001 +From 5ca3ff668002f9bf89c134aec9976526c61929da Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 7 May 2022 22:17:19 -0400 -Subject: [PATCH 05/31] Threading updates +Subject: [PATCH 05/27] Threading updates - Remove guards for threads and exception - Prefer scope gaurd over lock gaurd diff --git a/upstream_utils/llvm_patches/0006-Remove-DJB-hash-dependency.patch b/upstream_utils/llvm_patches/0006-Remove-DJB-hash-dependency.patch deleted file mode 100644 index b6246d381f..0000000000 --- a/upstream_utils/llvm_patches/0006-Remove-DJB-hash-dependency.patch +++ /dev/null @@ -1,62 +0,0 @@ -From 04f1186ea8f0160da1a1863a344ff9a9f55b6733 Mon Sep 17 00:00:00 2001 -From: PJ Reiniger -Date: Sat, 7 May 2022 22:24:34 -0400 -Subject: [PATCH 06/31] Remove DJB hash dependency - ---- - llvm/lib/Support/StringMap.cpp | 21 ++++++++++++++++++--- - 1 file changed, 18 insertions(+), 3 deletions(-) - -diff --git a/llvm/lib/Support/StringMap.cpp b/llvm/lib/Support/StringMap.cpp -index d9eeba619428..f0d5ae6de646 100644 ---- a/llvm/lib/Support/StringMap.cpp -+++ b/llvm/lib/Support/StringMap.cpp -@@ -12,11 +12,26 @@ - - #include "llvm/ADT/StringMap.h" - #include "llvm/ADT/StringExtras.h" --#include "llvm/Support/DJB.h" -+#include "llvm/Support/Compiler.h" - #include "llvm/Support/MathExtras.h" - - using namespace llvm; - -+/// HashString - Hash function for strings. -+/// -+/// This is the Bernstein hash function. -+// -+// FIXME: Investigate whether a modified bernstein hash function performs -+// better: http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx -+// X*33+c -> X*33^c -+static inline unsigned HashString(std::string_view str, -+ unsigned result = 0) noexcept { -+ for (std::string_view::size_type i = 0, e = str.size(); i != e; ++i) { -+ result = result * 33 + static_cast(str[i]); -+ } -+ return result; -+} -+ - /// Returns the number of buckets to allocate to ensure that the DenseMap can - /// accommodate \p NumEntries without need to grow(). - static unsigned getMinBucketToReserveForEntries(unsigned NumEntries) { -@@ -77,7 +92,7 @@ unsigned StringMapImpl::LookupBucketFor(std::string_view Name) { - init(16); - HTSize = NumBuckets; - } -- unsigned FullHashValue = djbHash(Name, 0); -+ unsigned FullHashValue = HashString(Name); - unsigned BucketNo = FullHashValue & (HTSize - 1); - unsigned *HashTable = (unsigned *)(TheTable + NumBuckets + 1); - -@@ -133,7 +148,7 @@ int StringMapImpl::FindKey(std::string_view Key) const { - unsigned HTSize = NumBuckets; - if (HTSize == 0) - return -1; // Really empty table? -- unsigned FullHashValue = djbHash(Key, 0); -+ unsigned FullHashValue = HashString(Key); - unsigned BucketNo = FullHashValue & (HTSize - 1); - unsigned *HashTable = (unsigned *)(TheTable + NumBuckets + 1); - --- -2.20.1.windows.1 - diff --git a/upstream_utils/llvm_patches/0007-ifdef-guard-safety.patch b/upstream_utils/llvm_patches/0006-ifdef-guard-safety.patch similarity index 99% rename from upstream_utils/llvm_patches/0007-ifdef-guard-safety.patch rename to upstream_utils/llvm_patches/0006-ifdef-guard-safety.patch index 8e84dac0e7..c8882bf85b 100644 --- a/upstream_utils/llvm_patches/0007-ifdef-guard-safety.patch +++ b/upstream_utils/llvm_patches/0006-ifdef-guard-safety.patch @@ -1,7 +1,7 @@ -From d16ac9833a8469fe49b564ad21e2331875b450b8 Mon Sep 17 00:00:00 2001 +From 20727a44aa8138cbda12065a6087390b4632b958 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 7 May 2022 22:28:13 -0400 -Subject: [PATCH 07/31] #ifdef guard safety +Subject: [PATCH 06/27] #ifdef guard safety Prevents redefinition if someone is pulling in real LLVM, since the macros are in global namespace --- diff --git a/upstream_utils/llvm_patches/0008-Explicitly-use-std.patch b/upstream_utils/llvm_patches/0007-Explicitly-use-std.patch similarity index 95% rename from upstream_utils/llvm_patches/0008-Explicitly-use-std.patch rename to upstream_utils/llvm_patches/0007-Explicitly-use-std.patch index 1eed55e543..a02ae70521 100644 --- a/upstream_utils/llvm_patches/0008-Explicitly-use-std.patch +++ b/upstream_utils/llvm_patches/0007-Explicitly-use-std.patch @@ -1,7 +1,7 @@ -From 945a1d5a54ad830f857625417da414d05d367a37 Mon Sep 17 00:00:00 2001 +From 6098845aed7416fde8a9c1f276571c8a1bc27799 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 7 May 2022 22:37:34 -0400 -Subject: [PATCH 08/31] Explicitly use std:: +Subject: [PATCH 07/27] Explicitly use std:: --- llvm/include/llvm/ADT/SmallSet.h | 2 +- @@ -64,7 +64,7 @@ index 6f3c94eed273..531f81ab5b3f 100644 EXPECT_EQ(F - Found + 1, *F); } diff --git a/llvm/unittests/ADT/StringMapTest.cpp b/llvm/unittests/ADT/StringMapTest.cpp -index 4c4aec2184b7..5211f01bbd73 100644 +index 18beb3878067..081b699adee3 100644 --- a/llvm/unittests/ADT/StringMapTest.cpp +++ b/llvm/unittests/ADT/StringMapTest.cpp @@ -308,7 +308,7 @@ TEST_F(StringMapTest, IterMapKeys) { diff --git a/upstream_utils/llvm_patches/0009-Remove-format_provider.patch b/upstream_utils/llvm_patches/0008-Remove-format_provider.patch similarity index 98% rename from upstream_utils/llvm_patches/0009-Remove-format_provider.patch rename to upstream_utils/llvm_patches/0008-Remove-format_provider.patch index ffb233b3b9..033ac9a00d 100644 --- a/upstream_utils/llvm_patches/0009-Remove-format_provider.patch +++ b/upstream_utils/llvm_patches/0008-Remove-format_provider.patch @@ -1,7 +1,7 @@ -From 1f42fe3358dc55b9686d9c2dd0725dd7e4a14efa Mon Sep 17 00:00:00 2001 +From c7d5902712292ad85b8580437c1f09a16d79def9 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 7 May 2022 22:53:50 -0400 -Subject: [PATCH 09/31] Remove format_provider +Subject: [PATCH 08/27] Remove format_provider --- llvm/include/llvm/Support/Chrono.h | 109 ------------------------ diff --git a/upstream_utils/llvm_patches/0013-Add-compiler-warning-pragrams.patch b/upstream_utils/llvm_patches/0009-Add-compiler-warning-pragrams.patch similarity index 98% rename from upstream_utils/llvm_patches/0013-Add-compiler-warning-pragrams.patch rename to upstream_utils/llvm_patches/0009-Add-compiler-warning-pragrams.patch index ad6d0d8b0b..6b56d34d6c 100644 --- a/upstream_utils/llvm_patches/0013-Add-compiler-warning-pragrams.patch +++ b/upstream_utils/llvm_patches/0009-Add-compiler-warning-pragrams.patch @@ -1,7 +1,7 @@ -From 2e9ec7d3e5c58424fde4312784e2a9faab58fe2c Mon Sep 17 00:00:00 2001 +From a55cc2394a9fca533d8d07e3b61e47fedb99cd1b Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 13:34:07 -0400 -Subject: [PATCH 13/31] Add compiler warning pragrams +Subject: [PATCH 09/27] Add compiler warning pragrams --- llvm/include/llvm/ADT/FunctionExtras.h | 10 ++++++++++ diff --git a/upstream_utils/llvm_patches/0010-Remove-reverse-iterator.patch b/upstream_utils/llvm_patches/0010-Remove-reverse-iterator.patch deleted file mode 100644 index 1b4abf6739..0000000000 --- a/upstream_utils/llvm_patches/0010-Remove-reverse-iterator.patch +++ /dev/null @@ -1,266 +0,0 @@ -From 29e7b322eab2284b434cc270bb36ade7c8a62755 Mon Sep 17 00:00:00 2001 -From: PJ Reiniger -Date: Sat, 7 May 2022 23:02:07 -0400 -Subject: [PATCH 10/31] Remove reverse iterator - ---- - llvm/include/llvm/ADT/DenseMap.h | 74 ++++------------------------- - llvm/include/llvm/ADT/SmallPtrSet.h | 21 +------- - 2 files changed, 11 insertions(+), 84 deletions(-) - -diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h -index 588c39faea2f..5e5c020adf0b 100644 ---- a/llvm/include/llvm/ADT/DenseMap.h -+++ b/llvm/include/llvm/ADT/DenseMap.h -@@ -76,8 +76,6 @@ public: - // empty buckets. - if (empty()) - return end(); -- if (shouldReverseIterate()) -- return makeIterator(getBucketsEnd() - 1, getBuckets(), *this); - return makeIterator(getBuckets(), getBucketsEnd(), *this); - } - inline iterator end() { -@@ -86,8 +84,6 @@ public: - inline const_iterator begin() const { - if (empty()) - return end(); -- if (shouldReverseIterate()) -- return makeConstIterator(getBucketsEnd() - 1, getBuckets(), *this); - return makeConstIterator(getBuckets(), getBucketsEnd(), *this); - } - inline const_iterator end() const { -@@ -150,18 +146,14 @@ public: - iterator find(const_arg_type_t Val) { - BucketT *TheBucket; - if (LookupBucketFor(Val, TheBucket)) -- return makeIterator(TheBucket, -- shouldReverseIterate() ? getBuckets() -- : getBucketsEnd(), -+ return makeIterator(TheBucket, getBucketsEnd(), - *this, true); - return end(); - } - const_iterator find(const_arg_type_t Val) const { - const BucketT *TheBucket; - if (LookupBucketFor(Val, TheBucket)) -- return makeConstIterator(TheBucket, -- shouldReverseIterate() ? getBuckets() -- : getBucketsEnd(), -+ return makeConstIterator(TheBucket, getBucketsEnd(), - *this, true); - return end(); - } -@@ -175,9 +167,7 @@ public: - iterator find_as(const LookupKeyT &Val) { - BucketT *TheBucket; - if (LookupBucketFor(Val, TheBucket)) -- return makeIterator(TheBucket, -- shouldReverseIterate() ? getBuckets() -- : getBucketsEnd(), -+ return makeIterator(TheBucket, getBucketsEnd(), - *this, true); - return end(); - } -@@ -185,9 +175,7 @@ public: - const_iterator find_as(const LookupKeyT &Val) const { - const BucketT *TheBucket; - if (LookupBucketFor(Val, TheBucket)) -- return makeConstIterator(TheBucket, -- shouldReverseIterate() ? getBuckets() -- : getBucketsEnd(), -+ return makeConstIterator(TheBucket, getBucketsEnd(), - *this, true); - return end(); - } -@@ -222,20 +210,14 @@ public: - std::pair try_emplace(KeyT &&Key, Ts &&... Args) { - BucketT *TheBucket; - if (LookupBucketFor(Key, TheBucket)) -- return std::make_pair(makeIterator(TheBucket, -- shouldReverseIterate() -- ? getBuckets() -- : getBucketsEnd(), -+ return std::make_pair(makeIterator(TheBucket, getBucketsEnd(), - *this, true), - false); // Already in map. - - // Otherwise, insert the new element. - TheBucket = - InsertIntoBucket(TheBucket, std::move(Key), std::forward(Args)...); -- return std::make_pair(makeIterator(TheBucket, -- shouldReverseIterate() -- ? getBuckets() -- : getBucketsEnd(), -+ return std::make_pair(makeIterator(TheBucket, getBucketsEnd(), - *this, true), - true); - } -@@ -247,19 +229,13 @@ public: - std::pair try_emplace(const KeyT &Key, Ts &&... Args) { - BucketT *TheBucket; - if (LookupBucketFor(Key, TheBucket)) -- return std::make_pair(makeIterator(TheBucket, -- shouldReverseIterate() -- ? getBuckets() -- : getBucketsEnd(), -+ return std::make_pair(makeIterator(TheBucket, getBucketsEnd(), - *this, true), - false); // Already in map. - - // Otherwise, insert the new element. - TheBucket = InsertIntoBucket(TheBucket, Key, std::forward(Args)...); -- return std::make_pair(makeIterator(TheBucket, -- shouldReverseIterate() -- ? getBuckets() -- : getBucketsEnd(), -+ return std::make_pair(makeIterator(TheBucket, getBucketsEnd(), - *this, true), - true); - } -@@ -274,20 +250,14 @@ public: - const LookupKeyT &Val) { - BucketT *TheBucket; - if (LookupBucketFor(Val, TheBucket)) -- return std::make_pair(makeIterator(TheBucket, -- shouldReverseIterate() -- ? getBuckets() -- : getBucketsEnd(), -+ return std::make_pair(makeIterator(TheBucket, getBucketsEnd(), - *this, true), - false); // Already in map. - - // Otherwise, insert the new element. - TheBucket = InsertIntoBucketWithLookup(TheBucket, std::move(KV.first), - std::move(KV.second), Val); -- return std::make_pair(makeIterator(TheBucket, -- shouldReverseIterate() -- ? getBuckets() -- : getBucketsEnd(), -+ return std::make_pair(makeIterator(TheBucket, getBucketsEnd(), - *this, true), - true); - } -@@ -464,20 +434,12 @@ private: - iterator makeIterator(BucketT *P, BucketT *E, - DebugEpochBase &Epoch, - bool NoAdvance=false) { -- if (shouldReverseIterate()) { -- BucketT *B = P == getBucketsEnd() ? getBuckets() : P + 1; -- return iterator(B, E, Epoch, NoAdvance); -- } - return iterator(P, E, Epoch, NoAdvance); - } - - const_iterator makeConstIterator(const BucketT *P, const BucketT *E, - const DebugEpochBase &Epoch, - const bool NoAdvance=false) const { -- if (shouldReverseIterate()) { -- const BucketT *B = P == getBucketsEnd() ? getBuckets() : P + 1; -- return const_iterator(B, E, Epoch, NoAdvance); -- } - return const_iterator(P, E, Epoch, NoAdvance); - } - -@@ -1214,10 +1176,6 @@ public: - assert(isHandleInSync() && "invalid construction!"); - - if (NoAdvance) return; -- if (shouldReverseIterate()) { -- RetreatPastEmptyBuckets(); -- return; -- } - AdvancePastEmptyBuckets(); - } - -@@ -1232,16 +1190,10 @@ public: - - reference operator*() const { - assert(isHandleInSync() && "invalid iterator access!"); -- assert(Ptr != End && "dereferencing end() iterator"); -- if (shouldReverseIterate()) -- return Ptr[-1]; - return *Ptr; - } - pointer operator->() const { - assert(isHandleInSync() && "invalid iterator access!"); -- assert(Ptr != End && "dereferencing end() iterator"); -- if (shouldReverseIterate()) -- return &(Ptr[-1]); - return Ptr; - } - -@@ -1261,12 +1213,6 @@ public: - - inline DenseMapIterator& operator++() { // Preincrement - assert(isHandleInSync() && "invalid iterator access!"); -- assert(Ptr != End && "incrementing end() iterator"); -- if (shouldReverseIterate()) { -- --Ptr; -- RetreatPastEmptyBuckets(); -- return *this; -- } - ++Ptr; - AdvancePastEmptyBuckets(); - return *this; -diff --git a/llvm/include/llvm/ADT/SmallPtrSet.h b/llvm/include/llvm/ADT/SmallPtrSet.h -index 981b741669b0..e46a5171e301 100644 ---- a/llvm/include/llvm/ADT/SmallPtrSet.h -+++ b/llvm/include/llvm/ADT/SmallPtrSet.h -@@ -226,10 +226,6 @@ protected: - public: - explicit SmallPtrSetIteratorImpl(const void *const *BP, const void*const *E) - : Bucket(BP), End(E) { -- if (shouldReverseIterate()) { -- RetreatIfNotValid(); -- return; -- } - AdvanceIfNotValid(); - } - -@@ -281,22 +277,11 @@ public: - // Most methods are provided by the base class. - - const PtrTy operator*() const { -- assert(isHandleInSync() && "invalid iterator access!"); -- if (shouldReverseIterate()) { -- assert(Bucket > End); -- return PtrTraits::getFromVoidPointer(const_cast(Bucket[-1])); -- } - assert(Bucket < End); - return PtrTraits::getFromVoidPointer(const_cast(*Bucket)); - } - - inline SmallPtrSetIterator& operator++() { // Preincrement -- assert(isHandleInSync() && "invalid iterator access!"); -- if (shouldReverseIterate()) { -- --Bucket; -- RetreatIfNotValid(); -- return *this; -- } - ++Bucket; - AdvanceIfNotValid(); - return *this; -@@ -400,8 +385,6 @@ public: - } - - iterator begin() const { -- if (shouldReverseIterate()) -- return makeIterator(EndPointer() - 1); - return makeIterator(CurArray); - } - iterator end() const { return makeIterator(EndPointer()); } -@@ -409,9 +392,7 @@ public: - private: - /// Create an iterator that dereferences to same place as the given pointer. - iterator makeIterator(const void *const *P) const { -- if (shouldReverseIterate()) -- return iterator(P == EndPointer() ? CurArray : P + 1, CurArray, *this); -- return iterator(P, EndPointer(), *this); -+ return iterator(P, EndPointer()); - } - }; - --- -2.20.1.windows.1 - diff --git a/upstream_utils/llvm_patches/0014-Remove-unused-functions.patch b/upstream_utils/llvm_patches/0010-Remove-unused-functions.patch similarity index 99% rename from upstream_utils/llvm_patches/0014-Remove-unused-functions.patch rename to upstream_utils/llvm_patches/0010-Remove-unused-functions.patch index cd5534853f..c0d5b617d1 100644 --- a/upstream_utils/llvm_patches/0014-Remove-unused-functions.patch +++ b/upstream_utils/llvm_patches/0010-Remove-unused-functions.patch @@ -1,7 +1,7 @@ -From e8352137c16b81ab7af248e608eca3a1d8221e37 Mon Sep 17 00:00:00 2001 +From 1354697da0c8661ef6030eb6355a680bbed7b752 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 13:43:50 -0400 -Subject: [PATCH 14/31] Remove unused functions +Subject: [PATCH 10/27] Remove unused functions --- llvm/include/llvm/ADT/SmallString.h | 80 ------ diff --git a/upstream_utils/llvm_patches/0015-Detemplatize-small-vector-base.patch b/upstream_utils/llvm_patches/0011-Detemplatize-small-vector-base.patch similarity index 98% rename from upstream_utils/llvm_patches/0015-Detemplatize-small-vector-base.patch rename to upstream_utils/llvm_patches/0011-Detemplatize-small-vector-base.patch index 1affda8a3d..ef47204036 100644 --- a/upstream_utils/llvm_patches/0015-Detemplatize-small-vector-base.patch +++ b/upstream_utils/llvm_patches/0011-Detemplatize-small-vector-base.patch @@ -1,7 +1,7 @@ -From b887e8f6e34e2ff2a3ad69f67f84f49ceb1f455e Mon Sep 17 00:00:00 2001 +From 0afb3b1de99d7f85899d3907e5e9a503a6ac599a Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Thu, 5 May 2022 23:18:34 -0400 -Subject: [PATCH 15/31] Detemplatize small vector base +Subject: [PATCH 11/27] Detemplatize small vector base --- llvm/include/llvm/ADT/SmallVector.h | 21 +++++++----------- diff --git a/upstream_utils/llvm_patches/0011-Remove-allocator-from-collections.patch b/upstream_utils/llvm_patches/0011-Remove-allocator-from-collections.patch deleted file mode 100644 index d034e97cba..0000000000 --- a/upstream_utils/llvm_patches/0011-Remove-allocator-from-collections.patch +++ /dev/null @@ -1,237 +0,0 @@ -From be653ec8d4b0a5944fcf084a911389cb0c5cc205 Mon Sep 17 00:00:00 2001 -From: PJ Reiniger -Date: Sat, 7 May 2022 23:07:38 -0400 -Subject: [PATCH 11/31] Remove allocator from collections - ---- - llvm/include/llvm/ADT/StringMap.h | 33 +++++++------------------- - llvm/include/llvm/ADT/StringMapEntry.h | 25 +++++++------------ - llvm/unittests/ADT/StringMapTest.cpp | 14 +++++------ - 3 files changed, 23 insertions(+), 49 deletions(-) - -diff --git a/llvm/include/llvm/ADT/StringMap.h b/llvm/include/llvm/ADT/StringMap.h -index 5f463cfef943..3b40bba37f58 100644 ---- a/llvm/include/llvm/ADT/StringMap.h -+++ b/llvm/include/llvm/ADT/StringMap.h -@@ -104,10 +104,8 @@ public: - /// keys that are "strings", which are basically ranges of bytes. This does some - /// funky memory allocation and hashing things to make it extremely efficient, - /// storing the string data *after* the value in the map. --template -+template - class StringMap : public StringMapImpl { -- AllocatorTy Allocator; -- - public: - using MapEntryTy = StringMapEntry; - -@@ -116,14 +114,6 @@ public: - explicit StringMap(unsigned InitialSize) - : StringMapImpl(InitialSize, static_cast(sizeof(MapEntryTy))) {} - -- explicit StringMap(AllocatorTy A) -- : StringMapImpl(static_cast(sizeof(MapEntryTy))), Allocator(A) { -- } -- -- StringMap(unsigned InitialSize, AllocatorTy A) -- : StringMapImpl(InitialSize, static_cast(sizeof(MapEntryTy))), -- Allocator(A) {} -- - StringMap(std::initializer_list> List) - : StringMapImpl(List.size(), static_cast(sizeof(MapEntryTy))) { - for (const auto &P : List) { -@@ -132,11 +122,10 @@ public: - } - - StringMap(StringMap &&RHS) -- : StringMapImpl(std::move(RHS)), Allocator(std::move(RHS.Allocator)) {} -+ : StringMapImpl(std::move(RHS)) {} - -- StringMap(const StringMap &RHS) -- : StringMapImpl(static_cast(sizeof(MapEntryTy))), -- Allocator(RHS.Allocator) { -+ StringMap(const StringMap &RHS) : -+ StringMapImpl(static_cast(sizeof(MapEntryTy))) { - if (RHS.empty()) - return; - -@@ -156,7 +145,7 @@ public: - } - - TheTable[I] = MapEntryTy::Create( -- static_cast(Bucket)->getKey(), Allocator, -+ static_cast(Bucket)->getKey(), - static_cast(Bucket)->getValue()); - HashTable[I] = RHSHashTable[I]; - } -@@ -171,7 +160,6 @@ public: - - StringMap &operator=(StringMap RHS) { - StringMapImpl::swap(RHS); -- std::swap(Allocator, RHS.Allocator); - return *this; - } - -@@ -183,16 +171,13 @@ public: - for (unsigned I = 0, E = NumBuckets; I != E; ++I) { - StringMapEntryBase *Bucket = TheTable[I]; - if (Bucket && Bucket != getTombstoneVal()) { -- static_cast(Bucket)->Destroy(Allocator); -+ static_cast(Bucket)->Destroy(); - } - } - } - free(TheTable); - } - -- AllocatorTy &getAllocator() { return Allocator; } -- const AllocatorTy &getAllocator() const { return Allocator; } -- - using key_type = const char *; - using mapped_type = ValueTy; - using value_type = StringMapEntry; -@@ -321,7 +306,7 @@ public: - - if (Bucket == getTombstoneVal()) - --NumTombstones; -- Bucket = MapEntryTy::Create(Key, Allocator, std::forward(Args)...); -+ Bucket = MapEntryTy::Create(Key, std::forward(Args)...); - ++NumItems; - assert(NumItems + NumTombstones <= NumBuckets); - -@@ -339,7 +324,7 @@ public: - for (unsigned I = 0, E = NumBuckets; I != E; ++I) { - StringMapEntryBase *&Bucket = TheTable[I]; - if (Bucket && Bucket != getTombstoneVal()) { -- static_cast(Bucket)->Destroy(Allocator); -+ static_cast(Bucket)->Destroy(); - } - Bucket = nullptr; - } -@@ -355,7 +340,7 @@ public: - void erase(iterator I) { - MapEntryTy &V = *I; - remove(&V); -- V.Destroy(Allocator); -+ V.Destroy(); - } - - bool erase(std::string_view Key) { -diff --git a/llvm/include/llvm/ADT/StringMapEntry.h b/llvm/include/llvm/ADT/StringMapEntry.h -index 93e13b5bb16c..66a30698d787 100644 ---- a/llvm/include/llvm/ADT/StringMapEntry.h -+++ b/llvm/include/llvm/ADT/StringMapEntry.h -@@ -33,22 +33,14 @@ protected: - /// Helper to tail-allocate \p Key. It'd be nice to generalize this so it - /// could be reused elsewhere, maybe even taking an llvm::function_ref to - /// type-erase the allocator and put it in a source file. -- template - static void *allocateWithKey(size_t EntrySize, size_t EntryAlign, -- std::string_view Key, AllocatorTy &Allocator); --}; -- --// Define out-of-line to dissuade inlining. --template --void *StringMapEntryBase::allocateWithKey(size_t EntrySize, size_t EntryAlign, -- std::string_view Key, -- AllocatorTy &Allocator) { -+ std::string_view Key) { - size_t KeyLength = Key.size(); - - // Allocate a new item with space for the string at the end and a null - // terminator. - size_t AllocSize = EntrySize + KeyLength + 1; -- void *Allocation = Allocator.Allocate(AllocSize, EntryAlign); -+ void *Allocation = safe_malloc(AllocSize); - assert(Allocation && "Unhandled out-of-memory"); - - // Copy the string information. -@@ -58,6 +50,7 @@ void *StringMapEntryBase::allocateWithKey(size_t EntrySize, size_t EntryAlign, - Buffer[KeyLength] = 0; // Null terminate for convenience of clients. - return Allocation; - } -+}; - - /// StringMapEntryStorage - Holds the value in a StringMapEntry. - /// -@@ -117,11 +110,11 @@ public: - - /// Create a StringMapEntry for the specified key construct the value using - /// \p InitiVals. -- template -- static StringMapEntry *Create(std::string_view key, AllocatorTy &allocator, -+ template -+ static StringMapEntry *Create(std::string_view key, - InitTy &&... initVals) { - return new (StringMapEntryBase::allocateWithKey( -- sizeof(StringMapEntry), alignof(StringMapEntry), key, allocator)) -+ sizeof(StringMapEntry), alignof(StringMapEntry), key)) - StringMapEntry(key.size(), std::forward(initVals)...); - } - -@@ -134,12 +127,10 @@ public: - - /// Destroy - Destroy this StringMapEntry, releasing memory back to the - /// specified allocator. -- template void Destroy(AllocatorTy &allocator) { -+ void Destroy() { - // Free memory referenced by the item. -- size_t AllocSize = sizeof(StringMapEntry) + this->getKeyLength() + 1; - this->~StringMapEntry(); -- allocator.Deallocate(static_cast(this), AllocSize, -- alignof(StringMapEntry)); -+ std::free(static_cast(this)); - } - }; - -diff --git a/llvm/unittests/ADT/StringMapTest.cpp b/llvm/unittests/ADT/StringMapTest.cpp -index 5211f01bbd73..28d710fe69e9 100644 ---- a/llvm/unittests/ADT/StringMapTest.cpp -+++ b/llvm/unittests/ADT/StringMapTest.cpp -@@ -223,13 +223,12 @@ TEST_F(StringMapTest, IterationTest) { - - // Test StringMapEntry::Create() method. - TEST_F(StringMapTest, StringMapEntryTest) { -- MallocAllocator Allocator; - StringMap::value_type *entry = - StringMap::value_type::Create( - std::string_view(testKeyFirst, testKeyLength), 1u); - EXPECT_STREQ(testKey, entry->first().data()); - EXPECT_EQ(1u, entry->second); -- entry->Destroy(Allocator); -+ entry->Destroy(); - } - - // Test insert() method. -@@ -238,7 +237,7 @@ TEST_F(StringMapTest, InsertTest) { - testMap.insert( - StringMap::value_type::Create( - std::string_view(testKeyFirst, testKeyLength), -- testMap.getAllocator(), 1u)); -+ 1u)); - assertSingleItemMap(); - } - -@@ -353,15 +352,14 @@ TEST_F(StringMapTest, MoveOnly) { - StringMap t; - t.insert(std::make_pair("Test", MoveOnly(42))); - std::string_view Key = "Test"; -- StringMapEntry::Create(Key, t.getAllocator(), MoveOnly(42)) -- ->Destroy(t.getAllocator()); -+ StringMapEntry::Create(Key, MoveOnly(42)) -+ ->Destroy(); - } - - TEST_F(StringMapTest, CtorArg) { - std::string_view Key = "Test"; -- MallocAllocator Allocator; -- StringMapEntry::Create(Key, Allocator, Immovable()) -- ->Destroy(Allocator); -+ StringMapEntry::Create(Key, Immovable()) -+ ->Destroy(); - } - - TEST_F(StringMapTest, MoveConstruct) { --- -2.20.1.windows.1 - diff --git a/upstream_utils/llvm_patches/0016-Add-vectors-to-raw_ostream.patch b/upstream_utils/llvm_patches/0012-Add-vectors-to-raw_ostream.patch similarity index 98% rename from upstream_utils/llvm_patches/0016-Add-vectors-to-raw_ostream.patch rename to upstream_utils/llvm_patches/0012-Add-vectors-to-raw_ostream.patch index 2bd8a1bb09..d578671cd2 100644 --- a/upstream_utils/llvm_patches/0016-Add-vectors-to-raw_ostream.patch +++ b/upstream_utils/llvm_patches/0012-Add-vectors-to-raw_ostream.patch @@ -1,7 +1,7 @@ -From eada33299195b46a8942e198ae8ae41185cd4f45 Mon Sep 17 00:00:00 2001 +From c01b703c5d54cb57f8a73215a4ca8aded32dd9ba Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 13:48:59 -0400 -Subject: [PATCH 16/31] Add vectors to raw_ostream +Subject: [PATCH 12/27] Add vectors to raw_ostream --- llvm/include/llvm/Support/raw_ostream.h | 115 ++++++++++++++++++++++++ diff --git a/upstream_utils/llvm_patches/0012-Remove-EpochTracker.patch b/upstream_utils/llvm_patches/0012-Remove-EpochTracker.patch deleted file mode 100644 index c5fb640be9..0000000000 --- a/upstream_utils/llvm_patches/0012-Remove-EpochTracker.patch +++ /dev/null @@ -1,91 +0,0 @@ -From ba61e94bf9e2273b6a2e5d3d4b2bb74f76536b19 Mon Sep 17 00:00:00 2001 -From: PJ Reiniger -Date: Sat, 7 May 2022 23:08:15 -0400 -Subject: [PATCH 12/31] Remove EpochTracker - ---- - llvm/include/llvm/ADT/SmallPtrSet.h | 14 ++++---------- - llvm/lib/Support/SmallPtrSet.cpp | 1 - - 2 files changed, 4 insertions(+), 11 deletions(-) - -diff --git a/llvm/include/llvm/ADT/SmallPtrSet.h b/llvm/include/llvm/ADT/SmallPtrSet.h -index e46a5171e301..2edc1f5e2066 100644 ---- a/llvm/include/llvm/ADT/SmallPtrSet.h -+++ b/llvm/include/llvm/ADT/SmallPtrSet.h -@@ -14,7 +14,6 @@ - #ifndef LLVM_ADT_SMALLPTRSET_H - #define LLVM_ADT_SMALLPTRSET_H - --#include "llvm/ADT/EpochTracker.h" - #include "llvm/Support/Compiler.h" - #include "llvm/Support/ReverseIteration.h" - #include "llvm/Support/type_traits.h" -@@ -46,7 +45,7 @@ namespace llvm { - /// (-2), to allow deletion. The hash table is resized when the table is 3/4 or - /// more. When this happens, the table is doubled in size. - /// --class SmallPtrSetImplBase : public DebugEpochBase { -+class SmallPtrSetImplBase { - friend class SmallPtrSetIteratorImpl; - - protected: -@@ -92,7 +91,6 @@ public: - size_type size() const { return NumNonEmpty - NumTombstones; } - - void clear() { -- incrementEpoch(); - // If the capacity of the array is huge, and the # elements used is small, - // shrink the array. - if (!isSmall()) { -@@ -139,14 +137,12 @@ protected: - if (LastTombstone != nullptr) { - *LastTombstone = Ptr; - --NumTombstones; -- incrementEpoch(); - return std::make_pair(LastTombstone, true); - } - - // Nope, there isn't. If we stay small, just 'pushback' now. - if (NumNonEmpty < CurArraySize) { - SmallArray[NumNonEmpty++] = Ptr; -- incrementEpoch(); - return std::make_pair(SmallArray + (NumNonEmpty - 1), true); - } - // Otherwise, hit the big set case, which will call grow. -@@ -259,8 +255,7 @@ protected: - - /// SmallPtrSetIterator - This implements a const_iterator for SmallPtrSet. - template --class SmallPtrSetIterator : public SmallPtrSetIteratorImpl, -- DebugEpochBase::HandleBase { -+class SmallPtrSetIterator : public SmallPtrSetIteratorImpl { - using PtrTraits = PointerLikeTypeTraits; - - public: -@@ -270,9 +265,8 @@ public: - using difference_type = std::ptrdiff_t; - using iterator_category = std::forward_iterator_tag; - -- explicit SmallPtrSetIterator(const void *const *BP, const void *const *E, -- const DebugEpochBase &Epoch) -- : SmallPtrSetIteratorImpl(BP, E), DebugEpochBase::HandleBase(&Epoch) {} -+ explicit SmallPtrSetIterator(const void *const *BP, const void *const *E) -+ : SmallPtrSetIteratorImpl(BP, E) {} - - // Most methods are provided by the base class. - -diff --git a/llvm/lib/Support/SmallPtrSet.cpp b/llvm/lib/Support/SmallPtrSet.cpp -index f6e2dfb8a6c9..4549db08e3ee 100644 ---- a/llvm/lib/Support/SmallPtrSet.cpp -+++ b/llvm/lib/Support/SmallPtrSet.cpp -@@ -59,7 +59,6 @@ SmallPtrSetImplBase::insert_imp_big(const void *Ptr) { - else - ++NumNonEmpty; // Track density. - *Bucket = Ptr; -- incrementEpoch(); - return std::make_pair(Bucket, true); - } - --- -2.20.1.windows.1 - diff --git a/upstream_utils/llvm_patches/0017-Extra-collections-features.patch b/upstream_utils/llvm_patches/0013-Extra-collections-features.patch similarity index 95% rename from upstream_utils/llvm_patches/0017-Extra-collections-features.patch rename to upstream_utils/llvm_patches/0013-Extra-collections-features.patch index dbc12dca58..e4817a3381 100644 --- a/upstream_utils/llvm_patches/0017-Extra-collections-features.patch +++ b/upstream_utils/llvm_patches/0013-Extra-collections-features.patch @@ -1,7 +1,7 @@ -From fc8a16f804f5d37e179f8eac521f8430e663d1a0 Mon Sep 17 00:00:00 2001 +From 1c2a3d6eb4737e5b822ca8729472ddcf5c4d78c2 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Tue, 3 May 2022 22:16:10 -0400 -Subject: [PATCH 17/31] Extra collections features +Subject: [PATCH 13/27] Extra collections features --- llvm/include/llvm/ADT/StringMap.h | 103 +++++++++++++++++++++++++++++- @@ -9,7 +9,7 @@ Subject: [PATCH 17/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 3b40bba37f58..af4be84e469d 100644 +index 5f463cfef943..ac0d4b363145 100644 --- a/llvm/include/llvm/ADT/StringMap.h +++ b/llvm/include/llvm/ADT/StringMap.h @@ -40,7 +40,7 @@ protected: @@ -21,7 +21,7 @@ index 3b40bba37f58..af4be84e469d 100644 : TheTable(RHS.TheTable), NumBuckets(RHS.NumBuckets), NumItems(RHS.NumItems), NumTombstones(RHS.NumTombstones), ItemSize(RHS.ItemSize) { -@@ -390,11 +390,27 @@ public: +@@ -405,11 +405,27 @@ public: return Tmp; } @@ -49,7 +49,7 @@ index 3b40bba37f58..af4be84e469d 100644 }; template -@@ -459,6 +475,91 @@ private: +@@ -474,6 +490,91 @@ private: std::string_view Key; }; diff --git a/upstream_utils/llvm_patches/0018-EpochTracker-abi-macro.patch b/upstream_utils/llvm_patches/0014-EpochTracker-abi-macro.patch similarity index 86% rename from upstream_utils/llvm_patches/0018-EpochTracker-abi-macro.patch rename to upstream_utils/llvm_patches/0014-EpochTracker-abi-macro.patch index ebb339aa6d..9e2d7da0fb 100644 --- a/upstream_utils/llvm_patches/0018-EpochTracker-abi-macro.patch +++ b/upstream_utils/llvm_patches/0014-EpochTracker-abi-macro.patch @@ -1,7 +1,7 @@ -From 0986c8a95cad971a1bf84259e1ab698497ca205c Mon Sep 17 00:00:00 2001 +From 72ab19d035da6d31695f3622270978608d7ef0ef Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Wed, 4 May 2022 00:01:00 -0400 -Subject: [PATCH 18/31] EpochTracker abi macro +Subject: [PATCH 14/27] EpochTracker abi macro --- llvm/include/llvm/ADT/EpochTracker.h | 2 +- diff --git a/upstream_utils/llvm_patches/0019-Delete-numbers-from-mathextras.patch b/upstream_utils/llvm_patches/0015-Delete-numbers-from-mathextras.patch similarity index 96% rename from upstream_utils/llvm_patches/0019-Delete-numbers-from-mathextras.patch rename to upstream_utils/llvm_patches/0015-Delete-numbers-from-mathextras.patch index 69b7c75690..d343418062 100644 --- a/upstream_utils/llvm_patches/0019-Delete-numbers-from-mathextras.patch +++ b/upstream_utils/llvm_patches/0015-Delete-numbers-from-mathextras.patch @@ -1,7 +1,7 @@ -From f2b2850258fe3aed54c64f8afac2565b00ddf4b0 Mon Sep 17 00:00:00 2001 +From bb8c33904fba6099ca17ddecd84fa20272c5a20c Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Thu, 5 May 2022 18:09:45 -0400 -Subject: [PATCH 19/31] Delete numbers from mathextras +Subject: [PATCH 15/27] Delete numbers from mathextras --- llvm/include/llvm/Support/MathExtras.h | 36 -------------------------- diff --git a/upstream_utils/llvm_patches/0020-Add-lerp-and-sgn.patch b/upstream_utils/llvm_patches/0016-Add-lerp-and-sgn.patch similarity index 92% rename from upstream_utils/llvm_patches/0020-Add-lerp-and-sgn.patch rename to upstream_utils/llvm_patches/0016-Add-lerp-and-sgn.patch index 451e4844db..3a32862e87 100644 --- a/upstream_utils/llvm_patches/0020-Add-lerp-and-sgn.patch +++ b/upstream_utils/llvm_patches/0016-Add-lerp-and-sgn.patch @@ -1,7 +1,7 @@ -From 2a2ac87a1ac74a1c6e29c205b3fd979ab77722b4 Mon Sep 17 00:00:00 2001 +From 08f507c2c558f3ae9fcd7a31c7ce33b0776bfe8a Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Tue, 3 May 2022 22:50:24 -0400 -Subject: [PATCH 20/31] Add lerp and sgn +Subject: [PATCH 16/27] Add lerp and sgn --- llvm/include/llvm/Support/MathExtras.h | 20 ++++++++++++++++++++ diff --git a/upstream_utils/llvm_patches/0021-Fixup-includes.patch b/upstream_utils/llvm_patches/0017-Fixup-includes.patch similarity index 92% rename from upstream_utils/llvm_patches/0021-Fixup-includes.patch rename to upstream_utils/llvm_patches/0017-Fixup-includes.patch index dc4f8927c6..5667aaf723 100644 --- a/upstream_utils/llvm_patches/0021-Fixup-includes.patch +++ b/upstream_utils/llvm_patches/0017-Fixup-includes.patch @@ -1,10 +1,10 @@ -From b013523b36cba3c8fc0ced2ca013a8763573d5a0 Mon Sep 17 00:00:00 2001 +From 8e868fdb545f3facb646418b5e127e360fe88a99 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 16:38:11 -0400 -Subject: [PATCH 21/31] Fixup includes +Subject: [PATCH 17/27] Fixup includes --- - llvm/include/llvm/ADT/StringMap.h | 5 ++++- + llvm/include/llvm/ADT/StringMap.h | 4 ++++ llvm/include/llvm/ADT/StringMapEntry.h | 4 ++++ llvm/include/llvm/Support/PointerLikeTypeTraits.h | 1 + llvm/lib/Support/ConvertUTFWrapper.cpp | 1 + @@ -13,17 +13,16 @@ Subject: [PATCH 21/31] Fixup includes llvm/unittests/ADT/SmallPtrSetTest.cpp | 2 ++ llvm/unittests/ADT/StringMapTest.cpp | 1 + llvm/unittests/Support/ConvertUTFTest.cpp | 2 ++ - 9 files changed, 24 insertions(+), 11 deletions(-) + 9 files changed, 24 insertions(+), 10 deletions(-) diff --git a/llvm/include/llvm/ADT/StringMap.h b/llvm/include/llvm/ADT/StringMap.h -index af4be84e469d..c41057cb6792 100644 +index ac0d4b363145..f7bf5ad9c063 100644 --- a/llvm/include/llvm/ADT/StringMap.h +++ b/llvm/include/llvm/ADT/StringMap.h -@@ -14,7 +14,10 @@ - #define LLVM_ADT_STRINGMAP_H +@@ -15,6 +15,10 @@ #include "llvm/ADT/StringMapEntry.h" --#include "llvm/Support/AllocatorBase.h" + #include "llvm/Support/AllocatorBase.h" +#include "llvm/Support/MemAlloc.h" +#include "llvm/Support/SmallVector.h" +#include "llvm/Support/iterator.h" @@ -32,7 +31,7 @@ index af4be84e469d..c41057cb6792 100644 #include #include diff --git a/llvm/include/llvm/ADT/StringMapEntry.h b/llvm/include/llvm/ADT/StringMapEntry.h -index 66a30698d787..1201bb8e69d4 100644 +index 93e13b5bb16c..cdf11d627200 100644 --- a/llvm/include/llvm/ADT/StringMapEntry.h +++ b/llvm/include/llvm/ADT/StringMapEntry.h @@ -15,6 +15,10 @@ @@ -143,7 +142,7 @@ index 531f81ab5b3f..3db8b6e37d31 100644 TEST(SmallPtrSetTest, Assignment) { diff --git a/llvm/unittests/ADT/StringMapTest.cpp b/llvm/unittests/ADT/StringMapTest.cpp -index 28d710fe69e9..60571cff6927 100644 +index 081b699adee3..64bb8f85c4b9 100644 --- a/llvm/unittests/ADT/StringMapTest.cpp +++ b/llvm/unittests/ADT/StringMapTest.cpp @@ -9,6 +9,7 @@ diff --git a/upstream_utils/llvm_patches/0022-use-std-is_trivially_copy_constructible.patch b/upstream_utils/llvm_patches/0018-use-std-is_trivially_copy_constructible.patch similarity index 97% rename from upstream_utils/llvm_patches/0022-use-std-is_trivially_copy_constructible.patch rename to upstream_utils/llvm_patches/0018-use-std-is_trivially_copy_constructible.patch index 84a6755b1e..9fc429f032 100644 --- a/upstream_utils/llvm_patches/0022-use-std-is_trivially_copy_constructible.patch +++ b/upstream_utils/llvm_patches/0018-use-std-is_trivially_copy_constructible.patch @@ -1,7 +1,7 @@ -From 6df7cc04af50a1afad6f8baf8ea0520576944bed Mon Sep 17 00:00:00 2001 +From 024847ab39cbe06024da3f5c63d9a667aff4e500 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 16:42:09 -0400 -Subject: [PATCH 22/31] use std is_trivially_copy_constructible +Subject: [PATCH 18/27] use std is_trivially_copy_constructible --- llvm/include/llvm/ADT/PointerIntPair.h | 12 ---- diff --git a/upstream_utils/llvm_patches/0023-Windows-Support.patch b/upstream_utils/llvm_patches/0019-Windows-Support.patch similarity index 98% rename from upstream_utils/llvm_patches/0023-Windows-Support.patch rename to upstream_utils/llvm_patches/0019-Windows-Support.patch index 034a29a655..e7f49706e2 100644 --- a/upstream_utils/llvm_patches/0023-Windows-Support.patch +++ b/upstream_utils/llvm_patches/0019-Windows-Support.patch @@ -1,7 +1,7 @@ -From 403d6612f25ae09b3bbeffe3ed75e8c498f80da5 Mon Sep 17 00:00:00 2001 +From 45d53c5dc0cc2924569a96c1ac1e4efcaaa60044 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Tue, 3 May 2022 20:22:38 -0400 -Subject: [PATCH 23/31] Windows Support +Subject: [PATCH 19/27] Windows Support --- .../llvm/Support/Windows/WindowsSupport.h | 45 +++++---- diff --git a/upstream_utils/llvm_patches/0024-Prefer-fmtlib.patch b/upstream_utils/llvm_patches/0020-Prefer-fmtlib.patch similarity index 95% rename from upstream_utils/llvm_patches/0024-Prefer-fmtlib.patch rename to upstream_utils/llvm_patches/0020-Prefer-fmtlib.patch index 541df1bb94..57dcfb829f 100644 --- a/upstream_utils/llvm_patches/0024-Prefer-fmtlib.patch +++ b/upstream_utils/llvm_patches/0020-Prefer-fmtlib.patch @@ -1,7 +1,7 @@ -From c67b1c2baf278050fb43bee7a7241392d64fbb0d Mon Sep 17 00:00:00 2001 +From 2a480ee8e89b322b91f596a5a9d63aa6b9a76af0 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 16:46:20 -0400 -Subject: [PATCH 24/31] Prefer fmtlib +Subject: [PATCH 20/27] Prefer fmtlib --- llvm/lib/Support/ErrorHandling.cpp | 20 ++++++-------------- diff --git a/upstream_utils/llvm_patches/0025-prefer-wpi-s-fs.h.patch b/upstream_utils/llvm_patches/0021-prefer-wpi-s-fs.h.patch similarity index 90% rename from upstream_utils/llvm_patches/0025-prefer-wpi-s-fs.h.patch rename to upstream_utils/llvm_patches/0021-prefer-wpi-s-fs.h.patch index 214bb790c5..f17899eba4 100644 --- a/upstream_utils/llvm_patches/0025-prefer-wpi-s-fs.h.patch +++ b/upstream_utils/llvm_patches/0021-prefer-wpi-s-fs.h.patch @@ -1,7 +1,7 @@ -From 07ffe44dd483a6fd847030ca9b76a225d5b7b2de Mon Sep 17 00:00:00 2001 +From c7a7fd016ae0636dcadc65705a9260f02c509495 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 16:49:36 -0400 -Subject: [PATCH 25/31] prefer wpi's fs.h +Subject: [PATCH 21/27] prefer wpi's fs.h --- llvm/include/llvm/Support/raw_ostream.h | 7 ++----- diff --git a/upstream_utils/llvm_patches/0026-Remove-unused-functions.patch b/upstream_utils/llvm_patches/0022-Remove-unused-functions.patch similarity index 92% rename from upstream_utils/llvm_patches/0026-Remove-unused-functions.patch rename to upstream_utils/llvm_patches/0022-Remove-unused-functions.patch index a80783d054..515b7b4df1 100644 --- a/upstream_utils/llvm_patches/0026-Remove-unused-functions.patch +++ b/upstream_utils/llvm_patches/0022-Remove-unused-functions.patch @@ -1,15 +1,30 @@ -From 7bac24e5310d67d6828b687aec2043966a955093 Mon Sep 17 00:00:00 2001 +From 8536e1f23d515eac3cbc0680f27aa6ab740b4796 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 19:16:51 -0400 -Subject: [PATCH 26/31] Remove unused functions +Subject: [PATCH 22/27] Remove unused functions --- + llvm/include/llvm/Support/DJB.h | 3 - llvm/include/llvm/Support/raw_ostream.h | 3 +- llvm/lib/Support/ErrorHandling.cpp | 16 ----- llvm/lib/Support/raw_ostream.cpp | 48 +++++++-------- llvm/unittests/ADT/SmallStringTest.cpp | 81 ------------------------- - 4 files changed, 22 insertions(+), 126 deletions(-) + 5 files changed, 22 insertions(+), 129 deletions(-) +diff --git a/llvm/include/llvm/Support/DJB.h b/llvm/include/llvm/Support/DJB.h +index 8737cd144c37..67b0ae91b4b1 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 27fb5c03e474..d228b05f4f9b 100644 --- a/llvm/include/llvm/Support/raw_ostream.h diff --git a/upstream_utils/llvm_patches/0027-Add-convienence-feature-to-SmallString.patch b/upstream_utils/llvm_patches/0023-Add-convienence-feature-to-SmallString.patch similarity index 88% rename from upstream_utils/llvm_patches/0027-Add-convienence-feature-to-SmallString.patch rename to upstream_utils/llvm_patches/0023-Add-convienence-feature-to-SmallString.patch index f8527e2ac0..07d399ea4d 100644 --- a/upstream_utils/llvm_patches/0027-Add-convienence-feature-to-SmallString.patch +++ b/upstream_utils/llvm_patches/0023-Add-convienence-feature-to-SmallString.patch @@ -1,7 +1,7 @@ -From 0e20a9a457bbcef8bd07a0c06fceb9641fba0ad2 Mon Sep 17 00:00:00 2001 +From 333f987aa17d7138af8bf6e41d5749041793a721 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Mon, 9 May 2022 00:18:29 -0400 -Subject: [PATCH 27/31] Add convienence feature to SmallString +Subject: [PATCH 23/27] Add convienence feature to SmallString --- llvm/include/llvm/ADT/SmallString.h | 8 +++++--- diff --git a/upstream_utils/llvm_patches/0028-OS-specific-changes.patch b/upstream_utils/llvm_patches/0024-OS-specific-changes.patch similarity index 93% rename from upstream_utils/llvm_patches/0028-OS-specific-changes.patch rename to upstream_utils/llvm_patches/0024-OS-specific-changes.patch index 12fd43d156..35fd143b77 100644 --- a/upstream_utils/llvm_patches/0028-OS-specific-changes.patch +++ b/upstream_utils/llvm_patches/0024-OS-specific-changes.patch @@ -1,7 +1,7 @@ -From 96ace137b394c0af8b3f1d9f3862cdf171adcfa4 Mon Sep 17 00:00:00 2001 +From 9d6e5efbd4b77747387b35a45d0c591126f7c08c Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 19:30:43 -0400 -Subject: [PATCH 28/31] OS specific changes +Subject: [PATCH 24/27] OS specific changes --- llvm/lib/Support/ErrorHandling.cpp | 13 +++++++------ diff --git a/upstream_utils/llvm_patches/0029-Use-smallvector-for-UTF-conversion.patch b/upstream_utils/llvm_patches/0025-Use-smallvector-for-UTF-conversion.patch similarity index 98% rename from upstream_utils/llvm_patches/0029-Use-smallvector-for-UTF-conversion.patch rename to upstream_utils/llvm_patches/0025-Use-smallvector-for-UTF-conversion.patch index 7098d834f8..9e9c897555 100644 --- a/upstream_utils/llvm_patches/0029-Use-smallvector-for-UTF-conversion.patch +++ b/upstream_utils/llvm_patches/0025-Use-smallvector-for-UTF-conversion.patch @@ -1,7 +1,7 @@ -From 6ec969e4a7a0bcbb3b54a48dc2bff84e1b431632 Mon Sep 17 00:00:00 2001 +From fa16120af5f965c13bd7b75a2e591cd250fad5fa Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Mon, 9 May 2022 00:04:30 -0400 -Subject: [PATCH 29/31] Use smallvector for UTF conversion +Subject: [PATCH 25/27] Use smallvector for UTF conversion --- llvm/include/llvm/Support/ConvertUTF.h | 6 +++--- diff --git a/upstream_utils/llvm_patches/0030-Prefer-to-use-static-pointers-in-raw_ostream.patch b/upstream_utils/llvm_patches/0026-Prefer-to-use-static-pointers-in-raw_ostream.patch similarity index 89% rename from upstream_utils/llvm_patches/0030-Prefer-to-use-static-pointers-in-raw_ostream.patch rename to upstream_utils/llvm_patches/0026-Prefer-to-use-static-pointers-in-raw_ostream.patch index 4a50806547..12ce3cb4bf 100644 --- a/upstream_utils/llvm_patches/0030-Prefer-to-use-static-pointers-in-raw_ostream.patch +++ b/upstream_utils/llvm_patches/0026-Prefer-to-use-static-pointers-in-raw_ostream.patch @@ -1,7 +1,7 @@ -From 6f0f7e6e4256d642673e3441468f44f6bd94fe12 Mon Sep 17 00:00:00 2001 +From 7bdbcabd3271aebb692ef06a950d1ec59341ddf9 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Thu, 19 May 2022 00:58:36 -0400 -Subject: [PATCH 30/31] Prefer to use static pointers in raw_ostream +Subject: [PATCH 26/27] Prefer to use static pointers in raw_ostream See #1401 --- diff --git a/upstream_utils/llvm_patches/0031-constexpr-endian-byte-swap.patch b/upstream_utils/llvm_patches/0027-constexpr-endian-byte-swap.patch similarity index 88% rename from upstream_utils/llvm_patches/0031-constexpr-endian-byte-swap.patch rename to upstream_utils/llvm_patches/0027-constexpr-endian-byte-swap.patch index 5545fdc07f..4887465d8d 100644 --- a/upstream_utils/llvm_patches/0031-constexpr-endian-byte-swap.patch +++ b/upstream_utils/llvm_patches/0027-constexpr-endian-byte-swap.patch @@ -1,7 +1,7 @@ -From 63e46567fe7f9d3e48beaca7827125bfe06e1004 Mon Sep 17 00:00:00 2001 +From 34652f999acd319bb507ca4d504050ec90981e18 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Thu, 19 May 2022 01:12:41 -0400 -Subject: [PATCH 31/31] constexpr endian byte swap +Subject: [PATCH 27/27] constexpr endian byte swap --- llvm/include/llvm/Support/Endian.h | 4 +++- diff --git a/upstream_utils/update_llvm.py b/upstream_utils/update_llvm.py index 1fe877604c..e759bac11c 100755 --- a/upstream_utils/update_llvm.py +++ b/upstream_utils/update_llvm.py @@ -54,8 +54,6 @@ def run_global_replacements(wpiutil_llvm_files): # Replace wpi/FileSystem.h with wpi/fs.h content = content.replace("include \"wpi/FileSystem.h\"", "include \"wpi/fs.h\"") - content = content.replace("#include \"wpi/ReverseIteration.h\"", - "#include \"wpi/PointerLikeTypeTraits.h\"") # Replace llvm_unreachable() with wpi_unreachable() content = content.replace("llvm_unreachable", "wpi_unreachable") @@ -163,32 +161,28 @@ def main(): os.path.join(patch_root, "0003-Wrap-std-min-max-calls-in-parens-for-windows-warning.patch"), os.path.join(patch_root, "0004-Change-uniqe_function-storage-size.patch"), os.path.join(patch_root, "0005-Threading-updates.patch"), - os.path.join(patch_root, "0006-Remove-DJB-hash-dependency.patch"), - os.path.join(patch_root, "0007-ifdef-guard-safety.patch"), - os.path.join(patch_root, "0008-Explicitly-use-std.patch"), - os.path.join(patch_root, "0009-Remove-format_provider.patch"), - os.path.join(patch_root, "0010-Remove-reverse-iterator.patch"), - os.path.join(patch_root, "0011-Remove-allocator-from-collections.patch"), - os.path.join(patch_root, "0012-Remove-EpochTracker.patch"), - os.path.join(patch_root, "0013-Add-compiler-warning-pragrams.patch"), - os.path.join(patch_root, "0014-Remove-unused-functions.patch"), - os.path.join(patch_root, "0015-Detemplatize-small-vector-base.patch"), - os.path.join(patch_root, "0016-Add-vectors-to-raw_ostream.patch"), - os.path.join(patch_root, "0017-Extra-collections-features.patch"), - os.path.join(patch_root, "0018-EpochTracker-abi-macro.patch"), - os.path.join(patch_root, "0019-Delete-numbers-from-mathextras.patch"), - os.path.join(patch_root, "0020-Add-lerp-and-sgn.patch"), - os.path.join(patch_root, "0021-Fixup-includes.patch"), - os.path.join(patch_root, "0022-use-std-is_trivially_copy_constructible.patch"), - os.path.join(patch_root, "0023-Windows-Support.patch"), - os.path.join(patch_root, "0024-Prefer-fmtlib.patch"), - os.path.join(patch_root, "0025-prefer-wpi-s-fs.h.patch"), - os.path.join(patch_root, "0026-Remove-unused-functions.patch"), - os.path.join(patch_root, "0027-Add-convienence-feature-to-SmallString.patch"), - os.path.join(patch_root, "0028-OS-specific-changes.patch"), - os.path.join(patch_root, "0029-Use-smallvector-for-UTF-conversion.patch"), - os.path.join(patch_root, "0030-Prefer-to-use-static-pointers-in-raw_ostream.patch"), - os.path.join(patch_root, "0031-constexpr-endian-byte-swap.patch"), + os.path.join(patch_root, "0006-ifdef-guard-safety.patch"), + os.path.join(patch_root, "0007-Explicitly-use-std.patch"), + os.path.join(patch_root, "0008-Remove-format_provider.patch"), + os.path.join(patch_root, "0009-Add-compiler-warning-pragrams.patch"), + os.path.join(patch_root, "0010-Remove-unused-functions.patch"), + os.path.join(patch_root, "0011-Detemplatize-small-vector-base.patch"), + os.path.join(patch_root, "0012-Add-vectors-to-raw_ostream.patch"), + os.path.join(patch_root, "0013-Extra-collections-features.patch"), + os.path.join(patch_root, "0014-EpochTracker-abi-macro.patch"), + os.path.join(patch_root, "0015-Delete-numbers-from-mathextras.patch"), + os.path.join(patch_root, "0016-Add-lerp-and-sgn.patch"), + os.path.join(patch_root, "0017-Fixup-includes.patch"), + os.path.join(patch_root, "0018-use-std-is_trivially_copy_constructible.patch"), + os.path.join(patch_root, "0019-Windows-Support.patch"), + os.path.join(patch_root, "0020-Prefer-fmtlib.patch"), + os.path.join(patch_root, "0021-prefer-wpi-s-fs.h.patch"), + os.path.join(patch_root, "0022-Remove-unused-functions.patch"), + os.path.join(patch_root, "0023-Add-convienence-feature-to-SmallString.patch"), + os.path.join(patch_root, "0024-OS-specific-changes.patch"), + os.path.join(patch_root, "0025-Use-smallvector-for-UTF-conversion.patch"), + os.path.join(patch_root, "0026-Prefer-to-use-static-pointers-in-raw_ostream.patch"), + os.path.join(patch_root, "0027-constexpr-endian-byte-swap.patch"), ] # yapf: enable diff --git a/wpiutil/.styleguide b/wpiutil/.styleguide index 4301c7da66..78e24fbf0d 100644 --- a/wpiutil/.styleguide +++ b/wpiutil/.styleguide @@ -13,6 +13,7 @@ cppSrcFileInclude { generatedFileExclude { src/main/native/cpp/llvm/ src/main/native/include/llvm/ + src/main/native/include/wpi/AllocatorBase\.h$ src/main/native/include/wpi/AlignOf\.h$ src/main/native/include/wpi/ArrayRef\.h$ src/main/native/include/wpi/Chrono\.h$ @@ -20,6 +21,7 @@ generatedFileExclude { src/main/native/include/wpi/ConvertUTF\.h$ src/main/native/include/wpi/DenseMap\.h$ src/main/native/include/wpi/DenseMapInfo\.h$ + src/main/native/include/wpi/DJB\.h$ src/main/native/include/wpi/EpochTracker\.h$ src/main/native/include/wpi/Endian\.h$ src/main/native/include/wpi/Errc\.h$ @@ -41,6 +43,7 @@ generatedFileExclude { src/main/native/include/wpi/PointerIntPair\.h$ src/main/native/include/wpi/PointerLikeTypeTraits\.h$ src/main/native/include/wpi/PointerUnion\.h$ + src/main/native/include/wpi/ReverseIteration\.h$ src/main/native/include/wpi/STLExtras\.h$ src/main/native/include/wpi/Signal\.h$ src/main/native/include/wpi/SmallPtrSet\.h$ diff --git a/wpiutil/src/main/native/cpp/llvm/SmallPtrSet.cpp b/wpiutil/src/main/native/cpp/llvm/SmallPtrSet.cpp index c5cb23cca0..e25882621a 100644 --- a/wpiutil/src/main/native/cpp/llvm/SmallPtrSet.cpp +++ b/wpiutil/src/main/native/cpp/llvm/SmallPtrSet.cpp @@ -59,6 +59,7 @@ SmallPtrSetImplBase::insert_imp_big(const void *Ptr) { else ++NumNonEmpty; // Track density. *Bucket = Ptr; + incrementEpoch(); return std::make_pair(Bucket, true); } diff --git a/wpiutil/src/main/native/cpp/llvm/StringMap.cpp b/wpiutil/src/main/native/cpp/llvm/StringMap.cpp index 68ece29b72..98a9309beb 100644 --- a/wpiutil/src/main/native/cpp/llvm/StringMap.cpp +++ b/wpiutil/src/main/native/cpp/llvm/StringMap.cpp @@ -12,26 +12,11 @@ #include "wpi/StringMap.h" #include "wpi/StringExtras.h" -#include "wpi/Compiler.h" +#include "wpi/DJB.h" #include "wpi/MathExtras.h" using namespace wpi; -/// HashString - Hash function for strings. -/// -/// This is the Bernstein hash function. -// -// FIXME: Investigate whether a modified bernstein hash function performs -// better: http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx -// X*33+c -> X*33^c -static inline unsigned HashString(std::string_view str, - unsigned result = 0) noexcept { - for (std::string_view::size_type i = 0, e = str.size(); i != e; ++i) { - result = result * 33 + static_cast(str[i]); - } - return result; -} - /// Returns the number of buckets to allocate to ensure that the DenseMap can /// accommodate \p NumEntries without need to grow(). static unsigned getMinBucketToReserveForEntries(unsigned NumEntries) { @@ -92,7 +77,7 @@ unsigned StringMapImpl::LookupBucketFor(std::string_view Name) { init(16); HTSize = NumBuckets; } - unsigned FullHashValue = HashString(Name); + unsigned FullHashValue = djbHash(Name, 0); unsigned BucketNo = FullHashValue & (HTSize - 1); unsigned *HashTable = (unsigned *)(TheTable + NumBuckets + 1); @@ -148,7 +133,7 @@ int StringMapImpl::FindKey(std::string_view Key) const { unsigned HTSize = NumBuckets; if (HTSize == 0) return -1; // Really empty table? - unsigned FullHashValue = HashString(Key); + unsigned FullHashValue = djbHash(Key, 0); unsigned BucketNo = FullHashValue & (HTSize - 1); unsigned *HashTable = (unsigned *)(TheTable + NumBuckets + 1); diff --git a/wpiutil/src/main/native/include/wpi/AllocatorBase.h b/wpiutil/src/main/native/include/wpi/AllocatorBase.h new file mode 100644 index 0000000000..10fef55743 --- /dev/null +++ b/wpiutil/src/main/native/include/wpi/AllocatorBase.h @@ -0,0 +1,103 @@ +//===- AllocatorBase.h - Simple memory allocation abstraction ---*- 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 MallocAllocator. MallocAllocator conforms to the LLVM +/// "Allocator" concept which consists of an Allocate method accepting a size +/// and alignment, and a Deallocate accepting a pointer and size. Further, the +/// LLVM "Allocator" concept has overloads of Allocate and Deallocate for +/// setting size and alignment based on the final type. These overloads are +/// typically provided by a base class template \c AllocatorBase. +/// +//===----------------------------------------------------------------------===// + +#ifndef WPIUTIL_WPI_ALLOCATORBASE_H +#define WPIUTIL_WPI_ALLOCATORBASE_H + +#include "wpi/Compiler.h" +#include "wpi/MemAlloc.h" + +namespace wpi { + +/// CRTP base class providing obvious overloads for the core \c +/// Allocate() methods of LLVM-style allocators. +/// +/// This base class both documents the full public interface exposed by all +/// LLVM-style allocators, and redirects all of the overloads to a single core +/// set of methods which the derived class must define. +template class AllocatorBase { +public: + /// Allocate \a Size bytes of \a Alignment aligned memory. This method + /// must be implemented by \c DerivedT. + void *Allocate(size_t Size, size_t Alignment) { +#ifdef __clang__ + static_assert(static_cast( + &AllocatorBase::Allocate) != + static_cast( + &DerivedT::Allocate), + "Class derives from AllocatorBase without implementing the " + "core Allocate(size_t, size_t) overload!"); +#endif + return static_cast(this)->Allocate(Size, Alignment); + } + + /// Deallocate \a Ptr to \a Size bytes of memory allocated by this + /// allocator. + void Deallocate(const void *Ptr, size_t Size, size_t Alignment) { +#ifdef __clang__ + static_assert( + static_cast( + &AllocatorBase::Deallocate) != + static_cast( + &DerivedT::Deallocate), + "Class derives from AllocatorBase without implementing the " + "core Deallocate(void *) overload!"); +#endif + return static_cast(this)->Deallocate(Ptr, Size, Alignment); + } + + // The rest of these methods are helpers that redirect to one of the above + // core methods. + + /// Allocate space for a sequence of objects without constructing them. + template T *Allocate(size_t Num = 1) { + return static_cast(Allocate(Num * sizeof(T), alignof(T))); + } + + /// Deallocate space for a sequence of objects without constructing them. + template + std::enable_if_t, void>::value, void> + Deallocate(T *Ptr, size_t Num = 1) { + Deallocate(static_cast(Ptr), Num * sizeof(T), alignof(T)); + } +}; + +class MallocAllocator : public AllocatorBase { +public: + void Reset() {} + + LLVM_ATTRIBUTE_RETURNS_NONNULL void *Allocate(size_t Size, size_t Alignment) { + return allocate_buffer(Size, Alignment); + } + + // Pull in base class overloads. + using AllocatorBase::Allocate; + + void Deallocate(const void *Ptr, size_t Size, size_t Alignment) { + deallocate_buffer(const_cast(Ptr), Size, Alignment); + } + + // Pull in base class overloads. + using AllocatorBase::Deallocate; + + void PrintStats() const {} +}; + +} // namespace wpi + +#endif // WPIUTIL_WPI_ALLOCATORBASE_H diff --git a/wpiutil/src/main/native/include/wpi/DJB.h b/wpiutil/src/main/native/include/wpi/DJB.h new file mode 100644 index 0000000000..2615bba4bd --- /dev/null +++ b/wpiutil/src/main/native/include/wpi/DJB.h @@ -0,0 +1,29 @@ +//===-- 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/include/wpi/DenseMap.h b/wpiutil/src/main/native/include/wpi/DenseMap.h index 2fb7e953ec..2158f8a8b7 100644 --- a/wpiutil/src/main/native/include/wpi/DenseMap.h +++ b/wpiutil/src/main/native/include/wpi/DenseMap.h @@ -19,7 +19,7 @@ #include "wpi/Compiler.h" #include "wpi/MathExtras.h" #include "wpi/MemAlloc.h" -#include "wpi/PointerLikeTypeTraits.h" +#include "wpi/ReverseIteration.h" #include "wpi/type_traits.h" #include #include @@ -76,6 +76,8 @@ public: // empty buckets. if (empty()) return end(); + if (shouldReverseIterate()) + return makeIterator(getBucketsEnd() - 1, getBuckets(), *this); return makeIterator(getBuckets(), getBucketsEnd(), *this); } inline iterator end() { @@ -84,6 +86,8 @@ public: inline const_iterator begin() const { if (empty()) return end(); + if (shouldReverseIterate()) + return makeConstIterator(getBucketsEnd() - 1, getBuckets(), *this); return makeConstIterator(getBuckets(), getBucketsEnd(), *this); } inline const_iterator end() const { @@ -146,14 +150,18 @@ public: iterator find(const_arg_type_t Val) { BucketT *TheBucket; if (LookupBucketFor(Val, TheBucket)) - return makeIterator(TheBucket, getBucketsEnd(), + return makeIterator(TheBucket, + shouldReverseIterate() ? getBuckets() + : getBucketsEnd(), *this, true); return end(); } const_iterator find(const_arg_type_t Val) const { const BucketT *TheBucket; if (LookupBucketFor(Val, TheBucket)) - return makeConstIterator(TheBucket, getBucketsEnd(), + return makeConstIterator(TheBucket, + shouldReverseIterate() ? getBuckets() + : getBucketsEnd(), *this, true); return end(); } @@ -167,7 +175,9 @@ public: iterator find_as(const LookupKeyT &Val) { BucketT *TheBucket; if (LookupBucketFor(Val, TheBucket)) - return makeIterator(TheBucket, getBucketsEnd(), + return makeIterator(TheBucket, + shouldReverseIterate() ? getBuckets() + : getBucketsEnd(), *this, true); return end(); } @@ -175,7 +185,9 @@ public: const_iterator find_as(const LookupKeyT &Val) const { const BucketT *TheBucket; if (LookupBucketFor(Val, TheBucket)) - return makeConstIterator(TheBucket, getBucketsEnd(), + return makeConstIterator(TheBucket, + shouldReverseIterate() ? getBuckets() + : getBucketsEnd(), *this, true); return end(); } @@ -210,14 +222,20 @@ public: std::pair try_emplace(KeyT &&Key, Ts &&... Args) { BucketT *TheBucket; if (LookupBucketFor(Key, TheBucket)) - return std::make_pair(makeIterator(TheBucket, getBucketsEnd(), + return std::make_pair(makeIterator(TheBucket, + shouldReverseIterate() + ? getBuckets() + : getBucketsEnd(), *this, true), false); // Already in map. // Otherwise, insert the new element. TheBucket = InsertIntoBucket(TheBucket, std::move(Key), std::forward(Args)...); - return std::make_pair(makeIterator(TheBucket, getBucketsEnd(), + return std::make_pair(makeIterator(TheBucket, + shouldReverseIterate() + ? getBuckets() + : getBucketsEnd(), *this, true), true); } @@ -229,13 +247,19 @@ public: std::pair try_emplace(const KeyT &Key, Ts &&... Args) { BucketT *TheBucket; if (LookupBucketFor(Key, TheBucket)) - return std::make_pair(makeIterator(TheBucket, getBucketsEnd(), + return std::make_pair(makeIterator(TheBucket, + shouldReverseIterate() + ? getBuckets() + : getBucketsEnd(), *this, true), false); // Already in map. // Otherwise, insert the new element. TheBucket = InsertIntoBucket(TheBucket, Key, std::forward(Args)...); - return std::make_pair(makeIterator(TheBucket, getBucketsEnd(), + return std::make_pair(makeIterator(TheBucket, + shouldReverseIterate() + ? getBuckets() + : getBucketsEnd(), *this, true), true); } @@ -250,14 +274,20 @@ public: const LookupKeyT &Val) { BucketT *TheBucket; if (LookupBucketFor(Val, TheBucket)) - return std::make_pair(makeIterator(TheBucket, getBucketsEnd(), + return std::make_pair(makeIterator(TheBucket, + shouldReverseIterate() + ? getBuckets() + : getBucketsEnd(), *this, true), false); // Already in map. // Otherwise, insert the new element. TheBucket = InsertIntoBucketWithLookup(TheBucket, std::move(KV.first), std::move(KV.second), Val); - return std::make_pair(makeIterator(TheBucket, getBucketsEnd(), + return std::make_pair(makeIterator(TheBucket, + shouldReverseIterate() + ? getBuckets() + : getBucketsEnd(), *this, true), true); } @@ -434,12 +464,20 @@ private: iterator makeIterator(BucketT *P, BucketT *E, DebugEpochBase &Epoch, bool NoAdvance=false) { + if (shouldReverseIterate()) { + BucketT *B = P == getBucketsEnd() ? getBuckets() : P + 1; + return iterator(B, E, Epoch, NoAdvance); + } return iterator(P, E, Epoch, NoAdvance); } const_iterator makeConstIterator(const BucketT *P, const BucketT *E, const DebugEpochBase &Epoch, const bool NoAdvance=false) const { + if (shouldReverseIterate()) { + const BucketT *B = P == getBucketsEnd() ? getBuckets() : P + 1; + return const_iterator(B, E, Epoch, NoAdvance); + } return const_iterator(P, E, Epoch, NoAdvance); } @@ -1176,6 +1214,10 @@ public: assert(isHandleInSync() && "invalid construction!"); if (NoAdvance) return; + if (shouldReverseIterate()) { + RetreatPastEmptyBuckets(); + return; + } AdvancePastEmptyBuckets(); } @@ -1190,10 +1232,16 @@ public: reference operator*() const { assert(isHandleInSync() && "invalid iterator access!"); + assert(Ptr != End && "dereferencing end() iterator"); + if (shouldReverseIterate()) + return Ptr[-1]; return *Ptr; } pointer operator->() const { assert(isHandleInSync() && "invalid iterator access!"); + assert(Ptr != End && "dereferencing end() iterator"); + if (shouldReverseIterate()) + return &(Ptr[-1]); return Ptr; } @@ -1213,6 +1261,12 @@ public: inline DenseMapIterator& operator++() { // Preincrement assert(isHandleInSync() && "invalid iterator access!"); + assert(Ptr != End && "incrementing end() iterator"); + if (shouldReverseIterate()) { + --Ptr; + RetreatPastEmptyBuckets(); + return *this; + } ++Ptr; AdvancePastEmptyBuckets(); return *this; diff --git a/wpiutil/src/main/native/include/wpi/ReverseIteration.h b/wpiutil/src/main/native/include/wpi/ReverseIteration.h new file mode 100644 index 0000000000..b4fb3ff7b9 --- /dev/null +++ b/wpiutil/src/main/native/include/wpi/ReverseIteration.h @@ -0,0 +1,15 @@ +#ifndef WPI_REVERSEITERATION_H +#define WPI_REVERSEITERATION_H + +#include "wpi/PointerLikeTypeTraits.h" + +namespace wpi { + +template +constexpr bool shouldReverseIterate() { + return false; +} + +} + +#endif diff --git a/wpiutil/src/main/native/include/wpi/SmallPtrSet.h b/wpiutil/src/main/native/include/wpi/SmallPtrSet.h index 209c916f03..133b0e3255 100644 --- a/wpiutil/src/main/native/include/wpi/SmallPtrSet.h +++ b/wpiutil/src/main/native/include/wpi/SmallPtrSet.h @@ -14,8 +14,9 @@ #ifndef WPIUTIL_WPI_SMALLPTRSET_H #define WPIUTIL_WPI_SMALLPTRSET_H +#include "wpi/EpochTracker.h" #include "wpi/Compiler.h" -#include "wpi/PointerLikeTypeTraits.h" +#include "wpi/ReverseIteration.h" #include "wpi/type_traits.h" #include #include @@ -45,7 +46,7 @@ namespace wpi { /// (-2), to allow deletion. The hash table is resized when the table is 3/4 or /// more. When this happens, the table is doubled in size. /// -class SmallPtrSetImplBase { +class SmallPtrSetImplBase : public DebugEpochBase { friend class SmallPtrSetIteratorImpl; protected: @@ -91,6 +92,7 @@ public: size_type size() const { return NumNonEmpty - NumTombstones; } void clear() { + incrementEpoch(); // If the capacity of the array is huge, and the # elements used is small, // shrink the array. if (!isSmall()) { @@ -137,12 +139,14 @@ protected: if (LastTombstone != nullptr) { *LastTombstone = Ptr; --NumTombstones; + incrementEpoch(); return std::make_pair(LastTombstone, true); } // Nope, there isn't. If we stay small, just 'pushback' now. if (NumNonEmpty < CurArraySize) { SmallArray[NumNonEmpty++] = Ptr; + incrementEpoch(); return std::make_pair(SmallArray + (NumNonEmpty - 1), true); } // Otherwise, hit the big set case, which will call grow. @@ -222,6 +226,10 @@ protected: public: explicit SmallPtrSetIteratorImpl(const void *const *BP, const void*const *E) : Bucket(BP), End(E) { + if (shouldReverseIterate()) { + RetreatIfNotValid(); + return; + } AdvanceIfNotValid(); } @@ -255,7 +263,8 @@ protected: /// SmallPtrSetIterator - This implements a const_iterator for SmallPtrSet. template -class SmallPtrSetIterator : public SmallPtrSetIteratorImpl { +class SmallPtrSetIterator : public SmallPtrSetIteratorImpl, + DebugEpochBase::HandleBase { using PtrTraits = PointerLikeTypeTraits; public: @@ -265,17 +274,29 @@ public: using difference_type = std::ptrdiff_t; using iterator_category = std::forward_iterator_tag; - explicit SmallPtrSetIterator(const void *const *BP, const void *const *E) - : SmallPtrSetIteratorImpl(BP, E) {} + explicit SmallPtrSetIterator(const void *const *BP, const void *const *E, + const DebugEpochBase &Epoch) + : SmallPtrSetIteratorImpl(BP, E), DebugEpochBase::HandleBase(&Epoch) {} // Most methods are provided by the base class. const PtrTy operator*() const { + assert(isHandleInSync() && "invalid iterator access!"); + if (shouldReverseIterate()) { + assert(Bucket > End); + return PtrTraits::getFromVoidPointer(const_cast(Bucket[-1])); + } assert(Bucket < End); return PtrTraits::getFromVoidPointer(const_cast(*Bucket)); } inline SmallPtrSetIterator& operator++() { // Preincrement + assert(isHandleInSync() && "invalid iterator access!"); + if (shouldReverseIterate()) { + --Bucket; + RetreatIfNotValid(); + return *this; + } ++Bucket; AdvanceIfNotValid(); return *this; @@ -379,6 +400,8 @@ public: } iterator begin() const { + if (shouldReverseIterate()) + return makeIterator(EndPointer() - 1); return makeIterator(CurArray); } iterator end() const { return makeIterator(EndPointer()); } @@ -386,7 +409,9 @@ public: private: /// Create an iterator that dereferences to same place as the given pointer. iterator makeIterator(const void *const *P) const { - return iterator(P, EndPointer()); + if (shouldReverseIterate()) + return iterator(P == EndPointer() ? CurArray : P + 1, CurArray, *this); + return iterator(P, EndPointer(), *this); } }; diff --git a/wpiutil/src/main/native/include/wpi/StringMap.h b/wpiutil/src/main/native/include/wpi/StringMap.h index fc2fd06745..c3fbb69f36 100644 --- a/wpiutil/src/main/native/include/wpi/StringMap.h +++ b/wpiutil/src/main/native/include/wpi/StringMap.h @@ -14,6 +14,7 @@ #define WPIUTIL_WPI_STRINGMAP_H #include "wpi/StringMapEntry.h" +#include "wpi/AllocatorBase.h" #include "wpi/MemAlloc.h" #include "wpi/SmallVector.h" #include "wpi/iterator.h" @@ -107,8 +108,10 @@ public: /// keys that are "strings", which are basically ranges of bytes. This does some /// funky memory allocation and hashing things to make it extremely efficient, /// storing the string data *after* the value in the map. -template +template class StringMap : public StringMapImpl { + AllocatorTy Allocator; + public: using MapEntryTy = StringMapEntry; @@ -117,6 +120,14 @@ public: explicit StringMap(unsigned InitialSize) : StringMapImpl(InitialSize, static_cast(sizeof(MapEntryTy))) {} + explicit StringMap(AllocatorTy A) + : StringMapImpl(static_cast(sizeof(MapEntryTy))), Allocator(A) { + } + + StringMap(unsigned InitialSize, AllocatorTy A) + : StringMapImpl(InitialSize, static_cast(sizeof(MapEntryTy))), + Allocator(A) {} + StringMap(std::initializer_list> List) : StringMapImpl(List.size(), static_cast(sizeof(MapEntryTy))) { for (const auto &P : List) { @@ -125,10 +136,11 @@ public: } StringMap(StringMap &&RHS) - : StringMapImpl(std::move(RHS)) {} + : StringMapImpl(std::move(RHS)), Allocator(std::move(RHS.Allocator)) {} - StringMap(const StringMap &RHS) : - StringMapImpl(static_cast(sizeof(MapEntryTy))) { + StringMap(const StringMap &RHS) + : StringMapImpl(static_cast(sizeof(MapEntryTy))), + Allocator(RHS.Allocator) { if (RHS.empty()) return; @@ -148,7 +160,7 @@ public: } TheTable[I] = MapEntryTy::Create( - static_cast(Bucket)->getKey(), + static_cast(Bucket)->getKey(), Allocator, static_cast(Bucket)->getValue()); HashTable[I] = RHSHashTable[I]; } @@ -163,6 +175,7 @@ public: StringMap &operator=(StringMap RHS) { StringMapImpl::swap(RHS); + std::swap(Allocator, RHS.Allocator); return *this; } @@ -174,13 +187,16 @@ public: for (unsigned I = 0, E = NumBuckets; I != E; ++I) { StringMapEntryBase *Bucket = TheTable[I]; if (Bucket && Bucket != getTombstoneVal()) { - static_cast(Bucket)->Destroy(); + static_cast(Bucket)->Destroy(Allocator); } } } free(TheTable); } + AllocatorTy &getAllocator() { return Allocator; } + const AllocatorTy &getAllocator() const { return Allocator; } + using key_type = const char *; using mapped_type = ValueTy; using value_type = StringMapEntry; @@ -309,7 +325,7 @@ public: if (Bucket == getTombstoneVal()) --NumTombstones; - Bucket = MapEntryTy::Create(Key, std::forward(Args)...); + Bucket = MapEntryTy::Create(Key, Allocator, std::forward(Args)...); ++NumItems; assert(NumItems + NumTombstones <= NumBuckets); @@ -327,7 +343,7 @@ public: for (unsigned I = 0, E = NumBuckets; I != E; ++I) { StringMapEntryBase *&Bucket = TheTable[I]; if (Bucket && Bucket != getTombstoneVal()) { - static_cast(Bucket)->Destroy(); + static_cast(Bucket)->Destroy(Allocator); } Bucket = nullptr; } @@ -343,7 +359,7 @@ public: void erase(iterator I) { MapEntryTy &V = *I; remove(&V); - V.Destroy(); + V.Destroy(Allocator); } bool erase(std::string_view Key) { diff --git a/wpiutil/src/main/native/include/wpi/StringMapEntry.h b/wpiutil/src/main/native/include/wpi/StringMapEntry.h index 98a8fcc7a4..a8491791cc 100644 --- a/wpiutil/src/main/native/include/wpi/StringMapEntry.h +++ b/wpiutil/src/main/native/include/wpi/StringMapEntry.h @@ -37,14 +37,22 @@ protected: /// Helper to tail-allocate \p Key. It'd be nice to generalize this so it /// could be reused elsewhere, maybe even taking an wpi::function_ref to /// type-erase the allocator and put it in a source file. + template static void *allocateWithKey(size_t EntrySize, size_t EntryAlign, - std::string_view Key) { + std::string_view Key, AllocatorTy &Allocator); +}; + +// Define out-of-line to dissuade inlining. +template +void *StringMapEntryBase::allocateWithKey(size_t EntrySize, size_t EntryAlign, + std::string_view Key, + AllocatorTy &Allocator) { size_t KeyLength = Key.size(); // Allocate a new item with space for the string at the end and a null // terminator. size_t AllocSize = EntrySize + KeyLength + 1; - void *Allocation = safe_malloc(AllocSize); + void *Allocation = Allocator.Allocate(AllocSize, EntryAlign); assert(Allocation && "Unhandled out-of-memory"); // Copy the string information. @@ -54,7 +62,6 @@ protected: Buffer[KeyLength] = 0; // Null terminate for convenience of clients. return Allocation; } -}; /// StringMapEntryStorage - Holds the value in a StringMapEntry. /// @@ -114,11 +121,11 @@ public: /// Create a StringMapEntry for the specified key construct the value using /// \p InitiVals. - template - static StringMapEntry *Create(std::string_view key, + template + static StringMapEntry *Create(std::string_view key, AllocatorTy &allocator, InitTy &&... initVals) { return new (StringMapEntryBase::allocateWithKey( - sizeof(StringMapEntry), alignof(StringMapEntry), key)) + sizeof(StringMapEntry), alignof(StringMapEntry), key, allocator)) StringMapEntry(key.size(), std::forward(initVals)...); } @@ -131,10 +138,12 @@ public: /// Destroy - Destroy this StringMapEntry, releasing memory back to the /// specified allocator. - void Destroy() { + template void Destroy(AllocatorTy &allocator) { // Free memory referenced by the item. + size_t AllocSize = sizeof(StringMapEntry) + this->getKeyLength() + 1; this->~StringMapEntry(); - std::free(static_cast(this)); + allocator.Deallocate(static_cast(this), AllocSize, + alignof(StringMapEntry)); } }; diff --git a/wpiutil/src/test/native/cpp/llvm/StringMapTest.cpp b/wpiutil/src/test/native/cpp/llvm/StringMapTest.cpp index bb01d30710..5602008f86 100644 --- a/wpiutil/src/test/native/cpp/llvm/StringMapTest.cpp +++ b/wpiutil/src/test/native/cpp/llvm/StringMapTest.cpp @@ -223,12 +223,13 @@ TEST_F(StringMapTest, IterationTest) { // Test StringMapEntry::Create() method. TEST_F(StringMapTest, StringMapEntryTest) { + MallocAllocator Allocator; StringMap::value_type *entry = StringMap::value_type::Create( - std::string_view(testKeyFirst, testKeyLength), 1u); + std::string_view(testKeyFirst, testKeyLength), Allocator, 1u); EXPECT_STREQ(testKey, entry->first().data()); EXPECT_EQ(1u, entry->second); - entry->Destroy(); + entry->Destroy(Allocator); } // Test insert() method. @@ -237,7 +238,7 @@ TEST_F(StringMapTest, InsertTest) { testMap.insert( StringMap::value_type::Create( std::string_view(testKeyFirst, testKeyLength), - 1u)); + testMap.getAllocator(), 1u)); assertSingleItemMap(); } @@ -352,14 +353,15 @@ TEST_F(StringMapTest, MoveOnly) { StringMap t; t.insert(std::make_pair("Test", MoveOnly(42))); std::string_view Key = "Test"; - StringMapEntry::Create(Key, MoveOnly(42)) - ->Destroy(); + StringMapEntry::Create(Key, t.getAllocator(), MoveOnly(42)) + ->Destroy(t.getAllocator()); } TEST_F(StringMapTest, CtorArg) { std::string_view Key = "Test"; - StringMapEntry::Create(Key, Immovable()) - ->Destroy(); + MallocAllocator Allocator; + StringMapEntry::Create(Key, Allocator, Immovable()) + ->Destroy(Allocator); } TEST_F(StringMapTest, MoveConstruct) {