14 #ifndef LLVM_EXECUTIONENGINE_ORC_EXECUTIONUTILS_H
15 #define LLVM_EXECUTIONENGINE_ORC_EXECUTIONUTILS_H
47 : Priority(Priority), Func(Func), Data(Data) {}
89 template <
typename JITLayerT>
96 typename JITLayerT::ModuleSetHandleT H)
97 : CtorDtorNames(std::move(CtorDtorNames)), H(H) {}
102 typedef void (*CtorDtorTy)();
105 for (
const auto &CtorDtorName : CtorDtorNames)
106 if (
auto CtorDtorSym = JITLayer.findSymbolIn(H, CtorDtorName,
false)) {
107 CtorDtorTy CtorDtor =
108 reinterpret_cast<CtorDtorTy
>(
109 static_cast<uintptr_t
>(CtorDtorSym.getAddress()));
117 std::vector<std::string> CtorDtorNames;
118 typename JITLayerT::ModuleSetHandleT H;
140 template <
typename MangleFtorT>
142 addOverride(Mangle(
"__dso_handle"), toTargetAddress(&DSOHandleOverride));
143 addOverride(Mangle(
"__cxa_atexit"), toTargetAddress(&CXAAtExitOverride));
148 auto I = CXXRuntimeOverrides.
find(Name);
149 if (
I != CXXRuntimeOverrides.
end())
160 template <
typename PtrTy>
162 return static_cast<TargetAddress>(
reinterpret_cast<uintptr_t
>(
P));
166 CXXRuntimeOverrides.
insert(std::make_pair(Name, Addr));
169 StringMap<TargetAddress> CXXRuntimeOverrides;
171 typedef void (*DestructorPtr)(
void*);
172 typedef std::pair<DestructorPtr, void*> CXXDestructorDataPair;
173 typedef std::vector<CXXDestructorDataPair> CXXDestructorDataPairList;
174 CXXDestructorDataPairList DSOHandleOverride;
175 static int CXAAtExitOverride(DestructorPtr Destructor,
void *Arg,
182 #endif // LLVM_EXECUTIONENGINE_ORC_EXECUTIONUTILS_H
Accessor for an element of the global_ctors/global_dtors array.
A Module instance is used to store all the information related to an LLVM module. ...
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
bool runViaLayer(JITLayerT &JITLayer) const
Run the recorded constructors/destructors through the given JIT layer.
iterator find(StringRef Key)
void runDestructors()
Run any destructors recorded by the overriden __cxa_atexit function (CXAAtExitOverride).
CtorDtorIterator & operator++()
Pre-increment iterator.
CtorDtorRunner(std::vector< std::string > CtorDtorNames, typename JITLayerT::ModuleSetHandleT H)
Construct a CtorDtorRunner for the given range using the given name mangling function.
Support class for static dtor execution.
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.
RuntimeDyld::SymbolInfo searchOverrides(const std::string &Name)
Search overrided symbols.
Convenience class for recording constructor/destructor names for later execution. ...
Element(unsigned Priority, const Function *Func, const Value *Data)
This iterator provides a convenient way to iterate over the elements of an llvm.global_ctors/llvm.global_dtors instance.
uint64_t TargetAddress
Represents an address in the target process's address space.
bool operator!=(const CtorDtorIterator &Other) const
Test iterators for inequality.
bool operator==(const CtorDtorIterator &Other) const
Test iterators for equality.
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
A range adaptor for a pair of iterators.
ConstantArray - Constant Array Declarations.
Element operator*() const
Dereference iterator.
LocalCXXRuntimeOverrides(const MangleFtorT &Mangle)
Create a runtime-overrides class.
iterator_range< CtorDtorIterator > getConstructors(const Module &M)
Create an iterator range over the entries of the llvm.global_ctors array.
Information about a named symbol.
LLVM Value Representation.