14 #ifndef LLVM_EXECUTIONENGINE_ORC_EXECUTIONUTILS_H 15 #define LLVM_EXECUTIONENGINE_ORC_EXECUTIONUTILS_H 50 this->Arch = std::move(Arch);
54 this->CPU = std::move(CPU);
58 this->RM = std::move(RM);
62 this->CM = std::move(CM);
66 addFeatures(
const std::vector<std::string> &FeatureVec);
94 : Priority(Priority), Func(Func), Data(Data) {}
136 template <
typename JITLayerT>
142 : CtorDtorNames(
std::move(CtorDtorNames)), K(K) {}
147 using CtorDtorTy = void (*)();
149 for (
const auto &CtorDtorName : CtorDtorNames) {
150 if (
auto CtorDtorSym = JITLayer.findSymbolIn(K, CtorDtorName,
false)) {
151 if (
auto AddrOrErr = CtorDtorSym.getAddress()) {
152 CtorDtorTy CtorDtor =
153 reinterpret_cast<CtorDtorTy
>(
static_cast<uintptr_t
>(*AddrOrErr));
156 return AddrOrErr.takeError();
158 if (
auto Err = CtorDtorSym.takeError())
161 return make_error<JITSymbolNotFound>(CtorDtorName);
168 std::vector<std::string> CtorDtorNames;
179 using CtorDtorList = std::vector<SymbolStringPtr>;
180 using CtorDtorPriorityMap = std::map<unsigned, CtorDtorList>;
183 CtorDtorPriorityMap CtorDtorsByPriority;
205 void runDestructors();
223 template <
typename MangleFtorT>
225 addOverride(Mangle(
"__dso_handle"), toTargetAddress(&DSOHandleOverride));
226 addOverride(Mangle(
"__cxa_atexit"), toTargetAddress(&CXAAtExitOverride));
231 auto I = CXXRuntimeOverrides.find(Name);
232 if (
I != CXXRuntimeOverrides.end())
239 CXXRuntimeOverrides.insert(std::make_pair(Name, Addr));
271 #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.
Compute iterated dominance frontiers using a linear time algorithm.
A Module instance is used to store all the information related to an LLVM module. ...
A symbol table that supports asynchoronous symbol queries.
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
Element(unsigned Priority, Function *Func, Value *Data)
JITTargetMachineBuilder & setRelocationModel(Optional< Reloc::Model > RM)
std::vector< CXXDestructorDataPair > CXXDestructorDataPairList
uint64_t VModuleKey
VModuleKey provides a unique identifier (allocated and managed by ExecutionSessions) for a module add...
SubtargetFeatures & getFeatures()
void(*)(void *) DestructorPtr
Mangles symbol names then uniques them in the context of an ExecutionSession.
bool operator!=(const SymbolStringPtr &LHS, const SymbolStringPtr &RHS)
Tagged union holding either a T or a Error.
JITEvaluatedSymbol searchOverrides(const std::string &Name)
Search overrided symbols.
APInt operator*(APInt a, uint64_t RHS)
This class provides a portable interface to dynamic libraries which also might be known as shared lib...
CXXDestructorDataPairList DSOHandleOverride
iterator_range< CtorDtorIterator > getDestructors(const Module &M)
Create an iterator range over the entries of the llvm.global_ctors array.
bool operator==(const SymbolStringPtr &LHS, const SymbolStringPtr &RHS)
uint64_t JITTargetAddress
Represents an address in the target process's address space.
Error runViaLayer(JITLayerT &JITLayer) const
Run the recorded constructors/destructors through the given JIT layer.
static Expected< JITTargetMachineBuilder > detectHost()
Convenience class for recording constructor/destructor names for later execution. ...
CtorDtorRunner(std::vector< std::string > CtorDtorNames, VModuleKey K)
Construct a CtorDtorRunner for the given range using the given name mangling function.
JITTargetMachineBuilder(Triple TT)
std::function< bool(SymbolStringPtr)> SymbolPredicate
Support class for static dtor execution.
JITTargetMachineBuilder & addFeatures(const std::vector< std::string > &FeatureVec)
std::pair< DestructorPtr, void * > CXXDestructorDataPair
Triple - Helper class for working with autoconf configuration names.
A utility class to expose symbols found via dlsym to the JIT.
static ErrorSuccess success()
Create a success value.
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.
Manages the enabling and disabling of subtarget specific features.
Represents a symbol that has been evaluated to an address already.
JITTargetMachineBuilder & setCPU(std::string CPU)
amdgpu Simplify well known AMD library false Value Value * Arg
LocalCXXRuntimeOverrides(const MangleFtorT &Mangle)
Create a runtime-overrides class.
Expected< std::unique_ptr< TargetMachine > > createTargetMachine()
iterator_range< CtorDtorIterator > getConstructors(const Module &M)
Create an iterator range over the entries of the llvm.global_ctors array.
TargetOptions & getOptions()
JITTargetMachineBuilder & setArch(std::string Arch)
JITTargetMachineBuilder & setCodeModel(Optional< CodeModel::Model > CM)
LLVM Value Representation.
Lightweight error class with error context and mandatory checking.
std::set< SymbolStringPtr > SymbolNameSet
A set of symbol names (represented by SymbolStringPtrs for.
A utility class for building TargetMachines for JITs.