Go to the documentation of this file.
17 #ifdef LLVM_ENABLE_EXCEPTIONS
27 #pragma GCC diagnostic push
28 #pragma GCC diagnostic ignored "-Waix-compat"
37 #pragma GCC diagnostic pop
41 sizeof(
unsigned) * 2 +
sizeof(
void *),
42 "wasted space in SmallVector size 0");
44 "wrong alignment for 16-byte aligned T");
46 "wrong alignment for 32-byte aligned T");
48 "missing padding for 16-byte aligned T");
50 "missing padding for 32-byte aligned T");
52 sizeof(
unsigned) * 2 +
sizeof(
void *) * 2,
53 "wasted space in SmallVector size 1");
56 sizeof(
void *) * 2 +
sizeof(
void *),
57 "1 byte elements have word-sized type for size and capacity");
63 std::string Reason =
"SmallVector unable to grow. Requested capacity (" +
65 ") is larger than maximum value for size type (" +
67 #ifdef LLVM_ENABLE_EXCEPTIONS
68 throw std::length_error(Reason);
79 "SmallVector capacity unable to grow. Already at maximum size " +
81 #ifdef LLVM_ENABLE_EXCEPTIONS
82 throw std::length_error(Reason);
89 template <
class Size_T>
90 static size_t getNewCapacity(
size_t MinSize,
size_t TSize,
size_t OldCapacity) {
95 if (MinSize > MaxSize)
102 if (OldCapacity == MaxSize)
107 size_t NewCapacity = 2 * OldCapacity + 1;
112 template <
class Size_T>
114 size_t &NewCapacity) {
115 NewCapacity = getNewCapacity<Size_T>(MinSize, TSize, this->capacity());
120 template <
class Size_T>
123 size_t NewCapacity = getNewCapacity<Size_T>(MinSize, TSize, this->capacity());
125 if (BeginX == FirstEl) {
129 memcpy(NewElts, this->BeginX,
size() * TSize);
132 NewElts =
safe_realloc(this->BeginX, NewCapacity * TSize);
135 this->BeginX = NewElts;
136 this->Capacity = NewCapacity;
145 #if SIZE_MAX > UINT32_MAX
150 "Expected SmallVectorBase<uint64_t> variant to be in use.");
153 "Expected SmallVectorBase<uint32_t> variant to be in use.");
This is an optimization pass for GlobalISel generic memory operations.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
void grow_pod(void *FirstEl, size_t MinSize, size_t TSize)
This is an implementation of the grow() method which only works on POD-like data types and is out of ...
static void report_at_maximum_capacity(size_t MaxSize)
Report that this vector is already at maximum capacity.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
static void report_size_overflow(size_t MinSize, size_t MaxSize)
Report that MinSize doesn't fit into this vector's size type.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
typename std::conditional< sizeof(T)< 4 &&sizeof(void *) >=8, uint64_t, uint32_t >::type SmallVectorSizeType
<%struct.s * > cast struct s *S to sbyte *< sbyte * > sbyte uint cast struct s *agg result to sbyte *< sbyte * > sbyte uint cast struct s *memtmp to sbyte *< sbyte * > sbyte uint ret void llc ends up issuing two memcpy or custom lower memcpy(of small size) to be ldmia/stmia. I think option 2 is better but the current register allocator cannot allocate a chunk of registers at a time. A feasible temporary solution is to use specific physical registers at the lowering time for small(<
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
Expected< ExpressionValue > min(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static size_t getNewCapacity(size_t MinSize, size_t TSize, size_t OldCapacity)
LLVM_ATTRIBUTE_RETURNS_NONNULL void * safe_realloc(void *Ptr, size_t Sz)
std::string to_string(const T &Value)
Align max(MaybeAlign Lhs, Align Rhs)
This is all the stuff common to all SmallVectors.
void * mallocForGrow(size_t MinSize, size_t TSize, size_t &NewCapacity)
This is a helper for grow() that's out of line to reduce code duplication.
LLVM_ATTRIBUTE_RETURNS_NONNULL void * safe_malloc(size_t Sz)