13#ifndef LLVM_EXECUTIONENGINE_ORC_EXECUTIONUTILS_H
14#define LLVM_EXECUTIONENGINE_ORC_EXECUTIONUTILS_H
39class MachOUniversalBinary;
106 : I(M.global_values().begin()), E(M.global_values().end()),
107 ObjFmt(
Triple(M.getTargetTriple()).getObjectFormat()) {
109 if (!isStaticInitGlobal(*I))
110 moveToNextStaticInitGlobal();
119 assert(I != E &&
"Increment past end of range");
120 moveToNextStaticInitGlobal();
128 void moveToNextStaticInitGlobal() {
130 while (I != E && !isStaticInitGlobal(*I))
153 using CtorDtorList = std::vector<SymbolStringPtr>;
154 using CtorDtorPriorityMap = std::map<unsigned, CtorDtorList>;
157 CtorDtorPriorityMap CtorDtorsByPriority;
207 std::mutex AtExitsMutex;
239 Load(
const char *FileName,
char GlobalPrefix,
250 std::move(AddAbsoluteSymbols));
300 std::unique_ptr<object::Archive> Archive,
320 return ImportedDynamicLibraries;
329 std::unique_ptr<MemoryBuffer> ArchiveBuffer,
330 std::unique_ptr<object::Archive> Archive,
333 Error buildObjectFilesMap();
337 std::set<std::string> ImportedDynamicLibraries;
338 std::unique_ptr<MemoryBuffer> ArchiveBuffer;
339 std::unique_ptr<object::Archive>
Archive;
354 static std::unique_ptr<DLLImportDefinitionGenerator>
370 static StringRef getImpPrefix() {
return "__imp_"; }
372 static StringRef getSectionName() {
return "$__DLLIMPORT_STUBS"; }
Machine Check Debug Module
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Allocate memory in an ever growing pool, as if by bump-pointer.
ConstantArray - Constant Array Declarations.
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
A Module instance is used to store all the information related to an LLVM module.
concat_iterator< GlobalValue, iterator, global_iterator, alias_iterator, ifunc_iterator > global_value_iterator
StringRef - Represent a constant reference to a string, i.e.
Triple - Helper class for working with autoconf configuration names.
LLVM Value Representation.
A range adaptor for a pair of iterators.
This iterator provides a convenient way to iterate over the elements of an llvm.global_ctors/llvm....
bool operator!=(const CtorDtorIterator &Other) const
Test iterators for inequality.
Element operator*() const
Dereference iterator.
CtorDtorIterator & operator++()
Pre-increment iterator.
bool operator==(const CtorDtorIterator &Other) const
Test iterators for equality.
CtorDtorRunner(JITDylib &JD)
void add(iterator_range< CtorDtorIterator > CtorDtors)
A utility class to create COFF dllimport GOT symbols (__imp_*) and PLT stubs.
static std::unique_ptr< DLLImportDefinitionGenerator > Create(ExecutionSession &ES, ObjectLinkingLayer &L)
Creates a DLLImportDefinitionGenerator instance.
Error tryToGenerate(LookupState &LS, LookupKind K, JITDylib &JD, JITDylibLookupFlags JDLookupFlags, const SymbolLookupSet &Symbols) override
DefinitionGenerators should override this method to insert new definitions into the parent JITDylib.
Definition generators can be attached to JITDylibs to generate new definitions for otherwise unresolv...
A utility class to expose symbols found via dlsym to the JIT.
std::function< bool(const SymbolStringPtr &)> SymbolPredicate
unique_function< Error(JITDylib &, SymbolMap)> AddAbsoluteSymbolsFn
static Expected< std::unique_ptr< DynamicLibrarySearchGenerator > > Load(const char *FileName, char GlobalPrefix, SymbolPredicate Allow=SymbolPredicate(), AddAbsoluteSymbolsFn AddAbsoluteSymbols=nullptr)
Permanently loads the library at the given path and, on success, returns a DynamicLibrarySearchGenera...
Error tryToGenerate(LookupState &LS, LookupKind K, JITDylib &JD, JITDylibLookupFlags JDLookupFlags, const SymbolLookupSet &Symbols) override
DefinitionGenerators should override this method to insert new definitions into the parent JITDylib.
static Expected< std::unique_ptr< DynamicLibrarySearchGenerator > > GetForCurrentProcess(char GlobalPrefix, SymbolPredicate Allow=SymbolPredicate(), AddAbsoluteSymbolsFn AddAbsoluteSymbols=nullptr)
Creates a DynamicLibrarySearchGenerator that searches for symbols in the current process.
An ExecutionSession represents a running JIT program.
An interface for Itanium __cxa_atexit interposer implementations.
void runAtExits(void *DSOHandle)
void registerAtExit(void(*F)(void *), void *Ctx, void *DSOHandle)
Represents a JIT'd dynamic library.
Support class for static dtor execution.
void(*)(void *) DestructorPtr
static int CXAAtExitOverride(DestructorPtr Destructor, void *Arg, void *DSOHandle)
std::vector< CXXDestructorDataPair > CXXDestructorDataPairList
CXXDestructorDataPairList DSOHandleOverride
std::pair< DestructorPtr, void * > CXXDestructorDataPair
void runDestructors()
Run any destructors recorded by the overriden __cxa_atexit function (CXAAtExitOverride).
Error enable(JITDylib &JD, MangleAndInterner &Mangler)
Wraps state for a lookup-in-progress.
Mangles symbol names then uniques them in the context of an ExecutionSession.
Interface for Layers that accept object files.
An ObjectLayer implementation built on JITLink.
This iterator provides a convenient way to iterate over GlobalValues that have initialization effects...
StaticInitGVIterator()=default
GlobalValue & operator*()
StaticInitGVIterator & operator++()
bool operator!=(const StaticInitGVIterator &O) const
bool operator==(const StaticInitGVIterator &O) const
StaticInitGVIterator(Module &M)
A utility class to expose symbols from a static library.
const std::set< std::string > & getImportedDynamicLibraries() const
Returns a list of filenames of dynamic libraries that this archive has imported.
unique_function< Error(MemoryBufferRef)> VisitMembersFunction
Callback for visiting archive members at construction time.
static VisitMembersFunction loadAllObjectFileMembers(ObjectLayer &L, JITDylib &JD)
A VisitMembersFunction that unconditionally loads all object files from the archive.
Error tryToGenerate(LookupState &LS, LookupKind K, JITDylib &JD, JITDylibLookupFlags JDLookupFlags, const SymbolLookupSet &Symbols) override
DefinitionGenerators should override this method to insert new definitions into the parent JITDylib.
static Expected< std::unique_ptr< StaticLibraryDefinitionGenerator > > Create(ObjectLayer &L, std::unique_ptr< MemoryBuffer > ArchiveBuffer, std::unique_ptr< object::Archive > Archive, VisitMembersFunction VisitMembers=VisitMembersFunction(), GetObjectFileInterface GetObjFileInterface=GetObjectFileInterface())
Try to create a StaticLibrarySearchGenerator from the given memory buffer and Archive object.
static Expected< std::unique_ptr< StaticLibraryDefinitionGenerator > > Load(ObjectLayer &L, const char *FileName, VisitMembersFunction VisitMembers=VisitMembersFunction(), GetObjectFileInterface GetObjFileInterface=GetObjectFileInterface())
Try to create a StaticLibraryDefinitionGenerator from the given path.
unique_function< Expected< MaterializationUnit::Interface >(ExecutionSession &ES, MemoryBufferRef ObjBuffer)> GetObjectFileInterface
Interface builder function for objects loaded from this archive.
A set of symbols to look up, each associated with a SymbolLookupFlags value.
Pointer to a pooled string representing a symbol name.
This class provides a portable interface to dynamic libraries which also might be known as shared lib...
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
iterator_range< CtorDtorIterator > getDestructors(const Module &M)
Create an iterator range over the entries of the llvm.global_ctors array.
iterator_range< StaticInitGVIterator > getStaticInitGVs(Module &M)
Create an iterator range over the GlobalValues that contribute to static initialization.
iterator_range< CtorDtorIterator > getConstructors(const Module &M)
Create an iterator range over the entries of the llvm.global_ctors array.
JITDylibLookupFlags
Lookup flags that apply to each dylib in the search order for a lookup.
LookupKind
Describes the kind of lookup being performed.
@ Resolved
Queried, materialization begun.
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
Accessor for an element of the global_ctors/global_dtors array.
Element(unsigned Priority, Function *Func, Value *Data)