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 JITDylib;
34class SymbolLookupSet;
35
37public:
38 /// Proxy for the executor-side dylib-open function. Given the manager
39 /// instance address, a path and mode flags it returns a handle to the opened
40 /// dylib.
41 using OpenProxy =
43
44 /// Proxy for the executor-side symbol-resolution function. Given the manager
45 /// instance address, a dylib handle and a lookup set it returns the resolved
46 /// addresses.
49
50 /// The resolved controller-side handle to an executor-side dylib manager: the
51 /// address of the manager instance (passed as the first argument to each
52 /// call) plus the proxies for its functions. These are protocol-agnostic:
53 /// sps::createEPCGenericDylibManager populates them for the runtime's SPS
54 /// controller interface, but a client targeting a different protocol can
55 /// build its own Bindings and pass them to the constructor.
61
62 /// Create an EPCGenericDylibManager instance from a given set of
63 /// dylib-manager bindings.
66
67 /// Loads the dylib with the given name.
69
70 /// Looks up symbols within the given dylib.
72 const SymbolLookupSet &Lookup) {
73 std::promise<MSVCPExpected<tpctypes::LookupResult>> RP;
74 auto RF = RP.get_future();
75 lookupAsync(H, Lookup, [&RP](auto R) { RP.set_value(std::move(R)); });
76 return RF.get();
77 }
78
81
82 /// Looks up symbols within the given dylib.
84 SymbolLookupCompleteFn Complete);
85
86 /// Load the dynamic library at the given path and return a handle to it.
87 /// If DylibPath is null this function will return the global handle for
88 /// the target process.
89 Expected<tpctypes::DylibHandle> loadDylib(const char *DylibPath) override;
90
91 /// Search for symbols in the target process.
92 void
94 DylibManager::SymbolLookupCompleteFn Complete) override;
95
96private:
98 Bindings B;
99};
100
101} // end namespace orc
102} // end namespace llvm
103
104#endif // LLVM_EXECUTIONENGINE_ORC_EPCGENERICDYLIBMANAGER_H
#define LLVM_ABI
Definition Compiler.h:215
#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:1111
Represents an address in the executor process.
Represents a JIT'd dynamic library.
Definition Core.h:675
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:1917
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:878
The resolved controller-side handle to an executor-side dylib manager: the address of the manager ins...