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 rt::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//===----------------------------------------------------------------------===//
17
18#ifndef LLVM_EXECUTIONENGINE_ORC_EPCGENERICDYLIBMANAGER_H
19#define LLVM_EXECUTIONENGINE_ORC_EPCGENERICDYLIBMANAGER_H
20
28
29namespace llvm {
30namespace orc {
31
32class JITDylib;
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.
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: the
52 /// Create methods populate them for the runtime's SPS controller interface,
53 /// but a client targeting a different protocol can build its own Bindings and
54 /// pass them to the constructor.
60
61 /// Create an EPCGenericDylibManager for the ORC runtime's NativeDylibManager
62 /// interface, resolving its symbols in the given JITDylib.
64
65 /// Create an EPCGenericDylibManager for the ORC runtime's NativeDylibManager
66 /// interface, resolving its symbols in the given ExecutionSession's bootstrap
67 /// JITDylib.
69
70 /// Create an EPCGenericDylibManager instance from a given set of
71 /// dylib-manager bindings.
74
75 /// Loads the dylib with the given name.
77
78 /// Looks up symbols within the given dylib.
80 const SymbolLookupSet &Lookup) {
81 std::promise<MSVCPExpected<tpctypes::LookupResult>> RP;
82 auto RF = RP.get_future();
83 lookupAsync(H, Lookup, [&RP](auto R) { RP.set_value(std::move(R)); });
84 return RF.get();
85 }
86
89
90 /// Looks up symbols within the given dylib.
92 SymbolLookupCompleteFn Complete);
93
94 /// Load the dynamic library at the given path and return a handle to it.
95 /// If DylibPath is null this function will return the global handle for
96 /// the target process.
97 Expected<tpctypes::DylibHandle> loadDylib(const char *DylibPath) override;
98
99 /// Search for symbols in the target process.
100 void
102 DylibManager::SymbolLookupCompleteFn Complete) override;
103
104private:
106 Bindings B;
107};
108
109} // end namespace orc
110} // end namespace llvm
111
112#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
rt::Proxy< Expected< tpctypes::DylibHandle >( ExecutorAddr, StringRef, uint64_t)> OpenProxy
Proxy for the executor-side dylib-open function.
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.
rt::Proxy< Expected< tpctypes::LookupResult >( ExecutorAddr, ExecutorAddr, SymbolLookupSet)> ResolveProxy
Proxy for the executor-side symbol-resolution function.
void lookupAsync(tpctypes::DylibHandle H, const SymbolLookupSet &Lookup, SymbolLookupCompleteFn Complete)
Looks up symbols within the given dylib.
static Expected< EPCGenericDylibManager > Create(JITDylib &JD)
Create an EPCGenericDylibManager for the ORC runtime's NativeDylibManager interface,...
Expected< tpctypes::LookupResult > lookup(tpctypes::DylibHandle H, const SymbolLookupSet &Lookup)
Looks up symbols within the given dylib.
EPCGenericDylibManager(ExecutionSession &ES, Bindings B)
Create an EPCGenericDylibManager instance from a given set of dylib-manager bindings.
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...