File tree Expand file tree Collapse file tree 1 file changed +11
-10
lines changed
llvm/include/llvm/Support Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Original file line number Diff line number Diff line change 1919#include " llvm/Support/Compiler.h"
2020#include " llvm/Support/ErrorHandling.h"
2121#include < cassert>
22+ #include < type_traits>
2223
2324namespace llvm {
2425
@@ -72,19 +73,19 @@ class Recycler {
7273 // / deleted; calling clear is one way to ensure this.
7374 template <class AllocatorType >
7475 void clear (AllocatorType &Allocator) {
75- while (FreeList) {
76- T *t = reinterpret_cast <T *>(pop_val ());
77- Allocator.Deallocate (t, Size, Align);
76+ if constexpr (std::is_same_v<std::decay_t <AllocatorType>,
77+ BumpPtrAllocator>) {
78+ // For BumpPtrAllocator, Deallocate is a no-op, so just drop the free
79+ // list.
80+ FreeList = nullptr ;
81+ } else {
82+ while (FreeList) {
83+ T *t = reinterpret_cast <T *>(pop_val ());
84+ Allocator.Deallocate (t, Size, Align);
85+ }
7886 }
7987 }
8088
81- // / Special case for BumpPtrAllocator which has an empty Deallocate()
82- // / function.
83- // /
84- // / There is no need to traverse the free list, pulling all the objects into
85- // / cache.
86- void clear (BumpPtrAllocator &) { FreeList = nullptr ; }
87-
8889 template <class SubClass , class AllocatorType >
8990 SubClass *Allocate (AllocatorType &Allocator) {
9091 static_assert (alignof (SubClass) <= Align,
You can’t perform that action at this time.
0 commit comments