[Lldb-commits] [lldb] 786c67f - [lldb] Add size checks for frequently allocated classes (#200939)
via lldb-commits
lldb-commits at lists.llvm.org
Mon Jun 8 02:39:07 PDT 2026
Author: Raphael Isemann
Date: 2026-06-08T10:39:03+01:00
New Revision: 786c67f26d2caa887646b5bb2020336c56b3ca73
URL: https://github.com/llvm/llvm-project/commit/786c67f26d2caa887646b5bb2020336c56b3ca73
DIFF: https://github.com/llvm/llvm-project/commit/786c67f26d2caa887646b5bb2020336c56b3ca73.diff
LOG: [lldb] Add size checks for frequently allocated classes (#200939)
Given how frequently we allocate these classes (or classes containing
these classes) on the heap, we should only grow them intentionally.
See also bd1b3d47462acf4f854f593bdd77b3f127adea46
Added:
Modified:
lldb/include/lldb/Core/Address.h
lldb/include/lldb/Core/AddressRange.h
lldb/include/lldb/Core/Mangled.h
lldb/include/lldb/Symbol/LineTable.h
lldb/include/lldb/Utility/ConstString.h
Removed:
################################################################################
diff --git a/lldb/include/lldb/Core/Address.h b/lldb/include/lldb/Core/Address.h
index 2b669aeba20ec..15fc30a2e3f92 100644
--- a/lldb/include/lldb/Core/Address.h
+++ b/lldb/include/lldb/Core/Address.h
@@ -501,6 +501,8 @@ class Address {
// know if this address used to have a valid section.
bool SectionWasDeletedPrivate() const;
};
+static_assert(sizeof(Address) <= sizeof(lldb::addr_t) + sizeof(lldb::SectionWP),
+ "High-volume object, size of object must be increased with care");
// NOTE: Be careful using this operator. It can correctly compare two
// addresses from the same Module correctly. It can't compare two addresses
diff --git a/lldb/include/lldb/Core/AddressRange.h b/lldb/include/lldb/Core/AddressRange.h
index 68a3ad0edd2d7..af26bb3b351a3 100644
--- a/lldb/include/lldb/Core/AddressRange.h
+++ b/lldb/include/lldb/Core/AddressRange.h
@@ -249,6 +249,8 @@ class AddressRange {
Address m_base_addr; ///< The section offset base address of this range.
lldb::addr_t m_byte_size = 0; ///< The size in bytes of this address range.
};
+static_assert(sizeof(AddressRange) <= sizeof(Address) + sizeof(lldb::addr_t),
+ "High-volume object, size of object must be increased with care");
// Forward-declarable wrapper.
class AddressRanges : public std::vector<lldb_private::AddressRange> {
diff --git a/lldb/include/lldb/Core/Mangled.h b/lldb/include/lldb/Core/Mangled.h
index e1ac0e8761f70..6c6f2574ad22e 100644
--- a/lldb/include/lldb/Core/Mangled.h
+++ b/lldb/include/lldb/Core/Mangled.h
@@ -332,6 +332,9 @@ class Mangled {
/// parts of the name (e.g., basename, arguments, etc.) begin and end.
mutable std::unique_ptr<DemangledNameInfo> m_demangled_info;
};
+static_assert(sizeof(Mangled) <= 2 * sizeof(ConstString) +
+ sizeof(std::unique_ptr<DemangledNameInfo>),
+ "High-volume object, size of object must be increased with care");
Stream &operator<<(Stream &s, const Mangled &obj);
diff --git a/lldb/include/lldb/Symbol/LineTable.h b/lldb/include/lldb/Symbol/LineTable.h
index 8dda9c7362f12..1d43a7c1b94b9 100644
--- a/lldb/include/lldb/Symbol/LineTable.h
+++ b/lldb/include/lldb/Symbol/LineTable.h
@@ -286,6 +286,10 @@ class LineTable {
/// is no file information.
uint16_t file_idx = 0;
};
+ static_assert(
+ sizeof(Entry) <=
+ sizeof(lldb::addr_t) + sizeof(uint32_t) + 2 * sizeof(uint16_t),
+ "High-volume object, size of object must be increased with care");
class Sequence {
public:
diff --git a/lldb/include/lldb/Utility/ConstString.h b/lldb/include/lldb/Utility/ConstString.h
index 3d312d95b45ee..1bfefec9638a5 100644
--- a/lldb/include/lldb/Utility/ConstString.h
+++ b/lldb/include/lldb/Utility/ConstString.h
@@ -412,6 +412,8 @@ class ConstString {
const char *m_string = nullptr;
};
+static_assert(sizeof(ConstString) <= sizeof(const char *),
+ "High-volume object, size of object must be increased with care");
/// Stream the string value \a str to the stream \a s
Stream &operator<<(Stream &s, ConstString str);
More information about the lldb-commits
mailing list