13 #ifndef LLVM_EXECUTIONENGINE_ORC_LEGACY_H 14 #define LLVM_EXECUTIONENGINE_ORC_LEGACY_H 43 virtual void anchor();
48 template <
typename GetResponsibilitySetFn,
typename LookupFn>
51 template <
typename GetResponsibilitySetFnRef,
typename LookupFnRef>
54 : GetResponsibilitySet(
55 std::forward<GetResponsibilitySetFnRef>(GetResponsibilitySet)),
59 return GetResponsibilitySet(Symbols);
64 return Lookup(std::move(Query), std::move(Symbols));
68 GetResponsibilitySetFn GetResponsibilitySet;
74 template <
typename GetResponsibilitySetFn,
typename LookupFn>
76 typename std::remove_cv<
77 typename std::remove_reference<GetResponsibilitySetFn>::type>
::type,
78 typename std::remove_cv<
79 typename std::remove_reference<LookupFn>::type>::type>>
83 typename std::remove_cv<
84 typename std::remove_reference<GetResponsibilitySetFn>::type>::type,
85 typename std::remove_cv<
86 typename std::remove_reference<LookupFn>::type>::type>;
87 return std::make_unique<LambdaSymbolResolverImpl>(
88 std::forward<GetResponsibilitySetFn>(GetResponsibilitySet),
89 std::forward<LookupFn>(
Lookup));
102 std::set<SymbolStringPtr> ResolvedStrings;
115 template <
typename FindSymbolFn>
118 FindSymbolFn FindSymbol) {
121 for (
auto &S : Symbols) {
123 if (!Sym.getFlags().isStrong())
125 }
else if (
auto Err = Sym.takeError())
126 return std::move(Err);
141 template <
typename FindSymbolFn>
146 bool NewSymbolsResolved =
false;
148 for (
auto &S : Symbols) {
150 if (
auto Addr = Sym.getAddress()) {
153 NewSymbolsResolved =
true;
158 }
else if (
auto Err = Sym.takeError()) {
162 SymbolsNotFound.
insert(S);
168 return SymbolsNotFound;
173 template <
typename LegacyLookupFn>
180 : ES(ES), LegacyLookup(
std::move(LegacyLookup)),
181 ReportError(
std::move(ReportError)) {}
184 if (
auto ResponsibilitySet =
186 return std::move(*ResponsibilitySet);
200 LegacyLookupFn LegacyLookup;
204 template <
typename LegacyLookupFn>
205 std::shared_ptr<LegacyLookupFnResolver<LegacyLookupFn>>
208 return std::make_shared<LegacyLookupFnResolver<LegacyLookupFn>>(
209 ES, std::move(LegacyLookup), std::move(ErrorReporter));
215 #endif // LLVM_EXECUTIONENGINE_ORC_LEGACY_H Represents a symbol in the JIT.
This class represents lattice values for constants.
SymbolNameSet getResponsibilitySet(const SymbolNameSet &Symbols) final
Returns the subset of the given symbols that the caller is responsible for materializing.
bool isComplete() const
Returns true if all symbols covered by this query have been resolved.
virtual SymbolNameSet getResponsibilitySet(const SymbolNameSet &Symbols)=0
Returns the subset of the given symbols that the caller is responsible for materializing.
void notifySymbolMetRequiredState(const SymbolStringPtr &Name, JITEvaluatedSymbol Sym)
Notify the query that a requested symbol has reached the required state.
std::set< StringRef > LookupSet
Implements SymbolResolver with a pair of supplied function objects for convenience.
LegacyLookupFnResolver(ExecutionSession &ES, LegacyLookupFn LegacyLookup, ErrorReporter ReportError)
std::unique_ptr< LambdaSymbolResolver< typename std::remove_cv< typename std::remove_reference< GetResponsibilitySetFn >::type >::type, typename std::remove_cv< typename std::remove_reference< LookupFn >::type >::type > > createSymbolResolver(GetResponsibilitySetFn &&GetResponsibilitySet, LookupFn &&Lookup)
Creates a SymbolResolver implementation from the pair of supplied function objects.
static int Lookup(ArrayRef< TableEntry > Table, unsigned Opcode)
Tagged union holding either a T or a Error.
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
Expected< SymbolNameSet > getResponsibilitySetWithLegacyFn(const SymbolNameSet &Symbols, FindSymbolFn FindSymbol)
Use the given legacy-style FindSymbol function (i.e.
void legacyFailQuery(AsynchronousSymbolQuery &Q, Error Err)
Legacy adapter. Remove once we kill off the old ORC layers.
void handleComplete()
Call the NotifyComplete callback.
LambdaSymbolResolver(GetResponsibilitySetFnRef &&GetResponsibilitySet, LookupFnRef &&Lookup)
std::function< void(Error)> ErrorReporter
DenseSet< SymbolStringPtr > SymbolNameSet
A set of symbol names (represented by SymbolStringPtrs for.
static void LLVM_ATTRIBUTE_NORETURN ReportError(uint64_t StartOffset, const char *ErrorMsg)
std::pair< iterator, bool > insert(const ValueT &V)
SymbolNameSet lookupWithLegacyFn(ExecutionSession &ES, AsynchronousSymbolQuery &Query, const SymbolNameSet &Symbols, FindSymbolFn FindSymbol)
Use the given legacy-style FindSymbol function (i.e.
Symbol resolution interface.
std::shared_ptr< LegacyLookupFnResolver< LegacyLookupFn > > createLegacyLookupResolver(ExecutionSession &ES, LegacyLookupFn LegacyLookup, std::function< void(Error)> ErrorReporter)
Used to notify clients when symbols can not be found during a lookup.
virtual ~SymbolResolver()=default
SymbolNameSet getResponsibilitySet(const SymbolNameSet &Symbols) final
Returns the subset of the given symbols that the caller is responsible for materializing.
An ExecutionSession represents a running JIT program.
SymbolResolver is a composable interface for looking up symbol flags and addresses using the Asynchro...
Represents a symbol that has been evaluated to an address already.
A symbol query that returns results via a callback when results are ready.
virtual SymbolNameSet lookup(std::shared_ptr< AsynchronousSymbolQuery > Query, SymbolNameSet Symbols)=0
For each symbol in Symbols that can be found, assigns that symbols value in Query.
SymbolNameSet lookup(std::shared_ptr< AsynchronousSymbolQuery > Query, SymbolNameSet Symbols) final
For each symbol in Symbols that can be found, assigns that symbols value in Query.
Lightweight error class with error context and mandatory checking.
SymbolNameSet lookup(std::shared_ptr< AsynchronousSymbolQuery > Query, SymbolNameSet Symbols) final
For each symbol in Symbols that can be found, assigns that symbols value in Query.
An ORC SymbolResolver implementation that uses a legacy findSymbol-like function to perform lookup;...
print Print MemDeps of function