LLVM 23.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 making calls to
10// ExecutorProcessControl::callWrapper.
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
27
28namespace llvm {
29namespace orc {
30
31class JITDylib;
32class SymbolLookupSet;
33
35public:
36 /// Function addresses for memory access.
42
43 /// Create an EPCGenericDylibManager instance by looking up the LLVM-style
44 /// SimpleExecutorDylibManager symbol names in the EPC's bootstrap table.
47
48 /// Create an EPCGenericDylibManager using the given implementation symbol
49 /// names. These will be looked up in the given JITDylib.
53
54 /// Create an EPCGenericDylibManager using the given implementation symbol
55 /// names. These will be looked up in the given ExecutionSession's bootstrap
56 /// JITDylib.
60
61 /// Create an EPCGenericDylibManager instance from a given set of function
62 /// addrs.
64 : EPC(EPC), SAs(SAs) {}
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
78 /// Looks up symbols within the given dylib.
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.
93 SymbolLookupCompleteFn Complete);
94
95 /// Looks up symbols within the given dylib.
98 SymbolLookupCompleteFn Complete);
99
100 /// Load the dynamic library at the given path and return a handle to it.
101 /// If DylibPath is null this function will return the global handle for
102 /// the target process.
104 loadDylib(const char *DylibPath) override;
105
106 /// Search for symbols in the target process.
107 LLVM_ABI void
109 DylibManager::SymbolLookupCompleteFn Complete) override;
110
111private:
113 SymbolAddrs SAs;
114};
115
116} // end namespace orc
117} // end namespace llvm
118
119#endif // LLVM_EXECUTIONENGINE_ORC_EPCGENERICDYLIBMANAGER_H
#define LLVM_ABI
Definition Compiler.h:213
#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
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 EPCGenericDylibManager instance by looking up the LLVM-style SimpleExecutorDylibManager sym...
Expected< tpctypes::LookupResult > lookup(tpctypes::DylibHandle H, const RemoteSymbolLookupSet &Lookup)
Looks up symbols within the given dylib.
LLVM_ABI 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.
static LLVM_ABI Expected< EPCGenericDylibManager > Create(JITDylib &JD, rt::SimpleExecutorDylibManagerSymbolNames SNs=rt::orc_rt_NativeDylibManagerSPSSymbols)
Create an EPCGenericDylibManager using the given implementation symbol names.
LLVM_ABI Expected< tpctypes::DylibHandle > open(StringRef Path, uint64_t Mode)
Loads the dylib with the given name.
EPCGenericDylibManager(ExecutorProcessControl &EPC, SymbolAddrs SAs)
Create an EPCGenericDylibManager instance from a given set of function addrs.
unique_function< void(Expected< tpctypes::LookupResult >)> SymbolLookupCompleteFn
An ExecutionSession represents a running JIT program.
Definition Core.h:1131
Represents an address in the executor process.
ExecutorProcessControl supports interaction with a JIT target process.
Represents a JIT'd dynamic library.
Definition Core.h:695
A set of symbols to look up, each associated with a SymbolLookupFlags value.
unique_function is a type-erasing functor similar to std::function.
const SimpleExecutorDylibManagerSymbolNames orc_rt_NativeDylibManagerSPSSymbols
Default symbol names for the ORC runtime's NativeDylibManager SPS interface.
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.
Symbol names for dylib management implementation.
Definition OrcRTBridge.h:85