LLVM  14.0.0git
Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
llvm::orc::LocalCXXRuntimeOverridesBase Class Reference

Support class for static dtor execution. More...

#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"

Inheritance diagram for llvm::orc::LocalCXXRuntimeOverridesBase:
Inheritance graph
Collaboration diagram for llvm::orc::LocalCXXRuntimeOverridesBase:
Collaboration graph

Public Member Functions

void runDestructors ()
 Run any destructors recorded by the overriden __cxa_atexit function (CXAAtExitOverride). More...

Protected Types

using DestructorPtr = void(*)(void *)
using CXXDestructorDataPair = std::pair< DestructorPtr, void * >
using CXXDestructorDataPairList = std::vector< CXXDestructorDataPair >

Protected Member Functions

template<typename PtrTy >
JITTargetAddress toTargetAddress (PtrTy *P)

Static Protected Member Functions

static int CXAAtExitOverride (DestructorPtr Destructor, void *Arg, void *DSOHandle)

Protected Attributes

CXXDestructorDataPairList DSOHandleOverride

Detailed Description

Support class for static dtor execution.

For hosted (in-process) JITs only!

If a __cxa_atexit function isn't found C++ programs that use static destructors will fail to link. However, we don't want to use the host process's __cxa_atexit, because it will schedule JIT'd destructors to run after the JIT has been torn down, which is no good. This class makes it easy to override __cxa_atexit (and the related __dso_handle).

To use, clients should manually call searchOverrides from their symbol resolver. This should generally be done after attempting symbol resolution inside the JIT, but before searching the host process's symbol table. When the client determines that destructors should be run (generally at JIT teardown or after a return from main), the runDestructors method should be called.

Definition at line 172 of file ExecutionUtils.h.

Member Typedef Documentation

◆ CXXDestructorDataPair

Definition at line 184 of file ExecutionUtils.h.

◆ CXXDestructorDataPairList

Definition at line 185 of file ExecutionUtils.h.

◆ DestructorPtr

using llvm::orc::LocalCXXRuntimeOverridesBase::DestructorPtr = void (*)(void *)

Definition at line 183 of file ExecutionUtils.h.

Member Function Documentation

◆ CXAAtExitOverride()

int llvm::orc::LocalCXXRuntimeOverridesBase::CXAAtExitOverride ( DestructorPtr  Destructor,
void *  Arg,
void *  DSOHandle 

Definition at line 175 of file ExecutionUtils.cpp.

References Arg.

Referenced by llvm::orc::LocalCXXRuntimeOverrides::enable().

◆ runDestructors()

void llvm::orc::LocalCXXRuntimeOverridesBase::runDestructors ( )

Run any destructors recorded by the overriden __cxa_atexit function (CXAAtExitOverride).

Definition at line 168 of file ExecutionUtils.cpp.

References DSOHandleOverride, and P.

◆ toTargetAddress()

template<typename PtrTy >
JITTargetAddress llvm::orc::LocalCXXRuntimeOverridesBase::toTargetAddress ( PtrTy *  P)

Definition at line 179 of file ExecutionUtils.h.

References P.

Referenced by llvm::orc::LocalCXXRuntimeOverrides::enable().

Member Data Documentation

◆ DSOHandleOverride

CXXDestructorDataPairList llvm::orc::LocalCXXRuntimeOverridesBase::DSOHandleOverride

The documentation for this class was generated from the following files: