[llvm-dev] RFC: [SmallVector] Adding SVec<T> and Vec<T> convenience wrappers.

Michael Kruse via llvm-dev llvm-dev at lists.llvm.org
Mon Nov 30 21:02:07 PST 2020


Am Mo., 30. Nov. 2020 um 19:34 Uhr schrieb Duncan P. N. Exon Smith
<dexonsmith at apple.com>:r<T, 0> has a number of benefits that make it
better in practice than std::vector, at least for LLVM code:
> - Interoperates with the pervasively used SmallVectorImpl<T>.
> - No exception guarantees, and thus none of the related, harmful pessimizations (std::vector::resize will do expensive copies instead of cheap moves in some cases, last I checked).
> - Customizations for using memcpy more often.
> - Smaller by a pointer for most `T` (64-bit pointers).

The LLVM project also hosts libc++, shouldn't we dogfood our own
implementations?

2 and 3 should be optimizations possible in the STL. I disagree that
SmallVectorImpl is pervasively used. The normal use case is a function
parameter where the caller creates a SmallVector just to pass it, and
can continue to do so with zero inline elements even if in other
places we use std::vector.

Michael


More information about the llvm-dev mailing list