[all-commits] [llvm/llvm-project] a56550: [ADT] Use Empty Base Optimization for Allocators

Nathan James via All-commits all-commits at lists.llvm.org
Tue Jul 12 15:57:21 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a565509308f9372c4de1c4c32afde461a42e81c8
      https://github.com/llvm/llvm-project/commit/a565509308f9372c4de1c4c32afde461a42e81c8
  Author: Nathan James <n.james93 at hotmail.co.uk>
  Date:   2022-07-12 (Tue, 12 Jul 2022)

  Changed paths:
    M llvm/include/llvm/ADT/ScopedHashTable.h
    M llvm/include/llvm/ADT/StringMap.h
    M llvm/include/llvm/Support/Allocator.h
    M llvm/include/llvm/Support/AllocatorBase.h
    M llvm/unittests/ADT/StringMapTest.cpp

  Log Message:
  -----------
  [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




More information about the All-commits mailing list