14 #ifndef LLVM_EXECUTIONENGINE_ORC_LEGACY_H 15 #define LLVM_EXECUTIONENGINE_ORC_LEGACY_H 44 virtual void anchor();
49 template <
typename LookupFlagsFn,
typename LookupFn>
52 template <
typename LookupFlagsFnRef,
typename LookupFnRef>
54 : LookupFlags(
std::forward<LookupFlagsFnRef>(LookupFlags)),
58 return LookupFlags(Symbols);
63 return Lookup(std::move(
Query), std::move(Symbols));
67 LookupFlagsFn LookupFlags;
73 template <
typename LookupFlagsFn,
typename LookupFn>
75 typename std::remove_cv<
76 typename std::remove_reference<LookupFlagsFn>::type>
::type,
77 typename std::remove_cv<
78 typename std::remove_reference<LookupFn>::type>::type>>
81 typename std::remove_cv<
82 typename std::remove_reference<LookupFlagsFn>::type>::type,
83 typename std::remove_cv<
84 typename std::remove_reference<LookupFn>::type>::type>;
85 return llvm::make_unique<LambdaSymbolResolverImpl>(
86 std::forward<LookupFlagsFn>(LookupFlags), std::forward<LookupFn>(
Lookup));
98 std::set<SymbolStringPtr> ResolvedStrings;
111 template <
typename FindSymbolFn>
113 FindSymbolFn FindSymbol) {
116 for (
auto &S : Symbols) {
118 SymbolFlags[S] = Sym.getFlags();
119 else if (
auto Err = Sym.takeError())
120 return std::move(Err);
135 template <
typename FindSymbolFn>
140 bool NewSymbolsResolved =
false;
142 for (
auto &S : Symbols) {
144 if (
auto Addr = Sym.getAddress()) {
147 NewSymbolsResolved =
true;
152 }
else if (
auto Err = Sym.takeError()) {
156 SymbolsNotFound.insert(S);
165 return SymbolsNotFound;
170 template <
typename LegacyLookupFn>
177 : ES(ES), LegacyLookup(
std::move(LegacyLookup)),
178 ReportError(
std::move(ReportError)) {}
182 return std::move(*SymbolFlags);
196 LegacyLookupFn LegacyLookup;
200 template <
typename LegacyLookupFn>
201 std::shared_ptr<LegacyLookupFnResolver<LegacyLookupFn>>
204 return std::make_shared<LegacyLookupFnResolver<LegacyLookupFn>>(
205 ES, std::move(LegacyLookup), std::move(ErrorReporter));
211 #endif // LLVM_EXECUTIONENGINE_ORC_LEGACY_H 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.
Represents a symbol in the JIT.
Compute iterated dominance frontiers using a linear time algorithm.
void resolve(const SymbolStringPtr &Name, JITEvaluatedSymbol Sym)
Set the resolved symbol information for the given symbol name.
std::set< StringRef > LookupSet
void legacyFailQuery(AsynchronousSymbolQuery &Q, Error Err)
Implements SymbolResolver with a pair of supplied function objects for convenience.
LambdaSymbolResolver(LookupFlagsFnRef &&LookupFlags, LookupFnRef &&Lookup)
LegacyLookupFnResolver(ExecutionSession &ES, LegacyLookupFn LegacyLookup, ErrorReporter ReportError)
std::map< SymbolStringPtr, JITSymbolFlags > SymbolFlagsMap
A map from symbol names (as SymbolStringPtrs) to JITSymbolFlags.
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...
void notifySymbolReady()
Notify the query that a requested symbol is ready for execution.
std::function< void(Error)> ErrorReporter
SymbolNameSet lookupWithLegacyFn(ExecutionSession &ES, AsynchronousSymbolQuery &Query, const SymbolNameSet &Symbols, FindSymbolFn FindSymbol)
Use the given legacy-style FindSymbol function (i.e.
Symbol resolution interface.
virtual SymbolFlagsMap lookupFlags(const SymbolNameSet &Symbols)=0
Returns the flags for each symbol in Symbols that can be found, along with the set of symbol that cou...
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
Expected< SymbolFlagsMap > lookupFlagsWithLegacyFn(const SymbolNameSet &Symbols, FindSymbolFn FindSymbol)
Use the given legacy-style FindSymbol function (i.e.
SymbolFlagsMap lookupFlags(const SymbolNameSet &Symbols) final
Returns the flags for each symbol in Symbols that can be found, along with the set of symbol that cou...
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.
SymbolFlagsMap lookupFlags(const SymbolNameSet &Symbols) final
Returns the flags for each symbol in Symbols that can be found, along with the set of symbol that cou...
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.
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)
std::set< SymbolStringPtr > SymbolNameSet
A set of symbol names (represented by SymbolStringPtrs for.
void handleFullyReady()
Calls the NotifySymbolsReady callback.
std::unique_ptr< LambdaSymbolResolver< typename std::remove_cv< typename std::remove_reference< LookupFlagsFn >::type >::type, typename std::remove_cv< typename std::remove_reference< LookupFn >::type >::type > > createSymbolResolver(LookupFlagsFn &&LookupFlags, LookupFn &&Lookup)
Creates a SymbolResolver implementation from the pair of supplied function objects.