14 #ifndef LLVM_EXECUTIONENGINE_ORC_EXECUTIONUTILS_H 15 #define LLVM_EXECUTIONENGINE_ORC_EXECUTIONUTILS_H 54 : Priority(Priority), Func(Func), Data(Data) {}
96 template <
typename JITLayerT>
102 : CtorDtorNames(
std::move(CtorDtorNames)), K(K) {}
107 using CtorDtorTy = void (*)();
109 for (
const auto &CtorDtorName : CtorDtorNames) {
110 if (
auto CtorDtorSym = JITLayer.findSymbolIn(K, CtorDtorName,
false)) {
111 if (
auto AddrOrErr = CtorDtorSym.getAddress()) {
112 CtorDtorTy CtorDtor =
113 reinterpret_cast<CtorDtorTy
>(
static_cast<uintptr_t
>(*AddrOrErr));
116 return AddrOrErr.takeError();
118 if (
auto Err = CtorDtorSym.takeError())
121 return make_error<JITSymbolNotFound>(CtorDtorName);
128 std::vector<std::string> CtorDtorNames;
139 using CtorDtorList = std::vector<SymbolStringPtr>;
140 using CtorDtorPriorityMap = std::map<unsigned, CtorDtorList>;
143 CtorDtorPriorityMap CtorDtorsByPriority;
165 void runDestructors();
183 template <
typename MangleFtorT>
185 addOverride(Mangle(
"__dso_handle"), toTargetAddress(&DSOHandleOverride));
186 addOverride(Mangle(
"__cxa_atexit"), toTargetAddress(&CXAAtExitOverride));
191 auto I = CXXRuntimeOverrides.find(Name);
192 if (
I != CXXRuntimeOverrides.end())
199 CXXRuntimeOverrides.insert(std::make_pair(Name, Addr));
239 return Load(
nullptr, DL, std::move(Allow));
253 #endif // LLVM_EXECUTIONENGINE_ORC_EXECUTIONUTILS_H JITTargetAddress toTargetAddress(PtrTy *P)
A parsed version of the target data layout string in and methods for querying it. ...
Accessor for an element of the global_ctors/global_dtors array.
This class represents lattice values for constants.
bool operator==(const CtorDtorIterator &Other) const
Test iterators for equality.
A Module instance is used to store all the information related to an LLVM module. ...
JITEvaluatedSymbol searchOverrides(const std::string &Name)
Search overrided symbols.
Convenience class for recording constructor/destructor names for later execution. ...
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
Element(unsigned Priority, Function *Func, Value *Data)
std::vector< CXXDestructorDataPair > CXXDestructorDataPairList
uint64_t VModuleKey
VModuleKey provides a unique identifier (allocated and managed by ExecutionSessions) for a module add...
void(*)(void *) DestructorPtr
CtorDtorIterator & operator++()
Pre-increment iterator.
static Expected< DynamicLibrarySearchGenerator > GetForCurrentProcess(const DataLayout &DL, SymbolPredicate Allow=SymbolPredicate())
Creates a DynamicLibrarySearchGenerator that searches for symbols in the current process.
amdgpu Simplify well known AMD library false Value Value const Twine & Name
Mangles symbol names then uniques them in the context of an ExecutionSession.
Tagged union holding either a T or a Error.
This class provides a portable interface to dynamic libraries which also might be known as shared lib...
CXXDestructorDataPairList DSOHandleOverride
LegacyLocalCXXRuntimeOverrides(const MangleFtorT &Mangle)
Create a runtime-overrides class.
std::function< bool(SymbolStringPtr)> SymbolPredicate
iterator_range< CtorDtorIterator > getDestructors(const Module &M)
Create an iterator range over the entries of the llvm.global_ctors array.
CtorDtorIterator(const GlobalVariable *GV, bool End)
Construct an iterator instance.
uint64_t JITTargetAddress
Represents an address in the target process's address space.
CtorDtorRunner(JITDylib &JD)
Support class for static dtor execution.
std::pair< DestructorPtr, void * > CXXDestructorDataPair
static ErrorSuccess success()
Create a success value.
A utility class to expose symbols found via dlsym to the JIT.
This iterator provides a convenient way to iterate over the elements of an llvm.global_ctors/llvm.global_dtors instance.
A range adaptor for a pair of iterators.
ConstantArray - Constant Array Declarations.
Represents a symbol that has been evaluated to an address already.
amdgpu Simplify well known AMD library false Value Value * Arg
iterator_range< CtorDtorIterator > getConstructors(const Module &M)
Create an iterator range over the entries of the llvm.global_ctors array.
LLVM Value Representation.
Element operator*() const
Dereference iterator.
Lightweight error class with error context and mandatory checking.
bool operator!=(const CtorDtorIterator &Other) const
Test iterators for inequality.
LegacyCtorDtorRunner(std::vector< std::string > CtorDtorNames, VModuleKey K)
Construct a CtorDtorRunner for the given range using the given name mangling function.
Error runViaLayer(JITLayerT &JITLayer) const
Run the recorded constructors/destructors through the given JIT layer.
A symbol table that supports asynchoronous symbol queries.