15#define DEBUG_TYPE "orc"
20Expected<std::unique_ptr<ExecutorResolutionGenerator>>
22 const char *LibraryPath,
25 auto H = DylibMgr.loadDylib(LibraryPath);
28 return std::make_unique<ExecutorResolutionGenerator>(
29 ES, DylibMgr, *H, std::move(Allow), std::move(AbsoluteSymbols));
36 if (LookupSet.
empty())
40 dbgs() <<
"ExecutorResolutionGenerator trying to generate " << LookupSet
45 for (
auto &[Name, LookupFlag] : LookupSet) {
46 if (Allow && !Allow(Name))
48 LookupSymbols.add(Name, LookupFlag);
52 DylibMgr.lookupSymbolsAsync(
53 LR, [
this, LS = std::move(LS), JD =
JITDylibSP(&JD),
54 LookupSymbols](
auto Result)
mutable {
57 dbgs() <<
"ExecutorResolutionGenerator lookup failed due to error";
59 return LS.continueLookup(
Result.takeError());
62 "Results for more than one library returned");
64 "Result has incorrect number of elements");
68 auto Syms =
Result->front().begin();
71 for (
auto &[Name, Flags] : LookupSymbols) {
72 const auto &Sym = *Syms++;
73 if (Sym && Sym->getAddress())
77 MissingSymbols.
insert(Name);
81 dbgs() <<
"ExecutorResolutionGenerator lookup returned " << NewSyms
90 this->ES.getSymbolStringPool(), std::move(MissingSymbols)));
92 LS.continueLookup(JD->
define(AbsoluteSymbols(std::move(NewSyms))));
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_UNLIKELY(EXPR)
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
std::pair< iterator, bool > insert(const ValueT &V)
friend class ExecutionSession
static Expected< std::unique_ptr< ExecutorResolutionGenerator > > Load(ExecutionSession &ES, DylibManager &DylibMgr, const char *LibraryPath, SymbolPredicate Allow=SymbolPredicate(), AbsoluteSymbolsFn AbsoluteSymbols=absoluteSymbols)
Permanently loads the library at the given path and, on success, returns an ExecutorResolutionGenerat...
unique_function< std::unique_ptr< MaterializationUnit >(SymbolMap)> AbsoluteSymbolsFn
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.
unique_function< bool(const SymbolStringPtr &)> SymbolPredicate
Represents a JIT'd dynamic library.
Error define(std::unique_ptr< MaterializationUnitType > &&MU, ResourceTrackerSP RT=nullptr)
Define all symbols provided by the materialization unit to be part of this JITDylib.
Wraps state for a lookup-in-progress.
A set of symbols to look up, each associated with a SymbolLookupFlags value.
IntrusiveRefCntPtr< JITDylib > JITDylibSP
JITDylibLookupFlags
Lookup flags that apply to each dylib in the search order for a lookup.
DenseMap< SymbolStringPtr, ExecutorSymbolDef > SymbolMap
A map from symbol names (as SymbolStringPtrs) to JITSymbols (address/flags pairs).
LookupKind
Describes the kind of lookup being performed.
DenseSet< SymbolStringPtr > SymbolNameSet
A set of symbol names (represented by SymbolStringPtrs for.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
A pair of a dylib and a set of symbols to be looked up.