9 #ifndef LLVM_SUPPORT_CRASHRECOVERYCONTEXT_H 10 #define LLVM_SUPPORT_CRASHRECOVERYCONTEXT_H 15 class CrashRecoveryContextCleanup;
83 return RunSafely([&]() { Fn(UserData); });
96 unsigned RequestedStackSize = 0) {
125 : context(context) {}
128 bool cleanupFired =
false;
131 virtual void recoverResources() = 0;
153 template<
typename Derived,
typename T>
168 return new Derived(context, x);
175 template <
typename T>
185 this->resource->~T();
190 template <
typename T>
202 template <
typename T>
209 T>(context, resource) {}
245 template <
typename T,
typename Cleanup = CrashRecoveryContextDeleteCleanup<T> >
251 : cleanup(
Cleanup::create(x)) {
266 #endif // LLVM_SUPPORT_CRASHRECOVERYCONTEXT_H static Derived * create(T *x)
Creates cleanup handler.
This class represents lattice values for constants.
Cleanup handler that reclaims resource by calling destructor on it.
Helper class for managing resource cleanups.
bool DumpStackAndCleanupOnFailure
Selects whether handling of failures should be done in the same way as for regular crashes...
static void Cleanup(DenseMap< Instruction *, Instruction *> &NewPredicates, SetVector< Instruction *> &MaybeDead, Loop *L)
Cleanup handler that reclaims resource by calling its method 'Release'.
An efficient, type-erasing, non-owning reference to a callable.
static CrashRecoveryContext * GetCurrent()
Return the active context, if the code is currently executing in a thread which is in a protected con...
void recoverResources() override
static void cleanup(BlockFrequencyInfoImplBase &BFI)
Clear all memory not needed downstream.
void recoverResources() override
~CrashRecoveryContextCleanupRegistrar()
virtual void recoverResources()
CrashRecoveryContextDeleteCleanup(CrashRecoveryContext *context, T *resource)
void unregisterCleanup(CrashRecoveryContextCleanup *cleanup)
Base class of cleanup handler that controls recovery of resources of the given type.
static void Enable()
Enable crash recovery.
Abstract base class of cleanup handlers.
CrashRecoveryContextCleanup(CrashRecoveryContext *context)
bool RunSafelyOnThread(function_ref< void()>, unsigned RequestedStackSize=0)
Execute the provide callback function (with the given arguments) in a protected context which is run ...
bool RunSafelyOnThread(void(*Fn)(void *), void *UserData, unsigned RequestedStackSize=0)
void registerCleanup(CrashRecoveryContextCleanup *cleanup)
Register cleanup handler, which is used when the recovery context is finished.
bool RunSafely(void(*Fn)(void *), void *UserData)
CrashRecoveryContextReleaseRefCleanup(CrashRecoveryContext *context, T *resource)
#define LLVM_ATTRIBUTE_NORETURN
bool RunSafely(function_ref< void()> Fn)
Execute the provided callback function (with the given arguments) in a protected context.
Crash recovery helper object.
LLVM_ATTRIBUTE_NORETURN void HandleExit(int RetCode)
Explicitly trigger a crash recovery in the current process, and return failure from RunSafely()...
Cleanup handler that reclaims resource by calling 'delete' on it.
CrashRecoveryContext * getContext() const
int RetCode
In case of a crash, this is the crash identifier.
CrashRecoveryContextCleanupBase(CrashRecoveryContext *context, T *resource)
static bool isRecoveringFromCrash()
Return true if the current thread is recovering from a crash.
CrashRecoveryContextCleanupRegistrar(T *x)
static void Disable()
Disable crash recovery.
CrashRecoveryContextDestructorCleanup(CrashRecoveryContext *context, T *resource)