LLVM 23.0.0git
JITLinkRedirectableSymbolManager.h
Go to the documentation of this file.
1//===- JITLinkRedirectableSymbolManager.h - JITLink redirection -*- 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// Redirectable Symbol Manager implementation using JITLink
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_EXECUTIONENGINE_ORC_JITLINKREDIRECABLESYMBOLMANAGER_H
14#define LLVM_EXECUTIONENGINE_ORC_JITLINKREDIRECABLESYMBOLMANAGER_H
15
21
22#include <atomic>
23
24namespace llvm {
25namespace orc {
26
29public:
30 /// Create redirection manager that uses JITLink based implementaion.
32 Create(ObjectLinkingLayer &ObjLinkingLayer, MemoryAccess &MemAccess) {
33 auto AnonymousPtrCreator(jitlink::getAnonymousPointerCreator(
34 ObjLinkingLayer.getExecutionSession().getTargetTriple()));
35 auto PtrJumpStubCreator(jitlink::getPointerJumpStubCreator(
36 ObjLinkingLayer.getExecutionSession().getTargetTriple()));
37 if (!AnonymousPtrCreator || !PtrJumpStubCreator)
38 return make_error<StringError>("Architecture not supported",
40 return std::unique_ptr<RedirectableSymbolManager>(
41 new JITLinkRedirectableSymbolManager(ObjLinkingLayer, MemAccess,
42 AnonymousPtrCreator,
43 PtrJumpStubCreator));
44 }
45
47 ObjectLinkingLayer &ObjLinkingLayer, MemoryAccess &MemAccess,
48 jitlink::AnonymousPointerCreator &AnonymousPtrCreator,
49 jitlink::PointerJumpStubCreator &PtrJumpStubCreator)
50 : ObjLinkingLayer(ObjLinkingLayer), MemAccess(MemAccess),
51 AnonymousPtrCreator(std::move(AnonymousPtrCreator)),
52 PtrJumpStubCreator(std::move(PtrJumpStubCreator)) {}
53
54 ObjectLinkingLayer &getObjectLinkingLayer() const { return ObjLinkingLayer; }
55
56 void emitRedirectableSymbols(std::unique_ptr<MaterializationResponsibility> R,
57 SymbolMap InitialDests) override;
58
59 Error redirect(JITDylib &JD, const SymbolMap &NewDests) override;
60
61private:
62 ObjectLinkingLayer &ObjLinkingLayer;
63 MemoryAccess &MemAccess;
64 jitlink::AnonymousPointerCreator AnonymousPtrCreator;
65 jitlink::PointerJumpStubCreator PtrJumpStubCreator;
66 std::atomic_size_t StubGraphIdx{0};
67};
68
69} // namespace orc
70} // namespace llvm
71
72#endif // LLVM_EXECUTIONENGINE_ORC_JITLINKREDIRECABLESYMBOLMANAGER_H
#define LLVM_ABI
Definition Compiler.h:213
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
Tagged union holding either a T or a Error.
Definition Error.h:485
Represents a JIT'd dynamic library.
Definition Core.h:919
JITLinkRedirectableSymbolManager(ObjectLinkingLayer &ObjLinkingLayer, MemoryAccess &MemAccess, jitlink::AnonymousPointerCreator &AnonymousPtrCreator, jitlink::PointerJumpStubCreator &PtrJumpStubCreator)
static Expected< std::unique_ptr< RedirectableSymbolManager > > Create(ObjectLinkingLayer &ObjLinkingLayer, MemoryAccess &MemAccess)
Create redirection manager that uses JITLink based implementaion.
APIs for manipulating memory in the target process.
An ObjectLayer implementation built on JITLink.
Base class for managing redirectable symbols in which a call gets redirected to another symbol in run...
DenseMap< SymbolStringPtr, ExecutorSymbolDef > SymbolMap
A map from symbol names (as SymbolStringPtrs) to JITSymbols (address/flags pairs).
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition Error.cpp:94
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
Definition Error.h:340
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:870