[all-commits] [llvm/llvm-project] ae9fd5: [SmallVector] Allow SmallVector<T>

Sean Silva via All-commits all-commits at lists.llvm.org
Thu Dec 3 17:27:03 PST 2020


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ae9fd5578e8ab59bcffe1fd2b6a91531dff5bde6
      https://github.com/llvm/llvm-project/commit/ae9fd5578e8ab59bcffe1fd2b6a91531dff5bde6
  Author: Sean Silva <silvasean at google.com>
  Date:   2020-12-03 (Thu, 03 Dec 2020)

  Changed paths:
    M llvm/docs/ProgrammersManual.rst
    M llvm/include/llvm/ADT/SmallVector.h
    M llvm/unittests/ADT/SmallVectorTest.cpp

  Log Message:
  -----------
  [SmallVector] Allow SmallVector<T>

This patch adds a capability to SmallVector to decide a number of
inlined elements automatically. The policy is:

- A minimum of 1 inlined elements, with more as long as
sizeof(SmallVector<T>) <= 64.
- If sizeof(T) is "too big", then trigger a static_assert: this dodges
the more pathological cases

This is expected to systematically improve SmallVector use in the
LLVM codebase, which has historically been plagued by semi-arbitrary /
cargo culted N parameters, often leading to bad outcomes due to
excessive sizeof(SmallVector<T, N>). This default also makes
programming more convenient by avoiding edit/rebuild cycles due to
forgetting to type the N parameter.

Differential Revision: https://reviews.llvm.org/D92522




More information about the All-commits mailing list