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
25
26namespace llvm {
27namespace orc {
28
29class SymbolLookupSet;
30
32public:
33 /// Function addresses for memory access.
39
40 /// Create an EPCGenericMemoryAccess instance from a given set of
41 /// function addrs.
44
45 /// Create an EPCGenericMemoryAccess instance from a given set of
46 /// function addrs.
48 : EPC(EPC), SAs(SAs) {}
49
50 /// Loads the dylib with the given name.
52
53 /// Looks up symbols within the given dylib.
55 const SymbolLookupSet &Lookup) {
56 std::promise<MSVCPExpected<tpctypes::LookupResult>> RP;
57 auto RF = RP.get_future();
58 lookupAsync(H, Lookup, [&RP](auto R) { RP.set_value(std::move(R)); });
59 return RF.get();
60 }
61
62 /// Looks up symbols within the given dylib.
65 std::promise<MSVCPExpected<tpctypes::LookupResult>> RP;
66 auto RF = RP.get_future();
67 lookupAsync(H, Lookup, [&RP](auto R) { RP.set_value(std::move(R)); });
68 return RF.get();
69 }
70
73
74 /// Looks up symbols within the given dylib.
77 SymbolLookupCompleteFn Complete);
78
79 /// Looks up symbols within the given dylib.
82 SymbolLookupCompleteFn Complete);
83
84 /// Load the dynamic library at the given path and return a handle to it.
85 /// If DylibPath is null this function will return the global handle for
86 /// the target process.
88 loadDylib(const char *DylibPath) override;
89
90 /// Search for symbols in the target process.
91 LLVM_ABI void
93 DylibManager::SymbolLookupCompleteFn Complete) override;
94
95private:
97 SymbolAddrs SAs;
98};
99
100} // end namespace orc
101} // end namespace llvm
102
103#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.