#ifndef LLVM_EXECUTIONENGINE_EXECUTIONENGINE_H
#define LLVM_EXECUTIONENGINE_EXECUTIONENGINE_H
-#include "RuntimeDyld.h"
#include "llvm-c/ExecutionEngine.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/ExecutionEngine/JITSymbol.h"
+#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Module.h"
-#include "llvm/IR/ValueHandle.h"
-#include "llvm/IR/ValueMap.h"
#include "llvm/Object/Binary.h"
+#include "llvm/Support/CBindingWrapping.h"
+#include "llvm/Support/CodeGen.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Mutex.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
+#include <algorithm>
+#include <cstdint>
#include <functional>
#include <map>
+#include <memory>
#include <string>
#include <vector>
namespace llvm {
-struct GenericValue;
class Constant;
-class DataLayout;
-class ExecutionEngine;
class Function;
-class GlobalVariable;
+struct GenericValue;
class GlobalValue;
+class GlobalVariable;
class JITEventListener;
-class MachineCodeInfo;
class MCJITMemoryManager;
-class MutexGuard;
class ObjectCache;
class RTDyldMemoryManager;
class Triple;
class Type;
namespace object {
- class Archive;
- class ObjectFile;
-}
+
+class Archive;
+class ObjectFile;
+
+} // end namespace object
/// \brief Helper class for helping synchronize access to the global address map
/// table. Access to this class should be serialized under a mutex.
class ExecutionEngineState {
public:
- typedef StringMap<uint64_t> GlobalAddressMapTy;
+ using GlobalAddressMapTy = StringMap<uint64_t>;
private:
-
/// GlobalAddressMap - A mapping between LLVM global symbol names values and
/// their actualized version...
GlobalAddressMapTy GlobalAddressMap;
std::map<uint64_t, std::string> GlobalAddressReverseMap;
public:
-
GlobalAddressMapTy &getGlobalAddressMap() {
return GlobalAddressMap;
}
};
namespace EngineKind {
+
// These are actually bitmasks that get or-ed together.
enum Kind {
JIT = 0x1,
Interpreter = 0x2
};
const static Kind Either = (Kind)(JIT | Interpreter);
-}
+
+} // end namespace EngineKind
/// Builder class for ExecutionEngines. Use this by stack-allocating a builder,
/// chaining the various set* methods, and terminating it with a .create()
// Create wrappers for C Binding types (see CBindingWrapping.h).
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ExecutionEngine, LLVMExecutionEngineRef)
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_EXECUTIONENGINE_EXECUTIONENGINE_H
-//===-- GenericValue.h - Represent any type of LLVM value -------*- C++ -*-===//
+//===- GenericValue.h - Represent any type of LLVM value --------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
-
#ifndef LLVM_EXECUTIONENGINE_GENERICVALUE_H
#define LLVM_EXECUTIONENGINE_GENERICVALUE_H
#include "llvm/ADT/APInt.h"
-#include "llvm/Support/DataTypes.h"
#include <vector>
namespace llvm {
-typedef void* PointerTy;
-class APInt;
+using PointerTy = void *;
struct GenericValue {
struct IntPair {
unsigned int second;
};
union {
- double DoubleVal;
- float FloatVal;
- PointerTy PointerVal;
- struct IntPair UIntPairVal;
- unsigned char Untyped[8];
+ double DoubleVal;
+ float FloatVal;
+ PointerTy PointerVal;
+ struct IntPair UIntPairVal;
+ unsigned char Untyped[8];
};
- APInt IntVal; // also used for long doubles.
+ APInt IntVal; // also used for long doubles.
// For aggregate data types.
std::vector<GenericValue> AggregateVal;
// to make code faster, set GenericValue to zero could be omitted, but it is
// potentially can cause problems, since GenericValue to store garbage
// instead of zero.
- GenericValue() : IntVal(1,0) {UIntPairVal.first = 0; UIntPairVal.second = 0;}
- explicit GenericValue(void *V) : PointerVal(V), IntVal(1,0) { }
+ GenericValue() : IntVal(1, 0) {
+ UIntPairVal.first = 0;
+ UIntPairVal.second = 0;
+ }
+ explicit GenericValue(void *V) : PointerVal(V), IntVal(1, 0) {}
};
inline GenericValue PTOGV(void *P) { return GenericValue(P); }
-inline void* GVTOP(const GenericValue &GV) { return GV.PointerVal; }
+inline void *GVTOP(const GenericValue &GV) { return GV.PointerVal; }
+
+} // end namespace llvm
-} // End llvm namespace.
-#endif
+#endif // LLVM_EXECUTIONENGINE_GENERICVALUE_H
#ifndef LLVM_EXECUTIONENGINE_JITEVENTLISTENER_H
#define LLVM_EXECUTIONENGINE_JITEVENTLISTENER_H
-#include "RuntimeDyld.h"
#include "llvm/Config/llvm-config.h"
+#include "llvm/ExecutionEngine/RuntimeDyld.h"
#include "llvm/IR/DebugLoc.h"
#include <cstdint>
#include <vector>
class OProfileWrapper;
namespace object {
- class ObjectFile;
+
+class ObjectFile;
+
} // end namespace object
/// JITEvent_EmittedFunctionDetails - Helper struct for containing information
/// The default implementation of each method does nothing.
class JITEventListener {
public:
- typedef JITEvent_EmittedFunctionDetails EmittedFunctionDetails;
+ using EmittedFunctionDetails = JITEvent_EmittedFunctionDetails;
public:
JITEventListener() = default;
-//===----------- JITSymbol.h - JIT symbol abstraction -----------*- C++ -*-===//
+//===- JITSymbol.h - JIT symbol abstraction ---------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
class GlobalValue;
namespace object {
- class BasicSymbolRef;
+
+class BasicSymbolRef;
+
} // end namespace object
/// @brief Represents an address in the target process's address space.
-typedef uint64_t JITTargetAddress;
+using JITTargetAddress = uint64_t;
/// @brief Flags for symbols in the JIT.
class JITSymbolFlags {
public:
- typedef uint8_t UnderlyingType;
+ using UnderlyingType = uint8_t;
enum FlagNames : UnderlyingType {
None = 0,
};
/// @brief Default-construct a JITSymbolFlags instance.
- JITSymbolFlags() : Flags(None) {}
+ JITSymbolFlags() = default;
/// @brief Construct a JITSymbolFlags instance from the given flags.
JITSymbolFlags(FlagNames Flags) : Flags(Flags) {}
static JITSymbolFlags fromObjectSymbol(const object::BasicSymbolRef &Symbol);
private:
- UnderlyingType Flags;
+ UnderlyingType Flags = None;
};
/// @brief Represents a symbol that has been evaluated to an address already.
class JITEvaluatedSymbol {
public:
/// @brief Create a 'null' symbol.
- JITEvaluatedSymbol(std::nullptr_t)
- : Address(0) {}
+ JITEvaluatedSymbol(std::nullptr_t) {}
/// @brief Create a symbol for the given address and flags.
JITEvaluatedSymbol(JITTargetAddress Address, JITSymbolFlags Flags)
JITSymbolFlags getFlags() const { return Flags; }
private:
- JITTargetAddress Address;
+ JITTargetAddress Address = 0;
JITSymbolFlags Flags;
};
/// @brief Represents a symbol in the JIT.
class JITSymbol {
public:
- typedef std::function<JITTargetAddress()> GetAddressFtor;
+ using GetAddressFtor = std::function<JITTargetAddress()>;
/// @brief Create a 'null' symbol that represents failure to find a symbol
/// definition.
- JITSymbol(std::nullptr_t)
- : CachedAddr(0) {}
+ JITSymbol(std::nullptr_t) {}
/// @brief Create a symbol for a definition with a known address.
JITSymbol(JITTargetAddress Addr, JITSymbolFlags Flags)
/// user can materialize the definition at any time by calling the getAddress
/// method.
JITSymbol(GetAddressFtor GetAddress, JITSymbolFlags Flags)
- : GetAddress(std::move(GetAddress)), CachedAddr(0), Flags(Flags) {}
+ : GetAddress(std::move(GetAddress)), Flags(Flags) {}
/// @brief Returns true if the symbol exists, false otherwise.
explicit operator bool() const { return CachedAddr || GetAddress; }
private:
GetAddressFtor GetAddress;
- JITTargetAddress CachedAddr;
+ JITTargetAddress CachedAddr = 0;
JITSymbolFlags Flags;
};
#include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
#include "llvm/ExecutionEngine/RuntimeDyld.h"
#include "llvm/IR/Attributes.h"
+#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalAlias.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/GlobalVariable.h"
+#include "llvm/IR/Instruction.h"
#include "llvm/IR/Mangler.h"
#include "llvm/IR/Module.h"
+#include "llvm/IR/Type.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/raw_ostream.h"
+#include "llvm/Transforms/Utils/ValueMapper.h"
#include <algorithm>
#include <cassert>
#include <functional>
#include <vector>
namespace llvm {
+
+class Value;
+
namespace orc {
/// @brief Compile-on-demand layer.
return LambdaMaterializer<MaterializerFtor>(std::move(M));
}
- typedef typename BaseLayerT::ModuleSetHandleT BaseLayerModuleSetHandleT;
+ using BaseLayerModuleSetHandleT = typename BaseLayerT::ModuleSetHandleT;
// Provide type-erasure for the Modules and MemoryManagers.
template <typename ResourceT>
class ResourceOwner {
public:
ResourceOwner() = default;
- ResourceOwner(const ResourceOwner&) = delete;
- ResourceOwner& operator=(const ResourceOwner&) = delete;
+ ResourceOwner(const ResourceOwner &) = delete;
+ ResourceOwner &operator=(const ResourceOwner &) = delete;
virtual ~ResourceOwner() = default;
virtual ResourceT& getResource() const = 0;
template <typename ResourceT, typename ResourcePtrT>
std::unique_ptr<ResourceOwner<ResourceT>>
wrapOwnership(ResourcePtrT ResourcePtr) {
- typedef ResourceOwnerImpl<ResourceT, ResourcePtrT> RO;
+ using RO = ResourceOwnerImpl<ResourceT, ResourcePtrT>;
return llvm::make_unique<RO>(std::move(ResourcePtr));
}
};
struct LogicalDylib {
- typedef std::function<JITSymbol(const std::string&)> SymbolResolverFtor;
+ using SymbolResolverFtor = std::function<JITSymbol(const std::string&)>;
- typedef std::function<typename BaseLayerT::ModuleSetHandleT(
- BaseLayerT&,
- std::unique_ptr<Module>,
- std::unique_ptr<JITSymbolResolver>)>
- ModuleAdderFtor;
+ using ModuleAdderFtor = std::function<typename BaseLayerT::ModuleSetHandleT(
+ BaseLayerT &, std::unique_ptr<Module>,
+ std::unique_ptr<JITSymbolResolver>)>;
struct SourceModuleEntry {
std::unique_ptr<ResourceOwner<Module>> SourceMod;
std::set<Function*> StubsToClone;
};
- typedef std::vector<SourceModuleEntry> SourceModulesList;
- typedef typename SourceModulesList::size_type SourceModuleHandle;
+ using SourceModulesList = std::vector<SourceModuleEntry>;
+ using SourceModuleHandle = typename SourceModulesList::size_type;
SourceModuleHandle
addSourceModule(std::unique_ptr<ResourceOwner<Module>> M) {
std::vector<BaseLayerModuleSetHandleT> BaseLayerHandles;
};
- typedef std::list<LogicalDylib> LogicalDylibList;
+ using LogicalDylibList = std::list<LogicalDylib>;
public:
/// @brief Handle to a set of loaded modules.
- typedef typename LogicalDylibList::iterator ModuleSetHandleT;
+ using ModuleSetHandleT = typename LogicalDylibList::iterator;
/// @brief Module partitioning functor.
- typedef std::function<std::set<Function*>(Function&)> PartitioningFtor;
+ using PartitioningFtor = std::function<std::set<Function*>(Function&)>;
/// @brief Builder for IndirectStubsManagers.
- typedef std::function<std::unique_ptr<IndirectStubsMgrT>()>
- IndirectStubsManagerBuilderT;
+ using IndirectStubsManagerBuilderT =
+ std::function<std::unique_ptr<IndirectStubsMgrT>()>;
/// @brief Construct a compile-on-demand layer instance.
CompileOnDemandLayer(BaseLayerT &BaseLayer, PartitioningFtor Partition,
ModuleSetHandleT addModuleSet(ModuleSetT Ms,
MemoryManagerPtrT MemMgr,
SymbolResolverPtrT Resolver) {
-
LogicalDylibs.push_back(LogicalDylib());
auto &LD = LogicalDylibs.back();
LD.ExternalSymbolResolver = std::move(Resolver);
private:
template <typename ModulePtrT>
void addLogicalModule(LogicalDylib &LD, ModulePtrT SrcMPtr) {
-
// Rename all static functions / globals to $static.X :
// This will unique the names across all modules in the logical dylib,
// simplifying symbol lookup.
};
} // end namespace orc
+
} // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_COMPILEONDEMANDLAYER_H
-//===-- CompileUtils.h - Utilities for compiling IR in the JIT --*- C++ -*-===//
+//===- CompileUtils.h - Utilities for compiling IR in the JIT ---*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
#ifndef LLVM_EXECUTIONENGINE_ORC_COMPILEUTILS_H
#define LLVM_EXECUTIONENGINE_ORC_COMPILEUTILS_H
+#include "llvm/ADT/SmallVector.h"
#include "llvm/ExecutionEngine/ObjectMemoryBuffer.h"
#include "llvm/IR/LegacyPassManager.h"
-#include "llvm/MC/MCContext.h"
+#include "llvm/Object/Binary.h"
#include "llvm/Object/ObjectFile.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
+#include <algorithm>
+#include <memory>
namespace llvm {
+
+class MCContext;
+class Module;
+
namespace orc {
/// @brief Simple compile functor: Takes a single IR module and returns an
new ObjectMemoryBuffer(std::move(ObjBufferSV)));
Expected<std::unique_ptr<object::ObjectFile>> Obj =
object::ObjectFile::createObjectFile(ObjBuffer->getMemBufferRef());
- typedef object::OwningBinary<object::ObjectFile> OwningObj;
+ using OwningObj = object::OwningBinary<object::ObjectFile>;
if (Obj)
return OwningObj(std::move(*Obj), std::move(ObjBuffer));
// TODO: Actually report errors helpfully.
TargetMachine &TM;
};
-} // End namespace orc.
-} // End namespace llvm.
+} // end namespace orc
+
+} // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_COMPILEUTILS_H
-//===-- ExecutionUtils.h - Utilities for executing code in Orc --*- C++ -*-===//
+//===- ExecutionUtils.h - Utilities for executing code in Orc ---*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
-#include "llvm/ExecutionEngine/RuntimeDyld.h"
+#include <algorithm>
+#include <cstdint>
+#include <string>
#include <vector>
+#include <utility>
namespace llvm {
/// getConstructors/getDestructors functions.
class CtorDtorIterator {
public:
-
/// @brief Accessor for an element of the global_ctors/global_dtors array.
///
/// This class provides a read-only view of the element with any casts on
template <typename JITLayerT>
class CtorDtorRunner {
public:
-
/// @brief Construct a CtorDtorRunner for the given range using the given
/// name mangling function.
CtorDtorRunner(std::vector<std::string> CtorDtorNames,
/// @brief Run the recorded constructors/destructors through the given JIT
/// layer.
bool runViaLayer(JITLayerT &JITLayer) const {
- typedef void (*CtorDtorTy)();
+ using CtorDtorTy = void (*)();
bool Error = false;
for (const auto &CtorDtorName : CtorDtorNames)
/// called.
class LocalCXXRuntimeOverrides {
public:
-
/// Create a runtime-overrides class.
template <typename MangleFtorT>
LocalCXXRuntimeOverrides(const MangleFtorT &Mangle) {
void runDestructors();
private:
-
template <typename PtrTy>
JITTargetAddress toTargetAddress(PtrTy* P) {
return static_cast<JITTargetAddress>(reinterpret_cast<uintptr_t>(P));
StringMap<JITTargetAddress> CXXRuntimeOverrides;
- typedef void (*DestructorPtr)(void*);
- typedef std::pair<DestructorPtr, void*> CXXDestructorDataPair;
- typedef std::vector<CXXDestructorDataPair> CXXDestructorDataPairList;
+ using DestructorPtr = void (*)(void *);
+ using CXXDestructorDataPair = std::pair<DestructorPtr, void *>;
+ using CXXDestructorDataPairList = std::vector<CXXDestructorDataPair>;
CXXDestructorDataPairList DSOHandleOverride;
static int CXAAtExitOverride(DestructorPtr Destructor, void *Arg,
void *DSOHandle);
};
-} // End namespace orc.
-} // End namespace llvm.
+} // end namespace orc
+
+} // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_EXECUTIONUTILS_H
-//===---- GlobalMappingLayer.h - Run all IR through a functor ---*- C++ -*-===//
+//===- GlobalMappingLayer.h - Run all IR through a functor ------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
#include "llvm/ExecutionEngine/JITSymbol.h"
#include <map>
+#include <string>
namespace llvm {
namespace orc {
class GlobalMappingLayer {
public:
/// @brief Handle to a set of added modules.
- typedef typename BaseLayerT::ModuleSetHandleT ModuleSetHandleT;
+ using ModuleSetHandleT = typename BaseLayerT::ModuleSetHandleT;
/// @brief Construct an GlobalMappingLayer with the given BaseLayer
GlobalMappingLayer(BaseLayerT &BaseLayer) : BaseLayer(BaseLayer) {}
std::map<std::string, JITTargetAddress> SymbolTable;
};
-} // End namespace orc.
-} // End namespace llvm.
+} // end namespace orc
+} // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_GLOBALMAPPINGLAYER_H
-//===------ IRCompileLayer.h -- Eagerly compile IR for JIT ------*- C++ -*-===//
+//===- IRCompileLayer.h -- Eagerly compile IR for JIT -----------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
#ifndef LLVM_EXECUTIONENGINE_ORC_IRCOMPILELAYER_H
#define LLVM_EXECUTIONENGINE_ORC_IRCOMPILELAYER_H
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/ExecutionEngine/ObjectCache.h"
+#include "llvm/Object/Binary.h"
#include "llvm/Object/ObjectFile.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include <algorithm>
+#include <functional>
#include <memory>
+#include <string>
+#include <vector>
namespace llvm {
+
+class Module;
+
namespace orc {
/// @brief Eager IR compiling layer.
/// the layer below, which must implement the object layer concept.
template <typename BaseLayerT> class IRCompileLayer {
public:
- typedef std::function<object::OwningBinary<object::ObjectFile>(Module &)>
- CompileFtor;
+ using CompileFtor =
+ std::function<object::OwningBinary<object::ObjectFile>(Module &)>;
private:
- typedef typename BaseLayerT::ObjSetHandleT ObjSetHandleT;
+ using ObjSetHandleT = typename BaseLayerT::ObjSetHandleT;
public:
/// @brief Handle to a set of compiled modules.
- typedef ObjSetHandleT ModuleSetHandleT;
+ using ModuleSetHandleT = ObjSetHandleT;
/// @brief Construct an IRCompileLayer with the given BaseLayer, which must
/// implement the ObjectLayer concept.
IRCompileLayer(BaseLayerT &BaseLayer, CompileFtor Compile)
- : BaseLayer(BaseLayer), Compile(std::move(Compile)), ObjCache(nullptr) {}
+ : BaseLayer(BaseLayer), Compile(std::move(Compile)) {}
/// @brief Set an ObjectCache to query before compiling.
void setObjectCache(ObjectCache *NewCache) { ObjCache = NewCache; }
BaseLayerT &BaseLayer;
CompileFtor Compile;
- ObjectCache *ObjCache;
+ ObjectCache *ObjCache = nullptr;
};
-} // End namespace orc.
-} // End namespace llvm.
+} // end namespace orc
+
+} // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_IRCOMPILINGLAYER_H
-//===----- IRTransformLayer.h - Run all IR through a functor ----*- C++ -*-===//
+//===- IRTransformLayer.h - Run all IR through a functor --------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
#define LLVM_EXECUTIONENGINE_ORC_IRTRANSFORMLAYER_H
#include "llvm/ExecutionEngine/JITSymbol.h"
+#include <string>
namespace llvm {
namespace orc {
class IRTransformLayer {
public:
/// @brief Handle to a set of added modules.
- typedef typename BaseLayerT::ModuleSetHandleT ModuleSetHandleT;
+ using ModuleSetHandleT = typename BaseLayerT::ModuleSetHandleT;
/// @brief Construct an IRTransformLayer with the given BaseLayer
IRTransformLayer(BaseLayerT &BaseLayer,
ModuleSetHandleT addModuleSet(ModuleSetT Ms,
MemoryManagerPtrT MemMgr,
SymbolResolverPtrT Resolver) {
-
for (auto I = Ms.begin(), E = Ms.end(); I != E; ++I)
*I = Transform(std::move(*I));
TransformFtor Transform;
};
-} // End namespace orc.
-} // End namespace llvm.
+} // end namespace orc
+} // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_IRTRANSFORMLAYER_H
-//===-- IndirectionUtils.h - Utilities for adding indirections --*- C++ -*-===//
+//===- IndirectionUtils.h - Utilities for adding indirections ---*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
-#include "llvm/IR/IRBuilder.h"
-#include "llvm/IR/Mangler.h"
-#include "llvm/IR/Module.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/Memory.h"
#include "llvm/Support/Process.h"
#include <vector>
namespace llvm {
+
+class Constant;
+class Function;
+class FunctionType;
+class GlobalAlias;
+class GlobalVariable;
+class Module;
+class PointerType;
+class Triple;
+class Value;
+
namespace orc {
/// @brief Target-independent base class for compile callback management.
class JITCompileCallbackManager {
public:
- typedef std::function<JITTargetAddress()> CompileFtor;
+ using CompileFtor = std::function<JITTargetAddress()>;
/// @brief Handle to a newly created compile callback. Can be used to get an
/// IR constant representing the address of the trampoline, and to set
protected:
JITTargetAddress ErrorHandlerAddress;
- typedef std::map<JITTargetAddress, CompileFtor> TrampolineMapT;
+ using TrampolineMapT = std::map<JITTargetAddress, CompileFtor>;
TrampolineMapT ActiveTrampolines;
std::vector<JITTargetAddress> AvailableTrampolines;
/// process to be used if a compile callback fails.
LocalJITCompileCallbackManager(JITTargetAddress ErrorHandlerAddress)
: JITCompileCallbackManager(ErrorHandlerAddress) {
-
/// Set up the resolver block.
std::error_code EC;
ResolverBlock = sys::OwningMemoryBlock(sys::Memory::allocateMappedMemory(
class IndirectStubsManager {
public:
/// @brief Map type for initializing the manager. See init.
- typedef StringMap<std::pair<JITTargetAddress, JITSymbolFlags>> StubInitsMap;
+ using StubInitsMap = StringMap<std::pair<JITTargetAddress, JITSymbolFlags>>;
virtual ~IndirectStubsManager() = default;
}
std::vector<typename TargetT::IndirectStubsInfo> IndirectStubsInfos;
- typedef std::pair<uint16_t, uint16_t> StubKey;
+ using StubKey = std::pair<uint16_t, uint16_t>;
std::vector<StubKey> FreeStubs;
StringMap<std::pair<StubKey, JITSymbolFlags>> StubIndexes;
};
ValueToValueMapTy &VMap);
} // end namespace orc
+
} // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_INDIRECTIONUTILS_H
-//===-- LambdaResolverMM - Redirect symbol lookup via a functor -*- C++ -*-===//
+//===- LambdaResolverMM - Redirect symbol lookup via a functor --*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
#define LLVM_EXECUTIONENGINE_ORC_LAMBDARESOLVER_H
#include "llvm/ADT/STLExtras.h"
-#include "llvm/ExecutionEngine/RuntimeDyld.h"
+#include "llvm/ExecutionEngine/JITSymbol.h"
#include <memory>
namespace llvm {
template <typename DylibLookupFtorT, typename ExternalLookupFtorT>
class LambdaResolver : public JITSymbolResolver {
public:
-
LambdaResolver(DylibLookupFtorT DylibLookupFtor,
ExternalLookupFtorT ExternalLookupFtor)
: DylibLookupFtor(DylibLookupFtor),
std::unique_ptr<LambdaResolver<DylibLookupFtorT, ExternalLookupFtorT>>
createLambdaResolver(DylibLookupFtorT DylibLookupFtor,
ExternalLookupFtorT ExternalLookupFtor) {
- typedef LambdaResolver<DylibLookupFtorT, ExternalLookupFtorT> LR;
+ using LR = LambdaResolver<DylibLookupFtorT, ExternalLookupFtorT>;
return make_unique<LR>(std::move(DylibLookupFtor),
std::move(ExternalLookupFtor));
}
-} // End namespace orc.
-} // End namespace llvm.
+} // end namespace orc
+} // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_LAMBDARESOLVER_H
/// (via JITSymbol::getAddress) for a symbol contained in this layer.
template <typename BaseLayerT> class LazyEmittingLayer {
public:
- typedef typename BaseLayerT::ModuleSetHandleT BaseLayerHandleT;
+ using BaseLayerHandleT = typename BaseLayerT::ModuleSetHandleT;
private:
class EmissionDeferredSet {
mutable std::unique_ptr<StringMap<const GlobalValue*>> MangledSymbols;
};
- typedef std::list<std::unique_ptr<EmissionDeferredSet>> ModuleSetListT;
+ using ModuleSetListT = std::list<std::unique_ptr<EmissionDeferredSet>>;
BaseLayerT &BaseLayer;
ModuleSetListT ModuleSetList;
public:
/// @brief Handle to a set of loaded modules.
- typedef typename ModuleSetListT::iterator ModuleSetHandleT;
+ using ModuleSetHandleT = typename ModuleSetListT::iterator;
/// @brief Construct a lazy emitting layer.
LazyEmittingLayer(BaseLayerT &BaseLayer) : BaseLayer(BaseLayer) {}
LazyEmittingLayer<BaseLayerT>::EmissionDeferredSet::create(
BaseLayerT &B, ModuleSetT Ms, MemoryManagerPtrT MemMgr,
SymbolResolverPtrT Resolver) {
- typedef EmissionDeferredSetImpl<ModuleSetT, MemoryManagerPtrT, SymbolResolverPtrT>
- EDS;
+ using EDS = EmissionDeferredSetImpl<ModuleSetT, MemoryManagerPtrT,
+ SymbolResolverPtrT>;
return llvm::make_unique<EDS>(std::move(Ms), std::move(MemMgr),
std::move(Resolver));
}
#define LLVM_EXECUTIONENGINE_ORC_OBJECTTRANSFORMLAYER_H
#include "llvm/ExecutionEngine/JITSymbol.h"
+#include <algorithm>
+#include <string>
namespace llvm {
namespace orc {
class ObjectTransformLayer {
public:
/// @brief Handle to a set of added objects.
- typedef typename BaseLayerT::ObjSetHandleT ObjSetHandleT;
+ using ObjSetHandleT = typename BaseLayerT::ObjSetHandleT;
/// @brief Construct an ObjectTransformLayer with the given BaseLayer
ObjectTransformLayer(BaseLayerT &BaseLayer,
typename SymbolResolverPtrT>
ObjSetHandleT addObjectSet(ObjSetT Objects, MemoryManagerPtrT MemMgr,
SymbolResolverPtrT Resolver) {
-
for (auto I = Objects.begin(), E = Objects.end(); I != E; ++I)
*I = Transform(std::move(*I));
TransformFtor Transform;
};
-} // End namespace orc.
-} // End namespace llvm.
+} // end namespace orc
+} // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_OBJECTTRANSFORMLAYER_H
-//===-------------- OrcABISupport.h - ABI support code ---------*- C++ -*-===//
+//===- OrcABISupport.h - ABI support code -----------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
#ifndef LLVM_EXECUTIONENGINE_ORC_ORCABISUPPORT_H
#define LLVM_EXECUTIONENGINE_ORC_ORCABISUPPORT_H
-#include "IndirectionUtils.h"
+#include "llvm/ExecutionEngine/JITSymbol.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Memory.h"
-#include "llvm/Support/Process.h"
+#include <algorithm>
+#include <cstdint>
namespace llvm {
namespace orc {
static const unsigned TrampolineSize = 1;
static const unsigned ResolverCodeSize = 1;
- typedef JITTargetAddress (*JITReentryFn)(void *CallbackMgr,
- void *TrampolineId);
+ using JITReentryFn = JITTargetAddress (*)(void *CallbackMgr,
+ void *TrampolineId);
static void writeResolverCode(uint8_t *ResolveMem, JITReentryFn Reentry,
void *CallbackMgr) {
class IndirectStubsInfo {
public:
const static unsigned StubSize = 1;
+
unsigned getNumStubs() const { llvm_unreachable("Not supported"); }
void *getStub(unsigned Idx) const { llvm_unreachable("Not supported"); }
void **getPtr(unsigned Idx) const { llvm_unreachable("Not supported"); }
public:
const static unsigned StubSize = StubSizeVal;
- GenericIndirectStubsInfo() : NumStubs(0) {}
+ GenericIndirectStubsInfo() = default;
GenericIndirectStubsInfo(unsigned NumStubs, sys::OwningMemoryBlock StubsMem)
: NumStubs(NumStubs), StubsMem(std::move(StubsMem)) {}
GenericIndirectStubsInfo(GenericIndirectStubsInfo &&Other)
: NumStubs(Other.NumStubs), StubsMem(std::move(Other.StubsMem)) {
Other.NumStubs = 0;
}
+
GenericIndirectStubsInfo &operator=(GenericIndirectStubsInfo &&Other) {
NumStubs = Other.NumStubs;
Other.NumStubs = 0;
}
private:
- unsigned NumStubs;
+ unsigned NumStubs = 0;
sys::OwningMemoryBlock StubsMem;
};
static const unsigned TrampolineSize = 12;
static const unsigned ResolverCodeSize = 0x120;
- typedef GenericIndirectStubsInfo<8> IndirectStubsInfo;
+ using IndirectStubsInfo = GenericIndirectStubsInfo<8>;
- typedef JITTargetAddress (*JITReentryFn)(void *CallbackMgr,
- void *TrampolineId);
+ using JITReentryFn = JITTargetAddress (*)(void *CallbackMgr,
+ void *TrampolineId);
/// @brief Write the resolver code into the given memory. The user is be
/// responsible for allocating the memory and setting permissions.
static const unsigned PointerSize = 8;
static const unsigned TrampolineSize = 8;
- typedef GenericIndirectStubsInfo<8> IndirectStubsInfo;
+ using IndirectStubsInfo = GenericIndirectStubsInfo<8>;
/// @brief Write the requsted number of trampolines into the given memory,
/// which must be big enough to hold 1 pointer, plus NumTrampolines
class OrcX86_64_SysV : public OrcX86_64_Base {
public:
static const unsigned ResolverCodeSize = 0x6C;
- typedef JITTargetAddress (*JITReentryFn)(void *CallbackMgr,
- void *TrampolineId);
+
+ using JITReentryFn = JITTargetAddress (*)(void *CallbackMgr,
+ void *TrampolineId);
/// @brief Write the resolver code into the given memory. The user is be
/// responsible for allocating the memory and setting permissions.
class OrcX86_64_Win32 : public OrcX86_64_Base {
public:
static const unsigned ResolverCodeSize = 0x74;
- typedef JITTargetAddress (*JITReentryFn)(void *CallbackMgr,
- void *TrampolineId);
+
+ using JITReentryFn = JITTargetAddress (*)(void *CallbackMgr,
+ void *TrampolineId);
/// @brief Write the resolver code into the given memory. The user is be
/// responsible for allocating the memory and setting permissions.
static const unsigned TrampolineSize = 8;
static const unsigned ResolverCodeSize = 0x4a;
- typedef GenericIndirectStubsInfo<8> IndirectStubsInfo;
+ using IndirectStubsInfo = GenericIndirectStubsInfo<8>;
- typedef JITTargetAddress (*JITReentryFn)(void *CallbackMgr,
- void *TrampolineId);
+ using JITReentryFn = JITTargetAddress (*)(void *CallbackMgr,
+ void *TrampolineId);
/// @brief Write the resolver code into the given memory. The user is be
/// responsible for allocating the memory and setting permissions.
unsigned MinStubs, void *InitialPtrVal);
};
-} // End namespace orc.
-} // End namespace llvm.
+} // end namespace orc
+} // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_ORCABISUPPORT_H
-//===---- OrcRemoteTargetClient.h - Orc Remote-target Client ----*- C++ -*-===//
+//===- OrcRemoteTargetClient.h - Orc Remote-target Client -------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
#ifndef LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETCLIENT_H
#define LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETCLIENT_H
-#include "IndirectionUtils.h"
-#include "OrcRemoteTargetRPCAPI.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ExecutionEngine/JITSymbol.h"
+#include "llvm/ExecutionEngine/Orc/IndirectionUtils.h"
+#include "llvm/ExecutionEngine/Orc/OrcRemoteTargetRPCAPI.h"
#include "llvm/ExecutionEngine/RuntimeDyld.h"
-#include <system_error>
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/Format.h"
+#include "llvm/Support/MathExtras.h"
+#include "llvm/Support/Memory.h"
+#include "llvm/Support/raw_ostream.h"
+#include <algorithm>
+#include <cassert>
+#include <cstdint>
+#include <memory>
+#include <string>
+#include <tuple>
+#include <utility>
+#include <vector>
#define DEBUG_TYPE "orc-remote"
DEBUG(dbgs() << "Allocator " << Id << " finalizing:\n");
for (auto &ObjAllocs : Unfinalized) {
-
for (auto &Alloc : ObjAllocs.CodeAllocs) {
DEBUG(dbgs() << " copying code: "
<< static_cast<void *>(Alloc.getLocalAddress()) << " -> "
OrcRemoteTargetClient &Remote;
ResourceIdMgr::ResourceId Id;
std::vector<RemoteIndirectStubsInfo> RemoteIndirectStubsInfos;
- typedef std::pair<uint16_t, uint16_t> StubKey;
+ using StubKey = std::pair<uint16_t, uint16_t>;
std::vector<StubKey> FreeStubs;
StringMap<std::pair<StubKey, JITSymbolFlags>> StubIndexes;
Expected<JITTargetAddress> reserveMem(ResourceIdMgr::ResourceId Id,
uint64_t Size, uint32_t Align) {
-
// Check for an 'out-of-band' error, e.g. from an MM destructor.
if (ExistingError)
return std::move(ExistingError);
-//===--- OrcRemoteTargetRPCAPI.h - Orc Remote-target RPC API ----*- C++ -*-===//
+//===- OrcRemoteTargetRPCAPI.h - Orc Remote-target RPC API ------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
#ifndef LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETRPCAPI_H
#define LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETRPCAPI_H
-#include "RPCUtils.h"
-#include "RawByteChannel.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
+#include "llvm/ExecutionEngine/Orc/RPCUtils.h"
+#include "llvm/ExecutionEngine/Orc/RawByteChannel.h"
namespace llvm {
namespace orc {
+
namespace remote {
class DirectBufferWriter {
return EC;
char *Addr = reinterpret_cast<char *>(static_cast<uintptr_t>(Dst));
- DBW = remote::DirectBufferWriter(0, Dst, Size);
+ DBW = remote::DirectBufferWriter(nullptr, Dst, Size);
return C.readBytes(Addr, Size);
}
protected:
class ResourceIdMgr {
public:
- typedef uint64_t ResourceId;
+ using ResourceId = uint64_t;
static const ResourceId InvalidId = ~0U;
ResourceId getNext() {
}
return NextId++;
}
+
void release(ResourceId I) { FreeIds.push_back(I); }
private:
};
} // end namespace remote
+
} // end namespace orc
} // end namespace llvm
-#endif
+#endif // LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETRPCAPI_H
-//===---- OrcRemoteTargetServer.h - Orc Remote-target Server ----*- C++ -*-===//
+//===- OrcRemoteTargetServer.h - Orc Remote-target Server -------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
#ifndef LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETSERVER_H
#define LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETSERVER_H
-#include "OrcRemoteTargetRPCAPI.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/ExecutionEngine/Orc/OrcError.h"
-#include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
+#include "llvm/ExecutionEngine/Orc/OrcRemoteTargetRPCAPI.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/Format.h"
template <typename ChannelT, typename TargetT>
class OrcRemoteTargetServer : public OrcRemoteTargetRPCAPI {
public:
- typedef std::function<JITTargetAddress(const std::string &Name)>
- SymbolLookupFtor;
+ using SymbolLookupFtor =
+ std::function<JITTargetAddress(const std::string &Name)>;
- typedef std::function<void(uint8_t *Addr, uint32_t Size)>
- EHFrameRegistrationFtor;
+ using EHFrameRegistrationFtor =
+ std::function<void(uint8_t *Addr, uint32_t Size)>;
OrcRemoteTargetServer(ChannelT &Channel, SymbolLookupFtor SymbolLookup,
EHFrameRegistrationFtor EHFramesRegister,
EHFrameRegistrationFtor EHFramesDeregister)
: OrcRemoteTargetRPCAPI(Channel), SymbolLookup(std::move(SymbolLookup)),
EHFramesRegister(std::move(EHFramesRegister)),
- EHFramesDeregister(std::move(EHFramesDeregister)),
- TerminateFlag(false) {
-
+ EHFramesDeregister(std::move(EHFramesDeregister)) {
using ThisT = typename std::remove_reference<decltype(*this)>::type;
addHandler<CallIntVoid>(*this, &ThisT::handleCallIntVoid);
addHandler<CallMain>(*this, &ThisT::handleCallMain);
struct Allocator {
Allocator() = default;
Allocator(Allocator &&Other) : Allocs(std::move(Other.Allocs)) {}
+
Allocator &operator=(Allocator &&Other) {
Allocs = std::move(Other.Allocs);
return *this;
}
Expected<int32_t> handleCallIntVoid(JITTargetAddress Addr) {
- typedef int (*IntVoidFnTy)();
+ using IntVoidFnTy = int (*)();
+
IntVoidFnTy Fn =
reinterpret_cast<IntVoidFnTy>(static_cast<uintptr_t>(Addr));
Expected<int32_t> handleCallMain(JITTargetAddress Addr,
std::vector<std::string> Args) {
- typedef int (*MainFnTy)(int, const char *[]);
+ using MainFnTy = int (*)(int, const char *[]);
MainFnTy Fn = reinterpret_cast<MainFnTy>(static_cast<uintptr_t>(Addr));
int ArgC = Args.size() + 1;
}
Error handleCallVoidVoid(JITTargetAddress Addr) {
- typedef void (*VoidVoidFnTy)();
+ using VoidVoidFnTy = void (*)();
+
VoidVoidFnTy Fn =
reinterpret_cast<VoidVoidFnTy>(static_cast<uintptr_t>(Addr));
SymbolLookupFtor SymbolLookup;
EHFrameRegistrationFtor EHFramesRegister, EHFramesDeregister;
std::map<ResourceIdMgr::ResourceId, Allocator> Allocators;
- typedef std::vector<typename TargetT::IndirectStubsInfo> ISBlockOwnerList;
+ using ISBlockOwnerList = std::vector<typename TargetT::IndirectStubsInfo>;
std::map<ResourceIdMgr::ResourceId, ISBlockOwnerList> IndirectStubsOwners;
sys::OwningMemoryBlock ResolverBlock;
std::vector<sys::OwningMemoryBlock> TrampolineBlocks;
- bool TerminateFlag;
+ bool TerminateFlag = false;
};
} // end namespace remote
#undef DEBUG_TYPE
-#endif
+#endif // LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETSERVER_H
-//===-- RTDyldObjectLinkingLayer.h - RTDyld-based jit linking --*- C++ -*-===//
+//===- RTDyldObjectLinkingLayer.h - RTDyld-based jit linking ---*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
-#include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/ExecutionEngine/RuntimeDyld.h"
-#include "llvm/ExecutionEngine/SectionMemoryManager.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Support/Error.h"
#include <algorithm>
bool Finalized = false;
};
- typedef std::list<std::unique_ptr<LinkedObjectSet>> LinkedObjectSetListT;
+ using LinkedObjectSetListT = std::list<std::unique_ptr<LinkedObjectSet>>;
public:
/// @brief Handle to a set of loaded objects.
- typedef LinkedObjectSetListT::iterator ObjSetHandleT;
+ using ObjSetHandleT = LinkedObjectSetListT::iterator;
};
/// @brief Default (no-op) action to perform when loading objects.
class RTDyldObjectLinkingLayer : public RTDyldObjectLinkingLayerBase {
public:
/// @brief Functor for receiving finalization notifications.
- typedef std::function<void(ObjSetHandleT)> NotifyFinalizedFtor;
+ using NotifyFinalizedFtor = std::function<void(ObjSetHandleT)>;
private:
template <typename ObjSetT, typename MemoryManagerPtrT,
SymbolResolverPtrT Resolver,
FinalizerFtor Finalizer,
bool ProcessAllSections) {
- typedef ConcreteLinkedObjectSet<ObjSetT, MemoryManagerPtrT,
- SymbolResolverPtrT, FinalizerFtor> LOS;
+ using LOS = ConcreteLinkedObjectSet<ObjSetT, MemoryManagerPtrT,
+ SymbolResolverPtrT, FinalizerFtor>;
return llvm::make_unique<LOS>(std::move(Objects), std::move(MemMgr),
std::move(Resolver), std::move(Finalizer),
ProcessAllSections);
public:
/// @brief LoadedObjectInfo list. Contains a list of owning pointers to
/// RuntimeDyld::LoadedObjectInfo instances.
- typedef std::vector<std::unique_ptr<RuntimeDyld::LoadedObjectInfo>>
- LoadedObjInfoList;
+ using LoadedObjInfoList =
+ std::vector<std::unique_ptr<RuntimeDyld::LoadedObjectInfo>>;
/// @brief Construct an ObjectLinkingLayer with the given NotifyLoaded,
/// and NotifyFinalized functors.
NotifyLoadedFtor NotifyLoaded = NotifyLoadedFtor(),
NotifyFinalizedFtor NotifyFinalized = NotifyFinalizedFtor())
: NotifyLoaded(std::move(NotifyLoaded)),
- NotifyFinalized(std::move(NotifyFinalized)),
- ProcessAllSections(false) {}
+ NotifyFinalized(std::move(NotifyFinalized)) {}
/// @brief Set the 'ProcessAllSections' flag.
///
LinkedObjectSetListT LinkedObjSetList;
NotifyLoadedFtor NotifyLoaded;
NotifyFinalizedFtor NotifyFinalized;
- bool ProcessAllSections;
+ bool ProcessAllSections = false;
};
} // end namespace orc
#ifndef LLVM_EXECUTIONENGINE_ORC_RAWBYTECHANNEL_H
#define LLVM_EXECUTIONENGINE_ORC_RAWBYTECHANNEL_H
-#include "OrcError.h"
-#include "RPCSerialization.h"
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/ExecutionEngine/Orc/RPCSerialization.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/Error.h"
-#include <cstddef>
#include <cstdint>
#include <mutex>
#include <string>
-#include <tuple>
#include <type_traits>
-#include <vector>
namespace llvm {
namespace orc {
/// Interface for byte-streams to be used with RPC.
class RawByteChannel {
public:
- virtual ~RawByteChannel() {}
+ virtual ~RawByteChannel() = default;
/// Read Size bytes from the stream into *Dst.
virtual Error readBytes(char *Dst, unsigned Size) = 0;
-//===-- RuntimeDyld.h - Run-time dynamic linker for MC-JIT ------*- C++ -*-===//
+//===- RuntimeDyld.h - Run-time dynamic linker for MC-JIT -------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
namespace llvm {
namespace object {
- template <typename T> class OwningBinary;
+
+template <typename T> class OwningBinary;
+
} // end namespace object
/// Base class for errors originating in RuntimeDyld, e.g. missing relocation
std::string ErrMsg;
};
-class RuntimeDyldImpl;
class RuntimeDyldCheckerImpl;
+class RuntimeDyldImpl;
class RuntimeDyld {
friend class RuntimeDyldCheckerImpl;
friend class RuntimeDyldImpl;
public:
- typedef std::map<object::SectionRef, unsigned> ObjSectionToIDMap;
+ using ObjSectionToIDMap = std::map<object::SectionRef, unsigned>;
LoadedObjectInfo(RuntimeDyldImpl &RTDyld, ObjSectionToIDMap ObjSecToIDMap)
: RTDyld(RTDyld), ObjSecToIDMap(std::move(ObjSecToIDMap)) {}
/// \brief Construct a RuntimeDyld instance.
RuntimeDyld(MemoryManager &MemMgr, JITSymbolResolver &Resolver);
RuntimeDyld(const RuntimeDyld &) = delete;
- void operator=(const RuntimeDyld &) = delete;
+ RuntimeDyld &operator=(const RuntimeDyld &) = delete;
~RuntimeDyld();
/// Add the referenced object file to the list of objects to be loaded and
-//===--- OrcCBindingsStack.h - Orc JIT stack for C bindings ---*- C++ -*---===//
+//===- OrcCBindingsStack.h - Orc JIT stack for C bindings -----*- C++ -*---===//
//
// The LLVM Compiler Infrastructure
//
#define LLVM_LIB_EXECUTIONENGINE_ORC_ORCCBINDINGSSTACK_H
#include "llvm-c/OrcBindings.h"
-#include "llvm/ADT/Triple.h"
+#include "llvm-c/TargetMachine.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h"
#include "llvm/ExecutionEngine/Orc/CompileUtils.h"
#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
+#include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
#include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
-#include "llvm/IR/LLVMContext.h"
+#include "llvm/ExecutionEngine/RuntimeDyld.h"
+#include "llvm/ExecutionEngine/SectionMemoryManager.h"
+#include "llvm/IR/DataLayout.h"
+#include "llvm/IR/Mangler.h"
+#include "llvm/IR/Module.h"
+#include "llvm/Support/CBindingWrapping.h"
#include "llvm/Support/Error.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/Target/TargetMachine.h"
+#include <algorithm>
+#include <cstdint>
+#include <functional>
+#include <memory>
+#include <set>
+#include <string>
+#include <vector>
namespace llvm {
class OrcCBindingsStack {
public:
- typedef orc::JITCompileCallbackManager CompileCallbackMgr;
- typedef orc::RTDyldObjectLinkingLayer<> ObjLayerT;
- typedef orc::IRCompileLayer<ObjLayerT> CompileLayerT;
- typedef orc::CompileOnDemandLayer<CompileLayerT, CompileCallbackMgr>
- CODLayerT;
+ using CompileCallbackMgr = orc::JITCompileCallbackManager;
+ using ObjLayerT = orc::RTDyldObjectLinkingLayer<>;
+ using CompileLayerT = orc::IRCompileLayer<ObjLayerT>;
+ using CODLayerT =
+ orc::CompileOnDemandLayer<CompileLayerT, CompileCallbackMgr>;
- typedef std::function<std::unique_ptr<CompileCallbackMgr>()>
- CallbackManagerBuilder;
+ using CallbackManagerBuilder =
+ std::function<std::unique_ptr<CompileCallbackMgr>()>;
- typedef CODLayerT::IndirectStubsManagerBuilderT IndirectStubsManagerBuilder;
+ using IndirectStubsManagerBuilder = CODLayerT::IndirectStubsManagerBuilderT;
private:
class GenericHandle {
public:
- virtual ~GenericHandle() {}
+ virtual ~GenericHandle() = default;
+
virtual JITSymbol findSymbolIn(const std::string &Name,
bool ExportedSymbolsOnly) = 0;
virtual void removeModule() = 0;
public:
// We need a 'ModuleSetHandleT' to conform to the layer concept.
- typedef unsigned ModuleSetHandleT;
+ using ModuleSetHandleT = unsigned;
- typedef unsigned ModuleHandleT;
+ using ModuleHandleT = unsigned;
OrcCBindingsStack(TargetMachine &TM,
std::unique_ptr<CompileCallbackMgr> CCMgr,
IndirectStubsManagerBuilder IndirectStubsMgrBuilder)
: DL(TM.createDataLayout()), IndirectStubsMgr(IndirectStubsMgrBuilder()),
- CCMgr(std::move(CCMgr)), ObjectLayer(),
+ CCMgr(std::move(CCMgr)),
CompileLayer(ObjectLayer, orc::SimpleCompiler(TM)),
CODLayer(CompileLayer,
[](Function &F) { return std::set<Function *>({&F}); },
if (ExternalResolver)
return JITSymbol(
ExternalResolver(Name.c_str(), ExternalResolverCtx),
- llvm::JITSymbolFlags::Exported);
+ JITSymbolFlags::Exported);
return JITSymbol(nullptr);
},
std::unique_ptr<RuntimeDyld::MemoryManager> MemMgr,
LLVMOrcSymbolResolverFn ExternalResolver,
void *ExternalResolverCtx) {
-
// Attach a data-layout if one isn't already present.
if (M->getDataLayout().isDefault())
M->setDataLayout(DL);
-//===---- OrcMCJITReplacement.h - Orc based MCJIT replacement ---*- C++ -*-===//
+//===- OrcMCJITReplacement.h - Orc based MCJIT replacement ------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
#include "llvm/ExecutionEngine/Orc/LazyEmittingLayer.h"
#include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
+#include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
#include "llvm/ExecutionEngine/RuntimeDyld.h"
+#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Mangler.h"
+#include "llvm/IR/Module.h"
#include "llvm/Object/Archive.h"
#include "llvm/Object/Binary.h"
#include "llvm/Object/ObjectFile.h"
#include <vector>
namespace llvm {
+
+class ObjectCache;
+
namespace orc {
class OrcMCJITReplacement : public ExecutionEngine {
};
private:
-
static ExecutionEngine *
createOrcMCJITReplacement(std::string *ErrorMsg,
std::shared_ptr<MCJITMemoryManager> MemMgr,
}
public:
- static void Register() {
- OrcMCJITReplacementCtor = createOrcMCJITReplacement;
- }
-
OrcMCJITReplacement(
std::shared_ptr<MCJITMemoryManager> MemMgr,
std::shared_ptr<JITSymbolResolver> ClientResolver,
CompileLayer(ObjectLayer, SimpleCompiler(*this->TM)),
LazyEmitLayer(CompileLayer) {}
- void addModule(std::unique_ptr<Module> M) override {
+ static void Register() {
+ OrcMCJITReplacementCtor = createOrcMCJITReplacement;
+ }
+ void addModule(std::unique_ptr<Module> M) override {
// If this module doesn't have a DataLayout attached then attach the
// default.
if (M->getDataLayout().isDefault()) {
class NotifyObjectLoadedT {
public:
- typedef std::vector<std::unique_ptr<RuntimeDyld::LoadedObjectInfo>>
- LoadedObjInfoListT;
+ using LoadedObjInfoListT =
+ std::vector<std::unique_ptr<RuntimeDyld::LoadedObjectInfo>>;
NotifyObjectLoadedT(OrcMCJITReplacement &M) : M(M) {}
return MangledName;
}
- typedef RTDyldObjectLinkingLayer<NotifyObjectLoadedT> ObjectLayerT;
- typedef IRCompileLayer<ObjectLayerT> CompileLayerT;
- typedef LazyEmittingLayer<CompileLayerT> LazyEmitLayerT;
+ using ObjectLayerT = RTDyldObjectLinkingLayer<NotifyObjectLoadedT>;
+ using CompileLayerT = IRCompileLayer<ObjectLayerT>;
+ using LazyEmitLayerT = LazyEmittingLayer<CompileLayerT>;
std::unique_ptr<TargetMachine> TM;
MCJITReplacementMemMgr MemMgr;
// We need to store ObjLayerT::ObjSetHandles for each of the object sets
// that have been emitted but not yet finalized so that we can forward the
// mapSectionAddress calls appropriately.
- typedef std::set<const void *> SectionAddrSet;
+ using SectionAddrSet = std::set<const void *>;
struct ObjSetHandleCompare {
bool operator()(ObjectLayerT::ObjSetHandleT H1,
ObjectLayerT::ObjSetHandleT H2) const {
};
} // end namespace orc
+
} // end namespace llvm
#endif // LLVM_LIB_EXECUTIONENGINE_ORC_MCJITREPLACEMENT_H
-//===------ OrcLazyJIT.cpp - Basic Orc-based JIT for lazy execution -------===//
+//===- OrcLazyJIT.cpp - Basic Orc-based JIT for lazy execution ------------===//
//
// The LLVM Compiler Infrastructure
//
//===----------------------------------------------------------------------===//
#include "OrcLazyJIT.h"
-#include "llvm/ExecutionEngine/Orc/OrcABISupport.h"
-#include "llvm/Support/Debug.h"
+#include "llvm/ADT/Triple.h"
+#include "llvm/ExecutionEngine/ExecutionEngine.h"
+#include "llvm/Support/CodeGen.h"
+#include "llvm/Support/CommandLine.h"
#include "llvm/Support/DynamicLibrary.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/FileSystem.h"
+#include <cstdint>
#include <cstdio>
+#include <cstdlib>
#include <system_error>
using namespace llvm;
namespace {
- enum class DumpKind { NoDump, DumpFuncsToStdOut, DumpModsToStdOut,
- DumpModsToDisk };
-
- cl::opt<DumpKind> OrcDumpKind("orc-lazy-debug",
- cl::desc("Debug dumping for the orc-lazy JIT."),
- cl::init(DumpKind::NoDump),
- cl::values(
- clEnumValN(DumpKind::NoDump, "no-dump",
- "Don't dump anything."),
- clEnumValN(DumpKind::DumpFuncsToStdOut,
- "funcs-to-stdout",
- "Dump function names to stdout."),
- clEnumValN(DumpKind::DumpModsToStdOut,
- "mods-to-stdout",
- "Dump modules to stdout."),
- clEnumValN(DumpKind::DumpModsToDisk,
- "mods-to-disk",
- "Dump modules to the current "
- "working directory. (WARNING: "
- "will overwrite existing files).")),
- cl::Hidden);
-
- cl::opt<bool> OrcInlineStubs("orc-lazy-inline-stubs",
- cl::desc("Try to inline stubs"),
- cl::init(true), cl::Hidden);
-}
+enum class DumpKind {
+ NoDump,
+ DumpFuncsToStdOut,
+ DumpModsToStdOut,
+ DumpModsToDisk
+};
+
+} // end anonymous namespace
+
+static cl::opt<DumpKind> OrcDumpKind(
+ "orc-lazy-debug", cl::desc("Debug dumping for the orc-lazy JIT."),
+ cl::init(DumpKind::NoDump),
+ cl::values(clEnumValN(DumpKind::NoDump, "no-dump", "Don't dump anything."),
+ clEnumValN(DumpKind::DumpFuncsToStdOut, "funcs-to-stdout",
+ "Dump function names to stdout."),
+ clEnumValN(DumpKind::DumpModsToStdOut, "mods-to-stdout",
+ "Dump modules to stdout."),
+ clEnumValN(DumpKind::DumpModsToDisk, "mods-to-disk",
+ "Dump modules to the current "
+ "working directory. (WARNING: "
+ "will overwrite existing files).")),
+ cl::Hidden);
+
+static cl::opt<bool> OrcInlineStubs("orc-lazy-inline-stubs",
+ cl::desc("Try to inline stubs"),
+ cl::init(true), cl::Hidden);
OrcLazyJIT::TransformFtor OrcLazyJIT::createDebugDumper() {
-
switch (OrcDumpKind) {
case DumpKind::NoDump:
return [](std::unique_ptr<Module> M) { return M; };
// Defined in lli.cpp.
CodeGenOpt::Level getOptLevel();
-
template <typename PtrTy>
static PtrTy fromTargetAddress(JITTargetAddress Addr) {
return reinterpret_cast<PtrTy>(static_cast<uintptr_t>(Addr));
return 1;
}
- typedef int (*MainFnPtr)(int, const char*[]);
+ using MainFnPtr = int (*)(int, const char*[]);
std::vector<const char *> ArgV;
for (auto &Arg : Args)
ArgV.push_back(Arg.c_str());
auto Main = fromTargetAddress<MainFnPtr>(MainSym.getAddress());
return Main(ArgV.size(), (const char**)ArgV.data());
}
-
-//===--- OrcLazyJIT.h - Basic Orc-based JIT for lazy execution --*- C++ -*-===//
+//===- OrcLazyJIT.h - Basic Orc-based JIT for lazy execution ----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
#ifndef LLVM_TOOLS_LLI_ORCLAZYJIT_H
#define LLVM_TOOLS_LLI_ORCLAZYJIT_H
-#include "llvm/ADT/Triple.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/Twine.h"
+#include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h"
#include "llvm/ExecutionEngine/Orc/CompileUtils.h"
#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
+#include "llvm/ExecutionEngine/Orc/IndirectionUtils.h"
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
#include "llvm/ExecutionEngine/Orc/IRTransformLayer.h"
+#include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
#include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
#include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
+#include "llvm/ExecutionEngine/SectionMemoryManager.h"
+#include "llvm/IR/DataLayout.h"
+#include "llvm/IR/GlobalValue.h"
+#include "llvm/IR/Mangler.h"
+#include "llvm/IR/Module.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/Target/TargetMachine.h"
+#include <algorithm>
+#include <functional>
+#include <memory>
+#include <set>
+#include <string>
+#include <vector>
namespace llvm {
class OrcLazyJIT {
public:
-
- typedef orc::JITCompileCallbackManager CompileCallbackMgr;
- typedef orc::RTDyldObjectLinkingLayer<> ObjLayerT;
- typedef orc::IRCompileLayer<ObjLayerT> CompileLayerT;
- typedef std::function<std::unique_ptr<Module>(std::unique_ptr<Module>)>
- TransformFtor;
- typedef orc::IRTransformLayer<CompileLayerT, TransformFtor> IRDumpLayerT;
- typedef orc::CompileOnDemandLayer<IRDumpLayerT, CompileCallbackMgr> CODLayerT;
- typedef CODLayerT::IndirectStubsManagerBuilderT
- IndirectStubsManagerBuilder;
- typedef CODLayerT::ModuleSetHandleT ModuleSetHandleT;
+ using CompileCallbackMgr = orc::JITCompileCallbackManager;
+ using ObjLayerT = orc::RTDyldObjectLinkingLayer<>;
+ using CompileLayerT = orc::IRCompileLayer<ObjLayerT>;
+ using TransformFtor =
+ std::function<std::unique_ptr<Module>(std::unique_ptr<Module>)>;
+ using IRDumpLayerT = orc::IRTransformLayer<CompileLayerT, TransformFtor>;
+ using CODLayerT = orc::CompileOnDemandLayer<IRDumpLayerT, CompileCallbackMgr>;
+ using IndirectStubsManagerBuilder = CODLayerT::IndirectStubsManagerBuilderT;
+ using ModuleSetHandleT = CODLayerT::ModuleSetHandleT;
OrcLazyJIT(std::unique_ptr<TargetMachine> TM,
std::unique_ptr<CompileCallbackMgr> CCMgr,
IndirectStubsManagerBuilder IndirectStubsMgrBuilder,
bool InlineStubs)
: TM(std::move(TM)), DL(this->TM->createDataLayout()),
- CCMgr(std::move(CCMgr)),
- ObjectLayer(),
+ CCMgr(std::move(CCMgr)),
CompileLayer(ObjectLayer, orc::SimpleCompiler(*this->TM)),
IRDumpLayer(CompileLayer, createDebugDumper()),
CODLayer(IRDumpLayer, extractSingleFunction, *this->CCMgr,
}
private:
-
std::string mangle(const std::string &Name) {
std::string MangledName;
{
} // end namespace llvm
-#endif
+#endif // LLVM_TOOLS_LLI_ORCLAZYJIT_H