Go to the documentation of this file.
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.");
99 assert(RefCount > 0 &&
"Reference count is already zero.");
101 delete static_cast<const Derived *
>(
this);
107 mutable std::atomic<int> RefCount{0};
118 "Destruction occurred when there are still references to this.");
127 void Retain()
const { RefCount.fetch_add(1, std::memory_order_relaxed); }
130 int NewRefCount = RefCount.fetch_sub(1, std::memory_order_acq_rel) - 1;
131 assert(NewRefCount >= 0 &&
"Reference count was already zero.");
132 if (NewRefCount == 0)
133 delete static_cast<const Derived *
>(
this);
158 static void retain(T *obj) { obj->Retain(); }
159 static void release(T *obj) { obj->Release(); }
180 std::enable_if_t<std::is_convertible<X *, T *>::value,
bool> =
true>
186 std::enable_if_t<std::is_convertible<X *, T *>::value,
bool> =
true>
201 explicit operator bool()
const {
return Obj; }
230 template <
class T,
class U>
233 return A.get() ==
B.get();
236 template <
class T,
class U>
239 return A.get() !=
B.get();
242 template <
class T,
class U>
247 template <
class T,
class U>
252 template <
class T,
class U>
257 template <
class T,
class U>
284 template <
typename From>
struct simplify_type;
303 template <
typename T,
typename...
Args>
310 #endif // LLVM_ADT_INTRUSIVEREFCNTPTR_H
This is an optimization pass for GlobalISel generic memory operations.
friend class IntrusiveRefCntPtr
~ThreadSafeRefCountedBase()
bool operator!=(uint64_t V1, const APInt &V2)
alloca< 16 x float >, align 16 %tmp2=alloca< 16 x float >, align 16 store< 16 x float > %A,< 16 x float > *%tmp %s=bitcast< 16 x float > *%tmp to i8 *%s2=bitcast< 16 x float > *%tmp2 to i8 *call void @llvm.memcpy.i64(i8 *%s, i8 *%s2, i64 64, i32 16) %R=load< 16 x float > *%tmp2 ret< 16 x float > %R } declare void @llvm.memcpy.i64(i8 *nocapture, i8 *nocapture, i64, i32) nounwind which compiles to:_foo:subl $140, %esp movaps %xmm3, 112(%esp) movaps %xmm2, 96(%esp) movaps %xmm1, 80(%esp) movaps %xmm0, 64(%esp) movl 60(%esp), %eax movl %eax, 124(%esp) movl 56(%esp), %eax movl %eax, 120(%esp) movl 52(%esp), %eax< many many more 32-bit copies > movaps(%esp), %xmm0 movaps 16(%esp), %xmm1 movaps 32(%esp), %xmm2 movaps 48(%esp), %xmm3 addl $140, %esp ret On Nehalem, it may even be cheaper to just use movups when unaligned than to fall back to lower-granularity chunks. Implement processor-specific optimizations for parity with GCC on these processors. GCC does two optimizations:1. ix86_pad_returns inserts a noop before ret instructions if immediately preceded by a conditional branch or is the target of a jump. 2. ix86_avoid_jump_misspredicts inserts noops in cases where a 16-byte block of code contains more than 3 branches. The first one is done for all AMDs, Core2, and "Generic" The second one is done for:Atom, Pentium Pro, all AMDs, Pentium 4, Nocona, Core 2, and "Generic" Testcase:int x(int a) { return(a &0xf0)> >4 tmp
A CRTP mixin class that adds reference counting to a type.
IntrusiveRefCntPtr(IntrusiveRefCntPtr &&S)
IntrusiveRefCntPtr & operator=(IntrusiveRefCntPtr S)
IntrusiveRefCntPtr(const IntrusiveRefCntPtr &S)
IntrusiveRefCntPtr< T > makeIntrusiveRefCnt(Args &&...A)
Factory function for creating intrusive ref counted pointers.
void swap(IntrusiveRefCntPtr &other)
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...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
A thread-safe version of RefCountedBase.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
IntrusiveRefCntPtr(T *obj)
RefCountedBase & operator=(const RefCountedBase &)=delete
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool operator==(uint64_t V1, const APInt &V2)
static SimpleType getSimplifiedValue(IntrusiveRefCntPtr< T > &Val)
static void retain(T *obj)
Class you can specialize to provide custom retain/release functionality for a type.
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
RefCountedBase(const RefCountedBase &)
The virtual file system interface.
ThreadSafeRefCountedBase(const ThreadSafeRefCountedBase &)
ThreadSafeRefCountedBase()=default
IntrusiveRefCntPtr(std::unique_ptr< X > S)
static void release(T *obj)
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
ThreadSafeRefCountedBase & operator=(const ThreadSafeRefCountedBase &)=delete
A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...
IntrusiveRefCntPtr(IntrusiveRefCntPtr< X > S)
void resetWithoutRelease()