14#ifndef LLVM_SUPPORT_RECYCLER_H
15#define LLVM_SUPPORT_RECYCLER_H
36template <
class T,
size_t Size = sizeof(T),
size_t Align = alignof(T)>
43 FreeNode *FreeList =
nullptr;
48 FreeList = FreeList->Next;
53 void push(FreeNode *
N) {
64 assert(!FreeList &&
"Non-empty recycler deleted!");
68 : FreeList(
std::exchange(
Other.FreeList, nullptr)) {}
74 template<
class AllocatorType>
76 if constexpr (std::is_same_v<std::decay_t<AllocatorType>,
83 T *t =
reinterpret_cast<T *
>(pop_val());
89 template<
class SubClass,
class AllocatorType>
91 static_assert(
alignof(SubClass) <=
Align,
92 "Recycler allocation alignment is less than object align!");
93 static_assert(
sizeof(SubClass) <=
Size,
94 "Recycler allocation size is less than object size!");
95 static_assert(
Size >=
sizeof(FreeNode) &&
96 "Recycler allocation size must be at least sizeof(FreeNode)");
97 return FreeList ?
reinterpret_cast<SubClass *
>(pop_val())
101 template<
class AllocatorType>
106 template<
class SubClass,
class AllocatorType>
108 push(
reinterpret_cast<FreeNode *
>(Element));
114template <
class T,
size_t Size,
size_t Align>
117 for (
auto *
I = FreeList;
I;
I =
I->Next)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
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)
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.
LLVM_ABI void PrintRecyclerStats(size_t Size, size_t Align, size_t FreeListSize)
PrintRecyclingAllocatorStats - Helper for RecyclingAllocator for printing statistics.
FunctionAddr VTableAddr Next
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
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.