LLVM 19.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
14
15namespace llvm {
16namespace orc {
17namespace shared {
18
19template <>
21 SymbolLookupSet::value_type> {
22public:
23 static size_t size(const SymbolLookupSet::value_type &V) {
25 *V.first, V.second == SymbolLookupFlags::RequiredSymbol);
26 }
27
28 static bool serialize(SPSOutputBuffer &OB,
31 OB, *V.first, V.second == SymbolLookupFlags::RequiredSymbol);
32 }
33};
34
35template <>
38public:
39 static constexpr bool available = true;
40};
41
42template <>
44 ExecutorProcessControl::LookupRequest> {
47
48public:
50 return MemberSerialization::size(ExecutorAddr(LR.Handle), LR.Symbols);
51 }
52
53 static bool serialize(SPSOutputBuffer &OB,
55 return MemberSerialization::serialize(OB, ExecutorAddr(LR.Handle),
56 LR.Symbols);
57 }
58};
59
60} // end namespace shared
61
65 SymbolAddrs SAs;
66 if (auto Err = EPC.getBootstrapSymbols(
67 {{SAs.Instance, rt::SimpleExecutorDylibManagerInstanceName},
68 {SAs.Open, rt::SimpleExecutorDylibManagerOpenWrapperName},
69 {SAs.Lookup, rt::SimpleExecutorDylibManagerLookupWrapperName}}))
70 return std::move(Err);
71 return EPCGenericDylibManager(EPC, std::move(SAs));
72}
73
74Expected<tpctypes::DylibHandle> EPCGenericDylibManager::open(StringRef Path,
75 uint64_t Mode) {
77 if (auto Err =
79 SAs.Open, H, SAs.Instance, Path, Mode))
80 return std::move(Err);
81 return H;
82}
83
84void EPCGenericDylibManager::lookupAsync(tpctypes::DylibHandle H,
86 SymbolLookupCompleteFn Complete) {
88 SAs.Lookup,
89 [Complete = std::move(Complete)](
90 Error SerializationErr,
92 if (SerializationErr) {
93 cantFail(Result.takeError());
94 Complete(std::move(SerializationErr));
95 }
96 Complete(std::move(Result));
97 },
98 SAs.Instance, H, Lookup);
99}
100
101void EPCGenericDylibManager::lookupAsync(tpctypes::DylibHandle H,
103 SymbolLookupCompleteFn Complete) {
105 SAs.Lookup,
106 [Complete = std::move(Complete)](
107 Error SerializationErr,
109 if (SerializationErr) {
110 cantFail(Result.takeError());
111 Complete(std::move(SerializationErr));
112 }
113 Complete(std::move(Result));
114 },
115 SAs.Instance, H, Lookup);
116}
117
118} // end namespace orc
119} // end namespace llvm
#define H(x, y, z)
Definition: MD5.cpp:57
static cl::opt< RegAllocEvictionAdvisorAnalysis::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysis::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:160
Tagged union holding either a T or a Error.
Definition: Error.h:474
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
static Expected< EPCGenericDylibManager > CreateWithDefaultBootstrapSymbols(ExecutorProcessControl &EPC)
Create an EPCGenericMemoryAccess instance from a given set of function addrs.
Represents an address in the executor process.
ExecutorProcessControl supports interaction with a JIT target process.
Error getBootstrapSymbols(ArrayRef< std::pair< ExecutorAddr &, StringRef > > Pairs) const
For each (ExecutorAddr&, StringRef) pair, looks up the string in the bootstrap symbols map and writes...
A set of symbols to look up, each associated with a SymbolLookupFlags value.
Definition: Core.h:183
std::pair< SymbolStringPtr, SymbolLookupFlags > value_type
Definition: Core.h:185
A utility class for serializing to a blob from a variadic list.
Output char buffer with overflow check.
static bool serialize(SPSOutputBuffer &OB, const ExecutorProcessControl::LookupRequest &LR)
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.
unique_function is a type-erasing functor similar to std::function.
shared::SPSExpected< shared::SPSSequence< shared::SPSExecutorSymbolDef > >(shared::SPSExecutorAddr, shared::SPSExecutorAddr, shared::SPSRemoteSymbolLookupSet) SPSSimpleExecutorDylibManagerLookupSignature
Definition: OrcRTBridge.h:60
shared::SPSExpected< shared::SPSExecutorAddr >(shared::SPSExecutorAddr, shared::SPSString, uint64_t) SPSSimpleExecutorDylibManagerOpenSignature
Definition: OrcRTBridge.h:55
std::vector< RemoteSymbolLookupSetElement > RemoteSymbolLookupSet
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Definition: Error.h:749
Function addresses for memory access.
A pair of a dylib and a set of symbols to be looked up.