[PATCH] D92526: [SmallVector] Allow SmallVector<T>

Sean Silva via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 2 16:45:40 PST 2020


silvas created this revision.
Herald added subscribers: llvm-commits, dexonsmith.
Herald added a project: LLVM.
silvas requested review of this revision.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92526

Files:
  llvm/docs/ProgrammersManual.rst
  llvm/include/llvm/ADT/SmallVector.h
  llvm/unittests/ADT/SmallVectorTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92526.309102.patch
Type: text/x-patch
Size: 5193 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201203/aa2cf03b/attachment.bin>


More information about the llvm-commits mailing list