13#ifndef LLVM_EXECUTIONENGINE_ORC_CORE_H
14#define LLVM_EXECUTIONENGINE_ORC_CORE_H
80 return *
reinterpret_cast<JITDylib *
>(JDAndFlag.load() &
96 bool isDefunct()
const {
return JDAndFlag.load() & 0x1; }
108 std::atomic_uintptr_t JDAndFlag;
150 std::vector<std::pair<JITDylib *, JITDylibLookupFlags>>;
158 O.reserve(JDs.
size());
160 O.push_back(std::make_pair(JD, Flags));
188 :
public ErrorInfo<ResourceTrackerDefunct> {
206 std::error_code convertToErrorCode()
const override;
220 std::shared_ptr<SymbolDependenceMap> Symbols);
227 std::shared_ptr<SymbolStringPool> SSP;
228 std::shared_ptr<SymbolDependenceMap> Symbols;
233 :
public ErrorInfo<UnsatisfiedSymbolDependencies> {
240 std::string Explanation);
245 std::shared_ptr<SymbolStringPool> SSP;
249 std::string Explanation;
266 std::shared_ptr<SymbolStringPool> SSP;
272 :
public ErrorInfo<SymbolsCouldNotBeRemoved> {
284 std::shared_ptr<SymbolStringPool> SSP;
293 :
public ErrorInfo<MissingSymbolDefinitions> {
301 std::error_code convertToErrorCode()
const override;
307 std::shared_ptr<SymbolStringPool> SSP;
317 :
public ErrorInfo<UnexpectedSymbolDefinitions> {
325 std::error_code convertToErrorCode()
const override;
331 std::shared_ptr<SymbolStringPool> SSP;
370 return RT->withResourceKeyDo(std::forward<Func>(
F));
472 : JD(RT->getJITDylib()), RT(
std::
move(RT)),
473 SymbolFlags(
std::
move(SymbolFlags)), InitSymbol(
std::
move(InitSymbol)) {
474 assert(!this->SymbolFlags.
empty() &&
"Materializing nothing?");
480 SymbolStringPtr InitSymbol;
502 void materialize(std::unique_ptr<MaterializationResponsibility> R)
override;
523inline std::unique_ptr<ReExportsMaterializationUnit>
525 return std::make_unique<ReExportsMaterializationUnit>(
532inline std::unique_ptr<ReExportsMaterializationUnit>
536 return std::make_unique<ReExportsMaterializationUnit>(
537 &SourceJD, SourceJDLookupFlags, std::move(Aliases));
580 bool isComplete()
const {
return OutstandingSymbolsCount == 0; }
586 SymbolState getRequiredState() {
return RequiredState; }
588 void addQueryDependence(
JITDylib &JD, SymbolStringPtr Name);
590 void removeQueryDependence(
JITDylib &JD,
const SymbolStringPtr &Name);
592 void dropSymbol(
const SymbolStringPtr &Name);
594 void handleFailed(
Error Err);
601 size_t OutstandingSymbolsCount;
602 SymbolState RequiredState;
623 LookupState(std::unique_ptr<InProgressLookupState> IPLS);
628 std::unique_ptr<InProgressLookupState> IPLS;
652 std::deque<LookupState> PendingLookups;
735 template <
typename GeneratorT>
736 GeneratorT &
addGenerator(std::unique_ptr<GeneratorT> DefGenerator);
769 bool LinkAgainstThisJITDylibFirst =
true);
807 template <
typename Func>
809 ->
decltype(
F(std::declval<const JITDylibSearchOrder &>()));
821 template <
typename MaterializationUnitType>
822 Error define(std::unique_ptr<MaterializationUnitType> &&MU,
835 template <
typename MaterializationUnitType>
836 Error define(std::unique_ptr<MaterializationUnitType> &MU,
887 using AsynchronousSymbolQuerySet =
888 std::set<std::shared_ptr<AsynchronousSymbolQuery>>;
890 using AsynchronousSymbolQueryList =
891 std::vector<std::shared_ptr<AsynchronousSymbolQuery>>;
893 struct UnmaterializedInfo {
894 UnmaterializedInfo(std::unique_ptr<MaterializationUnit> MU,
898 std::unique_ptr<MaterializationUnit> MU;
902 using UnmaterializedInfosMap =
903 DenseMap<SymbolStringPtr, std::shared_ptr<UnmaterializedInfo>>;
905 using UnmaterializedInfosList =
906 std::vector<std::shared_ptr<UnmaterializedInfo>>;
914 struct MaterializingInfo {
917 LLVM_ABI void addQuery(std::shared_ptr<AsynchronousSymbolQuery> Q);
919 LLVM_ABI AsynchronousSymbolQueryList
920 takeQueriesMeeting(SymbolState RequiredState);
921 AsynchronousSymbolQueryList takeAllPendingQueries() {
922 return std::move(PendingQueries);
924 bool hasQueriesPending()
const {
return !PendingQueries.empty(); }
925 const AsynchronousSymbolQueryList &pendingQueries()
const {
926 return PendingQueries;
929 AsynchronousSymbolQueryList PendingQueries;
932 using MaterializingInfosMap = DenseMap<SymbolStringPtr, MaterializingInfo>;
934 class SymbolTableEntry {
936 SymbolTableEntry() =
default;
937 SymbolTableEntry(JITSymbolFlags Flags)
939 MaterializerAttached(
false) {}
941 ExecutorAddr getAddress()
const {
return Addr; }
942 JITSymbolFlags getFlags()
const {
return Flags; }
945 bool hasMaterializerAttached()
const {
return MaterializerAttached; }
947 void setAddress(ExecutorAddr Addr) { this->Addr = Addr; }
948 void setFlags(JITSymbolFlags Flags) { this->Flags = Flags; }
950 assert(
static_cast<uint8_t
>(State) < (1 << 6) &&
951 "State does not fit in bitfield");
952 this->State =
static_cast<uint8_t
>(State);
955 void setMaterializerAttached(
bool MaterializerAttached) {
956 this->MaterializerAttached = MaterializerAttached;
959 ExecutorSymbolDef getSymbol()
const {
return {Addr, Flags}; }
963 JITSymbolFlags Flags;
965 uint8_t MaterializerAttached : 1;
968 using SymbolTable = DenseMap<SymbolStringPtr, SymbolTableEntry>;
972 struct RemoveTrackerResult {
973 AsynchronousSymbolQuerySet QueriesToFail;
974 std::shared_ptr<SymbolDependenceMap> FailedSymbols;
975 std::vector<std::unique_ptr<MaterializationUnit>> DefunctMUs;
978 RemoveTrackerResult IL_removeTracker(ResourceTracker &RT);
980 void transferTracker(ResourceTracker &DstRT, ResourceTracker &SrcRT);
985 installMaterializationUnit(std::unique_ptr<MaterializationUnit> MU,
986 ResourceTracker &RT);
991 Expected<SymbolFlagsMap>
996 std::unique_ptr<MaterializationUnit> MU);
998 Expected<std::unique_ptr<MaterializationResponsibility>>
1000 SymbolStringPtr InitSymbol);
1010 void shrinkMaterializationInfoMemory();
1013 enum { Open, Closing, Closed } State = Open;
1014 std::mutex GeneratorsMutex;
1015 SymbolTable Symbols;
1016 UnmaterializedInfosMap UnmaterializedInfos;
1017 MaterializingInfosMap MaterializingInfos;
1018 std::vector<std::shared_ptr<DefinitionGenerator>> DefGenerators;
1023 DenseMap<ResourceTracker *, SymbolNameVector> TrackerSymbols;
1024 DenseMap<ResourceTracker *, DenseSet<MaterializationResponsibility *>>
1078 std::unique_ptr<MaterializationResponsibility> MR)
1082 void run()
override;
1085 std::unique_ptr<MaterializationUnit> MU;
1086 std::unique_ptr<MaterializationResponsibility> MR;
1098 void run()
override;
1139 : Name(Name), Handler(
std::
move(Handler)), LF(LF) {}
1182 return EPC->getSymbolStringPool();
1200 assert(!GOpRecorder &&
"WaitingOnGraph recorder already set");
1205 void setPlatform(std::unique_ptr<Platform> P) { this->P = std::move(P); }
1213 std::lock_guard<std::recursive_mutex> Lock(SessionMutex);
1276 this->ReportError = std::move(ReportError);
1358 assert(
T &&
"T must be non-null");
1360 EPC->getDispatcher().dispatch(std::move(
T));
1365 return EPC->getBootstrapMap();
1369 template <
typename T,
typename SPSTagT>
1371 return EPC->getBootstrapMapValue<
T, SPSTagT>(
Key, Val);
1376 return EPC->getBootstrapSymbolsMap();
1383 ArrayRef<std::pair<ExecutorAddr &, StringRef>> Pairs)
const {
1384 return EPC->getBootstrapSymbols(Pairs);
1398 EPC->callWrapperAsync(WrapperFnAddr, std::move(OnComplete), ArgBuffer);
1403 template <
typename RunPolicyT,
typename FnT>
1406 EPC->callWrapperAsync(std::forward<RunPolicyT>(Runner), WrapperFnAddr,
1407 std::forward<FnT>(OnComplete), ArgBuffer);
1412 template <
typename FnT>
1415 EPC->callWrapperAsync(WrapperFnAddr, std::forward<FnT>(OnComplete),
1431 JITDylib &JD, std::vector<CallControllerHandlerBinding> Hs);
1436 template <
typename... BindingTs>
1438 (std::is_same_v<BindingTs, CallControllerHandlerBinding> && ...),
Error>
1440 std::vector<CallControllerHandlerBinding> Bs;
1441 Bs.reserve(
sizeof...(Hs));
1442 (Bs.push_back(std::move(Hs)), ...);
1459#ifdef EXPENSIVE_CHECKS
1464 static void logErrorsToStdErr(
Error Err) {
1468 void dispatchOutstandingMUs();
1470 static std::unique_ptr<MaterializationResponsibility>
1473 SymbolStringPtr InitSymbol) {
1474 auto &JD = RT.getJITDylib();
1475 std::unique_ptr<MaterializationResponsibility> MR(
1477 std::move(InitSymbol)));
1478 JD.TrackerMRs[&RT].insert(MR.get());
1491 Error IL_updateCandidatesFor(
JITDylib &JD, JITDylibLookupFlags JDLookupFlags,
1492 SymbolLookupSet &Candidates,
1493 SymbolLookupSet *NonCandidates);
1496 void OL_resumeLookupAfterGeneration(InProgressLookupState &IPLS);
1501 void OL_applyQueryPhase1(std::unique_ptr<InProgressLookupState> IPLS,
1508 void OL_completeLookup(std::unique_ptr<InProgressLookupState> IPLS,
1509 std::shared_ptr<AsynchronousSymbolQuery> Q,
1514 void OL_completeLookupFlags(
1515 std::unique_ptr<InProgressLookupState> IPLS,
1516 unique_function<
void(Expected<SymbolFlagsMap>)> OnComplete);
1528 struct EmitQueries {
1529 JITDylib::AsynchronousSymbolQuerySet Completed;
1530 JITDylib::AsynchronousSymbolQuerySet
Failed;
1531 DenseMap<AsynchronousSymbolQuery *, std::shared_ptr<SymbolDependenceMap>>
1536 IL_getSymbolState(
JITDylib *JD, NonOwningSymbolStringPtr Name);
1538 template <
typename UpdateSymbolFn,
typename UpdateQueryFn>
1539 void IL_collectQueries(JITDylib::AsynchronousSymbolQuerySet &Qs,
1540 WaitingOnGraph::ContainerElementsMap &QualifiedSymbols,
1541 UpdateSymbolFn &&UpdateSymbol,
1542 UpdateQueryFn &&UpdateQuery);
1545 WaitingOnGraph::SimplifyResult SR);
1552 std::pair<JITDylib::AsynchronousSymbolQuerySet,
1553 std::shared_ptr<SymbolDependenceMap>>
1557 std::unique_ptr<MaterializationUnit> MU);
1558 LLVM_ABI Expected<std::unique_ptr<MaterializationResponsibility>>
1562 void dumpDispatchInfo(Task &
T);
1565 mutable std::recursive_mutex SessionMutex;
1566 bool SessionOpen =
true;
1567 std::unique_ptr<ExecutorProcessControl> EPC;
1568 std::unique_ptr<Platform> P;
1571 std::vector<ResourceManager *> ResourceManagers;
1573 std::vector<JITDylibSP> JDs;
1576 WaitingOnGraph::OpRecorder *GOpRecorder =
nullptr;
1580 mutable std::recursive_mutex OutstandingMUsMutex;
1581 std::vector<std::pair<std::unique_ptr<MaterializationUnit>,
1582 std::unique_ptr<MaterializationResponsibility>>>
1585 mutable std::mutex CallControllerHandlersMutex;
1586 DenseMap<ExecutorAddr, std::unique_ptr<CallControllerHandlerFn>>
1587 CallControllerHandlers;
1601 return JD.getExecutionSession();
1604template <
typename GeneratorT>
1606 auto &
G = *DefGenerator;
1607 ES.runSessionLocked([&] {
1608 assert(State == Open &&
"Cannot add generator to closed JITDylib");
1609 DefGenerators.push_back(std::move(DefGenerator));
1614template <
typename Func>
1616 ->
decltype(
F(std::declval<const JITDylibSearchOrder &>())) {
1617 assert(State == Open &&
"Cannot use link order of closed JITDylib");
1618 return ES.runSessionLocked([&]() {
return F(LinkOrder); });
1621template <
typename MaterializationUnitType>
1624 assert(MU &&
"Can not define with a null MU");
1626 if (MU->getSymbols().empty()) {
1629 dbgs() <<
"Warning: Discarding empty MU " << MU->getName() <<
" for "
1635 dbgs() <<
"Defining MU " << MU->getName() <<
" for " <<
getName()
1638 dbgs() <<
"default)";
1642 dbgs() <<
"0x0, default will be used)\n";
1645 return ES.runSessionLocked([&,
this]() ->
Error {
1649 if (
auto Err = defineImpl(*MU))
1655 if (
auto *
P = ES.getPlatform()) {
1656 if (
auto Err =
P->notifyAdding(*RT, *MU))
1660 installMaterializationUnit(std::move(MU), *RT);
1665template <
typename MaterializationUnitType>
1668 assert(MU &&
"Can not define with a null MU");
1670 if (MU->getSymbols().empty()) {
1673 dbgs() <<
"Warning: Discarding empty MU " << MU->getName() <<
getName()
1679 dbgs() <<
"Defining MU " << MU->getName() <<
" for " <<
getName()
1682 dbgs() <<
"default)";
1686 dbgs() <<
"0x0, default will be used)\n";
1689 return ES.runSessionLocked([&,
this]() ->
Error {
1690 assert(State == Open &&
"JD is defunct");
1692 if (
auto Err = defineImpl(*MU))
1698 if (
auto *
P = ES.getPlatform()) {
1699 if (
auto Err =
P->notifyAdding(*RT, *MU))
1703 installMaterializationUnit(std::move(MU), *RT);
1756 std::move(SymbolFlags));
1764 std::unique_ptr<MaterializationUnit> MU) {
aarch64 falkor hwpf fix Falkor HW Prefetch Fix Late Phase
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Function Alias Analysis false
This file defines the DenseSet and SmallDenseSet classes.
This file defines the RefCountedBase, ThreadSafeRefCountedBase, and IntrusiveRefCntPtr classes.
static StringRef getName(Value *V)
#define DEBUG_WITH_TYPE(TYPE,...)
DEBUG_WITH_TYPE macro - This macro should be used by passes to emit debug information.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
Base class for user error types.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...
Flags for symbols in the JIT.
Inheritance utility for extensible RTTI.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Represent a constant reference to a string, i.e.
ThreadSafeRefCountedBase()=default
Triple - Helper class for working with autoconf configuration names.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Represents a JITDylib as seen by JITLink.
const std::string & getName() const
Get the name for this JITLinkDylib.
A symbol query that returns results via a callback when results are ready.
LLVM_ABI AsynchronousSymbolQuery(const SymbolLookupSet &Symbols, SymbolState RequiredState, SymbolsResolvedCallback NotifyComplete)
Create a query for the given symbols.
bool isComplete() const
Returns true if all symbols covered by this query have been resolved.
friend class InProgressFullLookupState
LLVM_ABI void notifySymbolMetRequiredState(const SymbolStringPtr &Name, ExecutorSymbolDef Sym)
Notify the query that a requested symbol has reached the required state.
friend class JITSymbolResolverAdapter
friend class MaterializationResponsibility
friend class ExecutionSession
Definition generators can be attached to JITDylibs to generate new definitions for otherwise unresolv...
virtual Error tryToGenerate(LookupState &LS, LookupKind K, JITDylib &JD, JITDylibLookupFlags JDLookupFlags, const SymbolLookupSet &LookupSet)=0
DefinitionGenerators should override this method to insert new definitions into the parent JITDylib.
friend class ExecutionSession
SymbolLookupFlags getLookupFlags() const
CallControllerHandlerFn takeHandler()
SymbolNameSpec getName() const
CallControllerHandlerBinding(SymbolNameSpec Name, CallControllerHandlerFn Handler, SymbolLookupFlags LF=SymbolLookupFlags::RequiredSymbol)
An ExecutionSession represents a running JIT program.
LLVM_ABI Error endSession()
End the session.
ExecutorProcessControl & getExecutorProcessControl()
Get the ExecutorProcessControl object associated with this ExecutionSession.
unique_function< void(shared::WrapperFunctionBuffer)> CallControllerReturnFn
Function type for returning results from a call-controller handler.
void reportError(Error Err)
Report a error for this execution session.
void callWrapperAsync(ExecutorAddr WrapperFnAddr, ExecutorProcessControl::IncomingWFRHandler OnComplete, ArrayRef< char > ArgBuffer)
Run a wrapper function in the executor.
friend class InProgressLookupFlagsState
ExecutionSession & operator=(const ExecutionSession &)=delete
const StringMap< ExecutorAddr > & getBootstrapSymbolsMap() const
Returns the bootstrap symbol map.
void setPlatform(std::unique_ptr< Platform > P)
Set the Platform for this ExecutionSession.
std::enable_if_t<(std::is_same_v< BindingTs, CallControllerHandlerBinding > &&...), Error > registerCallControllerHandlers(JITDylib &JD, BindingTs &&...Hs)
Convenience overload of registerCallControllerHandlers that takes the bindings as arguments,...
const Triple & getTargetTriple() const
Return the triple for the executor.
ExecutionSession(const ExecutionSession &)=delete
Platform * getPlatform()
Get the Platform for this session.
LLVM_ABI void lookupFlags(LookupKind K, JITDylibSearchOrder SearchOrder, SymbolLookupSet Symbols, unique_function< void(Expected< SymbolFlagsMap >)> OnComplete)
Search the given JITDylibs to find the flags associated with each of the given symbols.
SymbolStringPtr intern(StringRef SymName)
Add a symbol name to the SymbolStringPool and return a pointer to it.
LLVM_ABI JITDylib * getJITDylibByName(StringRef Name)
Return a pointer to the "name" JITDylib.
LLVM_ABI void runCallControllerHandler(CallControllerReturnFn Return, ExecutorAddr HandlerFnTagAddr, shared::WrapperFunctionBuffer ArgBytes)
Run the call-controller handler registered for the given tag address.
void callWrapperAsync(RunPolicyT &&Runner, ExecutorAddr WrapperFnAddr, FnT &&OnComplete, ArrayRef< char > ArgBuffer)
Run a wrapper function in the executor using the given Runner to dispatch OnComplete when the result ...
LLVM_ABI JITDylib & createBareJITDylib(std::string Name)
Add a new bare JITDylib to this ExecutionSession.
LLVM_ABI Error registerCallControllerHandlers(JITDylib &JD, std::vector< CallControllerHandlerBinding > Hs)
For each binding, look up its tag symbol in JD and register the binding's call-controller handler for...
JITDylib & getBootstrapJITDylib()
Returns a reference to the bootstrap JITDylib.
std::shared_ptr< SymbolStringPool > getSymbolStringPool()
Get the SymbolStringPool for this instance.
Error getBootstrapMapValue(StringRef Key, std::optional< T > &Val) const
Look up and SPS-deserialize a bootstrap map value.
friend class InProgressFullLookupState
Error getBootstrapSymbols(ArrayRef< std::pair< ExecutorAddr &, StringRef > > Pairs) const
For each (ExecutorAddr&, StringRef) pair, looks up the string in the bootstrap symbols map and writes...
const StringMap< std::vector< char > > & getBootstrapMap() const
Returns the bootstrap map.
LLVM_ABI void lookup(LookupKind K, const JITDylibSearchOrder &SearchOrder, SymbolLookupSet Symbols, SymbolState RequiredState, SymbolsResolvedCallback NotifyComplete, RegisterDependenciesFunction RegisterDependencies)
Search the given JITDylibs for the given symbols.
friend class MaterializationResponsibility
LLVM_ABI void registerResourceManager(ResourceManager &RM)
Register the given ResourceManager with this ExecutionSession.
LLVM_ABI ~ExecutionSession()
Destroy an ExecutionSession.
void setWaitingOnGraphOpRecorder(WaitingOnGraph::OpRecorder &R)
Set a WaitingOnGraph::Recorder to capture WaitingOnGraph operations.
LLVM_ABI void deregisterResourceManager(ResourceManager &RM)
Deregister the given ResourceManager with this ExecutionSession.
LLVM_ABI ExecutionSession(std::unique_ptr< ExecutorProcessControl > EPC)
Construct an ExecutionSession with the given ExecutorProcessControl object.
decltype(auto) runSessionLocked(Func &&F)
Run the given lambda with the session mutex locked.
LLVM_ABI void dump(raw_ostream &OS)
Dump the state of all the JITDylibs in this session.
friend class ResourceTracker
ExecutionSession & setErrorReporter(ErrorReporter ReportError)
Set the error reporter function.
ExecutionSession(ExecutionSession &&)=delete
LLVM_ABI Error removeJITDylibs(std::vector< JITDylibSP > JDsToRemove)
Removes the given JITDylibs from the ExecutionSession.
size_t getPageSize() const
LLVM_ABI Expected< JITDylib & > createJITDylib(std::string Name)
Add a new JITDylib to this ExecutionSession.
void dispatchTask(std::unique_ptr< Task > T)
Materialize the given unit.
unique_function< void(Error)> ErrorReporter
For reporting errors.
ExecutionSession & operator=(ExecutionSession &&)=delete
Error removeJITDylib(JITDylib &JD)
Calls removeJTIDylibs on the gives JITDylib.
void callWrapperAsync(ExecutorAddr WrapperFnAddr, FnT &&OnComplete, ArrayRef< char > ArgBuffer)
Run a wrapper function in the executor.
unique_function< void( CallControllerReturnFn, shared::WrapperFunctionBuffer)> CallControllerHandlerFn
A call-controller handler: handles calls from the executor made via the ORC runtime's call-controller...
Represents an address in the executor process.
A handler or incoming WrapperFunctionBuffers – either return values from callWrapper* calls,...
ExecutorProcessControl supports interaction with a JIT target process.
Represents a defining location for a JIT symbol.
FailedToMaterialize(std::shared_ptr< SymbolStringPool > SSP, std::shared_ptr< SymbolDependenceMap > Symbols)
const SymbolDependenceMap & getSymbols() const
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
void log(raw_ostream &OS) const override
Print an error message to an output stream.
JITDylibDefunct(JITDylibSP JD)
Represents a JIT'd dynamic library.
LLVM_ABI Error remove(const SymbolNameSet &Names)
Tries to remove the given symbols.
LLVM_ABI Error clear()
Calls remove on all trackers currently associated with this JITDylib.
JITDylib & operator=(JITDylib &&)=delete
LLVM_ABI void dump(raw_ostream &OS)
Dump current JITDylib state to OS.
friend class AsynchronousSymbolQuery
LLVM_ABI void replaceInLinkOrder(JITDylib &OldJD, JITDylib &NewJD, JITDylibLookupFlags JDLookupFlags=JITDylibLookupFlags::MatchExportedSymbolsOnly)
Replace OldJD with NewJD in the link order if OldJD is present.
Error define(std::unique_ptr< MaterializationUnitType > &&MU, ResourceTrackerSP RT=nullptr)
Define all symbols provided by the materialization unit to be part of this JITDylib.
ExecutionSession & getExecutionSession() const
Get a reference to the ExecutionSession for this JITDylib.
LLVM_ABI void addToLinkOrder(const JITDylibSearchOrder &NewLinks)
Append the given JITDylibSearchOrder to the link order for this JITDylib (discarding any elements alr...
LLVM_ABI ResourceTrackerSP createResourceTracker()
Create a resource tracker for this JITDylib.
auto withLinkOrderDo(Func &&F) -> decltype(F(std::declval< const JITDylibSearchOrder & >()))
Do something with the link order (run under the session lock).
friend class MaterializationResponsibility
LLVM_ABI void removeFromLinkOrder(JITDylib &JD)
Remove the given JITDylib from the link order for this JITDylib if it is present.
LLVM_ABI void setLinkOrder(JITDylibSearchOrder NewSearchOrder, bool LinkAgainstThisJITDylibFirst=true)
Set the link order to be used when fixing up definitions in JITDylib.
LLVM_ABI Expected< std::vector< JITDylibSP > > getReverseDFSLinkOrder()
Rteurn this JITDylib and its transitive dependencies in reverse DFS order based on linkage relationsh...
friend class ExecutionSession
LLVM_ABI ResourceTrackerSP getDefaultResourceTracker()
Get the default resource tracker for this JITDylib.
GeneratorT & addGenerator(std::unique_ptr< GeneratorT > DefGenerator)
Adds a definition generator to this JITDylib and returns a referenece to it.
JITDylib(const JITDylib &)=delete
JITDylib & operator=(const JITDylib &)=delete
JITDylib(JITDylib &&)=delete
LLVM_ABI void removeGenerator(DefinitionGenerator &G)
Remove a definition generator from this JITDylib.
LLVM_ABI Expected< std::vector< JITDylibSP > > getDFSLinkOrder()
Return this JITDylib and its transitive dependencies in DFS order based on linkage relationships.
Wraps state for a lookup-in-progress.
LLVM_ABI void continueLookup(Error Err)
Continue the lookup.
LLVM_ABI LookupState & operator=(LookupState &&)
friend class ExecutionSession
friend class OrcV2CAPIHelper
LLVM_ABI LookupState(LookupState &&)
LookupTask(LookupState LS)
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
MaterializationResponsibility & operator=(MaterializationResponsibility &&)=delete
ExecutionSession & getExecutionSession() const
Returns the ExecutionSession for this instance.
Error notifyResolved(const SymbolMap &Symbols)
Notifies the target JITDylib that the given symbols have been resolved.
~MaterializationResponsibility()
Destruct a MaterializationResponsibility instance.
Error replace(std::unique_ptr< MaterializationUnit > MU)
Transfers responsibility to the given MaterializationUnit for all symbols defined by that Materializa...
Error withResourceKeyDo(Func &&F) const
Runs the given callback under the session lock, passing in the associated ResourceKey.
Error defineMaterializing(SymbolFlagsMap SymbolFlags)
Attempt to claim responsibility for new definitions.
SymbolNameSet getRequestedSymbols() const
Returns the names of any symbols covered by this MaterializationResponsibility object that have queri...
Expected< std::unique_ptr< MaterializationResponsibility > > delegate(const SymbolNameSet &Symbols)
Delegates responsibility for the given symbols to the returned materialization responsibility.
const ResourceTrackerSP & getResourceTracker() const
Return the ResourceTracker associated with this instance.
const SymbolStringPtr & getInitializerSymbol() const
Returns the initialization pseudo-symbol, if any.
MaterializationResponsibility(MaterializationResponsibility &&)=delete
friend class ExecutionSession
Error notifyEmitted(ArrayRef< SymbolDependenceGroup > DepGroups)
Notifies the target JITDylib (and any pending queries on that JITDylib) that all symbols covered by t...
void failMaterialization()
Notify all not-yet-emitted covered by this MaterializationResponsibility instance that an error has o...
JITDylib & getTargetJITDylib() const
Returns the target JITDylib that these symbols are being materialized into.
const SymbolFlagsMap & getSymbols() const
Returns the symbol flags map for this responsibility instance.
MaterializationTask(std::unique_ptr< MaterializationUnit > MU, std::unique_ptr< MaterializationResponsibility > MR)
A MaterializationUnit represents a set of symbol definitions that can be materialized as a group,...
MaterializationUnit(Interface I)
const SymbolNameVector & getSymbols() const
std::shared_ptr< SymbolStringPool > getSymbolStringPool()
MissingSymbolDefinitions(std::shared_ptr< SymbolStringPool > SSP, std::string ModuleName, SymbolNameVector Symbols)
const std::string & getModuleName() const
ReExportsMaterializationUnit(JITDylib *SourceJD, JITDylibLookupFlags SourceJDLookupFlags, SymbolAliasMap Aliases)
SourceJD is allowed to be nullptr, in which case the source JITDylib is taken to be whatever JITDylib...
std::function< bool(SymbolStringPtr)> SymbolPredicate
Error tryToGenerate(LookupState &LS, LookupKind K, JITDylib &JD, JITDylibLookupFlags JDLookupFlags, const SymbolLookupSet &LookupSet) override
DefinitionGenerators should override this method to insert new definitions into the parent JITDylib.
ReexportsGenerator(JITDylib &SourceJD, JITDylibLookupFlags SourceJDLookupFlags, SymbolPredicate Allow=SymbolPredicate())
Create a reexports generator.
Listens for ResourceTracker operations.
virtual Error handleRemoveResources(JITDylib &JD, ResourceKey K)=0
This function will be called outside the session lock.
virtual ~ResourceManager()
virtual void handleTransferResources(JITDylib &JD, ResourceKey DstK, ResourceKey SrcK)=0
This function will be called inside the session lock.
ResourceTrackerDefunct(ResourceTrackerSP RT)
void log(raw_ostream &OS) const override
Print an error message to an output stream.
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
API to remove / transfer ownership of JIT resources.
JITDylib & getJITDylib() const
Return the JITDylib targeted by this tracker.
ResourceTracker & operator=(const ResourceTracker &)=delete
ResourceKey getKeyUnsafe() const
Returns the key associated with this tracker.
LLVM_ABI void transferTo(ResourceTracker &DstRT)
Transfer all resources associated with this key to the given tracker, which must target the same JITD...
ResourceTracker & operator=(ResourceTracker &&)=delete
LLVM_ABI ~ResourceTracker()
ResourceTracker(const ResourceTracker &)=delete
friend class MaterializationResponsibility
bool isDefunct() const
Return true if this tracker has become defunct.
ResourceTracker(ResourceTracker &&)=delete
Error withResourceKeyDo(Func &&F)
Runs the given callback under the session lock, passing in the associated ResourceKey.
friend class ExecutionSession
LLVM_ABI Error remove()
Remove all resources associated with this key.
A set of symbols to look up, each associated with a SymbolLookupFlags value.
A symbol name together with the naming level (SymbolNameKind) it is expressed in, so that a Mangler /...
Pointer to a pooled string representing a symbol name.
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
void log(raw_ostream &OS) const override
Print an error message to an output stream.
const SymbolNameSet & getSymbols() const
SymbolsCouldNotBeRemoved(std::shared_ptr< SymbolStringPool > SSP, SymbolNameSet Symbols)
std::shared_ptr< SymbolStringPool > getSymbolStringPool()
void log(raw_ostream &OS) const override
Print an error message to an output stream.
SymbolsNotFound(std::shared_ptr< SymbolStringPool > SSP, SymbolNameSet Symbols)
const SymbolNameVector & getSymbols() const
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
std::shared_ptr< SymbolStringPool > getSymbolStringPool()
UnexpectedSymbolDefinitions(std::shared_ptr< SymbolStringPool > SSP, std::string ModuleName, SymbolNameVector Symbols)
std::shared_ptr< SymbolStringPool > getSymbolStringPool()
const std::string & getModuleName() const
const SymbolNameVector & getSymbols() const
void log(raw_ostream &OS) const override
Print an error message to an output stream.
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
UnsatisfiedSymbolDependencies(std::shared_ptr< SymbolStringPool > SSP, JITDylibSP JD, SymbolNameSet FailedSymbols, SymbolDependenceMap BadDeps, std::string Explanation)
WaitingOnGraph class template.
C++ wrapper function buffer: Same as CWrapperFunctionBuffer but auto-releases memory.
This class implements an extremely fast bulk output stream that can only output to a stream.
unique_function is a type-erasing functor similar to std::function.
JITDylibSearchOrder makeJITDylibSearchOrder(ArrayRef< JITDylib * > JDs, JITDylibLookupFlags Flags=JITDylibLookupFlags::MatchExportedSymbolsOnly)
Convenience function for creating a search order from an ArrayRef of JITDylib*, all with the same fla...
std::vector< std::pair< JITDylib *, JITDylibLookupFlags > > JITDylibSearchOrder
A list of (JITDylib*, JITDylibLookupFlags) pairs to be used as a search order during symbol lookup.
IntrusiveRefCntPtr< JITDylib > JITDylibSP
IntrusiveRefCntPtr< ResourceTracker > ResourceTrackerSP
std::unique_ptr< ReExportsMaterializationUnit > symbolAliases(SymbolAliasMap Aliases)
Create a ReExportsMaterializationUnit with the given aliases.
std::function< void(const SymbolDependenceMap &)> RegisterDependenciesFunction
Callback to register the dependencies for a given query.
SymbolLookupFlags
Lookup flags that apply to each symbol in a lookup.
std::unique_ptr< ReExportsMaterializationUnit > reexports(JITDylib &SourceJD, SymbolAliasMap Aliases, JITDylibLookupFlags SourceJDLookupFlags=JITDylibLookupFlags::MatchExportedSymbolsOnly)
Create a materialization unit for re-exporting symbols from another JITDylib with alternative names/f...
JITDylibLookupFlags
Lookup flags that apply to each dylib in the search order for a lookup.
@ MatchExportedSymbolsOnly
detail::WaitingOnGraph< JITDylib *, NonOwningSymbolStringPtr > WaitingOnGraph
DenseMap< SymbolStringPtr, ExecutorSymbolDef > SymbolMap
A map from symbol names (as SymbolStringPtrs) to JITSymbols (address/flags pairs).
LookupKind
Describes the kind of lookup being performed.
LLVM_ABI RegisterDependenciesFunction NoDependenciesToRegister
This can be used as the value for a RegisterDependenciesFunction if there are no dependants to regist...
std::vector< SymbolStringPtr > SymbolNameVector
A vector of symbol names.
DenseMap< JITDylib *, SymbolNameSet > SymbolDependenceMap
A map from JITDylibs to sets of symbols.
DenseSet< SymbolStringPtr > SymbolNameSet
A set of symbol names (represented by SymbolStringPtrs for.
SymbolState
Represents the state that a symbol has reached during materialization.
@ Materializing
Added to the symbol table, never queried.
@ NeverSearched
No symbol should be in this state.
@ Ready
Emitted to memory, but waiting on transitive dependencies.
@ Emitted
Assigned address, still materializing.
@ Resolved
Queried, materialization begun.
DenseMap< SymbolStringPtr, SymbolAliasMapEntry > SymbolAliasMap
A map of Symbols to (Symbol, Flags) pairs.
unique_function< void(Expected< SymbolMap >)> SymbolsResolvedCallback
Callback to notify client that symbols have been resolved.
LLVM_ABI Expected< SymbolAliasMap > buildSimpleReexportsAliasMap(JITDylib &SourceJD, const SymbolNameSet &Symbols)
Build a SymbolAliasMap for the common case where you want to re-export symbols from another JITDylib ...
DenseMap< SymbolStringPtr, JITSymbolFlags > SymbolFlagsMap
A map from symbol names (as SymbolStringPtrs) to JITSymbolFlags.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner={})
Log all errors (if any) in E to OS.
testing::Matcher< const detail::ErrorHolder & > Failed()
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
ArrayRef(const T &OneElt) -> ArrayRef< T >
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.
SymbolAliasMapEntry()=default
JITSymbolFlags AliasFlags
SymbolAliasMapEntry(SymbolStringPtr Aliasee, JITSymbolFlags AliasFlags)
A set of symbols and the their dependencies.
SymbolDependenceMap Dependencies