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
26
27namespace llvm {
28namespace orc {
29
30class SymbolLookupSet;
31
33public:
34 /// Function addresses for memory access.
40
41 /// Create an EPCGenericMemoryAccess instance from a given set of
42 /// function addrs.
45
46 /// Create an EPCGenericMemoryAccess instance from a given set of
47 /// function addrs.
49 : EPC(EPC), SAs(SAs) {}
50
51 /// Loads the dylib with the given name.
53
54 /// Looks up symbols within the given dylib.
56 const SymbolLookupSet &Lookup) {
57 std::promise<MSVCPExpected<tpctypes::LookupResult>> RP;
58 auto RF = RP.get_future();
59 lookupAsync(H, Lookup, [&RP](auto R) { RP.set_value(std::move(R)); });
60 return RF.get();
61 }
62
63 /// Looks up symbols within the given dylib.
66 std::promise<MSVCPExpected<tpctypes::LookupResult>> RP;
67 auto RF = RP.get_future();
68 lookupAsync(H, Lookup, [&RP](auto R) { RP.set_value(std::move(R)); });
69 return RF.get();
70 }
71
74
75 /// Looks up symbols within the given dylib.
78 SymbolLookupCompleteFn Complete);
79
80 /// 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.
89 loadDylib(const char *DylibPath) override;
90
91 /// Search for symbols in the target process.
92 LLVM_ABI void
94 DylibManager::SymbolLookupCompleteFn Complete) override;
95
96private:
98 SymbolAddrs SAs;
99};
100
101} // end namespace orc
102} // end namespace llvm
103
104#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)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
Tagged union holding either a T or a Error.
Definition Error.h:485
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
unique_function< void(Expected< std::vector< 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.
static LLVM_ABI Expected< EPCGenericDylibManager > CreateWithDefaultBootstrapSymbols(ExecutorProcessControl &EPC)
Create an EPCGenericMemoryAccess instance from a given set of function addrs.
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.
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 EPCGenericMemoryAccess instance from a given set of function addrs.
LLVM_ABI void lookupSymbolsAsync(ArrayRef< DylibManager::LookupRequest > Request, DylibManager::SymbolLookupCompleteFn Complete) override
Search for symbols in the target process.
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
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.
std::vector< RemoteSymbolLookupSetElement > RemoteSymbolLookupSet
This is an optimization pass for GlobalISel generic memory operations.