60#ifndef LLVM_ADT_INTRUSIVEREFCNTPTR_H
61#define LLVM_ADT_INTRUSIVEREFCNTPTR_H
77 mutable unsigned RefCount = 0;
87 "Destruction occurred when there are still references to this.");
101 assert(RefCount > 0 &&
"Reference count is already zero.");
103 delete static_cast<const Derived *
>(
this);
109 mutable std::atomic<int> RefCount{0};
120 "Destruction occurred when there are still references to this.");
129 unsigned UseCount()
const {
return RefCount.load(std::memory_order_relaxed); }
131 void Retain()
const { RefCount.fetch_add(1, std::memory_order_relaxed); }
134 int NewRefCount = RefCount.fetch_sub(1, std::memory_order_acq_rel) - 1;
135 assert(NewRefCount >= 0 &&
"Reference count was already zero.");
136 if (NewRefCount == 0)
137 delete static_cast<const Derived *
>(
this);
162 static unsigned useCount(
const T *obj) {
return obj->UseCount(); }
185 std::enable_if_t<std::is_convertible<X *, T *>::value,
bool> =
true>
191 std::enable_if_t<std::is_convertible<X *, T *>::value,
bool> =
true>
206 explicit operator bool()
const {
return Obj; }
239template <
class T,
class U>
242 return A.get() ==
B.get();
245template <
class T,
class U>
248 return A.get() !=
B.get();
251template <
class T,
class U>
256template <
class T,
class U>
261template <
class T,
class U>
266template <
class T,
class U>
293template <
typename From>
struct simplify_type;
312template <
typename T,
typename... Args>
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...
IntrusiveRefCntPtr(T *obj)
IntrusiveRefCntPtr & operator=(IntrusiveRefCntPtr S)
unsigned useCount() const
IntrusiveRefCntPtr(IntrusiveRefCntPtr &&S)
IntrusiveRefCntPtr(const IntrusiveRefCntPtr &S)
void swap(IntrusiveRefCntPtr &other)
IntrusiveRefCntPtr(std::unique_ptr< X > S)
IntrusiveRefCntPtr(IntrusiveRefCntPtr< X > S)
void resetWithoutRelease()
IntrusiveRefCntPtr()=default
A CRTP mixin class that adds reference counting to a type.
RefCountedBase(const RefCountedBase &)
RefCountedBase & operator=(const RefCountedBase &)=delete
unsigned UseCount() const
A thread-safe version of RefCountedBase.
ThreadSafeRefCountedBase(const ThreadSafeRefCountedBase &)
~ThreadSafeRefCountedBase()
ThreadSafeRefCountedBase()=default
ThreadSafeRefCountedBase & operator=(const ThreadSafeRefCountedBase &)=delete
unsigned UseCount() const
This is an optimization pass for GlobalISel generic memory operations.
bool operator!=(uint64_t V1, const APInt &V2)
IntrusiveRefCntPtr< T > makeIntrusiveRefCnt(Args &&...A)
Factory function for creating intrusive ref counted pointers.
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)
Class you can specialize to provide custom retain/release functionality for a type.
static void retain(T *obj)
static unsigned useCount(const T *obj)
static void release(T *obj)
static SimpleType getSimplifiedValue(IntrusiveRefCntPtr< T > &Val)
static SimpleType getSimplifiedValue(const IntrusiveRefCntPtr< T > &Val)
Define a template that can be specialized by smart pointers to reflect the fact that they are automat...