LLVM 23.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
15
16namespace llvm {
17namespace orc {
18namespace shared {
19
20template <>
22 SymbolLookupSet::value_type> {
23public:
24 static size_t size(const SymbolLookupSet::value_type &V) {
26 *V.first, V.second == SymbolLookupFlags::RequiredSymbol);
27 }
28
29 static bool serialize(SPSOutputBuffer &OB,
32 OB, *V.first, V.second == SymbolLookupFlags::RequiredSymbol);
33 }
34};
35
36template <>
39public:
40 static constexpr bool available = true;
41};
42
43} // end namespace shared
44
48 SymbolAddrs SAs;
49 if (auto Err = EPC.getBootstrapSymbols(
50 {{SAs.Instance, rt::SimpleExecutorDylibManagerInstanceName},
51 {SAs.Open, rt::SimpleExecutorDylibManagerOpenWrapperName},
52 {SAs.Resolve, rt::SimpleExecutorDylibManagerResolveWrapperName}}))
53 return std::move(Err);
54 return EPCGenericDylibManager(EPC, std::move(SAs));
55}
56
60 auto &ES = JD.getExecutionSession();
61 SymbolAddrs SAs;
62 if (auto Err = lookupAndRecordAddrs(
64 {
65 {ES.intern(SNs.InstanceName), &SAs.Instance},
66 {ES.intern(SNs.OpenName), &SAs.Open},
67 {ES.intern(SNs.ResolveName), &SAs.Resolve},
68 }))
69 return std::move(Err);
70 return EPCGenericDylibManager(ES.getExecutorProcessControl(), std::move(SAs));
71}
72
78
80 uint64_t Mode) {
82 if (auto Err =
84 SAs.Open, H, SAs.Instance, Path, Mode))
85 return std::move(Err);
86 return H;
87}
88
91 SymbolLookupCompleteFn Complete) {
93 SAs.Resolve,
94 [Complete = std::move(Complete)](
95 Error SerializationErr,
97 if (SerializationErr) {
98 cantFail(Result.takeError());
99 Complete(std::move(SerializationErr));
100 return;
101 }
102 Complete(std::move(Result));
103 },
104 SAs.Instance, H, Lookup);
105}
106
109 SymbolLookupCompleteFn Complete) {
111 SAs.Resolve,
112 [Complete = std::move(Complete)](
113 Error SerializationErr,
115 if (SerializationErr) {
116 cantFail(Result.takeError());
117 Complete(std::move(SerializationErr));
118 return;
119 }
120 Complete(std::move(Result));
121 },
122 SAs.Instance, H, Lookup);
123}
124
126EPCGenericDylibManager::loadDylib(const char *DylibPath) {
127 return open(DylibPath, 0);
128}
129
133 lookupAsync(H, Symbols, std::move(Complete));
134}
135
136} // end namespace orc
137} // 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)
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
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
LLVM_ABI Expected< tpctypes::DylibHandle > loadDylib(const char *DylibPath) override
Load the dynamic library at the given path and return a handle to it.
LLVM_ABI void lookupSymbolsAsync(tpctypes::DylibHandle H, const SymbolLookupSet &Symbols, DylibManager::SymbolLookupCompleteFn Complete) override
Search for symbols in the target process.
static LLVM_ABI Expected< EPCGenericDylibManager > CreateWithDefaultBootstrapSymbols(ExecutorProcessControl &EPC)
Create an EPCGenericDylibManager instance by looking up the LLVM-style SimpleExecutorDylibManager sym...
LLVM_ABI void lookupAsync(tpctypes::DylibHandle H, const SymbolLookupSet &Lookup, SymbolLookupCompleteFn Complete)
Looks up symbols within the given dylib.
static LLVM_ABI Expected< EPCGenericDylibManager > Create(JITDylib &JD, rt::SimpleExecutorDylibManagerSymbolNames SNs=rt::orc_rt_NativeDylibManagerSPSSymbols)
Create an EPCGenericDylibManager using the given implementation symbol names.
LLVM_ABI Expected< tpctypes::DylibHandle > open(StringRef Path, uint64_t Mode)
Loads the dylib with the given name.
EPCGenericDylibManager(ExecutorProcessControl &EPC, SymbolAddrs SAs)
Create an EPCGenericDylibManager instance from a given set of function addrs.
unique_function< void(Expected< tpctypes::LookupResult >)> SymbolLookupCompleteFn
An ExecutionSession represents a running JIT program.
Definition Core.h:1131
JITDylib & getBootstrapJITDylib()
Returns a reference to the bootstrap JITDylib.
Definition Core.h:1192
Represents an address in the executor process.
ExecutorProcessControl supports interaction with a JIT target process.
Represents a JIT'd dynamic library.
Definition Core.h:695
ExecutionSession & getExecutionSession() const
Get a reference to the ExecutionSession for this JITDylib.
Definition Core.h:714
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.
shared::SPSExpected< shared::SPSSequence< shared::SPSOptional< shared::SPSExecutorAddr > > >( shared::SPSExecutorAddr, shared::SPSExecutorAddr, shared::SPSRemoteSymbolLookupSet) SPSSimpleExecutorDylibManagerResolveSignature
shared::SPSExpected< shared::SPSExecutorAddr >(shared::SPSExecutorAddr, shared::SPSString, uint64_t) SPSSimpleExecutorDylibManagerOpenSignature
Definition OrcRTBridge.h:96
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:173
std::vector< RemoteSymbolLookupSetElement > RemoteSymbolLookupSet
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.
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Definition Error.h:769
Symbol names for dylib management implementation.
Definition OrcRTBridge.h:85