LLVM 22.0.0git
|
Represents a JIT'd dynamic library. More...
#include "llvm/ExecutionEngine/Orc/Core.h"
Public Member Functions | |
JITDylib (const JITDylib &)=delete | |
JITDylib & | operator= (const JITDylib &)=delete |
JITDylib (JITDylib &&)=delete | |
JITDylib & | operator= (JITDylib &&)=delete |
LLVM_ABI | ~JITDylib () |
ExecutionSession & | getExecutionSession () const |
Get a reference to the ExecutionSession for this JITDylib. | |
LLVM_ABI void | dump (raw_ostream &OS) |
Dump current JITDylib state to OS. | |
LLVM_ABI Error | clear () |
Calls remove on all trackers currently associated with this JITDylib. | |
LLVM_ABI ResourceTrackerSP | getDefaultResourceTracker () |
Get the default resource tracker for this JITDylib. | |
LLVM_ABI ResourceTrackerSP | createResourceTracker () |
Create a resource tracker for this JITDylib. | |
template<typename GeneratorT> | |
GeneratorT & | addGenerator (std::unique_ptr< GeneratorT > DefGenerator) |
Adds a definition generator to this JITDylib and returns a referenece to it. | |
LLVM_ABI void | removeGenerator (DefinitionGenerator &G) |
Remove a definition generator from this JITDylib. | |
LLVM_ABI void | setLinkOrder (JITDylibSearchOrder NewSearchOrder, bool LinkAgainstThisJITDylibFirst=true) |
Set the link order to be used when fixing up definitions in JITDylib. | |
LLVM_ABI void | addToLinkOrder (const JITDylibSearchOrder &NewLinks) |
Append the given JITDylibSearchOrder to the link order for this JITDylib (discarding any elements already present in this JITDylib's link order). | |
LLVM_ABI void | addToLinkOrder (JITDylib &JD, JITDylibLookupFlags JDLookupFlags=JITDylibLookupFlags::MatchExportedSymbolsOnly) |
Add the given JITDylib to the link order for definitions in this JITDylib. | |
LLVM_ABI void | replaceInLinkOrder (JITDylib &OldJD, JITDylib &NewJD, JITDylibLookupFlags JDLookupFlags=JITDylibLookupFlags::MatchExportedSymbolsOnly) |
Replace OldJD with NewJD in the link order if OldJD is present. | |
LLVM_ABI void | removeFromLinkOrder (JITDylib &JD) |
Remove the given JITDylib from the link order for this JITDylib if it is present. | |
template<typename Func> | |
auto | withLinkOrderDo (Func &&F) -> decltype(F(std::declval< const JITDylibSearchOrder & >())) |
Do something with the link order (run under the session lock). | |
template<typename MaterializationUnitType> | |
Error | define (std::unique_ptr< MaterializationUnitType > &&MU, ResourceTrackerSP RT=nullptr) |
Define all symbols provided by the materialization unit to be part of this JITDylib. | |
template<typename MaterializationUnitType> | |
Error | define (std::unique_ptr< MaterializationUnitType > &MU, ResourceTrackerSP RT=nullptr) |
Define all symbols provided by the materialization unit to be part of this JITDylib. | |
LLVM_ABI Error | remove (const SymbolNameSet &Names) |
Tries to remove the given symbols. | |
LLVM_ABI Expected< std::vector< JITDylibSP > > | getDFSLinkOrder () |
Return this JITDylib and its transitive dependencies in DFS order based on linkage relationships. | |
LLVM_ABI Expected< std::vector< JITDylibSP > > | getReverseDFSLinkOrder () |
Rteurn this JITDylib and its transitive dependencies in reverse DFS order based on linkage relationships. | |
Public Member Functions inherited from llvm::ThreadSafeRefCountedBase< JITDylib > | |
unsigned | UseCount () const |
void | Retain () const |
void | Release () const |
Public Member Functions inherited from llvm::jitlink::JITLinkDylib | |
JITLinkDylib (std::string Name) | |
const std::string & | getName () const |
Get the name for this JITLinkDylib. |
Static Public Member Functions | |
static LLVM_ABI Expected< std::vector< JITDylibSP > > | getDFSLinkOrder (ArrayRef< JITDylibSP > JDs) |
Returns the given JITDylibs and all of their transitive dependencies in DFS order (based on linkage relationships). | |
static LLVM_ABI Expected< std::vector< JITDylibSP > > | getReverseDFSLinkOrder (ArrayRef< JITDylibSP > JDs) |
Returns the given JITDylibs and all of their transitive dependencies in reverse DFS order (based on linkage relationships). |
Friends | |
class | AsynchronousSymbolQuery |
class | ExecutionSession |
class | Platform |
class | MaterializationResponsibility |
Additional Inherited Members | |
Protected Member Functions inherited from llvm::ThreadSafeRefCountedBase< JITDylib > | |
ThreadSafeRefCountedBase ()=default | |
ThreadSafeRefCountedBase & | operator= (const ThreadSafeRefCountedBase &)=delete |
~ThreadSafeRefCountedBase () |
Represents a JIT'd dynamic library.
This class aims to mimic the behavior of a regular dylib or shared object, but without requiring the contained program representations to be compiled up-front. The JITDylib's content is defined by adding MaterializationUnits, and contained MaterializationUnits will typically rely on the JITDylib's links-against order to resolve external references (similar to a regular dylib).
The JITDylib object is a thin wrapper that references state held by the ExecutionSession. JITDylibs can be removed, clearing this underlying state and leaving the JITDylib object in a defunct state. In this state the JITDylib's name is guaranteed to remain accessible. If the ExecutionSession is still alive then other operations are callable but will return an Error or null result (depending on the API). It is illegal to call any operation other than getName on a JITDylib after the ExecutionSession has been torn down.
JITDylibs cannot be moved or copied. Their address is stable, and useful as a key in some JIT data structures.
References JITDylib().
Referenced by addToLinkOrder(), JITDylib(), JITDylib(), operator=(), operator=(), removeFromLinkOrder(), and replaceInLinkOrder().
|
delete |
References JITDylib().
llvm::orc::JITDylib::~JITDylib | ( | ) |
Definition at line 652 of file Core.cpp.
References llvm::dbgs(), llvm::jitlink::JITLinkDylib::getName(), and LLVM_DEBUG.
GeneratorT & llvm::orc::JITDylib::addGenerator | ( | std::unique_ptr< GeneratorT > | DefGenerator | ) |
Adds a definition generator to this JITDylib and returns a referenece to it.
When JITDylibs are searched during lookup, if no existing definition of a symbol is found, then any generators that have been added are run (in the order that they were added) to potentially generate a definition.
It is illegal to call this method on a defunct JITDylib and the client is responsible for ensuring that they do not do so.
Definition at line 1865 of file Core.h.
Referenced by llvm::orc::LLJIT::linkStaticLibraryInto(), llvm::orc::LLJIT::linkStaticLibraryInto(), llvm::orc::LLJIT::loadPlatformDynamicLibrary(), llvm::orc::LLJITBuilderState::prepareForConstruction(), and llvm::orc::COFFPlatform::setupJITDylib().
void llvm::orc::JITDylib::addToLinkOrder | ( | const JITDylibSearchOrder & | NewLinks | ) |
Append the given JITDylibSearchOrder to the link order for this JITDylib (discarding any elements already present in this JITDylib's link order).
Definition at line 1019 of file Core.cpp.
References addToLinkOrder(), and llvm::is_contained().
Referenced by addToLinkOrder(), addToLinkOrder(), llvm::orc::COFFPlatform::Create(), llvm::orc::LLJIT::createJITDylib(), llvm::orc::ExecutorNativePlatform::operator()(), llvm::orc::LoadAndLinkDynLibrary::operator()(), and llvm::orc::LLJIT::setUpGenericLLVMIRPlatform.
void llvm::orc::JITDylib::addToLinkOrder | ( | JITDylib & | JD, |
JITDylibLookupFlags | JDLookupFlags = JITDylibLookupFlags::MatchExportedSymbolsOnly ) |
Add the given JITDylib to the link order for definitions in this JITDylib.
It is illegal to call this method on a defunct JITDylib and the client is responsible for ensuring that they do not do so.
Definition at line 1031 of file Core.cpp.
References addToLinkOrder(), and JITDylib().
Error llvm::orc::JITDylib::clear | ( | ) |
Calls remove on all trackers currently associated with this JITDylib.
Does not run static deinits.
Note that removal happens outside the session lock, so new code may be added concurrently while the clear is underway, and the newly added code will not be cleared. Adding new code concurrently with a clear is usually a bug and should be avoided.
It is illegal to call this method on a defunct JITDylib and the client is responsible for ensuring that they do not do so.
Definition at line 656 of file Core.cpp.
References assert(), getDefaultResourceTracker(), llvm::joinErrors(), and llvm::Error::success().
ResourceTrackerSP llvm::orc::JITDylib::createResourceTracker | ( | ) |
Error llvm::orc::JITDylib::define | ( | std::unique_ptr< MaterializationUnitType > && | MU, |
ResourceTrackerSP | RT = nullptr ) |
Define all symbols provided by the materialization unit to be part of this JITDylib.
If RT is not specified then the default resource tracker will be used.
This overload always takes ownership of the MaterializationUnit. If any errors occur, the MaterializationUnit consumed.
It is illegal to call this method on a defunct JITDylib and the client is responsible for ensuring that they do not do so.
Definition at line 1882 of file Core.h.
References assert(), llvm::dbgs(), DEBUG_WITH_TYPE, llvm::IntrusiveRefCntPtr< T >::get(), getDefaultResourceTracker(), llvm::jitlink::JITLinkDylib::getName(), P, and llvm::Error::success().
Referenced by llvm::orc::ObjectLayer::add(), llvm::orc::Speculator::addSpeculationRuntime(), llvm::orc::COFFPlatform::Create(), llvm::orc::RedirectableSymbolManager::createRedirectableSymbols(), llvm::orc::LocalCXXRuntimeOverrides::enable(), llvm::orc::COFFVCRuntimeBootstrapper::initializeStaticVCRuntime(), llvm::orc::COFFPlatform::setupJITDylib(), llvm::orc::ELFNixPlatform::setupJITDylib(), llvm::orc::MachOPlatform::setupJITDylib(), llvm::orc::DynamicLibrarySearchGenerator::tryToGenerate(), and llvm::orc::ReexportsGenerator::tryToGenerate().
Error llvm::orc::JITDylib::define | ( | std::unique_ptr< MaterializationUnitType > & | MU, |
ResourceTrackerSP | RT = nullptr ) |
Define all symbols provided by the materialization unit to be part of this JITDylib.
This overload only takes ownership of the MaterializationUnit no error is generated. If an error occurs, ownership remains with the caller. This may allow the caller to modify the MaterializationUnit to correct the issue, then re-call define.
It is illegal to call this method on a defunct JITDylib and the client is responsible for ensuring that they do not do so.
Definition at line 1925 of file Core.h.
References assert(), llvm::dbgs(), DEBUG_WITH_TYPE, llvm::IntrusiveRefCntPtr< T >::get(), getDefaultResourceTracker(), llvm::jitlink::JITLinkDylib::getName(), P, and llvm::Error::success().
void llvm::orc::JITDylib::dump | ( | raw_ostream & | OS | ) |
ResourceTrackerSP llvm::orc::JITDylib::getDefaultResourceTracker | ( | ) |
Get the default resource tracker for this JITDylib.
It is illegal to call this method on a defunct JITDylib and the client is responsible for ensuring that they do not do so.
Definition at line 671 of file Core.cpp.
References assert().
Referenced by llvm::orc::IRLayer::add(), llvm::orc::LinkGraphLayer::add(), llvm::orc::LinkGraphLayer::add(), llvm::orc::ObjectLayer::add(), llvm::orc::LLJIT::addIRModule(), llvm::orc::LLJIT::addObjectFile(), clear(), define(), and define().
Expected< std::vector< JITDylibSP > > llvm::orc::JITDylib::getDFSLinkOrder | ( | ) |
Return this JITDylib and its transitive dependencies in DFS order based on linkage relationships.
If any JITDylib in the order is defunct then this method will return an error, otherwise returns the order.
Definition at line 1769 of file Core.cpp.
References getDFSLinkOrder().
Referenced by getDFSLinkOrder(), and getReverseDFSLinkOrder().
|
static |
Returns the given JITDylibs and all of their transitive dependencies in DFS order (based on linkage relationships).
Each JITDylib will appear only once.
If any JITDylib in the order is defunct then this method will return an error, otherwise returns the order.
Definition at line 1723 of file Core.cpp.
References llvm::SmallVectorTemplateCommon< T, typename >::back(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::count(), llvm::ArrayRef< T >::empty(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::ArrayRef< T >::front(), llvm::inconvertibleErrorCode(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), llvm::make_error(), llvm::SmallVectorTemplateBase< T, bool >::pop_back(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::orc::Result, and llvm::reverse().
|
inline |
Get a reference to the ExecutionSession for this JITDylib.
It is legal to call this method on a defunct JITDylib, however the result will only usable if the ExecutionSession is still alive. If this JITDylib is held by an error that may have torn down the JIT then the result should not be used.
Definition at line 921 of file Core.h.
References ExecutionSession.
Referenced by llvm::orc::buildSimpleReexportsAliasMap(), llvm::orc::LazyReexportsManager::handleRemoveResources(), llvm::orc::LLJITBuilderState::prepareForConstruction(), llvm::orc::ResourceTracker::remove(), llvm::orc::ResourceTracker::transferTo(), llvm::orc::ReexportsGenerator::tryToGenerate(), llvm::orc::ResourceTracker::withResourceKeyDo(), and llvm::orc::ResourceTracker::~ResourceTracker().
Expected< std::vector< JITDylibSP > > llvm::orc::JITDylib::getReverseDFSLinkOrder | ( | ) |
Rteurn this JITDylib and its transitive dependencies in reverse DFS order based on linkage relationships.
If any JITDylib in the order is defunct then this method will return an error, otherwise returns the order.
Definition at line 1773 of file Core.cpp.
References getReverseDFSLinkOrder().
Referenced by getReverseDFSLinkOrder().
|
static |
Returns the given JITDylibs and all of their transitive dependencies in reverse DFS order (based on linkage relationships).
Each JITDylib will appear only once.
If any JITDylib in the order is defunct then this method will return an error, otherwise returns the order.
Definition at line 1762 of file Core.cpp.
References getDFSLinkOrder(), and llvm::orc::Result.
References JITDylib().
References JITDylib(), and LLVM_ABI.
Error llvm::orc::JITDylib::remove | ( | const SymbolNameSet & | Names | ) |
Tries to remove the given symbols.
If any symbols are not defined in this JITDylib this method will return a SymbolsNotFound error covering the missing symbols.
If all symbols are found but some symbols are in the process of being materialized this method will return a SymbolsCouldNotBeRemoved error.
On success, all symbols are removed. On failure, the JITDylib state is left unmodified (no symbols are removed).
It is illegal to call this method on a defunct JITDylib and the client is responsible for ensuring that they do not do so.
Definition at line 1059 of file Core.cpp.
References assert(), I, llvm::make_error(), llvm::orc::Materializing, llvm::orc::NeverSearched, llvm::orc::Ready, remove(), and llvm::Error::success().
Referenced by remove().
void llvm::orc::JITDylib::removeFromLinkOrder | ( | JITDylib & | JD | ) |
Remove the given JITDylib from the link order for this JITDylib if it is present.
Otherwise this operation is a no-op.
It is illegal to call this method on a defunct JITDylib and the client is responsible for ensuring that they do not do so.
Definition at line 1047 of file Core.cpp.
References assert(), llvm::find_if(), I, JITDylib(), and removeFromLinkOrder().
Referenced by removeFromLinkOrder().
void llvm::orc::JITDylib::removeGenerator | ( | DefinitionGenerator & | G | ) |
Remove a definition generator from this JITDylib.
The given generator must exist in this JITDylib's generators list (i.e. have been added and not yet removed).
It is illegal to call this method on a defunct JITDylib and the client is responsible for ensuring that they do not do so.
Definition at line 688 of file Core.cpp.
References assert(), llvm::find_if(), G, H, and I.
void llvm::orc::JITDylib::replaceInLinkOrder | ( | JITDylib & | OldJD, |
JITDylib & | NewJD, | ||
JITDylibLookupFlags | JDLookupFlags = JITDylibLookupFlags::MatchExportedSymbolsOnly ) |
Replace OldJD with NewJD in the link order if OldJD is present.
Otherwise this operation is a no-op.
It is illegal to call this method on a defunct JITDylib and the client is responsible for ensuring that they do not do so.
Definition at line 1035 of file Core.cpp.
References assert(), JITDylib(), and replaceInLinkOrder().
Referenced by replaceInLinkOrder().
void llvm::orc::JITDylib::setLinkOrder | ( | JITDylibSearchOrder | NewSearchOrder, |
bool | LinkAgainstThisJITDylibFirst = true ) |
Set the link order to be used when fixing up definitions in JITDylib.
This will replace the previous link order, and apply to any symbol resolutions made for definitions in this JITDylib after the call to setLinkOrder (even if the definition itself was added before the call).
If LinkAgainstThisJITDylibFirst is true (the default) then this JITDylib will add itself to the beginning of the LinkOrder (Clients should not put this JITDylib in the list in this case, to avoid redundant lookups).
If LinkAgainstThisJITDylibFirst is false then the link order will be used as-is. The primary motivation for this feature is to support deliberate shadowing of symbols in this JITDylib by a facade JITDylib. For example, the facade may resolve function names to stubs, and the stubs may compile lazily by looking up symbols in this dylib. Adding the facade dylib as the first in the link order (instead of this dylib) ensures that definitions within this dylib resolve to the lazy-compiling stubs, rather than immediately materializing the definitions in this dylib.
It is illegal to call this method on a defunct JITDylib and the client is responsible for ensuring that they do not do so.
Definition at line 1004 of file Core.cpp.
References llvm::append_range(), assert(), llvm::orc::MatchAllSymbols, and setLinkOrder().
Referenced by setLinkOrder().
auto llvm::orc::JITDylib::withLinkOrderDo | ( | Func && | F | ) | -> decltype(F(std::declval<const JITDylibSearchOrder &>())) |
Do something with the link order (run under the session lock).
It is illegal to call this method on a defunct JITDylib and the client is responsible for ensuring that they do not do so.
Definition at line 1875 of file Core.h.
Referenced by llvm::orc::DLLImportDefinitionGenerator::tryToGenerate().
|
friend |
Definition at line 903 of file Core.h.
References AsynchronousSymbolQuery.
Referenced by AsynchronousSymbolQuery.
|
friend |
Definition at line 904 of file Core.h.
References ExecutionSession.
Referenced by ExecutionSession, and getExecutionSession().
|
friend |
Definition at line 906 of file Core.h.
References MaterializationResponsibility.
Referenced by MaterializationResponsibility.
|
friend |