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
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
42} // end namespace shared
43
47 SymbolAddrs SAs;
48 if (auto Err = EPC.getBootstrapSymbols(
49 {{SAs.Instance, rt::SimpleExecutorDylibManagerInstanceName},
50 {SAs.Open, rt::SimpleExecutorDylibManagerOpenWrapperName},
51 {SAs.Resolve, rt::SimpleExecutorDylibManagerResolveWrapperName}}))
52 return std::move(Err);
53 return EPCGenericDylibManager(EPC, std::move(SAs));
54}
55
57 uint64_t Mode) {
59 if (auto Err =
61 SAs.Open, H, SAs.Instance, Path, Mode))
62 return std::move(Err);
63 return H;
64}
65
68 SymbolLookupCompleteFn Complete) {
70 SAs.Resolve,
71 [Complete = std::move(Complete)](
72 Error SerializationErr,
74 Result) mutable {
75 if (SerializationErr) {
76 cantFail(Result.takeError());
77 Complete(std::move(SerializationErr));
78 return;
79 }
80 Complete(std::move(Result));
81 },
82 H, Lookup);
83}
84
87 SymbolLookupCompleteFn Complete) {
89 SAs.Resolve,
90 [Complete = std::move(Complete)](
91 Error SerializationErr,
93 Result) mutable {
94 if (SerializationErr) {
95 cantFail(Result.takeError());
96 Complete(std::move(SerializationErr));
97 return;
98 }
99 Complete(std::move(Result));
100 },
101 H, Lookup);
102}
103
105EPCGenericDylibManager::loadDylib(const char *DylibPath) {
106 return open(DylibPath, 0);
107}
108
112 lookupAsync(H, Symbols, std::move(Complete));
113}
114
115} // end namespace orc
116} // 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 EPCGenericMemoryAccess instance from a given set of function addrs.
LLVM_ABI void lookupAsync(tpctypes::DylibHandle H, const SymbolLookupSet &Lookup, SymbolLookupCompleteFn Complete)
Looks up symbols within the given dylib.
LLVM_ABI Expected< tpctypes::DylibHandle > open(StringRef Path, uint64_t Mode)
Loads the dylib with the given name.
unique_function< void(Expected< tpctypes::LookupResult >)> SymbolLookupCompleteFn
Represents an address in the executor process.
ExecutorProcessControl supports interaction with a JIT target process.
A set of symbols to look up, each associated with a SymbolLookupFlags value.
Definition Core.h:199
std::pair< SymbolStringPtr, SymbolLookupFlags > value_type
Definition Core.h:201
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::SPSExecutorAddr >(shared::SPSExecutorAddr, shared::SPSString, uint64_t) SPSSimpleExecutorDylibManagerOpenSignature
Definition OrcRTBridge.h:83
shared::SPSExpected< shared::SPSSequence< shared::SPSOptional< shared::SPSExecutorSymbolDef > > >( shared::SPSExecutorAddr, shared::SPSRemoteSymbolLookupSet) SPSSimpleExecutorDylibManagerResolveSignature
Definition OrcRTBridge.h:87
SPSTuple< SPSString, bool > SPSRemoteSymbolLookupSetElement
ExecutorAddr DylibHandle
A handle used to represent a loaded dylib in the target process.
std::vector< RemoteSymbolLookupSetElement > RemoteSymbolLookupSet
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