LLVM 20.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
19
20#include <atomic>
21
22namespace llvm {
23namespace orc {
24
26public:
27 /// Create redirection manager that uses JITLink based implementaion.
29 Create(ObjectLinkingLayer &ObjLinkingLayer) {
30 auto AnonymousPtrCreator(jitlink::getAnonymousPointerCreator(
31 ObjLinkingLayer.getExecutionSession().getTargetTriple()));
32 auto PtrJumpStubCreator(jitlink::getPointerJumpStubCreator(
33 ObjLinkingLayer.getExecutionSession().getTargetTriple()));
34 if (!AnonymousPtrCreator || !PtrJumpStubCreator)
35 return make_error<StringError>("Architecture not supported",
37 return std::unique_ptr<RedirectableSymbolManager>(
39 ObjLinkingLayer, AnonymousPtrCreator, PtrJumpStubCreator));
40 }
41
43 ObjectLinkingLayer &ObjLinkingLayer,
44 jitlink::AnonymousPointerCreator &AnonymousPtrCreator,
45 jitlink::PointerJumpStubCreator &PtrJumpStubCreator)
46 : ObjLinkingLayer(ObjLinkingLayer),
47 AnonymousPtrCreator(std::move(AnonymousPtrCreator)),
48 PtrJumpStubCreator(std::move(PtrJumpStubCreator)) {}
49
50 ObjectLinkingLayer &getObjectLinkingLayer() const { return ObjLinkingLayer; }
51
52 void emitRedirectableSymbols(std::unique_ptr<MaterializationResponsibility> R,
53 SymbolMap InitialDests) override;
54
55 Error redirect(JITDylib &JD, const SymbolMap &NewDests) override;
56
57private:
58 ObjectLinkingLayer &ObjLinkingLayer;
59 jitlink::AnonymousPointerCreator AnonymousPtrCreator;
60 jitlink::PointerJumpStubCreator PtrJumpStubCreator;
61 std::atomic_size_t StubGraphIdx{0};
62};
63
64} // namespace orc
65} // namespace llvm
66
67#endif // LLVM_EXECUTIONENGINE_ORC_JITLINKREDIRECABLESYMBOLMANAGER_H
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
Tagged union holding either a T or a Error.
Definition: Error.h:481
const Triple & getTargetTriple() const
Return the triple for the executor.
Definition: Core.h:1382
Represents a JIT'd dynamic library.
Definition: Core.h:897
void emitRedirectableSymbols(std::unique_ptr< MaterializationResponsibility > R, SymbolMap InitialDests) override
Emit redirectable symbol.
Error redirect(JITDylib &JD, const SymbolMap &NewDests) override
Change the redirection destination of given symbols to new destination symbols.
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
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:1873
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858