9#ifndef LLVM_SUPPORT_THREADSAFEALLOCATOR_H
10#define LLVM_SUPPORT_THREADSAFEALLOCATOR_H
28 LockGuard(std::atomic_flag &Flag) : Flag(Flag) {
29 if (
LLVM_UNLIKELY(Flag.test_and_set(std::memory_order_acquire)))
30 while (Flag.test_and_set(std::memory_order_acquire)) {
33 ~LockGuard() { Flag.clear(std::memory_order_release); }
34 std::atomic_flag &Flag;
39 return applyLocked([
N](AllocatorType &Alloc) {
return Alloc.Allocate(
N); });
48 template <
typename FnT,
57 std::atomic_flag Flag = ATOMIC_FLAG_INIT;
This file defines the BumpPtrAllocator interface.
#define LLVM_UNLIKELY(EXPR)
Thread-safe allocator adaptor.
auto Allocate(size_t Size, size_t Align)
This is an optimization pass for GlobalISel generic memory operations.
This struct is a compact representation of a valid (non-zero power of two) alignment.
This class provides various trait information about a callable object.