LLVM: include/llvm/ExecutionEngine/Orc/ExecutionUtils.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef LLVM_EXECUTIONENGINE_ORC_EXECUTIONUTILS_H
14#define LLVM_EXECUTIONENGINE_ORC_EXECUTIONUTILS_H
15
26#include
27#include
28#include
29#include
30
31namespace llvm {
32
38
41}
42
43namespace orc {
44
46
47
48
49
50
51
53public:
54
55
56
57
66
67
68
70
71
73
74
76
77
79
80
82
83
84
86
87private:
89 unsigned I;
90};
91
92
93
95
96
97
99
100
101
103public:
105
107 : I(M.global_values().begin()), E(M.global_values().end()),
108 ObjFmt(M.getTargetTriple().getObjectFormat()) {
109 if (I != E) {
110 if (!isStaticInitGlobal(*I))
111 moveToNextStaticInitGlobal();
112 } else
114 }
115
118
120 assert(I != E && "Increment past end of range");
121 moveToNextStaticInitGlobal();
122 return *this;
123 }
124
126
127private:
129 void moveToNextStaticInitGlobal() {
130 ++I;
131 while (I != E && !isStaticInitGlobal(*I))
132 ++I;
135 }
136
139};
140
141
142
146
148public:
152
153private:
154 using CtorDtorList = std::vector;
155 using CtorDtorPriorityMap = std::map<unsigned, CtorDtorList>;
156
158 CtorDtorPriorityMap CtorDtorsByPriority;
159};
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
177public:
178
179
181
182protected:
188 void *DSOHandle);
189};
190
195
196
198public:
202 };
203
206
207private:
208 std::mutex AtExitsMutex;
210};
211
212
213
214
215
216
218public:
221
222
223
224
225
226
227
228
229
230
235
236
237
238
240 Load(const char *FileName, char GlobalPrefix,
243
244
245
250 return Load(nullptr, GlobalPrefix, std::move(Allow),
251 std::move(AddAbsoluteSymbols));
252 }
253
257
258private:
260 SymbolPredicate Allow;
261 AddAbsoluteSymbolsFn AddAbsoluteSymbols;
263};
264
265
266
267
268
269
271public:
272
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
294
295
296
297
300
301 static std::unique_ptr
303
304
305
306
307
308
313
314
315
317 Create(ObjectLayer &L, std::unique_ptr ArchiveBuffer,
318 std::unique_ptrobject::Archive Archive,
321
322
323
324
325
326
327
328
330 Create(ObjectLayer &L, std::unique_ptr ArchiveBuffer,
333
337
338private:
339 StaticLibraryDefinitionGenerator(
340 ObjectLayer &L, std::unique_ptr ArchiveBuffer,
341 std::unique_ptrobject::Archive Archive,
344
347 std::unique_ptr ArchiveBuffer;
348 std::unique_ptrobject::Archive Archive;
350};
351
352
353
354
355
356
357
358
360public:
361
362 static std::unique_ptr
364
368
369private:
371 : ES(ES), L(L) {}
372
377
378 static StringRef getImpPrefix() { return "__imp_"; }
379
380 static StringRef getSectionName() { return "$__DLLIMPORT_STUBS"; }
381
384};
385
386}
387}
388
389#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
ConstantArray - Constant Array Declarations.
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
A Module instance is used to store all the information related to an LLVM module.
concat_iterator< GlobalValue, iterator, global_iterator, alias_iterator, ifunc_iterator > global_value_iterator
StringRef - Represent a constant reference to a string, i.e.
Triple - Helper class for working with autoconf configuration names.
LLVM Value Representation.
A range adaptor for a pair of iterators.
LLVM_ABI bool operator!=(const CtorDtorIterator &Other) const
Test iterators for inequality.
LLVM_ABI Element operator*() const
Dereference iterator.
LLVM_ABI CtorDtorIterator(const GlobalVariable *GV, bool End)
Construct an iterator instance.
LLVM_ABI CtorDtorIterator & operator++()
Pre-increment iterator.
LLVM_ABI bool operator==(const CtorDtorIterator &Other) const
Test iterators for equality.
CtorDtorRunner(JITDylib &JD)
Definition ExecutionUtils.h:149
LLVM_ABI void add(iterator_range< CtorDtorIterator > CtorDtors)
static std::unique_ptr< DLLImportDefinitionGenerator > Create(ExecutionSession &ES, ObjectLinkingLayer &L)
Creates a DLLImportDefinitionGenerator instance.
Error tryToGenerate(LookupState &LS, LookupKind K, JITDylib &JD, JITDylibLookupFlags JDLookupFlags, const SymbolLookupSet &Symbols) override
DefinitionGenerators should override this method to insert new definitions into the parent JITDylib.
Definition generators can be attached to JITDylibs to generate new definitions for otherwise unresolv...
friend class ExecutionSession
std::function< bool(const SymbolStringPtr &)> SymbolPredicate
Definition ExecutionUtils.h:219
unique_function< Error(JITDylib &, SymbolMap)> AddAbsoluteSymbolsFn
Definition ExecutionUtils.h:220
DynamicLibrarySearchGenerator(sys::DynamicLibrary Dylib, char GlobalPrefix, SymbolPredicate Allow=SymbolPredicate(), AddAbsoluteSymbolsFn AddAbsoluteSymbols=nullptr)
Create a DynamicLibrarySearchGenerator that searches for symbols in the given sys::DynamicLibrary.
static Expected< std::unique_ptr< DynamicLibrarySearchGenerator > > Load(const char *FileName, char GlobalPrefix, SymbolPredicate Allow=SymbolPredicate(), AddAbsoluteSymbolsFn AddAbsoluteSymbols=nullptr)
Permanently loads the library at the given path and, on success, returns a DynamicLibrarySearchGenera...
static Expected< std::unique_ptr< DynamicLibrarySearchGenerator > > GetForCurrentProcess(char GlobalPrefix, SymbolPredicate Allow=SymbolPredicate(), AddAbsoluteSymbolsFn AddAbsoluteSymbols=nullptr)
Creates a DynamicLibrarySearchGenerator that searches for symbols in the current process.
Definition ExecutionUtils.h:247
An interface for Itanium __cxa_atexit interposer implementations.
Definition ExecutionUtils.h:197
LLVM_ABI void runAtExits(void *DSOHandle)
LLVM_ABI void registerAtExit(void(*F)(void *), void *Ctx, void *DSOHandle)
Represents a JIT'd dynamic library.
Support class for static dtor execution.
Definition ExecutionUtils.h:176
void(*)(void *) DestructorPtr
Definition ExecutionUtils.h:183
static LLVM_ABI int CXAAtExitOverride(DestructorPtr Destructor, void *Arg, void *DSOHandle)
std::vector< CXXDestructorDataPair > CXXDestructorDataPairList
Definition ExecutionUtils.h:185
CXXDestructorDataPairList DSOHandleOverride
Definition ExecutionUtils.h:186
std::pair< DestructorPtr, void * > CXXDestructorDataPair
Definition ExecutionUtils.h:184
LLVM_ABI void runDestructors()
Run any destructors recorded by the overriden __cxa_atexit function (CXAAtExitOverride).
Definition ExecutionUtils.h:191
LLVM_ABI Error enable(JITDylib &JD, MangleAndInterner &Mangler)
Wraps state for a lookup-in-progress.
Mangles symbol names then uniques them in the context of an ExecutionSession.
Interface for Layers that accept object files.
An ObjectLayer implementation built on JITLink.
This iterator provides a convenient way to iterate over GlobalValues that have initialization effects...
Definition ExecutionUtils.h:102
StaticInitGVIterator()=default
GlobalValue & operator*()
Definition ExecutionUtils.h:125
StaticInitGVIterator & operator++()
Definition ExecutionUtils.h:119
bool operator!=(const StaticInitGVIterator &O) const
Definition ExecutionUtils.h:117
bool operator==(const StaticInitGVIterator &O) const
Definition ExecutionUtils.h:116
StaticInitGVIterator(Module &M)
Definition ExecutionUtils.h:106
static VisitMembersFunction loadAllObjectFileMembers(ObjectLayer &L, JITDylib &JD)
A VisitMembersFunction that unconditionally loads all object files from the archive.
unique_function< Expected< MaterializationUnit::Interface >( ExecutionSession &ES, MemoryBufferRef ObjBuffer)> GetObjectFileInterface
Interface builder function for objects loaded from this archive.
Definition ExecutionUtils.h:273
unique_function< Expected< bool >( object::Archive &, MemoryBufferRef, size_t)> VisitMembersFunction
Callback for visiting archive members at construction time.
Definition ExecutionUtils.h:292
Error tryToGenerate(LookupState &LS, LookupKind K, JITDylib &JD, JITDylibLookupFlags JDLookupFlags, const SymbolLookupSet &Symbols) override
DefinitionGenerators should override this method to insert new definitions into the parent JITDylib.
static Expected< std::unique_ptr< StaticLibraryDefinitionGenerator > > Create(ObjectLayer &L, std::unique_ptr< MemoryBuffer > ArchiveBuffer, std::unique_ptr< object::Archive > Archive, VisitMembersFunction VisitMembers=VisitMembersFunction(), GetObjectFileInterface GetObjFileInterface=GetObjectFileInterface())
Try to create a StaticLibrarySearchGenerator from the given memory buffer and Archive object.
static Expected< std::unique_ptr< StaticLibraryDefinitionGenerator > > Load(ObjectLayer &L, const char *FileName, VisitMembersFunction VisitMembers=VisitMembersFunction(), GetObjectFileInterface GetObjFileInterface=GetObjectFileInterface())
Try to create a StaticLibraryDefinitionGenerator from the given path.
static std::unique_ptr< MemoryBuffer > createMemberBuffer(object::Archive &A, MemoryBufferRef BufRef, size_t Index)
A set of symbols to look up, each associated with a SymbolLookupFlags value.
Pointer to a pooled string representing a symbol name.
This class provides a portable interface to dynamic libraries which also might be known as shared lib...
unique_function is a type-erasing functor similar to std::function.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
LLVM_ABI iterator_range< CtorDtorIterator > getDestructors(const Module &M)
Create an iterator range over the entries of the llvm.global_ctors array.
iterator_range< StaticInitGVIterator > getStaticInitGVs(Module &M)
Create an iterator range over the GlobalValues that contribute to static initialization.
Definition ExecutionUtils.h:143
LLVM_ABI iterator_range< CtorDtorIterator > getConstructors(const Module &M)
Create an iterator range over the entries of the llvm.global_ctors array.
JITDylibLookupFlags
Lookup flags that apply to each dylib in the search order for a lookup.
DenseMap< SymbolStringPtr, ExecutorSymbolDef > SymbolMap
A map from symbol names (as SymbolStringPtrs) to JITSymbols (address/flags pairs).
LookupKind
Describes the kind of lookup being performed.
@ Resolved
Queried, materialization begun.
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
Accessor for an element of the global_ctors/global_dtors array.
Definition ExecutionUtils.h:58
Value * Data
Definition ExecutionUtils.h:64
Element(unsigned Priority, Function *Func, Value *Data)
Definition ExecutionUtils.h:59
unsigned Priority
Definition ExecutionUtils.h:62
Function * Func
Definition ExecutionUtils.h:63
Definition ExecutionUtils.h:199
void(* F)(void *)
Definition ExecutionUtils.h:200
void * Ctx
Definition ExecutionUtils.h:201