From: Eugene Zelenko Date: Mon, 19 Jun 2017 23:37:52 +0000 (+0000) Subject: [ExecutionEngine] Fix some Clang-tidy modernize-use-using and Include What You Use... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b96297306a16ea4867ac245e0839d51e612b461a;p=llvm [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 --- diff --git a/include/llvm/ExecutionEngine/ExecutionEngine.h b/include/llvm/ExecutionEngine/ExecutionEngine.h index 1586f7b8066..2830a262875 100644 --- a/include/llvm/ExecutionEngine/ExecutionEngine.h +++ b/include/llvm/ExecutionEngine/ExecutionEngine.h @@ -15,54 +15,58 @@ #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 +#include #include #include +#include #include #include 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 GlobalAddressMapTy; + using GlobalAddressMapTy = StringMap; private: - /// GlobalAddressMap - A mapping between LLVM global symbol names values and /// their actualized version... GlobalAddressMapTy GlobalAddressMap; @@ -74,7 +78,6 @@ private: std::map GlobalAddressReverseMap; public: - GlobalAddressMapTy &getGlobalAddressMap() { return GlobalAddressMap; } @@ -509,13 +512,15 @@ private: }; 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() @@ -655,6 +660,6 @@ public: // 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 diff --git a/include/llvm/ExecutionEngine/GenericValue.h b/include/llvm/ExecutionEngine/GenericValue.h index 537745519dd..504e30a018b 100644 --- a/include/llvm/ExecutionEngine/GenericValue.h +++ b/include/llvm/ExecutionEngine/GenericValue.h @@ -1,4 +1,4 @@ -//===-- GenericValue.h - Represent any type of LLVM value -------*- C++ -*-===// +//===- GenericValue.h - Represent any type of LLVM value --------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -11,18 +11,15 @@ // //===----------------------------------------------------------------------===// - #ifndef LLVM_EXECUTIONENGINE_GENERICVALUE_H #define LLVM_EXECUTIONENGINE_GENERICVALUE_H #include "llvm/ADT/APInt.h" -#include "llvm/Support/DataTypes.h" #include namespace llvm { -typedef void* PointerTy; -class APInt; +using PointerTy = void *; struct GenericValue { struct IntPair { @@ -30,25 +27,29 @@ struct GenericValue { 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 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 diff --git a/include/llvm/ExecutionEngine/JITEventListener.h b/include/llvm/ExecutionEngine/JITEventListener.h index 94ec4e36a19..ff7840f00a4 100644 --- a/include/llvm/ExecutionEngine/JITEventListener.h +++ b/include/llvm/ExecutionEngine/JITEventListener.h @@ -15,8 +15,8 @@ #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 #include @@ -28,7 +28,9 @@ class MachineFunction; class OProfileWrapper; namespace object { - class ObjectFile; + +class ObjectFile; + } // end namespace object /// JITEvent_EmittedFunctionDetails - Helper struct for containing information @@ -57,7 +59,7 @@ struct JITEvent_EmittedFunctionDetails { /// The default implementation of each method does nothing. class JITEventListener { public: - typedef JITEvent_EmittedFunctionDetails EmittedFunctionDetails; + using EmittedFunctionDetails = JITEvent_EmittedFunctionDetails; public: JITEventListener() = default; diff --git a/include/llvm/ExecutionEngine/JITSymbol.h b/include/llvm/ExecutionEngine/JITSymbol.h index 88929482ce7..f09e95fddb9 100644 --- a/include/llvm/ExecutionEngine/JITSymbol.h +++ b/include/llvm/ExecutionEngine/JITSymbol.h @@ -1,4 +1,4 @@ -//===----------- JITSymbol.h - JIT symbol abstraction -----------*- C++ -*-===// +//===- JITSymbol.h - JIT symbol abstraction ---------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -26,16 +26,18 @@ namespace llvm { 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, @@ -46,7 +48,7 @@ public: }; /// @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) {} @@ -81,15 +83,14 @@ public: 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) @@ -105,19 +106,18 @@ public: 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 GetAddressFtor; + using GetAddressFtor = std::function; /// @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) @@ -137,7 +137,7 @@ public: /// 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; } @@ -157,7 +157,7 @@ public: private: GetAddressFtor GetAddress; - JITTargetAddress CachedAddr; + JITTargetAddress CachedAddr = 0; JITSymbolFlags Flags; }; diff --git a/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h b/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h index 2fccf8a0f62..f2dc13be10f 100644 --- a/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h +++ b/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h @@ -24,16 +24,20 @@ #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 #include #include @@ -46,6 +50,9 @@ #include namespace llvm { + +class Value; + namespace orc { /// @brief Compile-on-demand layer. @@ -77,15 +84,15 @@ private: return LambdaMaterializer(std::move(M)); } - typedef typename BaseLayerT::ModuleSetHandleT BaseLayerModuleSetHandleT; + using BaseLayerModuleSetHandleT = typename BaseLayerT::ModuleSetHandleT; // Provide type-erasure for the Modules and MemoryManagers. template 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; @@ -106,7 +113,7 @@ private: template std::unique_ptr> wrapOwnership(ResourcePtrT ResourcePtr) { - typedef ResourceOwnerImpl RO; + using RO = ResourceOwnerImpl; return llvm::make_unique(std::move(ResourcePtr)); } @@ -130,21 +137,19 @@ private: }; struct LogicalDylib { - typedef std::function SymbolResolverFtor; + using SymbolResolverFtor = std::function; - typedef std::function, - std::unique_ptr)> - ModuleAdderFtor; + using ModuleAdderFtor = std::function, + std::unique_ptr)>; struct SourceModuleEntry { std::unique_ptr> SourceMod; std::set StubsToClone; }; - typedef std::vector SourceModulesList; - typedef typename SourceModulesList::size_type SourceModuleHandle; + using SourceModulesList = std::vector; + using SourceModuleHandle = typename SourceModulesList::size_type; SourceModuleHandle addSourceModule(std::unique_ptr> M) { @@ -186,18 +191,18 @@ private: std::vector BaseLayerHandles; }; - typedef std::list LogicalDylibList; + using LogicalDylibList = std::list; 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(Function&)> PartitioningFtor; + using PartitioningFtor = std::function(Function&)>; /// @brief Builder for IndirectStubsManagers. - typedef std::function()> - IndirectStubsManagerBuilderT; + using IndirectStubsManagerBuilderT = + std::function()>; /// @brief Construct a compile-on-demand layer instance. CompileOnDemandLayer(BaseLayerT &BaseLayer, PartitioningFtor Partition, @@ -220,7 +225,6 @@ public: ModuleSetHandleT addModuleSet(ModuleSetT Ms, MemoryManagerPtrT MemMgr, SymbolResolverPtrT Resolver) { - LogicalDylibs.push_back(LogicalDylib()); auto &LD = LogicalDylibs.back(); LD.ExternalSymbolResolver = std::move(Resolver); @@ -303,7 +307,6 @@ public: private: template 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. @@ -581,6 +584,7 @@ private: }; } // end namespace orc + } // end namespace llvm #endif // LLVM_EXECUTIONENGINE_ORC_COMPILEONDEMANDLAYER_H diff --git a/include/llvm/ExecutionEngine/Orc/CompileUtils.h b/include/llvm/ExecutionEngine/Orc/CompileUtils.h index ce0864fbd9c..14b14943c82 100644 --- a/include/llvm/ExecutionEngine/Orc/CompileUtils.h +++ b/include/llvm/ExecutionEngine/Orc/CompileUtils.h @@ -1,4 +1,4 @@ -//===-- CompileUtils.h - Utilities for compiling IR in the JIT --*- C++ -*-===// +//===- CompileUtils.h - Utilities for compiling IR in the JIT ---*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -14,13 +14,24 @@ #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 +#include namespace llvm { + +class MCContext; +class Module; + namespace orc { /// @brief Simple compile functor: Takes a single IR module and returns an @@ -44,7 +55,7 @@ public: new ObjectMemoryBuffer(std::move(ObjBufferSV))); Expected> Obj = object::ObjectFile::createObjectFile(ObjBuffer->getMemBufferRef()); - typedef object::OwningBinary OwningObj; + using OwningObj = object::OwningBinary; if (Obj) return OwningObj(std::move(*Obj), std::move(ObjBuffer)); // TODO: Actually report errors helpfully. @@ -56,7 +67,8 @@ private: TargetMachine &TM; }; -} // End namespace orc. -} // End namespace llvm. +} // end namespace orc + +} // end namespace llvm #endif // LLVM_EXECUTIONENGINE_ORC_COMPILEUTILS_H diff --git a/include/llvm/ExecutionEngine/Orc/ExecutionUtils.h b/include/llvm/ExecutionEngine/Orc/ExecutionUtils.h index 71d847c0626..36a41891614 100644 --- a/include/llvm/ExecutionEngine/Orc/ExecutionUtils.h +++ b/include/llvm/ExecutionEngine/Orc/ExecutionUtils.h @@ -1,4 +1,4 @@ -//===-- ExecutionUtils.h - Utilities for executing code in Orc --*- C++ -*-===// +//===- ExecutionUtils.h - Utilities for executing code in Orc ---*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -17,8 +17,11 @@ #include "llvm/ADT/StringMap.h" #include "llvm/ADT/iterator_range.h" #include "llvm/ExecutionEngine/JITSymbol.h" -#include "llvm/ExecutionEngine/RuntimeDyld.h" +#include +#include +#include #include +#include namespace llvm { @@ -37,7 +40,6 @@ namespace orc { /// 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 @@ -89,7 +91,6 @@ iterator_range getDestructors(const Module &M); template class CtorDtorRunner { public: - /// @brief Construct a CtorDtorRunner for the given range using the given /// name mangling function. CtorDtorRunner(std::vector CtorDtorNames, @@ -99,7 +100,7 @@ public: /// @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) @@ -135,7 +136,6 @@ private: /// called. class LocalCXXRuntimeOverrides { public: - /// Create a runtime-overrides class. template LocalCXXRuntimeOverrides(const MangleFtorT &Mangle) { @@ -156,7 +156,6 @@ public: void runDestructors(); private: - template JITTargetAddress toTargetAddress(PtrTy* P) { return static_cast(reinterpret_cast(P)); @@ -168,15 +167,16 @@ private: StringMap CXXRuntimeOverrides; - typedef void (*DestructorPtr)(void*); - typedef std::pair CXXDestructorDataPair; - typedef std::vector CXXDestructorDataPairList; + using DestructorPtr = void (*)(void *); + using CXXDestructorDataPair = std::pair; + using CXXDestructorDataPairList = std::vector; 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 diff --git a/include/llvm/ExecutionEngine/Orc/GlobalMappingLayer.h b/include/llvm/ExecutionEngine/Orc/GlobalMappingLayer.h index 634d1480ae4..d582e9a3324 100644 --- a/include/llvm/ExecutionEngine/Orc/GlobalMappingLayer.h +++ b/include/llvm/ExecutionEngine/Orc/GlobalMappingLayer.h @@ -1,4 +1,4 @@ -//===---- GlobalMappingLayer.h - Run all IR through a functor ---*- C++ -*-===// +//===- GlobalMappingLayer.h - Run all IR through a functor ------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -17,6 +17,7 @@ #include "llvm/ExecutionEngine/JITSymbol.h" #include +#include namespace llvm { namespace orc { @@ -32,7 +33,7 @@ template 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) {} @@ -102,7 +103,7 @@ private: std::map SymbolTable; }; -} // End namespace orc. -} // End namespace llvm. +} // end namespace orc +} // end namespace llvm #endif // LLVM_EXECUTIONENGINE_ORC_GLOBALMAPPINGLAYER_H diff --git a/include/llvm/ExecutionEngine/Orc/IRCompileLayer.h b/include/llvm/ExecutionEngine/Orc/IRCompileLayer.h index f81d054440f..a6af0636df8 100644 --- a/include/llvm/ExecutionEngine/Orc/IRCompileLayer.h +++ b/include/llvm/ExecutionEngine/Orc/IRCompileLayer.h @@ -1,4 +1,4 @@ -//===------ IRCompileLayer.h -- Eagerly compile IR for JIT ------*- C++ -*-===// +//===- IRCompileLayer.h -- Eagerly compile IR for JIT -----------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -14,12 +14,23 @@ #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 +#include #include +#include +#include namespace llvm { + +class Module; + namespace orc { /// @brief Eager IR compiling layer. @@ -30,20 +41,20 @@ namespace orc { /// the layer below, which must implement the object layer concept. template class IRCompileLayer { public: - typedef std::function(Module &)> - CompileFtor; + using CompileFtor = + std::function(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; } @@ -137,10 +148,11 @@ private: 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 diff --git a/include/llvm/ExecutionEngine/Orc/IRTransformLayer.h b/include/llvm/ExecutionEngine/Orc/IRTransformLayer.h index c67297b111b..057309ee09b 100644 --- a/include/llvm/ExecutionEngine/Orc/IRTransformLayer.h +++ b/include/llvm/ExecutionEngine/Orc/IRTransformLayer.h @@ -1,4 +1,4 @@ -//===----- IRTransformLayer.h - Run all IR through a functor ----*- C++ -*-===// +//===- IRTransformLayer.h - Run all IR through a functor --------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -15,6 +15,7 @@ #define LLVM_EXECUTIONENGINE_ORC_IRTRANSFORMLAYER_H #include "llvm/ExecutionEngine/JITSymbol.h" +#include namespace llvm { namespace orc { @@ -28,7 +29,7 @@ template 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, @@ -45,7 +46,6 @@ public: ModuleSetHandleT addModuleSet(ModuleSetT Ms, MemoryManagerPtrT MemMgr, SymbolResolverPtrT Resolver) { - for (auto I = Ms.begin(), E = Ms.end(); I != E; ++I) *I = Transform(std::move(*I)); @@ -95,7 +95,7 @@ private: TransformFtor Transform; }; -} // End namespace orc. -} // End namespace llvm. +} // end namespace orc +} // end namespace llvm #endif // LLVM_EXECUTIONENGINE_ORC_IRTRANSFORMLAYER_H diff --git a/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h b/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h index 07bbd921dad..e038093d762 100644 --- a/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h +++ b/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h @@ -1,4 +1,4 @@ -//===-- IndirectionUtils.h - Utilities for adding indirections --*- C++ -*-===// +//===- IndirectionUtils.h - Utilities for adding indirections ---*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -18,9 +18,6 @@ #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" @@ -36,12 +33,23 @@ #include 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 CompileFtor; + using CompileFtor = std::function; /// @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 @@ -125,7 +133,7 @@ public: protected: JITTargetAddress ErrorHandlerAddress; - typedef std::map TrampolineMapT; + using TrampolineMapT = std::map; TrampolineMapT ActiveTrampolines; std::vector AvailableTrampolines; @@ -155,7 +163,6 @@ public: /// 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( @@ -220,7 +227,7 @@ private: class IndirectStubsManager { public: /// @brief Map type for initializing the manager. See init. - typedef StringMap> StubInitsMap; + using StubInitsMap = StringMap>; virtual ~IndirectStubsManager() = default; @@ -336,7 +343,7 @@ private: } std::vector IndirectStubsInfos; - typedef std::pair StubKey; + using StubKey = std::pair; std::vector FreeStubs; StringMap> StubIndexes; }; @@ -432,6 +439,7 @@ void cloneModuleFlagsMetadata(Module &Dst, const Module &Src, ValueToValueMapTy &VMap); } // end namespace orc + } // end namespace llvm #endif // LLVM_EXECUTIONENGINE_ORC_INDIRECTIONUTILS_H diff --git a/include/llvm/ExecutionEngine/Orc/LambdaResolver.h b/include/llvm/ExecutionEngine/Orc/LambdaResolver.h index cbe2a80edf1..6868640d38e 100644 --- a/include/llvm/ExecutionEngine/Orc/LambdaResolver.h +++ b/include/llvm/ExecutionEngine/Orc/LambdaResolver.h @@ -1,4 +1,4 @@ -//===-- LambdaResolverMM - Redirect symbol lookup via a functor -*- C++ -*-===// +//===- LambdaResolverMM - Redirect symbol lookup via a functor --*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -16,7 +16,7 @@ #define LLVM_EXECUTIONENGINE_ORC_LAMBDARESOLVER_H #include "llvm/ADT/STLExtras.h" -#include "llvm/ExecutionEngine/RuntimeDyld.h" +#include "llvm/ExecutionEngine/JITSymbol.h" #include namespace llvm { @@ -25,7 +25,6 @@ namespace orc { template class LambdaResolver : public JITSymbolResolver { public: - LambdaResolver(DylibLookupFtorT DylibLookupFtor, ExternalLookupFtorT ExternalLookupFtor) : DylibLookupFtor(DylibLookupFtor), @@ -49,12 +48,12 @@ template > createLambdaResolver(DylibLookupFtorT DylibLookupFtor, ExternalLookupFtorT ExternalLookupFtor) { - typedef LambdaResolver LR; + using LR = LambdaResolver; return make_unique(std::move(DylibLookupFtor), std::move(ExternalLookupFtor)); } -} // End namespace orc. -} // End namespace llvm. +} // end namespace orc +} // end namespace llvm #endif // LLVM_EXECUTIONENGINE_ORC_LAMBDARESOLVER_H diff --git a/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h b/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h index 53d4c0cfe5d..b44e69d1412 100644 --- a/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h +++ b/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h @@ -40,7 +40,7 @@ namespace orc { /// (via JITSymbol::getAddress) for a symbol contained in this layer. template class LazyEmittingLayer { public: - typedef typename BaseLayerT::ModuleSetHandleT BaseLayerHandleT; + using BaseLayerHandleT = typename BaseLayerT::ModuleSetHandleT; private: class EmissionDeferredSet { @@ -216,14 +216,14 @@ private: mutable std::unique_ptr> MangledSymbols; }; - typedef std::list> ModuleSetListT; + using ModuleSetListT = std::list>; 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) {} @@ -291,8 +291,8 @@ std::unique_ptr::EmissionDeferredSet> LazyEmittingLayer::EmissionDeferredSet::create( BaseLayerT &B, ModuleSetT Ms, MemoryManagerPtrT MemMgr, SymbolResolverPtrT Resolver) { - typedef EmissionDeferredSetImpl - EDS; + using EDS = EmissionDeferredSetImpl; return llvm::make_unique(std::move(Ms), std::move(MemMgr), std::move(Resolver)); } diff --git a/include/llvm/ExecutionEngine/Orc/ObjectTransformLayer.h b/include/llvm/ExecutionEngine/Orc/ObjectTransformLayer.h index 173c106cd3e..dc8c4537f48 100644 --- a/include/llvm/ExecutionEngine/Orc/ObjectTransformLayer.h +++ b/include/llvm/ExecutionEngine/Orc/ObjectTransformLayer.h @@ -15,6 +15,8 @@ #define LLVM_EXECUTIONENGINE_ORC_OBJECTTRANSFORMLAYER_H #include "llvm/ExecutionEngine/JITSymbol.h" +#include +#include namespace llvm { namespace orc { @@ -28,7 +30,7 @@ template 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, @@ -44,7 +46,6 @@ public: 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)); @@ -98,7 +99,7 @@ private: TransformFtor Transform; }; -} // End namespace orc. -} // End namespace llvm. +} // end namespace orc +} // end namespace llvm #endif // LLVM_EXECUTIONENGINE_ORC_OBJECTTRANSFORMLAYER_H diff --git a/include/llvm/ExecutionEngine/Orc/OrcABISupport.h b/include/llvm/ExecutionEngine/Orc/OrcABISupport.h index fa236b0de88..e1b55649b9f 100644 --- a/include/llvm/ExecutionEngine/Orc/OrcABISupport.h +++ b/include/llvm/ExecutionEngine/Orc/OrcABISupport.h @@ -1,4 +1,4 @@ -//===-------------- OrcABISupport.h - ABI support code ---------*- C++ -*-===// +//===- OrcABISupport.h - ABI support code -----------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -18,9 +18,12 @@ #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 +#include namespace llvm { namespace orc { @@ -37,8 +40,8 @@ public: 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) { @@ -55,6 +58,7 @@ public: 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"); } @@ -73,13 +77,14 @@ template class GenericIndirectStubsInfo { 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; @@ -104,7 +109,7 @@ public: } private: - unsigned NumStubs; + unsigned NumStubs = 0; sys::OwningMemoryBlock StubsMem; }; @@ -114,10 +119,10 @@ public: 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. @@ -148,7 +153,7 @@ public: 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 @@ -172,8 +177,9 @@ public: 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. @@ -187,8 +193,9 @@ public: 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. @@ -205,10 +212,10 @@ public: 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. @@ -231,7 +238,7 @@ public: unsigned MinStubs, void *InitialPtrVal); }; -} // End namespace orc. -} // End namespace llvm. +} // end namespace orc +} // end namespace llvm #endif // LLVM_EXECUTIONENGINE_ORC_ORCABISUPPORT_H diff --git a/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h b/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h index a19c30631c5..da02250ba16 100644 --- a/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h +++ b/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h @@ -1,4 +1,4 @@ -//===---- OrcRemoteTargetClient.h - Orc Remote-target Client ----*- C++ -*-===// +//===- OrcRemoteTargetClient.h - Orc Remote-target Client -------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -16,10 +16,29 @@ #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 +#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 +#include +#include +#include +#include +#include +#include +#include #define DEBUG_TYPE "orc-remote" @@ -207,7 +226,6 @@ public: DEBUG(dbgs() << "Allocator " << Id << " finalizing:\n"); for (auto &ObjAllocs : Unfinalized) { - for (auto &Alloc : ObjAllocs.CodeAllocs) { DEBUG(dbgs() << " copying code: " << static_cast(Alloc.getLocalAddress()) << " -> " @@ -469,7 +487,7 @@ public: OrcRemoteTargetClient &Remote; ResourceIdMgr::ResourceId Id; std::vector RemoteIndirectStubsInfos; - typedef std::pair StubKey; + using StubKey = std::pair; std::vector FreeStubs; StringMap> StubIndexes; @@ -710,7 +728,6 @@ private: Expected 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); diff --git a/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetRPCAPI.h b/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetRPCAPI.h index 3086ef0cdf8..07ae7f04d1a 100644 --- a/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetRPCAPI.h +++ b/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetRPCAPI.h @@ -1,4 +1,4 @@ -//===--- OrcRemoteTargetRPCAPI.h - Orc Remote-target RPC API ----*- C++ -*-===// +//===- OrcRemoteTargetRPCAPI.h - Orc Remote-target RPC API ------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -16,12 +16,13 @@ #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 { @@ -72,7 +73,7 @@ public: return EC; char *Addr = reinterpret_cast(static_cast(Dst)); - DBW = remote::DirectBufferWriter(0, Dst, Size); + DBW = remote::DirectBufferWriter(nullptr, Dst, Size); return C.readBytes(Addr, Size); } @@ -87,7 +88,7 @@ class OrcRemoteTargetRPCAPI protected: class ResourceIdMgr { public: - typedef uint64_t ResourceId; + using ResourceId = uint64_t; static const ResourceId InvalidId = ~0U; ResourceId getNext() { @@ -98,6 +99,7 @@ protected: } return NextId++; } + void release(ResourceId I) { FreeIds.push_back(I); } private: @@ -261,7 +263,8 @@ public: }; } // end namespace remote + } // end namespace orc } // end namespace llvm -#endif +#endif // LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETRPCAPI_H diff --git a/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetServer.h b/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetServer.h index a61ff102be0..58b01a35852 100644 --- a/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetServer.h +++ b/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetServer.h @@ -1,4 +1,4 @@ -//===---- OrcRemoteTargetServer.h - Orc Remote-target Server ----*- C++ -*-===// +//===- OrcRemoteTargetServer.h - Orc Remote-target Server -------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -15,10 +15,9 @@ #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" @@ -48,20 +47,18 @@ namespace remote { template class OrcRemoteTargetServer : public OrcRemoteTargetRPCAPI { public: - typedef std::function - SymbolLookupFtor; + using SymbolLookupFtor = + std::function; - typedef std::function - EHFrameRegistrationFtor; + using EHFrameRegistrationFtor = + std::function; 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::type; addHandler(*this, &ThisT::handleCallIntVoid); addHandler(*this, &ThisT::handleCallMain); @@ -106,6 +103,7 @@ private: struct Allocator { Allocator() = default; Allocator(Allocator &&Other) : Allocs(std::move(Other.Allocs)) {} + Allocator &operator=(Allocator &&Other) { Allocs = std::move(Other.Allocs); return *this; @@ -153,7 +151,8 @@ private: } Expected handleCallIntVoid(JITTargetAddress Addr) { - typedef int (*IntVoidFnTy)(); + using IntVoidFnTy = int (*)(); + IntVoidFnTy Fn = reinterpret_cast(static_cast(Addr)); @@ -166,7 +165,7 @@ private: Expected handleCallMain(JITTargetAddress Addr, std::vector Args) { - typedef int (*MainFnTy)(int, const char *[]); + using MainFnTy = int (*)(int, const char *[]); MainFnTy Fn = reinterpret_cast(static_cast(Addr)); int ArgC = Args.size() + 1; @@ -184,7 +183,8 @@ private: } Error handleCallVoidVoid(JITTargetAddress Addr) { - typedef void (*VoidVoidFnTy)(); + using VoidVoidFnTy = void (*)(); + VoidVoidFnTy Fn = reinterpret_cast(static_cast(Addr)); @@ -420,11 +420,11 @@ private: SymbolLookupFtor SymbolLookup; EHFrameRegistrationFtor EHFramesRegister, EHFramesDeregister; std::map Allocators; - typedef std::vector ISBlockOwnerList; + using ISBlockOwnerList = std::vector; std::map IndirectStubsOwners; sys::OwningMemoryBlock ResolverBlock; std::vector TrampolineBlocks; - bool TerminateFlag; + bool TerminateFlag = false; }; } // end namespace remote @@ -433,4 +433,4 @@ private: #undef DEBUG_TYPE -#endif +#endif // LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETSERVER_H diff --git a/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h b/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h index aabb44eef99..81193a157f5 100644 --- a/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h +++ b/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h @@ -1,4 +1,4 @@ -//===-- RTDyldObjectLinkingLayer.h - RTDyld-based jit linking --*- C++ -*-===// +//===- RTDyldObjectLinkingLayer.h - RTDyld-based jit linking ---*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -17,10 +17,8 @@ #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 @@ -76,11 +74,11 @@ protected: bool Finalized = false; }; - typedef std::list> LinkedObjectSetListT; + using LinkedObjectSetListT = std::list>; 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. @@ -101,7 +99,7 @@ template class RTDyldObjectLinkingLayer : public RTDyldObjectLinkingLayerBase { public: /// @brief Functor for receiving finalization notifications. - typedef std::function NotifyFinalizedFtor; + using NotifyFinalizedFtor = std::function; private: template LOS; + using LOS = ConcreteLinkedObjectSet; return llvm::make_unique(std::move(Objects), std::move(MemMgr), std::move(Resolver), std::move(Finalizer), ProcessAllSections); @@ -226,8 +224,8 @@ private: public: /// @brief LoadedObjectInfo list. Contains a list of owning pointers to /// RuntimeDyld::LoadedObjectInfo instances. - typedef std::vector> - LoadedObjInfoList; + using LoadedObjInfoList = + std::vector>; /// @brief Construct an ObjectLinkingLayer with the given NotifyLoaded, /// and NotifyFinalized functors. @@ -235,8 +233,7 @@ public: 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. /// @@ -357,7 +354,7 @@ private: LinkedObjectSetListT LinkedObjSetList; NotifyLoadedFtor NotifyLoaded; NotifyFinalizedFtor NotifyFinalized; - bool ProcessAllSections; + bool ProcessAllSections = false; }; } // end namespace orc diff --git a/include/llvm/ExecutionEngine/Orc/RawByteChannel.h b/include/llvm/ExecutionEngine/Orc/RawByteChannel.h index 52a546f7c6e..db810f4ef2e 100644 --- a/include/llvm/ExecutionEngine/Orc/RawByteChannel.h +++ b/include/llvm/ExecutionEngine/Orc/RawByteChannel.h @@ -10,20 +10,14 @@ #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 #include #include #include -#include #include -#include namespace llvm { namespace orc { @@ -32,7 +26,7 @@ namespace rpc { /// 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; diff --git a/include/llvm/ExecutionEngine/RuntimeDyld.h b/include/llvm/ExecutionEngine/RuntimeDyld.h index 9470866dc0d..1925489f795 100644 --- a/include/llvm/ExecutionEngine/RuntimeDyld.h +++ b/include/llvm/ExecutionEngine/RuntimeDyld.h @@ -1,4 +1,4 @@ -//===-- RuntimeDyld.h - Run-time dynamic linker for MC-JIT ------*- C++ -*-===// +//===- RuntimeDyld.h - Run-time dynamic linker for MC-JIT -------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -32,7 +32,9 @@ namespace llvm { namespace object { - template class OwningBinary; + +template class OwningBinary; + } // end namespace object /// Base class for errors originating in RuntimeDyld, e.g. missing relocation @@ -51,8 +53,8 @@ private: std::string ErrMsg; }; -class RuntimeDyldImpl; class RuntimeDyldCheckerImpl; +class RuntimeDyldImpl; class RuntimeDyld { friend class RuntimeDyldCheckerImpl; @@ -68,7 +70,7 @@ public: friend class RuntimeDyldImpl; public: - typedef std::map ObjSectionToIDMap; + using ObjSectionToIDMap = std::map; LoadedObjectInfo(RuntimeDyldImpl &RTDyld, ObjSectionToIDMap ObjSecToIDMap) : RTDyld(RTDyld), ObjSecToIDMap(std::move(ObjSecToIDMap)) {} @@ -186,7 +188,7 @@ public: /// \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 diff --git a/lib/ExecutionEngine/Orc/OrcCBindingsStack.h b/lib/ExecutionEngine/Orc/OrcCBindingsStack.h index a79dd844bf4..733b4f49549 100644 --- a/lib/ExecutionEngine/Orc/OrcCBindingsStack.h +++ b/lib/ExecutionEngine/Orc/OrcCBindingsStack.h @@ -1,4 +1,4 @@ -//===--- OrcCBindingsStack.h - Orc JIT stack for C bindings ---*- C++ -*---===// +//===- OrcCBindingsStack.h - Orc JIT stack for C bindings -----*- C++ -*---===// // // The LLVM Compiler Infrastructure // @@ -11,14 +11,32 @@ #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 +#include +#include +#include +#include +#include +#include namespace llvm { @@ -29,21 +47,22 @@ DEFINE_SIMPLE_CONVERSION_FUNCTIONS(TargetMachine, LLVMTargetMachineRef) class OrcCBindingsStack { public: - typedef orc::JITCompileCallbackManager CompileCallbackMgr; - typedef orc::RTDyldObjectLinkingLayer<> ObjLayerT; - typedef orc::IRCompileLayer CompileLayerT; - typedef orc::CompileOnDemandLayer - CODLayerT; + using CompileCallbackMgr = orc::JITCompileCallbackManager; + using ObjLayerT = orc::RTDyldObjectLinkingLayer<>; + using CompileLayerT = orc::IRCompileLayer; + using CODLayerT = + orc::CompileOnDemandLayer; - typedef std::function()> - CallbackManagerBuilder; + using CallbackManagerBuilder = + std::function()>; - 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; @@ -75,15 +94,15 @@ private: 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 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({&F}); }, @@ -153,7 +172,7 @@ public: if (ExternalResolver) return JITSymbol( ExternalResolver(Name.c_str(), ExternalResolverCtx), - llvm::JITSymbolFlags::Exported); + JITSymbolFlags::Exported); return JITSymbol(nullptr); }, @@ -167,7 +186,6 @@ public: std::unique_ptr MemMgr, LLVMOrcSymbolResolverFn ExternalResolver, void *ExternalResolverCtx) { - // Attach a data-layout if one isn't already present. if (M->getDataLayout().isDefault()) M->setDataLayout(DL); diff --git a/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h b/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h index 7dd6b17d33c..548ed6b4aa2 100644 --- a/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h +++ b/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h @@ -1,4 +1,4 @@ -//===---- OrcMCJITReplacement.h - Orc based MCJIT replacement ---*- C++ -*-===// +//===- OrcMCJITReplacement.h - Orc based MCJIT replacement ------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -24,9 +24,12 @@ #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" @@ -45,6 +48,9 @@ #include namespace llvm { + +class ObjectCache; + namespace orc { class OrcMCJITReplacement : public ExecutionEngine { @@ -151,7 +157,6 @@ class OrcMCJITReplacement : public ExecutionEngine { }; private: - static ExecutionEngine * createOrcMCJITReplacement(std::string *ErrorMsg, std::shared_ptr MemMgr, @@ -162,10 +167,6 @@ private: } public: - static void Register() { - OrcMCJITReplacementCtor = createOrcMCJITReplacement; - } - OrcMCJITReplacement( std::shared_ptr MemMgr, std::shared_ptr ClientResolver, @@ -178,8 +179,11 @@ public: CompileLayer(ObjectLayer, SimpleCompiler(*this->TM)), LazyEmitLayer(CompileLayer) {} - void addModule(std::unique_ptr M) override { + static void Register() { + OrcMCJITReplacementCtor = createOrcMCJITReplacement; + } + void addModule(std::unique_ptr M) override { // If this module doesn't have a DataLayout attached then attach the // default. if (M->getDataLayout().isDefault()) { @@ -308,8 +312,8 @@ private: class NotifyObjectLoadedT { public: - typedef std::vector> - LoadedObjInfoListT; + using LoadedObjInfoListT = + std::vector>; NotifyObjectLoadedT(OrcMCJITReplacement &M) : M(M) {} @@ -360,9 +364,9 @@ private: return MangledName; } - typedef RTDyldObjectLinkingLayer ObjectLayerT; - typedef IRCompileLayer CompileLayerT; - typedef LazyEmittingLayer LazyEmitLayerT; + using ObjectLayerT = RTDyldObjectLinkingLayer; + using CompileLayerT = IRCompileLayer; + using LazyEmitLayerT = LazyEmittingLayer; std::unique_ptr TM; MCJITReplacementMemMgr MemMgr; @@ -380,7 +384,7 @@ private: // 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 SectionAddrSet; + using SectionAddrSet = std::set; struct ObjSetHandleCompare { bool operator()(ObjectLayerT::ObjSetHandleT H1, ObjectLayerT::ObjSetHandleT H2) const { @@ -395,6 +399,7 @@ private: }; } // end namespace orc + } // end namespace llvm #endif // LLVM_LIB_EXECUTIONENGINE_ORC_MCJITREPLACEMENT_H diff --git a/tools/lli/OrcLazyJIT.cpp b/tools/lli/OrcLazyJIT.cpp index ec61ce5e154..899a7acdb1c 100644 --- a/tools/lli/OrcLazyJIT.cpp +++ b/tools/lli/OrcLazyJIT.cpp @@ -1,4 +1,4 @@ -//===------ OrcLazyJIT.cpp - Basic Orc-based JIT for lazy execution -------===// +//===- OrcLazyJIT.cpp - Basic Orc-based JIT for lazy execution ------------===// // // The LLVM Compiler Infrastructure // @@ -8,45 +8,50 @@ //===----------------------------------------------------------------------===// #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 #include +#include #include using namespace llvm; namespace { - enum class DumpKind { NoDump, DumpFuncsToStdOut, DumpModsToStdOut, - DumpModsToDisk }; - - cl::opt 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 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 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 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 M) { return M; }; @@ -98,7 +103,6 @@ OrcLazyJIT::TransformFtor OrcLazyJIT::createDebugDumper() { // Defined in lli.cpp. CodeGenOpt::Level getOptLevel(); - template static PtrTy fromTargetAddress(JITTargetAddress Addr) { return reinterpret_cast(static_cast(Addr)); @@ -151,11 +155,10 @@ int llvm::runOrcLazyJIT(std::vector> Ms, return 1; } - typedef int (*MainFnPtr)(int, const char*[]); + using MainFnPtr = int (*)(int, const char*[]); std::vector ArgV; for (auto &Arg : Args) ArgV.push_back(Arg.c_str()); auto Main = fromTargetAddress(MainSym.getAddress()); return Main(ArgV.size(), (const char**)ArgV.data()); } - diff --git a/tools/lli/OrcLazyJIT.h b/tools/lli/OrcLazyJIT.h index 56e7d36d05f..9a137a5abe8 100644 --- a/tools/lli/OrcLazyJIT.h +++ b/tools/lli/OrcLazyJIT.h @@ -1,4 +1,4 @@ -//===--- OrcLazyJIT.h - Basic Orc-based JIT for lazy execution --*- C++ -*-===// +//===- OrcLazyJIT.h - Basic Orc-based JIT for lazy execution ----*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -15,38 +15,52 @@ #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 +#include +#include +#include +#include +#include namespace llvm { class OrcLazyJIT { public: - - typedef orc::JITCompileCallbackManager CompileCallbackMgr; - typedef orc::RTDyldObjectLinkingLayer<> ObjLayerT; - typedef orc::IRCompileLayer CompileLayerT; - typedef std::function(std::unique_ptr)> - TransformFtor; - typedef orc::IRTransformLayer IRDumpLayerT; - typedef orc::CompileOnDemandLayer CODLayerT; - typedef CODLayerT::IndirectStubsManagerBuilderT - IndirectStubsManagerBuilder; - typedef CODLayerT::ModuleSetHandleT ModuleSetHandleT; + using CompileCallbackMgr = orc::JITCompileCallbackManager; + using ObjLayerT = orc::RTDyldObjectLinkingLayer<>; + using CompileLayerT = orc::IRCompileLayer; + using TransformFtor = + std::function(std::unique_ptr)>; + using IRDumpLayerT = orc::IRTransformLayer; + using CODLayerT = orc::CompileOnDemandLayer; + using IndirectStubsManagerBuilder = CODLayerT::IndirectStubsManagerBuilderT; + using ModuleSetHandleT = CODLayerT::ModuleSetHandleT; OrcLazyJIT(std::unique_ptr TM, std::unique_ptr 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, @@ -135,7 +149,6 @@ public: } private: - std::string mangle(const std::string &Name) { std::string MangledName; { @@ -172,4 +185,4 @@ int runOrcLazyJIT(std::vector> Ms, } // end namespace llvm -#endif +#endif // LLVM_TOOLS_LLI_ORCLAZYJIT_H