LLVM: lib/ExecutionEngine/JITLink/JITLinkGeneric.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef LIB_EXECUTIONENGINE_JITLINK_JITLINKGENERIC_H
14#define LIB_EXECUTIONENGINE_JITLINK_JITLINKGENERIC_H
15
17
18#define DEBUG_TYPE "jitlink"
19
20namespace llvm {
21namespace jitlink {
22
23
24
25
26
27
28
30public:
34 assert(this->Ctx && "Ctx can not be null");
35 assert(this->G && "G can not be null");
36 }
37
39
40protected:
44
45
47
48
49
50
52 return Ctx->shouldAddDefaultTargetPasses(TT);
53 }
54
55
56
57
58
60
61
62
63
64
65
66 void linkPhase1(std::unique_ptr Self);
67
68
69
70
71
73
74
75
76
77
78
79
80 void linkPhase3(std::unique_ptr Self,
82
83
84
86
87private:
88
89
91
92
93
95
98 void abandonAllocAndBailOut(std::unique_ptr Self, Error Err);
99
100 std::unique_ptr Ctx;
101 std::unique_ptr G;
103 std::unique_ptr Alloc;
104};
105
107public:
109
110
111
112
113 template <typename... ArgTs> static void link(ArgTs &&... Args) {
114 auto L = std::make_unique(std::forward(Args)...);
115
116
117
118
119
120
121
122
123 auto <mp = *L;
124 LTmp.linkPhase1(std::move(L));
125 }
126
127private:
128 const LinkerImpl &impl() const {
129 return static_cast<const LinkerImpl &>(*this);
130 }
131
132 Error fixUpBlocks(LinkGraph &G) const override {
134
135 for (auto &Sec : G.sections()) {
137
138 for (auto *B : Sec.blocks()) {
140
141
144 [](const Edge &E) {
145 return E.getKind() ==
146 Edge::KeepAlive;
147 })) &&
148 "Non-KeepAlive edges in zero-fill block?");
149
150
151
152
153 if (NoAllocSection)
154 (void)B->getMutableContent(G);
155
156 for (auto &E : B->edges()) {
157
158
159 if (.isRelocation())
160 continue;
161
162
163
164 assert((NoAllocSection || .getTarget().isDefined() ||
165 E.getTarget().getSection().getMemLifetime() !=
167 "Block in allocated section has edge pointing to no-alloc "
168 "section");
169
170
171 if (auto Err = impl().applyFixup(G, *B, E))
172 return Err;
173 }
174 }
175 }
176
178 }
179};
180
181
182
183
184
185
187
188}
189}
190
191#undef DEBUG_TYPE
192
193#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Function const char * Passes
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Triple - Helper class for working with autoconf configuration names.
DenseMap< orc::SymbolStringPtr, SymbolLookupFlags > LookupMap
Represents an allocation which has not been finalized yet.
void linkPhase4(std::unique_ptr< JITLinkerBase > Self, FinalizeResult FR)
void linkPhase3(std::unique_ptr< JITLinkerBase > Self, Expected< AsyncLookupResult > LookupResult)
PassConfiguration & getPassConfig()
Definition JITLinkGeneric.h:59
Expected< std::unique_ptr< InFlightAlloc > > AllocResult
Definition JITLinkGeneric.h:42
void linkPhase1(std::unique_ptr< JITLinkerBase > Self)
Expected< JITLinkMemoryManager::FinalizedAlloc > FinalizeResult
Definition JITLinkGeneric.h:43
JITLinkMemoryManager::InFlightAlloc InFlightAlloc
Definition JITLinkGeneric.h:41
void linkPhase2(std::unique_ptr< JITLinkerBase > Self, AllocResult AR)
JITLinkerBase(std::unique_ptr< JITLinkContext > Ctx, std::unique_ptr< LinkGraph > G, PassConfiguration Passes)
Definition JITLinkGeneric.h:31
bool shouldAddDefaultTargetPasses(const Triple &TT)
Definition JITLinkGeneric.h:51
LinkGraph & getGraph()
Definition JITLinkGeneric.h:46
Definition JITLinkGeneric.h:106
static void link(ArgTs &&... Args)
Link constructs a LinkerImpl instance and calls linkPhase1.
Definition JITLinkGeneric.h:113
JITLinkerBase(std::unique_ptr< JITLinkContext > Ctx, std::unique_ptr< LinkGraph > G, PassConfiguration Passes)
Definition JITLinkGeneric.h:31
void prune(LinkGraph &G)
Removes dead symbols/blocks/addressables.
DenseMap< orc::SymbolStringPtr, orc::ExecutorSymbolDef > AsyncLookupResult
A map of symbol names to resolved addresses.
std::vector< LinkGraphPassFunction > LinkGraphPassList
A list of LinkGraph passes.
@ NoAlloc
NoAlloc memory should not be allocated by the JITLinkMemoryManager at all.
This is an optimization pass for GlobalISel generic memory operations.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.
An LinkGraph pass configuration, consisting of a list of pre-prune, post-prune, and post-fixup passes...