13#ifndef LLVM_SUPPORT_MANAGEDSTATIC_H
14#define LLVM_SUPPORT_MANAGEDSTATIC_H
23 static void *
call() {
return new C(); }
44#if !defined(_MSC_VER) || (_MSC_VER >= 1925) || defined(__clang__)
45#define LLVM_USE_CONSTEXPR_CTOR
51#ifdef LLVM_USE_CONSTEXPR_CTOR
52 mutable std::atomic<void *>
Ptr{};
58 mutable std::atomic<void *>
Ptr;
66#ifdef LLVM_USE_CONSTEXPR_CTOR
81template <
class C,
class Creator =
object_creator<C>,
82 class Deleter =
object_deleter<C>>
87 void *Tmp =
Ptr.load(std::memory_order_acquire);
91 return *
static_cast<C *
>(
Ptr.load(std::memory_order_relaxed));
97 void *Tmp =
Ptr.load(std::memory_order_acquire);
101 return *
static_cast<C *
>(
Ptr.load(std::memory_order_relaxed));
109 return static_cast<C *
>(
Ptr.exchange(
nullptr));
ManagedStaticBase - Common base class for ManagedStatic instances.
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.
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.
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)