LLVM 24.0.0git
EPCGenericDylibManager.h
Go to the documentation of this file.
1//===- EPCGenericDylibManager.h -- Generic EPC Dylib management -*- C++ -*-===//
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//
9// Implements dylib loading and searching by calling executor-side wrapper
10// functions through Proxy objects.
11//
12// This simplifies the implementaton of new ExecutorProcessControl instances,
13// as this implementation will always work (at the cost of some performance
14// overhead for the calls).
15//
16// This header is protocol-agnostic. To build an instance that targets the ORC
17// runtime's SPS controller interface, see EPCGenericDylibManagerSPS.h.
18//
19//===----------------------------------------------------------------------===//
20
21#ifndef LLVM_EXECUTIONENGINE_ORC_EPCGENERICDYLIBMANAGER_H
22#define LLVM_EXECUTIONENGINE_ORC_EPCGENERICDYLIBMANAGER_H
23
29
30namespace llvm {
31namespace orc {
32
33class SymbolLookupSet;
34
36public:
37 /// Proxy for the executor-side dylib-open function. Given the manager
38 /// instance address, a path and mode flags it returns a handle to the opened
39 /// dylib.
40 using OpenProxy =
42
43 /// Proxy for the executor-side symbol-resolution function. Given the manager
44 /// instance address, a dylib handle and a lookup set it returns the resolved
45 /// addresses.
48
49 /// The resolved controller-side handle to an executor-side dylib manager: the
50 /// address of the manager instance (passed as the first argument to each
51 /// call) plus the proxies for its functions. These are protocol-agnostic:
52 /// sps::createEPCGenericDylibManager populates them for the runtime's SPS
53 /// controller interface, but a client targeting a different protocol can
54 /// build its own Bindings and pass them to the constructor.
60
61 /// Create an EPCGenericDylibManager instance from a given set of
62 /// dylib-manager bindings.
65
66 /// Loads the dylib with the given name.
68
69 /// Looks up symbols within the given dylib.
71 const SymbolLookupSet &Lookup) {
72 std::promise<MSVCPExpected<tpctypes::LookupResult>> RP;
73 auto RF = RP.get_future();
74 lookupAsync(H, Lookup, [&RP](auto R) { RP.set_value(std::move(R)); });
75 return RF.get();
76 }
77
80
81 /// Looks up symbols within the given dylib.
83 SymbolLookupCompleteFn Complete);
84
85 /// Load the dynamic library at the given path and return a handle to it.
86 /// If DylibPath is null this function will return the global handle for
87 /// the target process.
88 Expected<tpctypes::DylibHandle> loadDylib(const char *DylibPath) override;
89
90 /// Search for symbols in the target process.
91 void
93 DylibManager::SymbolLookupCompleteFn Complete) override;
94
95private:
97 Bindings B;
98};
99
100} // end namespace orc
101} // end namespace llvm
102
103#endif // LLVM_EXECUTIONENGINE_ORC_EPCGENERICDYLIBMANAGER_H
uint64_t uint64_t
#define LLVM_ABI
Definition Compiler.h:211
#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
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.
void lookupAsync(tpctypes::DylibHandle H, const SymbolLookupSet &Lookup, SymbolLookupCompleteFn Complete)
Looks up symbols within the given dylib.
Expected< tpctypes::LookupResult > lookup(tpctypes::DylibHandle H, const SymbolLookupSet &Lookup)
Looks up symbols within the given dylib.
Proxy< Expected< tpctypes::LookupResult >( ExecutorAddr, ExecutorAddr, SymbolLookupSet)> ResolveProxy
Proxy for the executor-side symbol-resolution function.
EPCGenericDylibManager(ExecutionSession &ES, Bindings B)
Create an EPCGenericDylibManager instance from a given set of dylib-manager bindings.
Proxy< Expected< tpctypes::DylibHandle >(ExecutorAddr, StringRef, uint64_t)> OpenProxy
Proxy for the executor-side dylib-open function.
unique_function< void(Expected< tpctypes::LookupResult >)> SymbolLookupCompleteFn
An ExecutionSession represents a running JIT program.
Definition Core.h:1096
Represents an address in the executor process.
A set of symbols to look up, each associated with a SymbolLookupFlags value.
unique_function is a type-erasing functor similar to std::function.
ExecutorAddr DylibHandle
A handle used to represent a loaded dylib in the target process.
This is an optimization pass for GlobalISel generic memory operations.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1933
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:879
The resolved controller-side handle to an executor-side dylib manager: the address of the manager ins...