14#ifndef LLVM_SUPPORT_RECYCLER_H
15#define LLVM_SUPPORT_RECYCLER_H
33template <
class T,
size_t Size = sizeof(T),
size_t Align = alignof(T)>
40 FreeNode *FreeList =
nullptr;
45 FreeList = FreeList->Next;
50 void push(FreeNode *
N) {
61 assert(!FreeList &&
"Non-empty recycler deleted!");
65 : FreeList(
std::exchange(
Other.FreeList, nullptr)) {}
71 template<
class AllocatorType>
74 T *t =
reinterpret_cast<T *
>(pop_val());
86 template<
class SubClass,
class AllocatorType>
88 static_assert(
alignof(SubClass) <=
Align,
89 "Recycler allocation alignment is less than object align!");
90 static_assert(
sizeof(SubClass) <=
Size,
91 "Recycler allocation size is less than object size!");
92 static_assert(
Size >=
sizeof(FreeNode) &&
93 "Recycler allocation size must be at least sizeof(FreeNode)");
94 return FreeList ?
reinterpret_cast<SubClass *
>(pop_val())
98 template<
class AllocatorType>
103 template<
class SubClass,
class AllocatorType>
105 push(
reinterpret_cast<FreeNode *
>(Element));
111template <
class T,
size_t Size,
size_t Align>
114 for (
auto *
I = FreeList;
I;
I =
I->Next)
This file defines the BumpPtrAllocator interface.
#define __asan_poison_memory_region(p, size)
#define __asan_unpoison_memory_region(p, size)
#define __msan_allocated_memory(p, size)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Allocate memory in an ever growing pool, as if by bump-pointer.
Recycler - This class manages a linked-list of deallocated nodes and facilitates reusing deallocated ...
void clear(BumpPtrAllocator &)
Special case for BumpPtrAllocator which has an empty Deallocate() function.
void clear(AllocatorType &Allocator)
clear - Release all the tracked allocations to the allocator.
Recycler(Recycler &&Other)
void Deallocate(AllocatorType &, SubClass *Element)
Recycler(const Recycler &)=delete
SubClass * Allocate(AllocatorType &Allocator)
T * Allocate(AllocatorType &Allocator)
This file defines classes to implement an intrusive doubly linked list class (i.e.
This is an optimization pass for GlobalISel generic memory operations.
void PrintRecyclerStats(size_t Size, size_t Align, size_t FreeListSize)
PrintRecyclingAllocatorStats - Helper for RecyclingAllocator for printing statistics.
Implement std::hash so that hash_code can be used in STL containers.
This struct is a compact representation of a valid (non-zero power of two) alignment.