13#ifndef LLVM_SUPPORT_MANAGEDSTATIC_H
14#define LLVM_SUPPORT_MANAGEDSTATIC_H
24 static void *
call() {
return new C(); }
45#if !defined(_MSC_VER) || (_MSC_VER >= 1925) || defined(__clang__)
46#define LLVM_USE_CONSTEXPR_CTOR
52#ifdef LLVM_USE_CONSTEXPR_CTOR
53 mutable std::atomic<void *>
Ptr{};
59 mutable std::atomic<void *>
Ptr;
65 void (*deleter)(
void *))
const;
68#ifdef LLVM_USE_CONSTEXPR_CTOR
83template <
class C,
class Creator =
object_creator<C>,
84 class Deleter =
object_deleter<C>>
89 void *Tmp =
Ptr.load(std::memory_order_acquire);
93 return *
static_cast<C *
>(
Ptr.load(std::memory_order_relaxed));
99 void *Tmp =
Ptr.load(std::memory_order_acquire);
103 return *
static_cast<C *
>(
Ptr.load(std::memory_order_relaxed));
111 return static_cast<C *
>(
Ptr.exchange(
nullptr));
ManagedStaticBase - Common base class for ManagedStatic instances.
LLVM_ABI void RegisterManagedStatic(void *(*creator)(), void(*deleter)(void *)) const
constexpr ManagedStaticBase()=default
void(* DeleterFn)(void *)
const ManagedStaticBase * Next
std::atomic< void * > Ptr
bool isConstructed() const
isConstructed - Return true if this object has not been created yet.
LLVM_ABI void destroy() const
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
const C * operator->() const
const C & operator*() const
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void llvm_shutdown()
llvm_shutdown - Deallocate and destroy all ManagedStatic variables.
llvm_shutdown_obj - This is a simple helper class that calls llvm_shutdown() when it is destroyed.
llvm_shutdown_obj()=default
object_creator - Helper method for ManagedStatic.
static void call(void *Ptr)
object_deleter - Helper method for ManagedStatic.
static void call(void *Ptr)