LLVM 17.0.0git
|
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and JDs. More...
#include "llvm/ExecutionEngine/Orc/Core.h"
Public Member Functions | |
MaterializationResponsibility (MaterializationResponsibility &&)=delete | |
MaterializationResponsibility & | operator= (MaterializationResponsibility &&)=delete |
~MaterializationResponsibility () | |
Destruct a MaterializationResponsibility instance. | |
template<typename Func > | |
Error | withResourceKeyDo (Func &&F) const |
Runs the given callback under the session lock, passing in the associated ResourceKey. | |
JITDylib & | getTargetJITDylib () const |
Returns the target JITDylib that these symbols are being materialized into. | |
ExecutionSession & | getExecutionSession () const |
Returns the ExecutionSession for this instance. | |
const SymbolFlagsMap & | getSymbols () const |
Returns the symbol flags map for this responsibility instance. | |
const SymbolStringPtr & | getInitializerSymbol () const |
Returns the initialization pseudo-symbol, if any. | |
SymbolNameSet | getRequestedSymbols () const |
Returns the names of any symbols covered by this MaterializationResponsibility object that have queries pending. | |
Error | notifyResolved (const SymbolMap &Symbols) |
Notifies the target JITDylib that the given symbols have been resolved. | |
Error | notifyEmitted () |
Notifies the target JITDylib (and any pending queries on that JITDylib) that all symbols covered by this MaterializationResponsibility instance have been emitted. | |
Error | defineMaterializing (SymbolFlagsMap SymbolFlags) |
Attempt to claim responsibility for new definitions. | |
void | defineNonExistent (ArrayRef< SymbolStringPtr > Symbols) |
Define the given symbols as non-existent, removing it from the symbol table and notifying any pending queries. | |
void | failMaterialization () |
Notify all not-yet-emitted covered by this MaterializationResponsibility instance that an error has occurred. | |
Error | replace (std::unique_ptr< MaterializationUnit > MU) |
Transfers responsibility to the given MaterializationUnit for all symbols defined by that MaterializationUnit. | |
Expected< std::unique_ptr< MaterializationResponsibility > > | delegate (const SymbolNameSet &Symbols) |
Delegates responsibility for the given symbols to the returned materialization responsibility. | |
void | addDependencies (const SymbolStringPtr &Name, const SymbolDependenceMap &Dependencies) |
void | addDependenciesForAll (const SymbolDependenceMap &Dependencies) |
Add dependencies that apply to all symbols covered by this instance. | |
Friends | |
class | ExecutionSession |
class | JITDylib |
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and JDs.
An instance of this class is passed to MaterializationUnits when their materialize method is called. It allows MaterializationUnits to resolve and emit symbols, or abandon materialization by notifying any unmaterialized symbols of an error.
|
delete |
|
inline |
Destruct a MaterializationResponsibility instance.
In debug mode this asserts that all symbols being tracked have been either emitted or notified of an error.
Definition at line 1927 of file Core.h.
References getExecutionSession().
|
inline |
Definition at line 1964 of file Core.h.
References getExecutionSession(), and Name.
|
inline |
Add dependencies that apply to all symbols covered by this instance.
Definition at line 1969 of file Core.h.
References getExecutionSession().
|
inline |
Attempt to claim responsibility for new definitions.
This method can be used to claim responsibility for symbols that are added to a materialization unit during the compilation process (e.g. literal pool symbols). Symbol linkage rules are the same as for symbols that are defined up front: duplicate strong definitions will result in errors. Duplicate weak definitions will be discarded (in which case they will not be added to this responsibility instance).
This method can be used by materialization units that want to add additional symbols at materialization time (e.g. stubs, compile callbacks, metadata).
Definition at line 1944 of file Core.h.
References getExecutionSession().
void llvm::orc::MaterializationResponsibility::defineNonExistent | ( | ArrayRef< SymbolStringPtr > | Symbols | ) |
Define the given symbols as non-existent, removing it from the symbol table and notifying any pending queries.
Queries that lookup up the symbol using the SymbolLookupFlags::WeaklyReferencedSymbol flag will behave as if the symbol had not been matched in the first place. Queries that required this symbol will fail with a missing symbol definition error.
This method is intended to support cleanup of special symbols like initializer symbols: Queries using SymbolLookupFlags::WeaklyReferencedSymbol can be used to trigger their emission, and this method can be used to remove them from the JITDylib once materialization is complete.
|
inline |
Delegates responsibility for the given symbols to the returned materialization responsibility.
Useful for breaking up work between threads, or different kinds of materialization processes.
Definition at line 1960 of file Core.h.
References getExecutionSession().
|
inline |
Notify all not-yet-emitted covered by this MaterializationResponsibility instance that an error has occurred.
This will remove all symbols covered by this MaterializationResponsibilty from the target JITDylib, and send an error to any queries waiting on these symbols.
Definition at line 1950 of file Core.h.
References getExecutionSession().
|
inline |
Returns the ExecutionSession for this instance.
Definition at line 1793 of file Core.h.
References llvm::orc::JITDylib::getExecutionSession().
Referenced by addDependencies(), addDependenciesForAll(), defineMaterializing(), delegate(), failMaterialization(), getRequestedSymbols(), notifyEmitted(), notifyResolved(), replace(), and ~MaterializationResponsibility().
|
inline |
Returns the initialization pseudo-symbol, if any.
This symbol will also be present in the SymbolFlagsMap for this MaterializationResponsibility object.
|
inline |
Returns the names of any symbols covered by this MaterializationResponsibility object that have queries pending.
This information can be used to return responsibility for unrequested symbols back to the JITDylib via the delegate method.
Definition at line 1931 of file Core.h.
References getExecutionSession().
|
inline |
|
inline |
|
inline |
Notifies the target JITDylib (and any pending queries on that JITDylib) that all symbols covered by this MaterializationResponsibility instance have been emitted.
This method will return an error if any symbols being resolved have been moved to the error state due to the failure of a dependency. If this method returns an error then clients should log it and call failMaterialize. If no dependencies have been registered for the symbols covered by this MaterializationResponsibiility then this method is guaranteed to return Error::success() and can be wrapped with cantFail.
Definition at line 1940 of file Core.h.
References getExecutionSession().
Notifies the target JITDylib that the given symbols have been resolved.
This will update the given symbols' addresses in the JITDylib, and notify any pending queries on the given symbols of their resolution. The given symbols must be ones covered by this MaterializationResponsibility instance. Individual calls to this method may resolve a subset of the symbols, but all symbols must have been resolved prior to calling emit.
This method will return an error if any symbols being resolved have been moved to the error state due to the failure of a dependency. If this method returns an error then clients should log it and call failMaterialize. If no dependencies have been registered for the symbols covered by this MaterializationResponsibiility then this method is guaranteed to return Error::success() and can be wrapped with cantFail.
Definition at line 1935 of file Core.h.
References getExecutionSession().
|
delete |
|
inline |
Transfers responsibility to the given MaterializationUnit for all symbols defined by that MaterializationUnit.
This allows materializers to break up work based on run-time information (e.g. by introspecting which symbols have actually been looked up and materializing only those).
Definition at line 1954 of file Core.h.
References getExecutionSession().
|
inline |
Runs the given callback under the session lock, passing in the associated ResourceKey.
This is the safe way to associate resources with trackers.
Definition at line 542 of file Core.h.
References F.
Referenced by llvm::orc::DebugObjectManagerPlugin::notifyEmitted(), and llvm::orc::EHFrameRegistrationPlugin::notifyEmitted().
|
friend |