Go to the documentation of this file.
14 #ifndef LLVM_SUPPORT_ARRAYRECYCLER_H
15 #define LLVM_SUPPORT_ARRAYRECYCLER_H
35 static_assert(
Align >=
alignof(FreeList),
"Object underaligned");
36 static_assert(
sizeof(
T) >=
sizeof(FreeList),
"Objects are too small");
43 T *pop(
unsigned Idx) {
44 if (Idx >= Bucket.size())
46 FreeList *Entry = Bucket[Idx];
50 Bucket[Idx] = Entry->Next;
52 return reinterpret_cast<T*
>(Entry);
56 void push(
unsigned Idx,
T *Ptr) {
57 assert(Ptr &&
"Cannot recycle NULL pointer");
58 FreeList *Entry =
reinterpret_cast<FreeList*
>(Ptr);
59 if (Idx >= Bucket.size())
60 Bucket.
resize(
size_t(Idx) + 1);
61 Entry->Next = Bucket[Idx];
98 assert(Bucket.empty() &&
"Non-empty ArrayRecycler deleted!");
103 template<
class AllocatorType>
105 for (; !Bucket.empty(); Bucket.pop_back())
106 while (
T *Ptr = pop(Bucket.size() - 1))
124 template<
class AllocatorType>
127 if (
T *Ptr = pop(Cap.getBucket()))
138 push(Cap.getBucket(), Ptr);
This is an optimization pass for GlobalISel generic memory operations.
#define __asan_poison_memory_region(p, size)
T * allocate(Capacity Cap, AllocatorType &Allocator)
Allocate an array of at least the requested capacity.
static Capacity get(size_t N)
Get the capacity of an array that can hold at least N elements.
unsigned getBucket() const
Get the bucket number for this capacity.
#define __asan_unpoison_memory_region(p, size)
void deallocate(Capacity Cap, T *Ptr)
Deallocate an array with the specified Capacity.
This struct is a compact representation of a valid (non-zero power of two) alignment.
void clear(BumpPtrAllocator &)
Special case for BumpPtrAllocator which has an empty Deallocate() function.
Allocate memory in an ever growing pool, as if by bump-pointer.
unsigned Log2_64_Ceil(uint64_t Value)
Return the ceil log base 2 of the specified value, 64 if the value is zero.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Capacity getNext() const
Get the next larger capacity.
void clear(AllocatorType &Allocator)
Release all the tracked allocations to the allocator.
The size of an allocated array is represented by a Capacity instance.
Recycle small arrays allocated from a BumpPtrAllocator.
#define __msan_allocated_memory(p, size)
size_t getSize() const
Get the number of elements in an array with this capacity.