LLVM 24.0.0git
EPCGenericDylibManager.cpp
Go to the documentation of this file.
1//===------- EPCGenericDylibManager.cpp -- Dylib management via EPC -------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10
16
17namespace llvm {
18namespace orc {
19namespace shared {
20
21// Serialize a local SymbolLookupSet directly as an SPSRemoteSymbolLookupSet,
22// avoiding a std::string copy of each (potentially large) symbol name.
23template <>
25 SymbolLookupSet::value_type> {
26public:
27 static size_t size(const SymbolLookupSet::value_type &V) {
29 *V.first, V.second == SymbolLookupFlags::RequiredSymbol);
30 }
31
32 static bool serialize(SPSOutputBuffer &OB,
35 OB, *V.first, V.second == SymbolLookupFlags::RequiredSymbol);
36 }
37};
38
39template <>
42public:
43 static constexpr bool available = true;
44};
45
46} // end namespace shared
47
48namespace {
49
54
55} // namespace
56
58 auto &ES = JD.getExecutionSession();
59 Bindings B;
60 // Instance is the executor-side manager object -- a data symbol passed as the
61 // first argument to each call, not a wrapper to proxy.
62 if (auto Err = lookupAndRecordAddrs(
65 &B.Instance}}))
66 return std::move(Err);
67 // The proxies resolve to the specs' default (NativeDylibManager) names.
68 if (auto Err = rt::buildProxies(JD, rt::proxyInit<OpenSpec>(&B.Open),
69 rt::proxyInit<ResolveSpec>(&B.Resolve)))
70 return std::move(Err);
71 return EPCGenericDylibManager(ES, std::move(B));
72}
73
76 return Create(ES.getBootstrapJITDylib());
77}
78
80 uint64_t Mode) {
81 return B.Open(ES, B.Instance, Path, Mode);
82}
83
86 SymbolLookupCompleteFn Complete) {
87 B.Resolve(std::move(Complete), ES, B.Instance, H, Lookup);
88}
89
91EPCGenericDylibManager::loadDylib(const char *DylibPath) {
92 return open(DylibPath, 0);
93}
94
98 lookupAsync(H, Symbols, std::move(Complete));
99}
100
101} // end namespace orc
102} // end namespace llvm
#define H(x, y, z)
Definition MD5.cpp:56
static cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))
static int Lookup(ArrayRef< TableEntry > Table, unsigned Opcode)
Tagged union holding either a T or a Error.
Definition Error.h:485
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
unique_function< void(Expected< tpctypes::LookupResult >)> SymbolLookupCompleteFn
rt::Proxy< Expected< tpctypes::DylibHandle >( ExecutorAddr, StringRef, uint64_t)> OpenProxy
Proxy for the executor-side dylib-open function.
Expected< tpctypes::DylibHandle > loadDylib(const char *DylibPath) override
Load the dynamic library at the given path and return a handle to it.
void lookupSymbolsAsync(tpctypes::DylibHandle H, const SymbolLookupSet &Symbols, DylibManager::SymbolLookupCompleteFn Complete) override
Search for symbols in the target process.
rt::Proxy< Expected< tpctypes::LookupResult >( ExecutorAddr, ExecutorAddr, SymbolLookupSet)> ResolveProxy
Proxy for the executor-side symbol-resolution function.
void lookupAsync(tpctypes::DylibHandle H, const SymbolLookupSet &Lookup, SymbolLookupCompleteFn Complete)
Looks up symbols within the given dylib.
static Expected< EPCGenericDylibManager > Create(JITDylib &JD)
Create an EPCGenericDylibManager for the ORC runtime's NativeDylibManager interface,...
Expected< tpctypes::DylibHandle > open(StringRef Path, uint64_t Mode)
Loads the dylib with the given name.
EPCGenericDylibManager(ExecutionSession &ES, Bindings B)
Create an EPCGenericDylibManager instance from a given set of dylib-manager bindings.
unique_function< void(Expected< tpctypes::LookupResult >)> SymbolLookupCompleteFn
An ExecutionSession represents a running JIT program.
Definition Core.h:1111
Represents a JIT'd dynamic library.
Definition Core.h:675
ExecutionSession & getExecutionSession() const
Get a reference to the ExecutionSession for this JITDylib.
Definition Core.h:694
A set of symbols to look up, each associated with a SymbolLookupFlags value.
std::pair< SymbolStringPtr, SymbolLookupFlags > value_type
A utility class for serializing to a blob from a variadic list.
Output char buffer with overflow check.
Specialize to describe how to serialize/deserialize to/from the given concrete type.
Specialize this to implement 'trivial' sequence serialization for a concrete sequence type.
constexpr char NativeDylibManagerInstanceName[]
The executor-side dylib-manager instance.
ProxyInit< FnT > proxyInit(Proxy< FnT > *P, typename Proxy< FnT >::DispatchFn Dispatch, StringRef Name, SymbolLookupFlags LookupFlags=SymbolLookupFlags::RequiredSymbol)
Definition Proxy.h:167
Error buildProxies(JITDylib &JD)
buildProxies base case.
Definition Proxy.h:188
SPSTuple< SPSString, bool > SPSRemoteSymbolLookupSetElement
ExecutorAddr DylibHandle
A handle used to represent a loaded dylib in the target process.
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...
Definition Core.h:153
LLVM_ABI void lookupAndRecordAddrs(unique_function< void(Error)> OnRecorded, ExecutionSession &ES, LookupKind K, const JITDylibSearchOrder &SearchOrder, std::vector< std::pair< SymbolStringPtr, ExecutorAddr * > > Pairs, SymbolLookupFlags LookupFlags=SymbolLookupFlags::RequiredSymbol)
Record addresses of the given symbols in the given ExecutorAddrs.
This is an optimization pass for GlobalISel generic memory operations.
The resolved controller-side handle to an executor-side dylib manager: the address of the manager ins...
Open the dylib at the given path with the given mode flags; returns a handle to it.
Resolve the given lookup set within the given dylib.