[ADT] Use Empty Base Optimization for Allocators
authorNathan James <n.james93@hotmail.co.uk>
Tue, 12 Jul 2022 22:57:03 +0000 (23:57 +0100)
committerNathan James <n.james93@hotmail.co.uk>
Tue, 12 Jul 2022 22:57:04 +0000 (23:57 +0100)
commita565509308f9372c4de1c4c32afde461a42e81c8
tree146b9e9d84151930ba9f9ba0b9ccede9459b495a
parent1ce3f94570eb8cca5c63a29268973bd352161c0b
[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
llvm/include/llvm/ADT/ScopedHashTable.h
llvm/include/llvm/ADT/StringMap.h
llvm/include/llvm/Support/Allocator.h
llvm/include/llvm/Support/AllocatorBase.h
llvm/unittests/ADT/StringMapTest.cpp