[clang] [clang-tools-extra] [lldb] [llvm] Revert "[Allocator] Drop RedZoneSize (non-sanitizer) and BytesAllocated members" (PR #207685)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 6 02:17:09 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-support
@llvm/pr-subscribers-clang-tools-extra
Author: Raphael Isemann (Teemperor)
<details>
<summary>Changes</summary>
Reverts llvm/llvm-project#<!-- -->205711
This removes LLDB functionality without anyone from LLDB having approved or seen the code.
---
Patch is 26.13 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/207685.diff
17 Files Affected:
- (modified) clang-tools-extra/clangd/CompileCommands.cpp (+2-2)
- (modified) clang/unittests/Lex/PPMemoryAllocationsTest.cpp (+4-7)
- (modified) lldb/include/lldb/Utility/ConstString.h (+3)
- (modified) lldb/source/Target/Statistics.cpp (+2)
- (modified) lldb/source/Utility/ConstString.cpp (+1)
- (modified) lldb/test/API/commands/statistics/basic/TestStats.py (+2)
- (modified) llvm/include/llvm/Support/Allocator.h (+28-19)
- (modified) llvm/include/llvm/Support/PerThreadBumpPtrAllocator.h (+10)
- (modified) llvm/lib/Support/Allocator.cpp (+4-1)
- (modified) llvm/lib/TableGen/Record.cpp (+1)
- (modified) llvm/tools/llubi/lib/Context.cpp (+3-3)
- (modified) llvm/tools/llubi/lib/Context.h (-1)
- (modified) llvm/unittests/ADT/ConcurrentHashtableTest.cpp (+47)
- (modified) llvm/unittests/DebugInfo/MSF/MappedBlockStreamTest.cpp (+12)
- (modified) llvm/unittests/Support/AllocatorTest.cpp (+5-1)
- (modified) llvm/unittests/Support/PerThreadBumpPtrAllocatorTest.cpp (+5-3)
- (modified) llvm/unittests/Support/ThreadSafeAllocatorTest.cpp (+1-1)
``````````diff
diff --git a/clang-tools-extra/clangd/CompileCommands.cpp b/clang-tools-extra/clangd/CompileCommands.cpp
index b5965d163d7db..e8005435e1836 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -560,8 +560,8 @@ llvm::ArrayRef<ArgStripper::Rule> ArgStripper::rulesFor(llvm::StringRef Arg) {
dlog(" {0} #={1} *={2} Mode={3}", R.Text, R.ExactArgs, R.PrefixArgs,
int(R.Modes));
}
- dlog("Table spellings={0} rules={1} allocator-bytes={2}", Result->size(),
- RuleCount, Result->getAllocator().getTotalMemory());
+ dlog("Table spellings={0} rules={1} string-bytes={2}", Result->size(),
+ RuleCount, Result->getAllocator().getBytesAllocated());
#endif
// The static table will never be destroyed.
return Result.release();
diff --git a/clang/unittests/Lex/PPMemoryAllocationsTest.cpp b/clang/unittests/Lex/PPMemoryAllocationsTest.cpp
index ebdb0346b3bed..f873774eb2019 100644
--- a/clang/unittests/Lex/PPMemoryAllocationsTest.cpp
+++ b/clang/unittests/Lex/PPMemoryAllocationsTest.cpp
@@ -77,13 +77,10 @@ TEST_F(PPMemoryAllocationsTest, PPMacroDefinesAllocations) {
PP.LexTokensUntilEOF();
- // Use the total slab memory held by the preprocessor's allocator as a proxy.
- // Over a million #defines the per-allocation slab overhead is negligible, so
- // this closely tracks the bytes requested for storing the macro information.
- size_t TotalMemory = PP.getPreprocessorAllocator().getTotalMemory();
- float BytesPerDefine = float(TotalMemory) / float(NumMacros);
- llvm::errs() << "Preprocessor allocator memory for " << NumMacros
- << " #define: " << TotalMemory << "\n";
+ size_t NumAllocated = PP.getPreprocessorAllocator().getBytesAllocated();
+ float BytesPerDefine = float(NumAllocated) / float(NumMacros);
+ llvm::errs() << "Num preprocessor allocations for " << NumMacros
+ << " #define: " << NumAllocated << "\n";
llvm::errs() << "Bytes per #define: " << BytesPerDefine << "\n";
// On arm64-apple-macos, we get around 120 bytes per define.
// Assume a reasonable upper bound based on that number that we don't want
diff --git a/lldb/include/lldb/Utility/ConstString.h b/lldb/include/lldb/Utility/ConstString.h
index 4452df1ecc6b1..1bfefec9638a5 100644
--- a/lldb/include/lldb/Utility/ConstString.h
+++ b/lldb/include/lldb/Utility/ConstString.h
@@ -393,7 +393,10 @@ class ConstString {
struct MemoryStats {
size_t GetBytesTotal() const { return bytes_total; }
+ size_t GetBytesUsed() const { return bytes_used; }
+ size_t GetBytesUnused() const { return bytes_total - bytes_used; }
size_t bytes_total = 0;
+ size_t bytes_used = 0;
};
static MemoryStats GetMemoryStats();
diff --git a/lldb/source/Target/Statistics.cpp b/lldb/source/Target/Statistics.cpp
index 6227d099642f2..9fee5108e736a 100644
--- a/lldb/source/Target/Statistics.cpp
+++ b/lldb/source/Target/Statistics.cpp
@@ -111,6 +111,8 @@ json::Value ModuleStats::ToJSON() const {
llvm::json::Value ConstStringStats::ToJSON() const {
json::Object obj;
obj.try_emplace<int64_t>("bytesTotal", stats.GetBytesTotal());
+ obj.try_emplace<int64_t>("bytesUsed", stats.GetBytesUsed());
+ obj.try_emplace<int64_t>("bytesUnused", stats.GetBytesUnused());
return obj;
}
diff --git a/lldb/source/Utility/ConstString.cpp b/lldb/source/Utility/ConstString.cpp
index 8def38c03dceb..3d79731a47d5a 100644
--- a/lldb/source/Utility/ConstString.cpp
+++ b/lldb/source/Utility/ConstString.cpp
@@ -196,6 +196,7 @@ class Pool {
std::shared_lock<PoolMutex> lock(pool.m_mutex);
const Allocator &alloc = pool.m_string_map.getAllocator();
stats.bytes_total += alloc.getTotalMemory();
+ stats.bytes_used += alloc.getBytesAllocated();
}
return stats;
}
diff --git a/lldb/test/API/commands/statistics/basic/TestStats.py b/lldb/test/API/commands/statistics/basic/TestStats.py
index c65d1d8785160..a32b8feecc5cf 100644
--- a/lldb/test/API/commands/statistics/basic/TestStats.py
+++ b/lldb/test/API/commands/statistics/basic/TestStats.py
@@ -348,6 +348,8 @@ def test_memory(self):
strings = memory["strings"]
strings_keys = [
"bytesTotal",
+ "bytesUsed",
+ "bytesUnused",
]
self.verify_keys(strings, '"strings"', strings_keys, None)
diff --git a/llvm/include/llvm/Support/Allocator.h b/llvm/include/llvm/Support/Allocator.h
index bb0ca118e2015..ea8e8a829ee55 100644
--- a/llvm/include/llvm/Support/Allocator.h
+++ b/llvm/include/llvm/Support/Allocator.h
@@ -18,7 +18,6 @@
#define LLVM_SUPPORT_ALLOCATOR_H
#include "llvm/ADT/SmallVector.h"
-#include "llvm/Config/abi-breaking.h"
#include "llvm/Support/Alignment.h"
#include "llvm/Support/AllocatorBase.h"
#include "llvm/Support/Compiler.h"
@@ -37,7 +36,9 @@ namespace detail {
// We call out to an external function to actually print the message as the
// printing code uses Allocator.h in its implementation.
-LLVM_ABI void printBumpPtrAllocatorStats(unsigned NumSlabs, size_t TotalMemory);
+LLVM_ABI void printBumpPtrAllocatorStats(unsigned NumSlabs,
+ size_t BytesAllocated,
+ size_t TotalMemory);
} // end namespace detail
@@ -95,12 +96,11 @@ class BumpPtrAllocatorImpl
BumpPtrAllocatorImpl(BumpPtrAllocatorImpl &&Old)
: AllocTy(std::move(Old.getAllocator())), CurPtr(Old.CurPtr),
EndSentinel(Old.EndSentinel), Slabs(std::move(Old.Slabs)),
- CustomSizedSlabs(std::move(Old.CustomSizedSlabs)) {
-#if LLVM_ENABLE_ABI_BREAKING_CHECKS
- RedZoneSize = Old.RedZoneSize;
-#endif
+ CustomSizedSlabs(std::move(Old.CustomSizedSlabs)),
+ BytesAllocated(Old.BytesAllocated), RedZoneSize(Old.RedZoneSize) {
Old.CurPtr = nullptr;
Old.EndSentinel = 0;
+ Old.BytesAllocated = 0;
Old.Slabs.clear();
Old.CustomSizedSlabs.clear();
}
@@ -116,15 +116,15 @@ class BumpPtrAllocatorImpl
CurPtr = RHS.CurPtr;
EndSentinel = RHS.EndSentinel;
-#if LLVM_ENABLE_ABI_BREAKING_CHECKS
+ BytesAllocated = RHS.BytesAllocated;
RedZoneSize = RHS.RedZoneSize;
-#endif
Slabs = std::move(RHS.Slabs);
CustomSizedSlabs = std::move(RHS.CustomSizedSlabs);
AllocTy::operator=(std::move(RHS.getAllocator()));
RHS.CurPtr = nullptr;
RHS.EndSentinel = 0;
+ RHS.BytesAllocated = 0;
RHS.Slabs.clear();
RHS.CustomSizedSlabs.clear();
return *this;
@@ -141,6 +141,7 @@ class BumpPtrAllocatorImpl
return;
// Reset the state.
+ BytesAllocated = 0;
CurPtr = (char *)Slabs.front();
EndSentinel = uintptr_t(CurPtr) + SlabSize + 1;
@@ -157,10 +158,12 @@ class BumpPtrAllocatorImpl
// Allocate(0, N) is valid, it returns a non-null pointer (which should not
// be dereferenced).
LLVM_ATTRIBUTE_RETURNS_NONNULL void *Allocate(size_t Size, Align Alignment) {
+ // Keep track of how many bytes we've allocated.
+ BytesAllocated += Size;
+
size_t SizeToAllocate = Size;
-#if LLVM_ADDRESS_SANITIZER_BUILD && LLVM_ENABLE_ABI_BREAKING_CHECKS
- // Add trailing bytes as a "red zone" under ASan. RedZoneSize only exists
- // when both conditions are true.
+#if LLVM_ADDRESS_SANITIZER_BUILD
+ // Add trailing bytes as a "red zone" under ASan.
SizeToAllocate += RedZoneSize;
#endif
SizeToAllocate = alignToPowerOf2(SizeToAllocate, MinAlign);
@@ -305,14 +308,15 @@ class BumpPtrAllocatorImpl
return TotalMemory;
}
- void setRedZoneSize([[maybe_unused]] size_t NewSize) {
-#if LLVM_ENABLE_ABI_BREAKING_CHECKS
+ size_t getBytesAllocated() const { return BytesAllocated; }
+
+ void setRedZoneSize(size_t NewSize) {
RedZoneSize = NewSize;
-#endif
}
void PrintStats() const {
- detail::printBumpPtrAllocatorStats(Slabs.size(), getTotalMemory());
+ detail::printBumpPtrAllocatorStats(Slabs.size(), BytesAllocated,
+ getTotalMemory());
}
private:
@@ -331,11 +335,14 @@ class BumpPtrAllocatorImpl
/// Custom-sized slabs allocated for too-large allocation requests.
SmallVector<std::pair<void *, size_t>, 0> CustomSizedSlabs;
-#if LLVM_ENABLE_ABI_BREAKING_CHECKS
- /// The number of bytes to put between allocations when running under a
- /// sanitizer.
+ /// How many bytes we've allocated.
+ ///
+ /// Used so that we can compute how much space was wasted.
+ size_t BytesAllocated = 0;
+
+ /// The number of bytes to put between allocations when running under
+ /// a sanitizer.
size_t RedZoneSize = 1;
-#endif
static size_t computeSlabSize(unsigned SlabIdx) {
// Scale the actual allocated slab size based on the number of slabs
@@ -465,6 +472,8 @@ template <typename T> class SpecificBumpPtrAllocator {
std::optional<int64_t> identifyObject(const void *Ptr) {
return Allocator.identifyObject(Ptr);
}
+
+ size_t getBytesAllocated() const { return Allocator.getBytesAllocated(); }
};
} // end namespace llvm
diff --git a/llvm/include/llvm/Support/PerThreadBumpPtrAllocator.h b/llvm/include/llvm/Support/PerThreadBumpPtrAllocator.h
index 0448fb2a12a9b..f94d18f62e9ab 100644
--- a/llvm/include/llvm/Support/PerThreadBumpPtrAllocator.h
+++ b/llvm/include/llvm/Support/PerThreadBumpPtrAllocator.h
@@ -82,6 +82,16 @@ class PerThreadAllocator
return TotalMemory;
}
+ /// Return allocated size by all allocators.
+ size_t getBytesAllocated() const {
+ size_t BytesAllocated = 0;
+
+ for (size_t Idx = 0; Idx < getNumberOfAllocators(); Idx++)
+ BytesAllocated += Allocators[Idx].getBytesAllocated();
+
+ return BytesAllocated;
+ }
+
/// Set red zone for all allocators.
void setRedZoneSize(size_t NewSize) {
for (size_t Idx = 0; Idx < getNumberOfAllocators(); Idx++)
diff --git a/llvm/lib/Support/Allocator.cpp b/llvm/lib/Support/Allocator.cpp
index 6ff68f1be3d63..1af5744bf301e 100644
--- a/llvm/lib/Support/Allocator.cpp
+++ b/llvm/lib/Support/Allocator.cpp
@@ -17,9 +17,12 @@ namespace llvm {
namespace detail {
-void printBumpPtrAllocatorStats(unsigned NumSlabs, size_t TotalMemory) {
+void printBumpPtrAllocatorStats(unsigned NumSlabs, size_t BytesAllocated,
+ size_t TotalMemory) {
errs() << "\nNumber of memory regions: " << NumSlabs << '\n'
+ << "Bytes used: " << BytesAllocated << '\n'
<< "Bytes allocated: " << TotalMemory << '\n'
+ << "Bytes wasted: " << (TotalMemory - BytesAllocated)
<< " (includes alignment, etc)\n";
}
diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp
index e9d7febf12272..e21588101dc37 100644
--- a/llvm/lib/TableGen/Record.cpp
+++ b/llvm/lib/TableGen/Record.cpp
@@ -120,6 +120,7 @@ void detail::RecordKeeperImpl::dumpAllocationStats(raw_ostream &OS) const {
OS << "TheVarBitInitPool size = " << TheVarBitInitPool.size() << '\n';
OS << "TheVarDefInitPool size = " << TheVarDefInitPool.size() << '\n';
OS << "TheFieldInitPool size = " << TheFieldInitPool.size() << '\n';
+ OS << "Bytes allocated = " << Allocator.getBytesAllocated() << '\n';
OS << "Total allocator memory = " << Allocator.getTotalMemory() << "\n\n";
OS << "Number of records instantiated = " << LastRecordID << '\n';
diff --git a/llvm/tools/llubi/lib/Context.cpp b/llvm/tools/llubi/lib/Context.cpp
index e89f7a43b45c6..bd7c966a1c7e9 100644
--- a/llvm/tools/llubi/lib/Context.cpp
+++ b/llvm/tools/llubi/lib/Context.cpp
@@ -368,8 +368,9 @@ const MaterializedConstant *Context::getConstantValue(Constant *C) {
if (Val.isNone())
return nullptr;
if (!Val.isCacheable()) {
- assert(NoncacheableConstCount <= 1024 && "Unbounded temporary buffer.");
- ++NoncacheableConstCount;
+ assert(NoncacheableConstBuffer.getBytesAllocated() <=
+ 1024 * sizeof(MaterializedConstant) &&
+ "Unbounded temporary buffer.");
return new (NoncacheableConstBuffer.Allocate())
MaterializedConstant(std::move(Val));
}
@@ -379,7 +380,6 @@ const MaterializedConstant *Context::getConstantValue(Constant *C) {
void Context::resetNoncacheableConstantBuffer() {
NoncacheableConstBuffer.DestroyAll();
- NoncacheableConstCount = 0;
}
APInt Context::getTag(uint32_t BitWidth, Provenance &Prov) {
diff --git a/llvm/tools/llubi/lib/Context.h b/llvm/tools/llubi/lib/Context.h
index 097f0d1e0ab8b..d8e3450c4accd 100644
--- a/llvm/tools/llubi/lib/Context.h
+++ b/llvm/tools/llubi/lib/Context.h
@@ -306,7 +306,6 @@ class Context {
// Temporary buffer for non-cacheable constants (e.g.,
// undef/ptrtoint/inttoptr).
SpecificBumpPtrAllocator<MaterializedConstant> NoncacheableConstBuffer;
- size_t NoncacheableConstCount = 0;
DenseMap<Function *, Pointer> FuncAddrMap;
DenseMap<BasicBlock *, Pointer> BlockAddrMap;
DenseMap<uint64_t, std::pair<Function *, IntrusiveRefCntPtr<MemoryObject>>>
diff --git a/llvm/unittests/ADT/ConcurrentHashtableTest.cpp b/llvm/unittests/ADT/ConcurrentHashtableTest.cpp
index 446b41795143e..05c480959142b 100644
--- a/llvm/unittests/ADT/ConcurrentHashtableTest.cpp
+++ b/llvm/unittests/ADT/ConcurrentHashtableTest.cpp
@@ -49,6 +49,7 @@ TEST(ConcurrentHashTableTest, AddStringEntries) {
parallel::TaskGroup tg;
tg.spawn([&]() {
+ size_t AllocatedBytesAtStart = Allocator.getBytesAllocated();
std::pair<String *, bool> res1 = HashTable.insert("1");
// Check entry is inserted.
EXPECT_TRUE(res1.first->getKey() == "1");
@@ -78,6 +79,8 @@ TEST(ConcurrentHashTableTest, AddStringEntries) {
// Check first entry is still valid.
EXPECT_TRUE(res1.first->getKey() == "1");
+ // Check data was allocated by allocator.
+ EXPECT_TRUE(Allocator.getBytesAllocated() > AllocatedBytesAtStart);
// Check statistic.
std::string StatisticString;
@@ -104,10 +107,15 @@ TEST(ConcurrentHashTableTest, AddStringMultiplueEntries) {
tg.spawn([&]() {
// Check insertion.
for (size_t I = 0; I < NumElements; I++) {
+ BumpPtrAllocator &ThreadLocalAllocator =
+ Allocator.getThreadLocalAllocator();
+ size_t AllocatedBytesAtStart = ThreadLocalAllocator.getBytesAllocated();
std::string StringForElement = formatv("{0}", I);
std::pair<String *, bool> Entry = HashTable.insert(StringForElement);
EXPECT_TRUE(Entry.second);
EXPECT_TRUE(Entry.first->getKey() == StringForElement);
+ EXPECT_TRUE(ThreadLocalAllocator.getBytesAllocated() >
+ AllocatedBytesAtStart);
}
std::string StatisticString;
@@ -121,10 +129,16 @@ TEST(ConcurrentHashTableTest, AddStringMultiplueEntries) {
// Check insertion of duplicates.
for (size_t I = 0; I < NumElements; I++) {
+ BumpPtrAllocator &ThreadLocalAllocator =
+ Allocator.getThreadLocalAllocator();
+ size_t AllocatedBytesAtStart = ThreadLocalAllocator.getBytesAllocated();
std::string StringForElement = formatv("{0}", I);
std::pair<String *, bool> Entry = HashTable.insert(StringForElement);
EXPECT_FALSE(Entry.second);
EXPECT_TRUE(Entry.first->getKey() == StringForElement);
+ // Check no additional bytes were allocated for duplicate.
+ EXPECT_TRUE(ThreadLocalAllocator.getBytesAllocated() ==
+ AllocatedBytesAtStart);
}
// Check statistic.
@@ -151,10 +165,15 @@ TEST(ConcurrentHashTableTest, AddStringMultiplueEntriesWithResize) {
tg.spawn([&]() {
// Check insertion.
for (size_t I = 0; I < NumElements; I++) {
+ BumpPtrAllocator &ThreadLocalAllocator =
+ Allocator.getThreadLocalAllocator();
+ size_t AllocatedBytesAtStart = ThreadLocalAllocator.getBytesAllocated();
std::string StringForElement = formatv("{0} {1}", I, I + 100);
std::pair<String *, bool> Entry = HashTable.insert(StringForElement);
EXPECT_TRUE(Entry.second);
EXPECT_TRUE(Entry.first->getKey() == StringForElement);
+ EXPECT_TRUE(ThreadLocalAllocator.getBytesAllocated() >
+ AllocatedBytesAtStart);
}
std::string StatisticString;
@@ -168,10 +187,16 @@ TEST(ConcurrentHashTableTest, AddStringMultiplueEntriesWithResize) {
// Check insertion of duplicates.
for (size_t I = 0; I < NumElements; I++) {
+ BumpPtrAllocator &ThreadLocalAllocator =
+ Allocator.getThreadLocalAllocator();
+ size_t AllocatedBytesAtStart = ThreadLocalAllocator.getBytesAllocated();
std::string StringForElement = formatv("{0} {1}", I, I + 100);
std::pair<String *, bool> Entry = HashTable.insert(StringForElement);
EXPECT_FALSE(Entry.second);
EXPECT_TRUE(Entry.first->getKey() == StringForElement);
+ // Check no additional bytes were allocated for duplicate.
+ EXPECT_TRUE(ThreadLocalAllocator.getBytesAllocated() ==
+ AllocatedBytesAtStart);
}
// Check statistic.
@@ -192,10 +217,15 @@ TEST(ConcurrentHashTableTest, AddStringEntriesParallel) {
// Check parallel insertion.
parallelFor(0, NumElements, [&](size_t I) {
+ BumpPtrAllocator &ThreadLocalAllocator =
+ Allocator.getThreadLocalAllocator();
+ size_t AllocatedBytesAtStart = ThreadLocalAllocator.getBytesAllocated();
std::string StringForElement = formatv("{0}", I);
std::pair<String *, bool> Entry = HashTable.insert(StringForElement);
EXPECT_TRUE(Entry.second);
EXPECT_TRUE(Entry.first->getKey() == StringForElement);
+ EXPECT_TRUE(ThreadLocalAllocator.getBytesAllocated() >
+ AllocatedBytesAtStart);
});
std::string StatisticString;
@@ -209,10 +239,16 @@ TEST(ConcurrentHashTableTest, AddStringEntriesParallel) {
// Check parallel insertion of duplicates.
parallelFor(0, NumElements, [&](size_t I) {
+ BumpPtrAllocator &ThreadLocalAllocator =
+ Allocator.getThreadLocalAllocator();
+ size_t AllocatedBytesAtStart = ThreadLocalAllocator.getBytesAllocated();
std::string StringForElement = formatv("{0}", I);
std::pair<String *, bool> Entry = HashTable.insert(StringForElement);
EXPECT_FALSE(Entry.second);
EXPECT_TRUE(Entry.first->getKey() == StringForElement);
+ // Check no additional bytes were allocated for duplicate.
+ EXPECT_TRUE(ThreadLocalAllocator.getBytesAllocated() ==
+ AllocatedBytesAtStart);
});
// Check statistic.
@@ -232,10 +268,15 @@ TEST(ConcurrentHashTableTest, AddStringEntriesParallelWithResize) {
// Check parallel insertion.
parallelFor(0, NumElements, [&](size_t I) {
+ BumpPtrAllocator &ThreadLocalAllocator =
+ Allocator.getThreadLocalAllocator();
+ size_t AllocatedBytesAtStart = ThreadLocalAllocator.getBytesAllocated();
std::string StringForElement = formatv("{0}", I);
std::pair<String *, bool> Entry = HashTable.insert(StringForElement);
EXPECT_TRUE(Entry.second);
EXPECT_TRUE(Entry.first->getKey() == StringForElement);
+ EXPECT_TRUE(ThreadLocalAllocator.getBytesAllocated() >
+ AllocatedBytesAtStart);
});
std::string StatisticString;
@@ -249,10 +290,16 @@ TEST(ConcurrentHashTableTest, AddStringEntriesParallelWithResize) {
// Check parallel insertion of duplicates.
parallelFor(0, NumElements, [&](size_t I) {
+ BumpPtrAllocator &ThreadLocalAllocator =
+ Allocator.getThreadLocalAllocator();
+ size_t AllocatedBytesAtStart = ThreadLocalAllocator.getBytesAllocated();
std::string StringForElement = formatv("{0}", I);
std::pair<String *, bool> Entry = HashTable.insert(StringForElement);
EXPECT_FALSE(Entry.second);
EXPECT_TRUE(Entry.first->getKey() == StringForElement);
+ // Check no additional bytes were allocated for duplicate.
+ EXPECT_TRUE(ThreadLocalAllocator.getBytesAllocated() ==
+ AllocatedBytesAtStart);
});
// Check statistic.
diff --git a/llvm/unittests/DebugInfo/MSF/MappedBlockStreamTest.cpp b/llvm/unittests/DebugInfo/MSF/MappedBlockStreamTest.cpp
index 86be4ee0f2aab..d1f04e9b28a34 100644
--- a/llvm/unittests/DebugInfo/MSF/MappedBlockStreamTest.cpp
+++ b/llvm/unittests/DebugInfo/MSF/MappedBlockStreamTest.cpp
@@ -110,6 +110,7 @@ TEST(MappedBlockStreamTest, ReadOntoNonEmptyBuffer) {
StringRef Str = "ZYXWVUTSRQPONMLKJIHGFEDCBA";
EXPECT_THAT_ERROR(R.readFixedString(Str, 1), Succeeded());
EXPECT_EQ(Str, StringRef("A"));
+ EXPECT_EQ(0U, F.Allocator.getBytesAllocated());
}
// Tests that a read which crosses a bl...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/207685
More information about the cfe-commits
mailing list