[SmallVector] Allow SmallVector<T>
authorSean Silva <silvasean@google.com>
Thu, 3 Dec 2020 18:38:37 +0000 (10:38 -0800)
committerSean Silva <silvasean@google.com>
Fri, 4 Dec 2020 01:21:44 +0000 (17:21 -0800)
commitae9fd5578e8ab59bcffe1fd2b6a91531dff5bde6
treeb1d00e8f7dac6ee86949f82fbae44e98150f3d05
parent2f0de582949d1c9b5beff591b3735b6c02c45033
[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
llvm/docs/ProgrammersManual.rst
llvm/include/llvm/ADT/SmallVector.h
llvm/unittests/ADT/SmallVectorTest.cpp