15 #ifndef LLVM_SUPPORT_RECYCLER_H 16 #define LLVM_SUPPORT_RECYCLER_H 34 template <
class T,
size_t Size = sizeof(T),
size_t Align = alignof(T)>
41 FreeNode *FreeList =
nullptr;
46 FreeList = FreeList->Next;
51 void push(FreeNode *
N) {
62 assert(!FreeList &&
"Non-empty recycler deleted!");
68 template<
class AllocatorType>
71 T *t =
reinterpret_cast<T *
>(pop_val());
72 Allocator.Deallocate(t);
83 template<
class SubClass,
class AllocatorType>
85 static_assert(
alignof(SubClass) <=
Align,
86 "Recycler allocation alignment is less than object align!");
87 static_assert(
sizeof(SubClass) <=
Size,
88 "Recycler allocation size is less than object size!");
89 return FreeList ?
reinterpret_cast<SubClass *
>(pop_val())
90 : static_cast<SubClass *>(Allocator.Allocate(
Size,
Align));
93 template<
class AllocatorType>
98 template<
class SubClass,
class AllocatorType>
100 push(reinterpret_cast<FreeNode *>(Element));
106 template <
class T,
size_t Size,
size_t Align>
109 for (
auto *
I = FreeList;
I;
I =
I->Next)
#define __asan_poison_memory_region(p, size)
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
This class represents lattice values for constants.
void PrintRecyclerStats(size_t Size, size_t Align, size_t FreeListSize)
PrintRecyclingAllocatorStats - Helper for RecyclingAllocator for printing statistics.
#define __asan_unpoison_memory_region(p, size)
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
void clear(BumpPtrAllocator &)
Special case for BumpPtrAllocator which has an empty Deallocate() function.
#define __msan_allocated_memory(p, size)
SubClass * Allocate(AllocatorType &Allocator)
Allocate memory in an ever growing pool, as if by bump-pointer.
T * Allocate(AllocatorType &Allocator)
Recycler - This class manages a linked-list of deallocated nodes and facilitates reusing deallocated ...
void Deallocate(AllocatorType &, SubClass *Element)
void clear(AllocatorType &Allocator)
clear - Release all the tracked allocations to the allocator.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())