14 #ifndef LLVM_EXECUTIONENGINE_ORC_LEGACY_H 15 #define LLVM_EXECUTIONENGINE_ORC_LEGACY_H 44 virtual void anchor();
49 template <
typename GetResponsibilitySetFn,
typename LookupFn>
52 template <
typename GetResponsibilitySetFnRef,
typename LookupFnRef>
55 : GetResponsibilitySet(
56 std::forward<GetResponsibilitySetFnRef>(GetResponsibilitySet)),
60 return GetResponsibilitySet(Symbols);
65 return Lookup(std::move(
Query), std::move(Symbols));
69 GetResponsibilitySetFn GetResponsibilitySet;
75 template <
typename GetResponsibilitySetFn,
typename LookupFn>
77 typename std::remove_cv<
78 typename std::remove_reference<GetResponsibilitySetFn>::type>
::type,
79 typename std::remove_cv<
80 typename std::remove_reference<LookupFn>::type>::type>>
84 typename std::remove_cv<
85 typename std::remove_reference<GetResponsibilitySetFn>::type>::type,
86 typename std::remove_cv<
87 typename std::remove_reference<LookupFn>::type>::type>;
88 return llvm::make_unique<LambdaSymbolResolverImpl>(
89 std::forward<GetResponsibilitySetFn>(GetResponsibilitySet),
90 std::forward<LookupFn>(
Lookup));
103 std::set<SymbolStringPtr> ResolvedStrings;
116 template <
typename FindSymbolFn>
119 FindSymbolFn FindSymbol) {
122 for (
auto &S : Symbols) {
124 if (!Sym.getFlags().isStrong())
126 }
else if (
auto Err = Sym.takeError())
127 return std::move(Err);
142 template <
typename FindSymbolFn>
147 bool NewSymbolsResolved =
false;
149 for (
auto &S : Symbols) {
151 if (
auto Addr = Sym.getAddress()) {
154 NewSymbolsResolved =
true;
159 }
else if (
auto Err = Sym.takeError()) {
163 SymbolsNotFound.
insert(S);
172 return SymbolsNotFound;
177 template <
typename LegacyLookupFn>
184 : ES(ES), LegacyLookup(
std::move(LegacyLookup)),
185 ReportError(
std::move(ReportError)) {}
188 if (
auto ResponsibilitySet =
190 return std::move(*ResponsibilitySet);
204 LegacyLookupFn LegacyLookup;
208 template <
typename LegacyLookupFn>
209 std::shared_ptr<LegacyLookupFnResolver<LegacyLookupFn>>
212 return std::make_shared<LegacyLookupFnResolver<LegacyLookupFn>>(
213 ES, std::move(LegacyLookup), std::move(ErrorReporter));
219 #endif // LLVM_EXECUTIONENGINE_ORC_LEGACY_H std::function< void(Expected< LookupResult >)> OnResolvedFunction
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.
void resolve(const SymbolStringPtr &Name, JITEvaluatedSymbol Sym)
Set the resolved symbol information for the given symbol name.
virtual SymbolNameSet getResponsibilitySet(const SymbolNameSet &Symbols)=0
Returns the subset of the given symbols that the caller is responsible for materializing.
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 notifySymbolReady()
Notify the query that a requested symbol is ready for execution.
void legacyFailQuery(AsynchronousSymbolQuery &Q, Error Err)
Legacy adapter. Remove once we kill off the old ORC layers.
LambdaSymbolResolver(GetResponsibilitySetFnRef &&GetResponsibilitySet, LookupFnRef &&Lookup)
std::function< void(Error)> ErrorReporter
DenseSet< SymbolStringPtr > SymbolNameSet
A set of symbol names (represented by SymbolStringPtrs for.
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.
static void Query(const MachineInstr &MI, AliasAnalysis &AA, bool &Read, bool &Write, bool &Effects, bool &StackPointer)
bool isFullyReady() const
Returns true if all symbols covered by this query are ready.
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
bool isFullyResolved() const
Returns true if all symbols covered by this query have been resolved.
void handleFullyResolved()
Call the NotifySymbolsResolved callback.
static void LLVM_ATTRIBUTE_NORETURN ReportError(uint32_t StartOffset, const char *ErrorMsg)
void handleFullyReady()
Calls the NotifySymbolsReady callback.