[Lldb-commits] [clang] [clang-tools-extra] [lldb] [llvm] Revert "[Allocator] Drop RedZoneSize (non-sanitizer) and BytesAllocated members" (PR #207685)
Teemperor wrote: Closing, see #207694 https://github.com/llvm/llvm-project/pull/207685 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [llvm] Revert "[Allocator] Drop RedZoneSize (non-sanitizer) and BytesAllocated members" (PR #207685)
https://github.com/Teemperor auto_merge_disabled https://github.com/llvm/llvm-project/pull/207685 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [llvm] Revert "[Allocator] Drop RedZoneSize (non-sanitizer) and BytesAllocated members" (PR #207685)
github-actions[bot] wrote:
:warning: C/C++ code formatter, clang-format found issues in your code.
:warning:
You can test this locally with the following command:
``bash
git-clang-format --diff origin/main HEAD --extensions h,cpp --
clang-tools-extra/clangd/CompileCommands.cpp
clang/unittests/Lex/PPMemoryAllocationsTest.cpp
lldb/include/lldb/Utility/ConstString.h lldb/source/Target/Statistics.cpp
lldb/source/Utility/ConstString.cpp llvm/include/llvm/Support/Allocator.h
llvm/include/llvm/Support/PerThreadBumpPtrAllocator.h
llvm/lib/Support/Allocator.cpp llvm/lib/TableGen/Record.cpp
llvm/tools/llubi/lib/Context.cpp llvm/tools/llubi/lib/Context.h
llvm/unittests/ADT/ConcurrentHashtableTest.cpp
llvm/unittests/DebugInfo/MSF/MappedBlockStreamTest.cpp
llvm/unittests/Support/AllocatorTest.cpp
llvm/unittests/Support/PerThreadBumpPtrAllocatorTest.cpp
llvm/unittests/Support/ThreadSafeAllocatorTest.cpp --diff_from_common_commit
``
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
View the diff from clang-format here.
``diff
diff --git a/llvm/include/llvm/Support/Allocator.h
b/llvm/include/llvm/Support/Allocator.h
index ea8e8a829..188de5177 100644
--- a/llvm/include/llvm/Support/Allocator.h
+++ b/llvm/include/llvm/Support/Allocator.h
@@ -310,9 +310,7 @@ public:
size_t getBytesAllocated() const { return BytesAllocated; }
- void setRedZoneSize(size_t NewSize) {
-RedZoneSize = NewSize;
- }
+ void setRedZoneSize(size_t NewSize) { RedZoneSize = NewSize; }
void PrintStats() const {
detail::printBumpPtrAllocatorStats(Slabs.size(), BytesAllocated,
``
https://github.com/llvm/llvm-project/pull/207685
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [llvm] Revert "[Allocator] Drop RedZoneSize (non-sanitizer) and BytesAllocated members" (PR #207685)
https://github.com/Teemperor auto_merge_enabled https://github.com/llvm/llvm-project/pull/207685 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [llvm] Revert "[Allocator] Drop RedZoneSize (non-sanitizer) and BytesAllocated members" (PR #207685)
llvmorg-github-actions[bot] wrote:
@llvm/pr-subscribers-llvm-support
@llvm/pr-subscribers-clang-tools-extra
Author: Raphael Isemann (Teemperor)
Changes
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::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("bytesTotal", stats.GetBytesTotal());
+ obj.try_emplace("bytesUsed", stats.GetBytesUsed());
+ obj.try_emplace("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/so
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [llvm] Revert "[Allocator] Drop RedZoneSize (non-sanitizer) and BytesAllocated members" (PR #207685)
https://github.com/Teemperor created
https://github.com/llvm/llvm-project/pull/207685
Reverts llvm/llvm-project#205711
This removes LLDB functionality without anyone from LLDB having approved or
seen the code.
>From a0b14a1ae4b81a484682bd0d1da07259b5e7be0a Mon Sep 17 00:00:00 2001
From: Raphael Isemann
Date: Mon, 6 Jul 2026 10:13:57 +0100
Subject: [PATCH] =?UTF-8?q?Revert=20"[Allocator]=20Drop=20RedZoneSize=20(n?=
=?UTF-8?q?on-sanitizer)=20and=20BytesAllocated=20membe=E2=80=A6"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This reverts commit ca59c69132eef55cc42bf8854706590dfddf5584.
---
clang-tools-extra/clangd/CompileCommands.cpp | 4 +-
.../unittests/Lex/PPMemoryAllocationsTest.cpp | 11 ++---
lldb/include/lldb/Utility/ConstString.h | 3 ++
lldb/source/Target/Statistics.cpp | 2 +
lldb/source/Utility/ConstString.cpp | 1 +
.../commands/statistics/basic/TestStats.py| 2 +
llvm/include/llvm/Support/Allocator.h | 47 +++
.../llvm/Support/PerThreadBumpPtrAllocator.h | 10
llvm/lib/Support/Allocator.cpp| 5 +-
llvm/lib/TableGen/Record.cpp | 1 +
llvm/tools/llubi/lib/Context.cpp | 6 +--
llvm/tools/llubi/lib/Context.h| 1 -
.../unittests/ADT/ConcurrentHashtableTest.cpp | 47 +++
.../DebugInfo/MSF/MappedBlockStreamTest.cpp | 12 +
llvm/unittests/Support/AllocatorTest.cpp | 6 ++-
.../Support/PerThreadBumpPtrAllocatorTest.cpp | 8 ++--
.../Support/ThreadSafeAllocatorTest.cpp | 2 +-
17 files changed, 130 insertions(+), 38 deletions(-)
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::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("bytesTotal", stats.GetBytesTotal());
+ obj.try_emplace("bytesUsed", stats.GetBytesUsed());
+ obj.try_emplace("bytesUnused", stats.GetBytesUnused());
return obj;
}
diff --git a/lldb/sour
