aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/ADT/StringMapTest.cpp
diff options
context:
space:
mode:
authorNathan James <n.james93@hotmail.co.uk>2022-07-12 23:57:03 +0100
committerNathan James <n.james93@hotmail.co.uk>2022-07-12 23:57:04 +0100
commita565509308f9372c4de1c4c32afde461a42e81c8 (patch)
tree146b9e9d84151930ba9f9ba0b9ccede9459b495a /llvm/unittests/ADT/StringMapTest.cpp
parent1ce3f94570eb8cca5c63a29268973bd352161c0b (diff)
downloadllvm-a565509308f9372c4de1c4c32afde461a42e81c8.zip
llvm-a565509308f9372c4de1c4c32afde461a42e81c8.tar.gz
llvm-a565509308f9372c4de1c4c32afde461a42e81c8.tar.bz2
[ADT] Use Empty Base Optimization for Allocators
In D94439, BumpPtrAllocator changed its implementation to use an empty base optimization for the underlying allocator. This patch builds on that by extending its functionality to more classes as well as enabling the underlying allocator to be a reference type, something not currently possible as you can't derive from a reference. The main place this sees use is in StringMaps which often use the default MallocAllocator, yet have to pay the size of a pointer for no reason. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D129206
Diffstat (limited to 'llvm/unittests/ADT/StringMapTest.cpp')
-rw-r--r--llvm/unittests/ADT/StringMapTest.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/StringMapTest.cpp b/llvm/unittests/ADT/StringMapTest.cpp
index 817fec6..1eac07b 100644
--- a/llvm/unittests/ADT/StringMapTest.cpp
+++ b/llvm/unittests/ADT/StringMapTest.cpp
@@ -17,6 +17,10 @@ using namespace llvm;
namespace {
+static_assert(sizeof(StringMap<uint32_t>) <
+ sizeof(StringMap<uint32_t, MallocAllocator &>),
+ "Ensure empty base optimization happens with default allocator");
+
// Test fixture
class StringMapTest : public testing::Test {
protected: