llvm.org GIT mirror llvm / b962973
[ExecutionEngine] Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes (NFC). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305760 91177308-0d34-0410-b5e6-96231b3b80d8 Eugene Zelenko 2 years ago
25 changed file(s) with 395 addition(s) and 291 deletion(s). Raw diff Collapse all Expand all
1414 #ifndef LLVM_EXECUTIONENGINE_EXECUTIONENGINE_H
1515 #define LLVM_EXECUTIONENGINE_EXECUTIONENGINE_H
1616
17 #include "RuntimeDyld.h"
1817 #include "llvm-c/ExecutionEngine.h"
18 #include "llvm/ADT/ArrayRef.h"
19 #include "llvm/ADT/Optional.h"
1920 #include "llvm/ADT/SmallVector.h"
21 #include "llvm/ADT/StringMap.h"
2022 #include "llvm/ADT/StringRef.h"
23 #include "llvm/ExecutionEngine/JITSymbol.h"
24 #include "llvm/IR/DataLayout.h"
2125 #include "llvm/IR/Module.h"
22 #include "llvm/IR/ValueHandle.h"
23 #include "llvm/IR/ValueMap.h"
2426 #include "llvm/Object/Binary.h"
27 #include "llvm/Support/CBindingWrapping.h"
28 #include "llvm/Support/CodeGen.h"
2529 #include "llvm/Support/ErrorHandling.h"
2630 #include "llvm/Support/Mutex.h"
2731 #include "llvm/Target/TargetMachine.h"
2832 #include "llvm/Target/TargetOptions.h"
33 #include
34 #include
2935 #include
3036 #include
37 #include
3138 #include
3239 #include
3340
3441 namespace llvm {
3542
43 class Constant;
44 class Function;
3645 struct GenericValue;
37 class Constant;
38 class DataLayout;
39 class ExecutionEngine;
40 class Function;
46 class GlobalValue;
4147 class GlobalVariable;
42 class GlobalValue;
4348 class JITEventListener;
44 class MachineCodeInfo;
4549 class MCJITMemoryManager;
46 class MutexGuard;
4750 class ObjectCache;
4851 class RTDyldMemoryManager;
4952 class Triple;
5053 class Type;
5154
5255 namespace object {
53 class Archive;
54 class ObjectFile;
55 }
56
57 class Archive;
58 class ObjectFile;
59
60 } // end namespace object
5661
5762 /// \brief Helper class for helping synchronize access to the global address map
5863 /// table. Access to this class should be serialized under a mutex.
5964 class ExecutionEngineState {
6065 public:
61 typedef StringMap GlobalAddressMapTy;
66 using GlobalAddressMapTy = StringMap;
6267
6368 private:
64
6569 /// GlobalAddressMap - A mapping between LLVM global symbol names values and
6670 /// their actualized version...
6771 GlobalAddressMapTy GlobalAddressMap;
7377 std::map GlobalAddressReverseMap;
7478
7579 public:
76
7780 GlobalAddressMapTy &getGlobalAddressMap() {
7881 return GlobalAddressMap;
7982 }
508511 };
509512
510513 namespace EngineKind {
514
511515 // These are actually bitmasks that get or-ed together.
512516 enum Kind {
513517 JIT = 0x1,
514518 Interpreter = 0x2
515519 };
516520 const static Kind Either = (Kind)(JIT | Interpreter);
517 }
521
522 } // end namespace EngineKind
518523
519524 /// Builder class for ExecutionEngines. Use this by stack-allocating a builder,
520525 /// chaining the various set* methods, and terminating it with a .create()
654659 // Create wrappers for C Binding types (see CBindingWrapping.h).
655660 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ExecutionEngine, LLVMExecutionEngineRef)
656661
657 } // End llvm namespace
658
659 #endif
662 } // end namespace llvm
663
664 #endif // LLVM_EXECUTIONENGINE_EXECUTIONENGINE_H
None //===-- GenericValue.h - Represent any type of LLVM value -------*- C++ -*-===//
0 //===- GenericValue.h - Represent any type of LLVM value --------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1010 //
1111 //===----------------------------------------------------------------------===//
1212
13
1413 #ifndef LLVM_EXECUTIONENGINE_GENERICVALUE_H
1514 #define LLVM_EXECUTIONENGINE_GENERICVALUE_H
1615
1716 #include "llvm/ADT/APInt.h"
18 #include "llvm/Support/DataTypes.h"
1917 #include
2018
2119 namespace llvm {
2220
23 typedef void* PointerTy;
24 class APInt;
21 using PointerTy = void *;
2522
2623 struct GenericValue {
2724 struct IntPair {
2926 unsigned int second;
3027 };
3128 union {
32 double DoubleVal;
33 float FloatVal;
34 PointerTy PointerVal;
35 struct IntPair UIntPairVal;
36 unsigned char Untyped[8];
29 double DoubleVal;
30 float FloatVal;
31 PointerTy PointerVal;
32 struct IntPair UIntPairVal;
33 unsigned char Untyped[8];
3734 };
38 APInt IntVal; // also used for long doubles.
35 APInt IntVal; // also used for long doubles.
3936 // For aggregate data types.
4037 std::vector AggregateVal;
4138
4239 // to make code faster, set GenericValue to zero could be omitted, but it is
4340 // potentially can cause problems, since GenericValue to store garbage
4441 // instead of zero.
45 GenericValue() : IntVal(1,0) {UIntPairVal.first = 0; UIntPairVal.second = 0;}
46 explicit GenericValue(void *V) : PointerVal(V), IntVal(1,0) { }
42 GenericValue() : IntVal(1, 0) {
43 UIntPairVal.first = 0;
44 UIntPairVal.second = 0;
45 }
46 explicit GenericValue(void *V) : PointerVal(V), IntVal(1, 0) {}
4747 };
4848
4949 inline GenericValue PTOGV(void *P) { return GenericValue(P); }
50 inline void* GVTOP(const GenericValue &GV) { return GV.PointerVal; }
50 inline void *GVTOP(const GenericValue &GV) { return GV.PointerVal; }
5151
52 } // End llvm namespace.
53 #endif
52 } // end namespace llvm
53
54 #endif // LLVM_EXECUTIONENGINE_GENERICVALUE_H
1414 #ifndef LLVM_EXECUTIONENGINE_JITEVENTLISTENER_H
1515 #define LLVM_EXECUTIONENGINE_JITEVENTLISTENER_H
1616
17 #include "RuntimeDyld.h"
1817 #include "llvm/Config/llvm-config.h"
18 #include "llvm/ExecutionEngine/RuntimeDyld.h"
1919 #include "llvm/IR/DebugLoc.h"
2020 #include
2121 #include
2727 class OProfileWrapper;
2828
2929 namespace object {
30 class ObjectFile;
30
31 class ObjectFile;
32
3133 } // end namespace object
3234
3335 /// JITEvent_EmittedFunctionDetails - Helper struct for containing information
5658 /// The default implementation of each method does nothing.
5759 class JITEventListener {
5860 public:
59 typedef JITEvent_EmittedFunctionDetails EmittedFunctionDetails;
61 using EmittedFunctionDetails = JITEvent_EmittedFunctionDetails;
6062
6163 public:
6264 JITEventListener() = default;
None //===----------- JITSymbol.h - JIT symbol abstraction -----------*- C++ -*-===//
0 //===- JITSymbol.h - JIT symbol abstraction ---------------------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
2525 class GlobalValue;
2626
2727 namespace object {
28 class BasicSymbolRef;
28
29 class BasicSymbolRef;
30
2931 } // end namespace object
3032
3133 /// @brief Represents an address in the target process's address space.
32 typedef uint64_t JITTargetAddress;
34 using JITTargetAddress = uint64_t;
3335
3436 /// @brief Flags for symbols in the JIT.
3537 class JITSymbolFlags {
3638 public:
37 typedef uint8_t UnderlyingType;
39 using UnderlyingType = uint8_t;
3840
3941 enum FlagNames : UnderlyingType {
4042 None = 0,
4547 };
4648
4749 /// @brief Default-construct a JITSymbolFlags instance.
48 JITSymbolFlags() : Flags(None) {}
50 JITSymbolFlags() = default;
4951
5052 /// @brief Construct a JITSymbolFlags instance from the given flags.
5153 JITSymbolFlags(FlagNames Flags) : Flags(Flags) {}
8082 static JITSymbolFlags fromObjectSymbol(const object::BasicSymbolRef &Symbol);
8183
8284 private:
83 UnderlyingType Flags;
85 UnderlyingType Flags = None;
8486 };
8587
8688 /// @brief Represents a symbol that has been evaluated to an address already.
8789 class JITEvaluatedSymbol {
8890 public:
8991 /// @brief Create a 'null' symbol.
90 JITEvaluatedSymbol(std::nullptr_t)
91 : Address(0) {}
92 JITEvaluatedSymbol(std::nullptr_t) {}
9293
9394 /// @brief Create a symbol for the given address and flags.
9495 JITEvaluatedSymbol(JITTargetAddress Address, JITSymbolFlags Flags)
104105 JITSymbolFlags getFlags() const { return Flags; }
105106
106107 private:
107 JITTargetAddress Address;
108 JITTargetAddress Address = 0;
108109 JITSymbolFlags Flags;
109110 };
110111
111112 /// @brief Represents a symbol in the JIT.
112113 class JITSymbol {
113114 public:
114 typedef std::function GetAddressFtor;
115 using GetAddressFtor = std::function;
115116
116117 /// @brief Create a 'null' symbol that represents failure to find a symbol
117118 /// definition.
118 JITSymbol(std::nullptr_t)
119 : CachedAddr(0) {}
119 JITSymbol(std::nullptr_t) {}
120120
121121 /// @brief Create a symbol for a definition with a known address.
122122 JITSymbol(JITTargetAddress Addr, JITSymbolFlags Flags)
136136 /// user can materialize the definition at any time by calling the getAddress
137137 /// method.
138138 JITSymbol(GetAddressFtor GetAddress, JITSymbolFlags Flags)
139 : GetAddress(std::move(GetAddress)), CachedAddr(0), Flags(Flags) {}
139 : GetAddress(std::move(GetAddress)), Flags(Flags) {}
140140
141141 /// @brief Returns true if the symbol exists, false otherwise.
142142 explicit operator bool() const { return CachedAddr || GetAddress; }
156156
157157 private:
158158 GetAddressFtor GetAddress;
159 JITTargetAddress CachedAddr;
159 JITTargetAddress CachedAddr = 0;
160160 JITSymbolFlags Flags;
161161 };
162162
2323 #include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
2424 #include "llvm/ExecutionEngine/RuntimeDyld.h"
2525 #include "llvm/IR/Attributes.h"
26 #include "llvm/IR/Constant.h"
2627 #include "llvm/IR/Constants.h"
2728 #include "llvm/IR/DataLayout.h"
2829 #include "llvm/IR/Function.h"
2930 #include "llvm/IR/GlobalAlias.h"
3031 #include "llvm/IR/GlobalValue.h"
3132 #include "llvm/IR/GlobalVariable.h"
33 #include "llvm/IR/Instruction.h"
3234 #include "llvm/IR/Mangler.h"
3335 #include "llvm/IR/Module.h"
36 #include "llvm/IR/Type.h"
3437 #include "llvm/Support/Casting.h"
3538 #include "llvm/Support/raw_ostream.h"
39 #include "llvm/Transforms/Utils/ValueMapper.h"
3640 #include
3741 #include
3842 #include
4549 #include
4650
4751 namespace llvm {
52
53 class Value;
54
4855 namespace orc {
4956
5057 /// @brief Compile-on-demand layer.
7683 return LambdaMaterializer(std::move(M));
7784 }
7885
79 typedef typename BaseLayerT::ModuleSetHandleT BaseLayerModuleSetHandleT;
86 using BaseLayerModuleSetHandleT = typename BaseLayerT::ModuleSetHandleT;
8087
8188 // Provide type-erasure for the Modules and MemoryManagers.
8289 template
8390 class ResourceOwner {
8491 public:
8592 ResourceOwner() = default;
86 ResourceOwner(const ResourceOwner&) = delete;
87 ResourceOwner& operator=(const ResourceOwner&) = delete;
93 ResourceOwner(const ResourceOwner &) = delete;
94 ResourceOwner &operator=(const ResourceOwner &) = delete;
8895 virtual ~ResourceOwner() = default;
8996
9097 virtual ResourceT& getResource() const = 0;
105112 template
106113 std::unique_ptr>
107114 wrapOwnership(ResourcePtrT ResourcePtr) {
108 typedef ResourceOwnerImpl RO;
115 using RO = ResourceOwnerImpl;
109116 return llvm::make_unique(std::move(ResourcePtr));
110117 }
111118
129136 };
130137
131138 struct LogicalDylib {
132 typedef std::function SymbolResolverFtor;
133
134 typedef std::function
135 BaseLayerT&,
136 std::unique_ptr,
137 std::unique_ptr)>
138 ModuleAdderFtor;
139 using SymbolResolverFtor = std::function;
140
141 using ModuleAdderFtor = std::function
142 BaseLayerT &, std::unique_ptr,
143 std::unique_ptr)>;
139144
140145 struct SourceModuleEntry {
141146 std::unique_ptr> SourceMod;
142147 std::set StubsToClone;
143148 };
144149
145 typedef std::vector SourceModulesList;
146 typedef typename SourceModulesList::size_type SourceModuleHandle;
150 using SourceModulesList = std::vector;
151 using SourceModuleHandle = typename SourceModulesList::size_type;
147152
148153 SourceModuleHandle
149154 addSourceModule(std::unique_ptr> M) {
185190 std::vector BaseLayerHandles;
186191 };
187192
188 typedef std::list LogicalDylibList;
193 using LogicalDylibList = std::list;
189194
190195 public:
191196 /// @brief Handle to a set of loaded modules.
192 typedef typename LogicalDylibList::iterator ModuleSetHandleT;
197 using ModuleSetHandleT = typename LogicalDylibList::iterator;
193198
194199 /// @brief Module partitioning functor.
195 typedef std::function(Function&)> PartitioningFtor;
200 using PartitioningFtor = std::function(Function&)>;
196201
197202 /// @brief Builder for IndirectStubsManagers.
198 typedef std::function()>
199 IndirectStubsManagerBuilderT;
203 using IndirectStubsManagerBuilderT =
204 std::function()>;
200205
201206 /// @brief Construct a compile-on-demand layer instance.
202207 CompileOnDemandLayer(BaseLayerT &BaseLayer, PartitioningFtor Partition,
219224 ModuleSetHandleT addModuleSet(ModuleSetT Ms,
220225 MemoryManagerPtrT MemMgr,
221226 SymbolResolverPtrT Resolver) {
222
223227 LogicalDylibs.push_back(LogicalDylib());
224228 auto &LD = LogicalDylibs.back();
225229 LD.ExternalSymbolResolver = std::move(Resolver);
302306 private:
303307 template
304308 void addLogicalModule(LogicalDylib &LD, ModulePtrT SrcMPtr) {
305
306309 // Rename all static functions / globals to $static.X :
307310 // This will unique the names across all modules in the logical dylib,
308311 // simplifying symbol lookup.
580583 };
581584
582585 } // end namespace orc
586
583587 } // end namespace llvm
584588
585589 #endif // LLVM_EXECUTIONENGINE_ORC_COMPILEONDEMANDLAYER_H
None //===-- CompileUtils.h - Utilities for compiling IR in the JIT --*- C++ -*-===//
0 //===- CompileUtils.h - Utilities for compiling IR in the JIT ---*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1313 #ifndef LLVM_EXECUTIONENGINE_ORC_COMPILEUTILS_H
1414 #define LLVM_EXECUTIONENGINE_ORC_COMPILEUTILS_H
1515
16 #include "llvm/ADT/SmallVector.h"
1617 #include "llvm/ExecutionEngine/ObjectMemoryBuffer.h"
1718 #include "llvm/IR/LegacyPassManager.h"
18 #include "llvm/MC/MCContext.h"
19 #include "llvm/Object/Binary.h"
1920 #include "llvm/Object/ObjectFile.h"
21 #include "llvm/Support/Error.h"
22 #include "llvm/Support/ErrorHandling.h"
23 #include "llvm/Support/MemoryBuffer.h"
24 #include "llvm/Support/raw_ostream.h"
2025 #include "llvm/Target/TargetMachine.h"
26 #include
27 #include
2128
2229 namespace llvm {
30
31 class MCContext;
32 class Module;
33
2334 namespace orc {
2435
2536 /// @brief Simple compile functor: Takes a single IR module and returns an
4354 new ObjectMemoryBuffer(std::move(ObjBufferSV)));
4455 Expected> Obj =
4556 object::ObjectFile::createObjectFile(ObjBuffer->getMemBufferRef());
46 typedef object::OwningBinary OwningObj;
57 using OwningObj = object::OwningBinary;
4758 if (Obj)
4859 return OwningObj(std::move(*Obj), std::move(ObjBuffer));
4960 // TODO: Actually report errors helpfully.
5566 TargetMachine &TM;
5667 };
5768
58 } // End namespace orc.
59 } // End namespace llvm.
69 } // end namespace orc
70
71 } // end namespace llvm
6072
6173 #endif // LLVM_EXECUTIONENGINE_ORC_COMPILEUTILS_H
None //===-- ExecutionUtils.h - Utilities for executing code in Orc --*- C++ -*-===//
0 //===- ExecutionUtils.h - Utilities for executing code in Orc ---*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1616 #include "llvm/ADT/StringMap.h"
1717 #include "llvm/ADT/iterator_range.h"
1818 #include "llvm/ExecutionEngine/JITSymbol.h"
19 #include "llvm/ExecutionEngine/RuntimeDyld.h"
19 #include
20 #include
21 #include
2022 #include
23 #include
2124
2225 namespace llvm {
2326
3639 /// getConstructors/getDestructors functions.
3740 class CtorDtorIterator {
3841 public:
39
4042 /// @brief Accessor for an element of the global_ctors/global_dtors array.
4143 ///
4244 /// This class provides a read-only view of the element with any casts on
8890 template
8991 class CtorDtorRunner {
9092 public:
91
9293 /// @brief Construct a CtorDtorRunner for the given range using the given
9394 /// name mangling function.
9495 CtorDtorRunner(std::vector CtorDtorNames,
9899 /// @brief Run the recorded constructors/destructors through the given JIT
99100 /// layer.
100101 bool runViaLayer(JITLayerT &JITLayer) const {
101 typedef void (*CtorDtorTy)();
102 using CtorDtorTy = void (*)();
102103
103104 bool Error = false;
104105 for (const auto &CtorDtorName : CtorDtorNames)
134135 /// called.
135136 class LocalCXXRuntimeOverrides {
136137 public:
137
138138 /// Create a runtime-overrides class.
139139 template
140140 LocalCXXRuntimeOverrides(const MangleFtorT &Mangle) {
155155 void runDestructors();
156156
157157 private:
158
159158 template
160159 JITTargetAddress toTargetAddress(PtrTy* P) {
161160 return static_cast(reinterpret_cast(P));
167166
168167 StringMap CXXRuntimeOverrides;
169168
170 typedef void (*DestructorPtr)(void*);
171 typedef std::pair CXXDestructorDataPair;
172 typedef std::vector CXXDestructorDataPairList;
169 using DestructorPtr = void (*)(void *);
170 using CXXDestructorDataPair = std::pair;
171 using CXXDestructorDataPairList = std::vector;
173172 CXXDestructorDataPairList DSOHandleOverride;
174173 static int CXAAtExitOverride(DestructorPtr Destructor, void *Arg,
175174 void *DSOHandle);
176175 };
177176
178 } // End namespace orc.
179 } // End namespace llvm.
177 } // end namespace orc
178
179 } // end namespace llvm
180180
181181 #endif // LLVM_EXECUTIONENGINE_ORC_EXECUTIONUTILS_H
None //===---- GlobalMappingLayer.h - Run all IR through a functor ---*- C++ -*-===//
0 //===- GlobalMappingLayer.h - Run all IR through a functor ------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1616
1717 #include "llvm/ExecutionEngine/JITSymbol.h"
1818 #include
19 #include
1920
2021 namespace llvm {
2122 namespace orc {
3132 class GlobalMappingLayer {
3233 public:
3334 /// @brief Handle to a set of added modules.
34 typedef typename BaseLayerT::ModuleSetHandleT ModuleSetHandleT;
35 using ModuleSetHandleT = typename BaseLayerT::ModuleSetHandleT;
3536
3637 /// @brief Construct an GlobalMappingLayer with the given BaseLayer
3738 GlobalMappingLayer(BaseLayerT &BaseLayer) : BaseLayer(BaseLayer) {}
101102 std::map SymbolTable;
102103 };
103104
104 } // End namespace orc.
105 } // End namespace llvm.
105 } // end namespace orc
106 } // end namespace llvm
106107
107108 #endif // LLVM_EXECUTIONENGINE_ORC_GLOBALMAPPINGLAYER_H
None //===------ IRCompileLayer.h -- Eagerly compile IR for JIT ------*- C++ -*-===//
0 //===- IRCompileLayer.h -- Eagerly compile IR for JIT -----------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1313 #ifndef LLVM_EXECUTIONENGINE_ORC_IRCOMPILELAYER_H
1414 #define LLVM_EXECUTIONENGINE_ORC_IRCOMPILELAYER_H
1515
16 #include "llvm/ADT/STLExtras.h"
1617 #include "llvm/ExecutionEngine/JITSymbol.h"
1718 #include "llvm/ExecutionEngine/ObjectCache.h"
19 #include "llvm/Object/Binary.h"
1820 #include "llvm/Object/ObjectFile.h"
21 #include "llvm/Support/Error.h"
22 #include "llvm/Support/MemoryBuffer.h"
23 #include
24 #include
1925 #include
26 #include
27 #include
2028
2129 namespace llvm {
30
31 class Module;
32
2233 namespace orc {
2334
2435 /// @brief Eager IR compiling layer.
2940 /// the layer below, which must implement the object layer concept.
3041 template class IRCompileLayer {
3142 public:
32 typedef std::function(Module &)>
33 CompileFtor;
43 using CompileFtor =
44 std::function(Module &)>;
3445
3546 private:
36 typedef typename BaseLayerT::ObjSetHandleT ObjSetHandleT;
47 using ObjSetHandleT = typename BaseLayerT::ObjSetHandleT;
3748
3849 public:
3950 /// @brief Handle to a set of compiled modules.
40 typedef ObjSetHandleT ModuleSetHandleT;
51 using ModuleSetHandleT = ObjSetHandleT;
4152
4253 /// @brief Construct an IRCompileLayer with the given BaseLayer, which must
4354 /// implement the ObjectLayer concept.
4455 IRCompileLayer(BaseLayerT &BaseLayer, CompileFtor Compile)
45 : BaseLayer(BaseLayer), Compile(std::move(Compile)), ObjCache(nullptr) {}
56 : BaseLayer(BaseLayer), Compile(std::move(Compile)) {}
4657
4758 /// @brief Set an ObjectCache to query before compiling.
4859 void setObjectCache(ObjectCache *NewCache) { ObjCache = NewCache; }
136147
137148 BaseLayerT &BaseLayer;
138149 CompileFtor Compile;
139 ObjectCache *ObjCache;
150 ObjectCache *ObjCache = nullptr;
140151 };
141152
142 } // End namespace orc.
143 } // End namespace llvm.
153 } // end namespace orc
154
155 } // end namespace llvm
144156
145157 #endif // LLVM_EXECUTIONENGINE_ORC_IRCOMPILINGLAYER_H
None //===----- IRTransformLayer.h - Run all IR through a functor ----*- C++ -*-===//
0 //===- IRTransformLayer.h - Run all IR through a functor --------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1414 #define LLVM_EXECUTIONENGINE_ORC_IRTRANSFORMLAYER_H
1515
1616 #include "llvm/ExecutionEngine/JITSymbol.h"
17 #include
1718
1819 namespace llvm {
1920 namespace orc {
2728 class IRTransformLayer {
2829 public:
2930 /// @brief Handle to a set of added modules.
30 typedef typename BaseLayerT::ModuleSetHandleT ModuleSetHandleT;
31 using ModuleSetHandleT = typename BaseLayerT::ModuleSetHandleT;
3132
3233 /// @brief Construct an IRTransformLayer with the given BaseLayer
3334 IRTransformLayer(BaseLayerT &BaseLayer,
4445 ModuleSetHandleT addModuleSet(ModuleSetT Ms,
4546 MemoryManagerPtrT MemMgr,
4647 SymbolResolverPtrT Resolver) {
47
4848 for (auto I = Ms.begin(), E = Ms.end(); I != E; ++I)
4949 *I = Transform(std::move(*I));
5050
9494 TransformFtor Transform;
9595 };
9696
97 } // End namespace orc.
98 } // End namespace llvm.
97 } // end namespace orc
98 } // end namespace llvm
9999
100100 #endif // LLVM_EXECUTIONENGINE_ORC_IRTRANSFORMLAYER_H
None //===-- IndirectionUtils.h - Utilities for adding indirections --*- C++ -*-===//
0 //===- IndirectionUtils.h - Utilities for adding indirections ---*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1717 #include "llvm/ADT/StringRef.h"
1818 #include "llvm/ADT/Twine.h"
1919 #include "llvm/ExecutionEngine/JITSymbol.h"
20 #include "llvm/IR/IRBuilder.h"
21 #include "llvm/IR/Mangler.h"
22 #include "llvm/IR/Module.h"
2320 #include "llvm/Support/Error.h"
2421 #include "llvm/Support/Memory.h"
2522 #include "llvm/Support/Process.h"
3532 #include
3633
3734 namespace llvm {
35
36 class Constant;
37 class Function;
38 class FunctionType;
39 class GlobalAlias;
40 class GlobalVariable;
41 class Module;
42 class PointerType;
43 class Triple;
44 class Value;
45
3846 namespace orc {
3947
4048 /// @brief Target-independent base class for compile callback management.
4149 class JITCompileCallbackManager {
4250 public:
43 typedef std::function CompileFtor;
51 using CompileFtor = std::function;
4452
4553 /// @brief Handle to a newly created compile callback. Can be used to get an
4654 /// IR constant representing the address of the trampoline, and to set
124132 protected:
125133 JITTargetAddress ErrorHandlerAddress;
126134
127 typedef std::map TrampolineMapT;
135 using TrampolineMapT = std::map;
128136 TrampolineMapT ActiveTrampolines;
129137 std::vector AvailableTrampolines;
130138
154162 /// process to be used if a compile callback fails.
155163 LocalJITCompileCallbackManager(JITTargetAddress ErrorHandlerAddress)
156164 : JITCompileCallbackManager(ErrorHandlerAddress) {
157
158165 /// Set up the resolver block.
159166 std::error_code EC;
160167 ResolverBlock = sys::OwningMemoryBlock(sys::Memory::allocateMappedMemory(
219226 class IndirectStubsManager {
220227 public:
221228 /// @brief Map type for initializing the manager. See init.
222 typedef StringMap> StubInitsMap;
229 using StubInitsMap = StringMap>;
223230
224231 virtual ~IndirectStubsManager() = default;
225232
335342 }
336343
337344 std::vector IndirectStubsInfos;
338 typedef std::pair StubKey;
345 using StubKey = std::pair;
339346 std::vector FreeStubs;
340347 StringMap> StubIndexes;
341348 };
431438 ValueToValueMapTy &VMap);
432439
433440 } // end namespace orc
441
434442 } // end namespace llvm
435443
436444 #endif // LLVM_EXECUTIONENGINE_ORC_INDIRECTIONUTILS_H
None //===-- LambdaResolverMM - Redirect symbol lookup via a functor -*- C++ -*-===//
0 //===- LambdaResolverMM - Redirect symbol lookup via a functor --*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1515 #define LLVM_EXECUTIONENGINE_ORC_LAMBDARESOLVER_H
1616
1717 #include "llvm/ADT/STLExtras.h"
18 #include "llvm/ExecutionEngine/RuntimeDyld.h"
18 #include "llvm/ExecutionEngine/JITSymbol.h"
1919 #include
2020
2121 namespace llvm {
2424 template
2525 class LambdaResolver : public JITSymbolResolver {
2626 public:
27
2827 LambdaResolver(DylibLookupFtorT DylibLookupFtor,
2928 ExternalLookupFtorT ExternalLookupFtor)
3029 : DylibLookupFtor(DylibLookupFtor),
4847 std::unique_ptr>
4948 createLambdaResolver(DylibLookupFtorT DylibLookupFtor,
5049 ExternalLookupFtorT ExternalLookupFtor) {
51 typedef LambdaResolver LR;
50 using LR = LambdaResolver;
5251 return make_unique(std::move(DylibLookupFtor),
5352 std::move(ExternalLookupFtor));
5453 }
5554
56 } // End namespace orc.
57 } // End namespace llvm.
55 } // end namespace orc
56 } // end namespace llvm
5857
5958 #endif // LLVM_EXECUTIONENGINE_ORC_LAMBDARESOLVER_H
3939 /// (via JITSymbol::getAddress) for a symbol contained in this layer.
4040 template class LazyEmittingLayer {
4141 public:
42 typedef typename BaseLayerT::ModuleSetHandleT BaseLayerHandleT;
42 using BaseLayerHandleT = typename BaseLayerT::ModuleSetHandleT;
4343
4444 private:
4545 class EmissionDeferredSet {
215215 mutable std::unique_ptr> MangledSymbols;
216216 };
217217
218 typedef std::list> ModuleSetListT;
218 using ModuleSetListT = std::list>;
219219
220220 BaseLayerT &BaseLayer;
221221 ModuleSetListT ModuleSetList;
222222
223223 public:
224224 /// @brief Handle to a set of loaded modules.
225 typedef typename ModuleSetListT::iterator ModuleSetHandleT;
225 using ModuleSetHandleT = typename ModuleSetListT::iterator;
226226
227227 /// @brief Construct a lazy emitting layer.
228228 LazyEmittingLayer(BaseLayerT &BaseLayer) : BaseLayer(BaseLayer) {}
290290 LazyEmittingLayer::EmissionDeferredSet::create(
291291 BaseLayerT &B, ModuleSetT Ms, MemoryManagerPtrT MemMgr,
292292 SymbolResolverPtrT Resolver) {
293 typedef EmissionDeferredSetImpl
294 EDS;
293 using EDS = EmissionDeferredSetImpl
294 SymbolResolverPtrT>;
295295 return llvm::make_unique(std::move(Ms), std::move(MemMgr),
296296 std::move(Resolver));
297297 }
1414 #define LLVM_EXECUTIONENGINE_ORC_OBJECTTRANSFORMLAYER_H
1515
1616 #include "llvm/ExecutionEngine/JITSymbol.h"
17 #include
18 #include
1719
1820 namespace llvm {
1921 namespace orc {
2729 class ObjectTransformLayer {
2830 public:
2931 /// @brief Handle to a set of added objects.
30 typedef typename BaseLayerT::ObjSetHandleT ObjSetHandleT;
32 using ObjSetHandleT = typename BaseLayerT::ObjSetHandleT;
3133
3234 /// @brief Construct an ObjectTransformLayer with the given BaseLayer
3335 ObjectTransformLayer(BaseLayerT &BaseLayer,
4345 typename SymbolResolverPtrT>
4446 ObjSetHandleT addObjectSet(ObjSetT Objects, MemoryManagerPtrT MemMgr,
4547 SymbolResolverPtrT Resolver) {
46
4748 for (auto I = Objects.begin(), E = Objects.end(); I != E; ++I)
4849 *I = Transform(std::move(*I));
4950
9798 TransformFtor Transform;
9899 };
99100
100 } // End namespace orc.
101 } // End namespace llvm.
101 } // end namespace orc
102 } // end namespace llvm
102103
103104 #endif // LLVM_EXECUTIONENGINE_ORC_OBJECTTRANSFORMLAYER_H
None //===-------------- OrcABISupport.h - ABI support code ---------*- C++ -*-===//
0 //===- OrcABISupport.h - ABI support code -----------------------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1717 #ifndef LLVM_EXECUTIONENGINE_ORC_ORCABISUPPORT_H
1818 #define LLVM_EXECUTIONENGINE_ORC_ORCABISUPPORT_H
1919
20 #include "IndirectionUtils.h"
20 #include "llvm/ExecutionEngine/JITSymbol.h"
21 #include "llvm/Support/Error.h"
22 #include "llvm/Support/ErrorHandling.h"
2123 #include "llvm/Support/Memory.h"
22 #include "llvm/Support/Process.h"
24 #include
25 #include
2326
2427 namespace llvm {
2528 namespace orc {
3639 static const unsigned TrampolineSize = 1;
3740 static const unsigned ResolverCodeSize = 1;
3841
39 typedef JITTargetAddress (*JITReentryFn)(void *CallbackMgr,
40 void *TrampolineId);
42 using JITReentryFn = JITTargetAddress (*)(void *CallbackMgr,
43 void *TrampolineId);
4144
4245 static void writeResolverCode(uint8_t *ResolveMem, JITReentryFn Reentry,
4346 void *CallbackMgr) {
5457 class IndirectStubsInfo {
5558 public:
5659 const static unsigned StubSize = 1;
60
5761 unsigned getNumStubs() const { llvm_unreachable("Not supported"); }
5862 void *getStub(unsigned Idx) const { llvm_unreachable("Not supported"); }
5963 void **getPtr(unsigned Idx) const { llvm_unreachable("Not supported"); }
7276 public:
7377 const static unsigned StubSize = StubSizeVal;
7478
75 GenericIndirectStubsInfo() : NumStubs(0) {}
79 GenericIndirectStubsInfo() = default;
7680 GenericIndirectStubsInfo(unsigned NumStubs, sys::OwningMemoryBlock StubsMem)
7781 : NumStubs(NumStubs), StubsMem(std::move(StubsMem)) {}
7882 GenericIndirectStubsInfo(GenericIndirectStubsInfo &&Other)
7983 : NumStubs(Other.NumStubs), StubsMem(std::move(Other.StubsMem)) {
8084 Other.NumStubs = 0;
8185 }
86
8287 GenericIndirectStubsInfo &operator=(GenericIndirectStubsInfo &&Other) {
8388 NumStubs = Other.NumStubs;
8489 Other.NumStubs = 0;
103108 }
104109
105110 private:
106 unsigned NumStubs;
111 unsigned NumStubs = 0;
107112 sys::OwningMemoryBlock StubsMem;
108113 };
109114
113118 static const unsigned TrampolineSize = 12;
114119 static const unsigned ResolverCodeSize = 0x120;
115120
116 typedef GenericIndirectStubsInfo<8> IndirectStubsInfo;
117
118 typedef JITTargetAddress (*JITReentryFn)(void *CallbackMgr,
119 void *TrampolineId);
121 using IndirectStubsInfo = GenericIndirectStubsInfo<8>;
122
123 using JITReentryFn = JITTargetAddress (*)(void *CallbackMgr,
124 void *TrampolineId);
120125
121126 /// @brief Write the resolver code into the given memory. The user is be
122127 /// responsible for allocating the memory and setting permissions.
147152 static const unsigned PointerSize = 8;
148153 static const unsigned TrampolineSize = 8;
149154
150 typedef GenericIndirectStubsInfo<8> IndirectStubsInfo;
155 using IndirectStubsInfo = GenericIndirectStubsInfo<8>;
151156
152157 /// @brief Write the requsted number of trampolines into the given memory,
153158 /// which must be big enough to hold 1 pointer, plus NumTrampolines
171176 class OrcX86_64_SysV : public OrcX86_64_Base {
172177 public:
173178 static const unsigned ResolverCodeSize = 0x6C;
174 typedef JITTargetAddress (*JITReentryFn)(void *CallbackMgr,
175 void *TrampolineId);
179
180 using JITReentryFn = JITTargetAddress (*)(void *CallbackMgr,
181 void *TrampolineId);
176182
177183 /// @brief Write the resolver code into the given memory. The user is be
178184 /// responsible for allocating the memory and setting permissions.
186192 class OrcX86_64_Win32 : public OrcX86_64_Base {
187193 public:
188194 static const unsigned ResolverCodeSize = 0x74;
189 typedef JITTargetAddress (*JITReentryFn)(void *CallbackMgr,
190 void *TrampolineId);
195
196 using JITReentryFn = JITTargetAddress (*)(void *CallbackMgr,
197 void *TrampolineId);
191198
192199 /// @brief Write the resolver code into the given memory. The user is be
193200 /// responsible for allocating the memory and setting permissions.
204211 static const unsigned TrampolineSize = 8;
205212 static const unsigned ResolverCodeSize = 0x4a;
206213
207 typedef GenericIndirectStubsInfo<8> IndirectStubsInfo;
208
209 typedef JITTargetAddress (*JITReentryFn)(void *CallbackMgr,
210 void *TrampolineId);
214 using IndirectStubsInfo = GenericIndirectStubsInfo<8>;
215
216 using JITReentryFn = JITTargetAddress (*)(void *CallbackMgr,
217 void *TrampolineId);
211218
212219 /// @brief Write the resolver code into the given memory. The user is be
213220 /// responsible for allocating the memory and setting permissions.
230237 unsigned MinStubs, void *InitialPtrVal);
231238 };
232239
233 } // End namespace orc.
234 } // End namespace llvm.
240 } // end namespace orc
241 } // end namespace llvm
235242
236243 #endif // LLVM_EXECUTIONENGINE_ORC_ORCABISUPPORT_H
None //===---- OrcRemoteTargetClient.h - Orc Remote-target Client ----*- C++ -*-===//
0 //===- OrcRemoteTargetClient.h - Orc Remote-target Client -------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1515 #ifndef LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETCLIENT_H
1616 #define LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETCLIENT_H
1717
18 #include "IndirectionUtils.h"
19 #include "OrcRemoteTargetRPCAPI.h"
18 #include "llvm/ADT/Optional.h"
19 #include "llvm/ADT/STLExtras.h"
20 #include "llvm/ADT/StringMap.h"
21 #include "llvm/ADT/StringRef.h"
22 #include "llvm/ExecutionEngine/JITSymbol.h"
23 #include "llvm/ExecutionEngine/Orc/IndirectionUtils.h"
24 #include "llvm/ExecutionEngine/Orc/OrcRemoteTargetRPCAPI.h"
2025 #include "llvm/ExecutionEngine/RuntimeDyld.h"
21 #include
26 #include "llvm/Support/Debug.h"
27 #include "llvm/Support/Error.h"
28 #include "llvm/Support/ErrorHandling.h"
29 #include "llvm/Support/Format.h"
30 #include "llvm/Support/MathExtras.h"
31 #include "llvm/Support/Memory.h"
32 #include "llvm/Support/raw_ostream.h"
33 #include
34 #include
35 #include
36 #include
37 #include
38 #include
39 #include
40 #include
2241
2342 #define DEBUG_TYPE "orc-remote"
2443
206225 DEBUG(dbgs() << "Allocator " << Id << " finalizing:\n");
207226
208227 for (auto &ObjAllocs : Unfinalized) {
209
210228 for (auto &Alloc : ObjAllocs.CodeAllocs) {
211229 DEBUG(dbgs() << " copying code: "
212230 << static_cast(Alloc.getLocalAddress()) << " -> "
468486 OrcRemoteTargetClient &Remote;
469487 ResourceIdMgr::ResourceId Id;
470488 std::vector RemoteIndirectStubsInfos;
471 typedef std::pair StubKey;
489 using StubKey = std::pair;
472490 std::vector FreeStubs;
473491 StringMap> StubIndexes;
474492
709727
710728 Expected reserveMem(ResourceIdMgr::ResourceId Id,
711729 uint64_t Size, uint32_t Align) {
712
713730 // Check for an 'out-of-band' error, e.g. from an MM destructor.
714731 if (ExistingError)
715732 return std::move(ExistingError);
None //===--- OrcRemoteTargetRPCAPI.h - Orc Remote-target RPC API ----*- C++ -*-===//
0 //===- OrcRemoteTargetRPCAPI.h - Orc Remote-target RPC API ------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1515 #ifndef LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETRPCAPI_H
1616 #define LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETRPCAPI_H
1717
18 #include "RPCUtils.h"
19 #include "RawByteChannel.h"
2018 #include "llvm/ExecutionEngine/JITSymbol.h"
19 #include "llvm/ExecutionEngine/Orc/RPCUtils.h"
20 #include "llvm/ExecutionEngine/Orc/RawByteChannel.h"
2121
2222 namespace llvm {
2323 namespace orc {
24
2425 namespace remote {
2526
2627 class DirectBufferWriter {
7172 return EC;
7273 char *Addr = reinterpret_cast(static_cast(Dst));
7374
74 DBW = remote::DirectBufferWriter(0, Dst, Size);
75 DBW = remote::DirectBufferWriter(nullptr, Dst, Size);
7576
7677 return C.readBytes(Addr, Size);
7778 }
8687 protected:
8788 class ResourceIdMgr {
8889 public:
89 typedef uint64_t ResourceId;
90 using ResourceId = uint64_t;
9091 static const ResourceId InvalidId = ~0U;
9192
9293 ResourceId getNext() {
9798 }
9899 return NextId++;
99100 }
101
100102 void release(ResourceId I) { FreeIds.push_back(I); }
101103
102104 private:
260262 };
261263
262264 } // end namespace remote
265
263266 } // end namespace orc
264267 } // end namespace llvm
265268
266 #endif
269 #endif // LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETRPCAPI_H
None //===---- OrcRemoteTargetServer.h - Orc Remote-target Server ----*- C++ -*-===//
0 //===- OrcRemoteTargetServer.h - Orc Remote-target Server -------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1414 #ifndef LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETSERVER_H
1515 #define LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETSERVER_H
1616
17 #include "OrcRemoteTargetRPCAPI.h"
1817 #include "llvm/ExecutionEngine/JITSymbol.h"
1918 #include "llvm/ExecutionEngine/Orc/OrcError.h"
20 #include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
19 #include "llvm/ExecutionEngine/Orc/OrcRemoteTargetRPCAPI.h"
2120 #include "llvm/Support/Debug.h"
2221 #include "llvm/Support/Error.h"
2322 #include "llvm/Support/Format.h"
4746 template
4847 class OrcRemoteTargetServer : public OrcRemoteTargetRPCAPI {
4948 public:
50 typedef std::function
51 SymbolLookupFtor;
52
53 typedef std::function
54 EHFrameRegistrationFtor;
49 using SymbolLookupFtor =
50 std::function;
51
52 using EHFrameRegistrationFtor =
53 std::function;
5554
5655 OrcRemoteTargetServer(ChannelT &Channel, SymbolLookupFtor SymbolLookup,
5756 EHFrameRegistrationFtor EHFramesRegister,
5857 EHFrameRegistrationFtor EHFramesDeregister)
5958 : OrcRemoteTargetRPCAPI(Channel), SymbolLookup(std::move(SymbolLookup)),
6059 EHFramesRegister(std::move(EHFramesRegister)),
61 EHFramesDeregister(std::move(EHFramesDeregister)),
62 TerminateFlag(false) {
63
60 EHFramesDeregister(std::move(EHFramesDeregister)) {
6461 using ThisT = typename std::remove_reference::type;
6562 addHandler(*this, &ThisT::handleCallIntVoid);
6663 addHandler(*this, &ThisT::handleCallMain);
105102 struct Allocator {
106103 Allocator() = default;
107104 Allocator(Allocator &&Other) : Allocs(std::move(Other.Allocs)) {}
105
108106 Allocator &operator=(Allocator &&Other) {
109107 Allocs = std::move(Other.Allocs);
110108 return *this;
152150 }
153151
154152 Expected handleCallIntVoid(JITTargetAddress Addr) {
155 typedef int (*IntVoidFnTy)();
153 using IntVoidFnTy = int (*)();
154
156155 IntVoidFnTy Fn =
157156 reinterpret_cast(static_cast(Addr));
158157
165164
166165 Expected handleCallMain(JITTargetAddress Addr,
167166 std::vector Args) {
168 typedef int (*MainFnTy)(int, const char *[]);
167 using MainFnTy = int (*)(int, const char *[]);
169168
170169 MainFnTy Fn = reinterpret_cast(static_cast(Addr));
171170 int ArgC = Args.size() + 1;
183182 }
184183
185184 Error handleCallVoidVoid(JITTargetAddress Addr) {
186 typedef void (*VoidVoidFnTy)();
185 using VoidVoidFnTy = void (*)();
186
187187 VoidVoidFnTy Fn =
188188 reinterpret_cast(static_cast(Addr));
189189
419419 SymbolLookupFtor SymbolLookup;
420420 EHFrameRegistrationFtor EHFramesRegister, EHFramesDeregister;
421421 std::map Allocators;
422 typedef std::vector ISBlockOwnerList;
422 using ISBlockOwnerList = std::vector;
423423 std::map IndirectStubsOwners;
424424 sys::OwningMemoryBlock ResolverBlock;
425425 std::vector TrampolineBlocks;
426 bool TerminateFlag;
426 bool TerminateFlag = false;
427427 };
428428
429429 } // end namespace remote
432432
433433 #undef DEBUG_TYPE
434434
435 #endif
435 #endif // LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETSERVER_H
None //===-- RTDyldObjectLinkingLayer.h - RTDyld-based jit linking --*- C++ -*-===//
0 //===- RTDyldObjectLinkingLayer.h - RTDyld-based jit linking ---*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1616 #include "llvm/ADT/STLExtras.h"
1717 #include "llvm/ADT/StringMap.h"
1818 #include "llvm/ADT/StringRef.h"
19 #include "llvm/ExecutionEngine/ExecutionEngine.h"
2019 #include "llvm/ExecutionEngine/JITSymbol.h"
2120 #include "llvm/ExecutionEngine/RuntimeDyld.h"
22 #include "llvm/ExecutionEngine/SectionMemoryManager.h"
2321 #include "llvm/Object/ObjectFile.h"
2422 #include "llvm/Support/Error.h"
2523 #include
7573 bool Finalized = false;
7674 };
7775
78 typedef std::list> LinkedObjectSetListT;
76 using LinkedObjectSetListT = std::list>;
7977
8078 public:
8179 /// @brief Handle to a set of loaded objects.
82 typedef LinkedObjectSetListT::iterator ObjSetHandleT;
80 using ObjSetHandleT = LinkedObjectSetListT::iterator;
8381 };
8482
8583 /// @brief Default (no-op) action to perform when loading objects.
10098 class RTDyldObjectLinkingLayer : public RTDyldObjectLinkingLayerBase {
10199 public:
102100 /// @brief Functor for receiving finalization notifications.
103 typedef std::function NotifyFinalizedFtor;
101 using NotifyFinalizedFtor = std::function;
104102
105103 private:
106104 template
215213 SymbolResolverPtrT Resolver,
216214 FinalizerFtor Finalizer,
217215 bool ProcessAllSections) {
218 typedef ConcreteLinkedObjectSet
219 SymbolResolverPtrT, FinalizerFtor> LOS;
216 using LOS = ConcreteLinkedObjectSet
217 SymbolResolverPtrT, FinalizerFtor>;
220218 return llvm::make_unique(std::move(Objects), std::move(MemMgr),
221219 std::move(Resolver), std::move(Finalizer),
222220 ProcessAllSections);
225223 public:
226224 /// @brief LoadedObjectInfo list. Contains a list of owning pointers to
227225 /// RuntimeDyld::LoadedObjectInfo instances.
228 typedef std::vector>
229 LoadedObjInfoList;
226 using LoadedObjInfoList =
227 std::vector>;
230228
231229 /// @brief Construct an ObjectLinkingLayer with the given NotifyLoaded,
232230 /// and NotifyFinalized functors.
234232 NotifyLoadedFtor NotifyLoaded = NotifyLoadedFtor(),
235233 NotifyFinalizedFtor NotifyFinalized = NotifyFinalizedFtor())
236234 : NotifyLoaded(std::move(NotifyLoaded)),
237 NotifyFinalized(std::move(NotifyFinalized)),
238 ProcessAllSections(false) {}
235 NotifyFinalized(std::move(NotifyFinalized)) {}
239236
240237 /// @brief Set the 'ProcessAllSections' flag.
241238 ///
356353 LinkedObjectSetListT LinkedObjSetList;
357354 NotifyLoadedFtor NotifyLoaded;
358355 NotifyFinalizedFtor NotifyFinalized;
359 bool ProcessAllSections;
356 bool ProcessAllSections = false;
360357 };
361358
362359 } // end namespace orc
99 #ifndef LLVM_EXECUTIONENGINE_ORC_RAWBYTECHANNEL_H
1010 #define LLVM_EXECUTIONENGINE_ORC_RAWBYTECHANNEL_H
1111
12 #include "OrcError.h"
13 #include "RPCSerialization.h"
14 #include "llvm/ADT/ArrayRef.h"
15 #include "llvm/ADT/STLExtras.h"
1612 #include "llvm/ADT/StringRef.h"
13 #include "llvm/ExecutionEngine/Orc/RPCSerialization.h"
1714 #include "llvm/Support/Endian.h"
1815 #include "llvm/Support/Error.h"
19 #include
2016 #include
2117 #include
2218 #include
23 #include
2419 #include
25 #include
2620
2721 namespace llvm {
2822 namespace orc {
3125 /// Interface for byte-streams to be used with RPC.
3226 class RawByteChannel {
3327 public:
34 virtual ~RawByteChannel() {}
28 virtual ~RawByteChannel() = default;
3529
3630 /// Read Size bytes from the stream into *Dst.
3731 virtual Error readBytes(char *Dst, unsigned Size) = 0;
None //===-- RuntimeDyld.h - Run-time dynamic linker for MC-JIT ------*- C++ -*-===//
0 //===- RuntimeDyld.h - Run-time dynamic linker for MC-JIT -------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
3131 namespace llvm {
3232
3333 namespace object {
34 template class OwningBinary;
34
35 template class OwningBinary;
36
3537 } // end namespace object
3638
3739 /// Base class for errors originating in RuntimeDyld, e.g. missing relocation
5052 std::string ErrMsg;
5153 };
5254
55 class RuntimeDyldCheckerImpl;
5356 class RuntimeDyldImpl;
54 class RuntimeDyldCheckerImpl;
5557
5658 class RuntimeDyld {
5759 friend class RuntimeDyldCheckerImpl;
6769 friend class RuntimeDyldImpl;
6870
6971 public:
70 typedef std::map ObjSectionToIDMap;
72 using ObjSectionToIDMap = std::map;
7173
7274 LoadedObjectInfo(RuntimeDyldImpl &RTDyld, ObjSectionToIDMap ObjSecToIDMap)
7375 : RTDyld(RTDyld), ObjSecToIDMap(std::move(ObjSecToIDMap)) {}
185187 /// \brief Construct a RuntimeDyld instance.
186188 RuntimeDyld(MemoryManager &MemMgr, JITSymbolResolver &Resolver);
187189 RuntimeDyld(const RuntimeDyld &) = delete;
188 void operator=(const RuntimeDyld &) = delete;
190 RuntimeDyld &operator=(const RuntimeDyld &) = delete;
189191 ~RuntimeDyld();
190192
191193 /// Add the referenced object file to the list of objects to be loaded and
None //===--- OrcCBindingsStack.h - Orc JIT stack for C bindings ---*- C++ -*---===//
0 //===- OrcCBindingsStack.h - Orc JIT stack for C bindings -----*- C++ -*---===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1010 #define LLVM_LIB_EXECUTIONENGINE_ORC_ORCCBINDINGSSTACK_H
1111
1212 #include "llvm-c/OrcBindings.h"
13 #include "llvm/ADT/Triple.h"
13 #include "llvm-c/TargetMachine.h"
14 #include "llvm/ADT/STLExtras.h"
15 #include "llvm/ADT/StringRef.h"
16 #include "llvm/ExecutionEngine/JITSymbol.h"
1417 #include "llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h"
1518 #include "llvm/ExecutionEngine/Orc/CompileUtils.h"
1619 #include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
1720 #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
21 #include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
1822 #include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
19 #include "llvm/IR/LLVMContext.h"
23 #include "llvm/ExecutionEngine/RuntimeDyld.h"
24 #include "llvm/ExecutionEngine/SectionMemoryManager.h"
25 #include "llvm/IR/DataLayout.h"
26 #include "llvm/IR/Mangler.h"
27 #include "llvm/IR/Module.h"
28 #include "llvm/Support/CBindingWrapping.h"
2029 #include "llvm/Support/Error.h"
30 #include "llvm/Support/raw_ostream.h"
31 #include "llvm/Target/TargetMachine.h"
32 #include
33 #include
34 #include
35 #include
36 #include
37 #include
38 #include
2139
2240 namespace llvm {
2341
2846
2947 class OrcCBindingsStack {
3048 public:
31 typedef orc::JITCompileCallbackManager CompileCallbackMgr;
32 typedef orc::RTDyldObjectLinkingLayer<> ObjLayerT;
33 typedef orc::IRCompileLayer CompileLayerT;
34 typedef orc::CompileOnDemandLayer
35 CODLayerT;
36
37 typedef std::function()>
38 CallbackManagerBuilder;
39
40 typedef CODLayerT::IndirectStubsManagerBuilderT IndirectStubsManagerBuilder;
49 using CompileCallbackMgr = orc::JITCompileCallbackManager;
50 using ObjLayerT = orc::RTDyldObjectLinkingLayer<>;
51 using CompileLayerT = orc::IRCompileLayer;
52 using CODLayerT =
53 orc::CompileOnDemandLayer;
54
55 using CallbackManagerBuilder =
56 std::function()>;
57
58 using IndirectStubsManagerBuilder = CODLayerT::IndirectStubsManagerBuilderT;
4159
4260 private:
4361 class GenericHandle {
4462 public:
45 virtual ~GenericHandle() {}
63 virtual ~GenericHandle() = default;
64
4665 virtual JITSymbol findSymbolIn(const std::string &Name,
4766 bool ExportedSymbolsOnly) = 0;
4867 virtual void removeModule() = 0;
7493
7594 public:
7695 // We need a 'ModuleSetHandleT' to conform to the layer concept.
77 typedef unsigned ModuleSetHandleT;
78
79 typedef unsigned ModuleHandleT;
96 using ModuleSetHandleT = unsigned;
97
98 using ModuleHandleT = unsigned;
8099
81100 OrcCBindingsStack(TargetMachine &TM,
82101 std::unique_ptr CCMgr,
83102 IndirectStubsManagerBuilder IndirectStubsMgrBuilder)
84103 : DL(TM.createDataLayout()), IndirectStubsMgr(IndirectStubsMgrBuilder()),
85 CCMgr(std::move(CCMgr)), ObjectLayer(),
104 CCMgr(std::move(CCMgr)),
86105 CompileLayer(ObjectLayer, orc::SimpleCompiler(TM)),
87106 CODLayer(CompileLayer,
88107 [](Function &F) { return std::set({&F}); },
152171 if (ExternalResolver)
153172 return JITSymbol(
154173 ExternalResolver(Name.c_str(), ExternalResolverCtx),
155 llvm::JITSymbolFlags::Exported);
174 JITSymbolFlags::Exported);
156175
157176 return JITSymbol(nullptr);
158177 },
166185 std::unique_ptr MemMgr,
167186 LLVMOrcSymbolResolverFn ExternalResolver,
168187 void *ExternalResolverCtx) {
169
170188 // Attach a data-layout if one isn't already present.
171189 if (M->getDataLayout().isDefault())
172190 M->setDataLayout(DL);
None //===---- OrcMCJITReplacement.h - Orc based MCJIT replacement ---*- C++ -*-===//
0 //===- OrcMCJITReplacement.h - Orc based MCJIT replacement ------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
2323 #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
2424 #include "llvm/ExecutionEngine/Orc/LazyEmittingLayer.h"
2525 #include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
26 #include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
2627 #include "llvm/ExecutionEngine/RuntimeDyld.h"
28 #include "llvm/IR/DataLayout.h"
2729 #include "llvm/IR/Function.h"
2830 #include "llvm/IR/Mangler.h"
31 #include "llvm/IR/Module.h"
2932 #include "llvm/Object/Archive.h"
3033 #include "llvm/Object/Binary.h"
3134 #include "llvm/Object/ObjectFile.h"
4447 #include
4548
4649 namespace llvm {
50
51 class ObjectCache;
52
4753 namespace orc {
4854
4955 class OrcMCJITReplacement : public ExecutionEngine {
150156 };
151157
152158 private:
153
154159 static ExecutionEngine *
155160 createOrcMCJITReplacement(std::string *ErrorMsg,
156161 std::shared_ptr MemMgr,
161166 }
162167
163168 public:
164 static void Register() {
165 OrcMCJITReplacementCtor = createOrcMCJITReplacement;
166 }
167
168169 OrcMCJITReplacement(
169170 std::shared_ptr MemMgr,
170171 std::shared_ptr ClientResolver,
177178 CompileLayer(ObjectLayer, SimpleCompiler(*this->TM)),
178179 LazyEmitLayer(CompileLayer) {}
179180
181 static void Register() {
182 OrcMCJITReplacementCtor = createOrcMCJITReplacement;
183 }
184
180185 void addModule(std::unique_ptr M) override {
181
182186 // If this module doesn't have a DataLayout attached then attach the
183187 // default.
184188 if (M->getDataLayout().isDefault()) {
307311
308312 class NotifyObjectLoadedT {
309313 public:
310 typedef std::vector>
311 LoadedObjInfoListT;
314 using LoadedObjInfoListT =
315 std::vector>;
312316
313317 NotifyObjectLoadedT(OrcMCJITReplacement &M) : M(M) {}
314318
359363 return MangledName;
360364 }
361365
362 typedef RTDyldObjectLinkingLayer ObjectLayerT;
363 typedef IRCompileLayer CompileLayerT;
364 typedef LazyEmittingLayer LazyEmitLayerT;
366 using ObjectLayerT = RTDyldObjectLinkingLayer;
367 using CompileLayerT = IRCompileLayer;
368 using LazyEmitLayerT = LazyEmittingLayer;
365369
366370 std::unique_ptr TM;
367371 MCJITReplacementMemMgr MemMgr;
379383 // We need to store ObjLayerT::ObjSetHandles for each of the object sets
380384 // that have been emitted but not yet finalized so that we can forward the
381385 // mapSectionAddress calls appropriately.
382 typedef std::set SectionAddrSet;
386 using SectionAddrSet = std::set;
383387 struct ObjSetHandleCompare {
384388 bool operator()(ObjectLayerT::ObjSetHandleT H1,
385389 ObjectLayerT::ObjSetHandleT H2) const {
394398 };
395399
396400 } // end namespace orc
401
397402 } // end namespace llvm
398403
399404 #endif // LLVM_LIB_EXECUTIONENGINE_ORC_MCJITREPLACEMENT_H
None //===------ OrcLazyJIT.cpp - Basic Orc-based JIT for lazy execution -------===//
0 //===- OrcLazyJIT.cpp - Basic Orc-based JIT for lazy execution ------------===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
77 //===----------------------------------------------------------------------===//
88
99 #include "OrcLazyJIT.h"
10 #include "llvm/ExecutionEngine/Orc/OrcABISupport.h"
11 #include "llvm/Support/Debug.h"
10 #include "llvm/ADT/Triple.h"
11 #include "llvm/ExecutionEngine/ExecutionEngine.h"
12 #include "llvm/Support/CodeGen.h"
13 #include "llvm/Support/CommandLine.h"
1214 #include "llvm/Support/DynamicLibrary.h"
15 #include "llvm/Support/ErrorHandling.h"
16 #include "llvm/Support/FileSystem.h"
17 #include
1318 #include
19 #include
1420 #include
1521
1622 using namespace llvm;
1723
1824 namespace {
1925
20 enum class DumpKind { NoDump, DumpFuncsToStdOut, DumpModsToStdOut,
21 DumpModsToDisk };
26 enum class DumpKind {
27 NoDump,
28 DumpFuncsToStdOut,
29 DumpModsToStdOut,
30 DumpModsToDisk
31 };
2232
23 cl::opt OrcDumpKind("orc-lazy-debug",
24 cl::desc("Debug dumping for the orc-lazy JIT."),
25 cl::init(DumpKind::NoDump),
26 cl::values(
27 clEnumValN(DumpKind::NoDump, "no-dump",
28 "Don't dump anything."),
29 clEnumValN(DumpKind::DumpFuncsToStdOut,
30 "funcs-to-stdout",
31 "Dump function names to stdout."),
32 clEnumValN(DumpKind::DumpModsToStdOut,
33 "mods-to-stdout",
34 "Dump modules to stdout."),
35 clEnumValN(DumpKind::DumpModsToDisk,
36 "mods-to-disk",
37 "Dump modules to the current "
38 "working directory. (WARNING: "
39 "will overwrite existing files).")),
40 cl::Hidden);
33 } // end anonymous namespace
4134
42 cl::opt OrcInlineStubs("orc-lazy-inline-stubs",
43 cl::desc("Try to inline stubs"),
44 cl::init(true), cl::Hidden);
45 }
35 static cl::opt OrcDumpKind(
36 "orc-lazy-debug", cl::desc("Debug dumping for the orc-lazy JIT."),
37 cl::init(DumpKind::NoDump),
38 cl::values(clEnumValN(DumpKind::NoDump, "no-dump", "Don't dump anything."),
39 clEnumValN(DumpKind::DumpFuncsToStdOut, "funcs-to-stdout",
40 "Dump function names to stdout."),
41 clEnumValN(DumpKind::DumpModsToStdOut, "mods-to-stdout",
42 "Dump modules to stdout."),
43 clEnumValN(DumpKind::DumpModsToDisk, "mods-to-disk",
44 "Dump modules to the current "
45 "working directory. (WARNING: "
46 "will overwrite existing files).")),
47 cl::Hidden);
48
49 static cl::opt OrcInlineStubs("orc-lazy-inline-stubs",
50 cl::desc("Try to inline stubs"),
51 cl::init(true), cl::Hidden);
4652
4753 OrcLazyJIT::TransformFtor OrcLazyJIT::createDebugDumper() {
48
4954 switch (OrcDumpKind) {
5055 case DumpKind::NoDump:
5156 return [](std::unique_ptr M) { return M; };
96101
97102 // Defined in lli.cpp.
98103 CodeGenOpt::Level getOptLevel();
99
100104
101105 template
102106 static PtrTy fromTargetAddress(JITTargetAddress Addr) {
150154 return 1;
151155 }
152156
153 typedef int (*MainFnPtr)(int, const char*[]);
157 using MainFnPtr = int (*)(int, const char*[]);
154158 std::vector ArgV;
155159 for (auto &Arg : Args)
156160 ArgV.push_back(Arg.c_str());
157161 auto Main = fromTargetAddress(MainSym.getAddress());
158162 return Main(ArgV.size(), (const char**)ArgV.data());
159163 }
160
None //===--- OrcLazyJIT.h - Basic Orc-based JIT for lazy execution --*- C++ -*-===//
0 //===- OrcLazyJIT.h - Basic Orc-based JIT for lazy execution ----*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1414 #ifndef LLVM_TOOLS_LLI_ORCLAZYJIT_H
1515 #define LLVM_TOOLS_LLI_ORCLAZYJIT_H
1616
17 #include "llvm/ADT/Triple.h"
17 #include "llvm/ADT/STLExtras.h"
18 #include "llvm/ADT/Twine.h"
19 #include "llvm/ExecutionEngine/JITSymbol.h"
1820 #include "llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h"
1921 #include "llvm/ExecutionEngine/Orc/CompileUtils.h"
2022 #include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
23 #include "llvm/ExecutionEngine/Orc/IndirectionUtils.h"
2124 #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
2225 #include "llvm/ExecutionEngine/Orc/IRTransformLayer.h"
26 #include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
2327 #include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
2428 #include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
29 #include "llvm/ExecutionEngine/SectionMemoryManager.h"
30 #include "llvm/IR/DataLayout.h"
31 #include "llvm/IR/GlobalValue.h"
32 #include "llvm/IR/Mangler.h"
33 #include "llvm/IR/Module.h"
34 #include "llvm/Support/raw_ostream.h"
35 #include "llvm/Target/TargetMachine.h"
36 #include
37 #include
38 #include
39 #include
40 #include
41 #include
2542
2643 namespace llvm {
2744
2845 class OrcLazyJIT {
2946 public:
30
31 typedef orc::JITCompileCallbackManager CompileCallbackMgr;
32 typedef orc::RTDyldObjectLinkingLayer<> ObjLayerT;
33 typedef orc::IRCompileLayer CompileLayerT;
34 typedef std::function(std::unique_ptr)>
35 TransformFtor;
36 typedef orc::IRTransformLayer IRDumpLayerT;
37 typedef orc::CompileOnDemandLayer CODLayerT;
38 typedef CODLayerT::IndirectStubsManagerBuilderT
39 IndirectStubsManagerBuilder;
40 typedef CODLayerT::ModuleSetHandleT ModuleSetHandleT;
47 using CompileCallbackMgr = orc::JITCompileCallbackManager;
48 using ObjLayerT = orc::RTDyldObjectLinkingLayer<>;
49 using CompileLayerT = orc::IRCompileLayer;
50 using TransformFtor =
51 std::function(std::unique_ptr)>;
52 using IRDumpLayerT = orc::IRTransformLayer;
53 using CODLayerT = orc::CompileOnDemandLayer;
54 using IndirectStubsManagerBuilder = CODLayerT::IndirectStubsManagerBuilderT;
55 using ModuleSetHandleT = CODLayerT::ModuleSetHandleT;
4156
4257 OrcLazyJIT(std::unique_ptr TM,
4358 std::unique_ptr CCMgr,
4459 IndirectStubsManagerBuilder IndirectStubsMgrBuilder,
4560 bool InlineStubs)
4661 : TM(std::move(TM)), DL(this->TM->createDataLayout()),
47 CCMgr(std::move(CCMgr)),
48 ObjectLayer(),
62 CCMgr(std::move(CCMgr)),
4963 CompileLayer(ObjectLayer, orc::SimpleCompiler(*this->TM)),
5064 IRDumpLayer(CompileLayer, createDebugDumper()),
5165 CODLayer(IRDumpLayer, extractSingleFunction, *this->CCMgr,
134148 }
135149
136150 private:
137
138151 std::string mangle(const std::string &Name) {
139152 std::string MangledName;
140153 {
171184
172185 } // end namespace llvm
173186
174 #endif
187 #endif // LLVM_TOOLS_LLI_ORCLAZYJIT_H