LLVM 22.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
20
21#include <atomic>
22
23namespace llvm {
24namespace orc {
25
28public:
29 /// Create redirection manager that uses JITLink based implementaion.
31 Create(ObjectLinkingLayer &ObjLinkingLayer) {
32 auto AnonymousPtrCreator(jitlink::getAnonymousPointerCreator(
33 ObjLinkingLayer.getExecutionSession().getTargetTriple()));
34 auto PtrJumpStubCreator(jitlink::getPointerJumpStubCreator(
35 ObjLinkingLayer.getExecutionSession().getTargetTriple()));
36 if (!AnonymousPtrCreator || !PtrJumpStubCreator)
37 return make_error<StringError>("Architecture not supported",
39 return std::unique_ptr<RedirectableSymbolManager>(
41 ObjLinkingLayer, AnonymousPtrCreator, PtrJumpStubCreator));
42 }
43
45 ObjectLinkingLayer &ObjLinkingLayer,
46 jitlink::AnonymousPointerCreator &AnonymousPtrCreator,
47 jitlink::PointerJumpStubCreator &PtrJumpStubCreator)
48 : ObjLinkingLayer(ObjLinkingLayer),
49 AnonymousPtrCreator(std::move(AnonymousPtrCreator)),
50 PtrJumpStubCreator(std::move(PtrJumpStubCreator)) {}
51
52 ObjectLinkingLayer &getObjectLinkingLayer() const { return ObjLinkingLayer; }
53
54 void emitRedirectableSymbols(std::unique_ptr<MaterializationResponsibility> R,
55 SymbolMap InitialDests) override;
56
57 Error redirect(JITDylib &JD, const SymbolMap &NewDests) override;
58
59private:
60 ObjectLinkingLayer &ObjLinkingLayer;
61 jitlink::AnonymousPointerCreator AnonymousPtrCreator;
62 jitlink::PointerJumpStubCreator PtrJumpStubCreator;
63 std::atomic_size_t StubGraphIdx{0};
64};
65
66} // namespace orc
67} // namespace llvm
68
69#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
const Triple & getTargetTriple() const
Return the triple for the executor.
Definition: Core.h:1398
Represents a JIT'd dynamic library.
Definition: Core.h:902
static Expected< std::unique_ptr< RedirectableSymbolManager > > Create(ObjectLinkingLayer &ObjLinkingLayer)
Create redirection manager that uses JITLink based implementaion.
JITLinkRedirectableSymbolManager(ObjectLinkingLayer &ObjLinkingLayer, jitlink::AnonymousPointerCreator &AnonymousPtrCreator, jitlink::PointerJumpStubCreator &PtrJumpStubCreator)
ExecutionSession & getExecutionSession()
An ObjectLayer implementation built on JITLink.
Base class for managing redirectable symbols in which a call gets redirected to another symbol in run...
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
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:98
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:1886
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:856