[ExecutionEngine] Fix some Clang-tidy modernize-use-default, modernize-use-equals-delete and Include What You Use warnings; other minor fixes.

Differential revision: https://reviews.llvm.org/D26729

llvm-svn: 287126
This commit is contained in:
Eugene Zelenko 2016-11-16 18:07:33 +00:00
parent 95eae57d78
commit cecb0183b2
10 changed files with 148 additions and 93 deletions

View File

@ -18,18 +18,18 @@
#include "RuntimeDyld.h" #include "RuntimeDyld.h"
#include "llvm/Config/llvm-config.h" #include "llvm/Config/llvm-config.h"
#include "llvm/IR/DebugLoc.h" #include "llvm/IR/DebugLoc.h"
#include "llvm/Support/DataTypes.h" #include <cstdint>
#include <vector> #include <vector>
namespace llvm { namespace llvm {
class Function;
class IntelJITEventsWrapper;
class MachineFunction; class MachineFunction;
class OProfileWrapper; class OProfileWrapper;
class IntelJITEventsWrapper;
namespace object { namespace object {
class ObjectFile; class ObjectFile;
} } // end namespace object
/// JITEvent_EmittedFunctionDetails - Helper struct for containing information /// JITEvent_EmittedFunctionDetails - Helper struct for containing information
/// about a generated machine code function. /// about a generated machine code function.
@ -60,8 +60,8 @@ public:
typedef JITEvent_EmittedFunctionDetails EmittedFunctionDetails; typedef JITEvent_EmittedFunctionDetails EmittedFunctionDetails;
public: public:
JITEventListener() {} JITEventListener() = default;
virtual ~JITEventListener() {} virtual ~JITEventListener() = default;
/// NotifyObjectEmitted - Called after an object has been successfully /// NotifyObjectEmitted - Called after an object has been successfully
/// emitted to memory. NotifyFunctionEmitted will not be called for /// emitted to memory. NotifyFunctionEmitted will not be called for
@ -105,7 +105,6 @@ public:
static JITEventListener *createOProfileJITEventListener( static JITEventListener *createOProfileJITEventListener(
OProfileWrapper* AlternativeImpl); OProfileWrapper* AlternativeImpl);
#else #else
static JITEventListener *createOProfileJITEventListener() { return nullptr; } static JITEventListener *createOProfileJITEventListener() { return nullptr; }
static JITEventListener *createOProfileJITEventListener( static JITEventListener *createOProfileJITEventListener(
@ -113,10 +112,11 @@ public:
return nullptr; return nullptr;
} }
#endif // USE_OPROFILE #endif // USE_OPROFILE
private: private:
virtual void anchor(); virtual void anchor();
}; };
} // end namespace llvm. } // end namespace llvm
#endif // defined LLVM_EXECUTIONENGINE_JITEVENTLISTENER_H #endif // LLVM_EXECUTIONENGINE_JITEVENTLISTENER_H

View File

@ -14,10 +14,12 @@
#ifndef LLVM_EXECUTIONENGINE_JITSYMBOL_H #ifndef LLVM_EXECUTIONENGINE_JITSYMBOL_H
#define LLVM_EXECUTIONENGINE_JITSYMBOL_H #define LLVM_EXECUTIONENGINE_JITSYMBOL_H
#include "llvm/Support/DataTypes.h" #include <algorithm>
#include <string>
#include <cassert> #include <cassert>
#include <cstddef>
#include <cstdint>
#include <functional> #include <functional>
#include <string>
namespace llvm { namespace llvm {
@ -25,7 +27,7 @@ class GlobalValue;
namespace object { namespace object {
class BasicSymbolRef; class BasicSymbolRef;
} } // end namespace object
/// @brief Represents an address in the target process's address space. /// @brief Represents an address in the target process's address space.
typedef uint64_t JITTargetAddress; typedef uint64_t JITTargetAddress;
@ -33,7 +35,6 @@ typedef uint64_t JITTargetAddress;
/// @brief Flags for symbols in the JIT. /// @brief Flags for symbols in the JIT.
class JITSymbolFlags { class JITSymbolFlags {
public: public:
typedef uint8_t UnderlyingType; typedef uint8_t UnderlyingType;
enum FlagNames : UnderlyingType { enum FlagNames : UnderlyingType {
@ -86,7 +87,6 @@ private:
/// @brief Represents a symbol that has been evaluated to an address already. /// @brief Represents a symbol that has been evaluated to an address already.
class JITEvaluatedSymbol { class JITEvaluatedSymbol {
public: public:
/// @brief Create a 'null' symbol. /// @brief Create a 'null' symbol.
JITEvaluatedSymbol(std::nullptr_t) JITEvaluatedSymbol(std::nullptr_t)
: Address(0) {} : Address(0) {}
@ -112,7 +112,6 @@ private:
/// @brief Represents a symbol in the JIT. /// @brief Represents a symbol in the JIT.
class JITSymbol { class JITSymbol {
public: public:
typedef std::function<JITTargetAddress()> GetAddressFtor; typedef std::function<JITTargetAddress()> GetAddressFtor;
/// @brief Create a 'null' symbol that represents failure to find a symbol /// @brief Create a 'null' symbol that represents failure to find a symbol
@ -165,7 +164,7 @@ private:
/// \brief Symbol resolution. /// \brief Symbol resolution.
class JITSymbolResolver { class JITSymbolResolver {
public: public:
virtual ~JITSymbolResolver() {} virtual ~JITSymbolResolver() = default;
/// This method returns the address of the specified symbol if it exists /// This method returns the address of the specified symbol if it exists
/// within the logical dynamic library represented by this JITSymbolResolver. /// within the logical dynamic library represented by this JITSymbolResolver.
@ -193,6 +192,6 @@ private:
virtual void anchor(); virtual void anchor();
}; };
} // End namespace llvm. } // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_JITSYMBOL_H #endif // LLVM_EXECUTIONENGINE_JITSYMBOL_H

View File

@ -1,4 +1,4 @@
//===-- ObjectCache.h - Class definition for the ObjectCache -----C++ -*-===// //===-- ObjectCache.h - Class definition for the ObjectCache ----*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -11,6 +11,7 @@
#define LLVM_EXECUTIONENGINE_OBJECTCACHE_H #define LLVM_EXECUTIONENGINE_OBJECTCACHE_H
#include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/MemoryBuffer.h"
#include <memory>
namespace llvm { namespace llvm {
@ -21,10 +22,11 @@ class Module;
/// have already been compiled and an object file is available. /// have already been compiled and an object file is available.
class ObjectCache { class ObjectCache {
virtual void anchor(); virtual void anchor();
public:
ObjectCache() { }
virtual ~ObjectCache() { } public:
ObjectCache() = default;
virtual ~ObjectCache() = default;
/// notifyObjectCompiled - Provides a pointer to compiled code for Module M. /// notifyObjectCompiled - Provides a pointer to compiled code for Module M.
virtual void notifyObjectCompiled(const Module *M, MemoryBufferRef Obj) = 0; virtual void notifyObjectCompiled(const Module *M, MemoryBufferRef Obj) = 0;
@ -35,6 +37,6 @@ public:
virtual std::unique_ptr<MemoryBuffer> getObject(const Module* M) = 0; virtual std::unique_ptr<MemoryBuffer> getObject(const Module* M) = 0;
}; };
} } // end namespace llvm
#endif #endif // LLVM_EXECUTIONENGINE_OBJECTCACHE_H

View File

@ -15,15 +15,35 @@
#ifndef LLVM_EXECUTIONENGINE_ORC_COMPILEONDEMANDLAYER_H #ifndef LLVM_EXECUTIONENGINE_ORC_COMPILEONDEMANDLAYER_H
#define LLVM_EXECUTIONENGINE_ORC_COMPILEONDEMANDLAYER_H #define LLVM_EXECUTIONENGINE_ORC_COMPILEONDEMANDLAYER_H
#include "IndirectionUtils.h" #include "llvm/ADT/APInt.h"
#include "LambdaResolver.h"
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Debug.h" #include "llvm/ADT/StringRef.h"
#include "llvm/Transforms/Utils/Cloning.h" #include "llvm/ADT/Twine.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/ExecutionEngine/RuntimeDyld.h"
#include "llvm/ExecutionEngine/Orc/IndirectionUtils.h"
#include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
#include "llvm/IR/Attributes.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/Mangler.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
#include <functional>
#include <iterator>
#include <list> #include <list>
#include <memory> #include <memory>
#include <set> #include <set>
#include <string>
#include <utility> #include <utility>
#include <vector>
namespace llvm { namespace llvm {
namespace orc { namespace orc {
@ -40,11 +60,11 @@ template <typename BaseLayerT,
typename IndirectStubsMgrT = IndirectStubsManager> typename IndirectStubsMgrT = IndirectStubsManager>
class CompileOnDemandLayer { class CompileOnDemandLayer {
private: private:
template <typename MaterializerFtor> template <typename MaterializerFtor>
class LambdaMaterializer final : public ValueMaterializer { class LambdaMaterializer final : public ValueMaterializer {
public: public:
LambdaMaterializer(MaterializerFtor M) : M(std::move(M)) {} LambdaMaterializer(MaterializerFtor M) : M(std::move(M)) {}
Value *materialize(Value *V) final { return M(V); } Value *materialize(Value *V) final { return M(V); }
private: private:
@ -66,7 +86,8 @@ private:
ResourceOwner() = default; ResourceOwner() = default;
ResourceOwner(const ResourceOwner&) = delete; ResourceOwner(const ResourceOwner&) = delete;
ResourceOwner& operator=(const ResourceOwner&) = delete; ResourceOwner& operator=(const ResourceOwner&) = delete;
virtual ~ResourceOwner() { } virtual ~ResourceOwner() = default;
virtual ResourceT& getResource() const = 0; virtual ResourceT& getResource() const = 0;
}; };
@ -75,7 +96,9 @@ private:
public: public:
ResourceOwnerImpl(ResourcePtrT ResourcePtr) ResourceOwnerImpl(ResourcePtrT ResourcePtr)
: ResourcePtr(std::move(ResourcePtr)) {} : ResourcePtr(std::move(ResourcePtr)) {}
ResourceT& getResource() const override { return *ResourcePtr; } ResourceT& getResource() const override { return *ResourcePtr; }
private: private:
ResourcePtrT ResourcePtr; ResourcePtrT ResourcePtr;
}; };
@ -161,7 +184,6 @@ private:
typedef std::list<LogicalDylib> LogicalDylibList; typedef std::list<LogicalDylib> LogicalDylibList;
public: public:
/// @brief Handle to a set of loaded modules. /// @brief Handle to a set of loaded modules.
typedef typename LogicalDylibList::iterator ModuleSetHandleT; typedef typename LogicalDylibList::iterator ModuleSetHandleT;
@ -258,9 +280,8 @@ public:
if (auto LMResources = LDI->getLogicalModuleResourcesForSymbol(FuncName, false)) { if (auto LMResources = LDI->getLogicalModuleResourcesForSymbol(FuncName, false)) {
Module &SrcM = LMResources->SourceModule->getResource(); Module &SrcM = LMResources->SourceModule->getResource();
std::string CalledFnName = mangle(FuncName, SrcM.getDataLayout()); std::string CalledFnName = mangle(FuncName, SrcM.getDataLayout());
if (auto EC = LMResources->StubsMgr->updatePointer(CalledFnName, FnBodyAddr)) { if (auto EC = LMResources->StubsMgr->updatePointer(CalledFnName, FnBodyAddr))
return false; return false;
}
else else
return true; return true;
} }
@ -269,7 +290,6 @@ public:
} }
private: private:
template <typename ModulePtrT> template <typename ModulePtrT>
void addLogicalModule(LogicalDylib &LD, ModulePtrT SrcMPtr) { void addLogicalModule(LogicalDylib &LD, ModulePtrT SrcMPtr) {
@ -547,7 +567,7 @@ private:
bool CloneStubsIntoPartitions; bool CloneStubsIntoPartitions;
}; };
} // End namespace orc. } // end namespace orc
} // End namespace llvm. } // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_COMPILEONDEMANDLAYER_H #endif // LLVM_EXECUTIONENGINE_ORC_COMPILEONDEMANDLAYER_H

View File

@ -14,14 +14,26 @@
#ifndef LLVM_EXECUTIONENGINE_ORC_INDIRECTIONUTILS_H #ifndef LLVM_EXECUTIONENGINE_ORC_INDIRECTIONUTILS_H
#define LLVM_EXECUTIONENGINE_ORC_INDIRECTIONUTILS_H #define LLVM_EXECUTIONENGINE_ORC_INDIRECTIONUTILS_H
#include "LambdaResolver.h" #include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/ExecutionEngine/JITSymbol.h" #include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/ExecutionEngine/RuntimeDyld.h"
#include "llvm/IR/IRBuilder.h" #include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Mangler.h" #include "llvm/IR/Mangler.h"
#include "llvm/IR/Module.h" #include "llvm/IR/Module.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/Memory.h"
#include "llvm/Support/Process.h" #include "llvm/Support/Process.h"
#include "llvm/Transforms/Utils/ValueMapper.h" #include "llvm/Transforms/Utils/ValueMapper.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <functional>
#include <map>
#include <memory>
#include <system_error>
#include <utility>
#include <vector>
namespace llvm { namespace llvm {
namespace orc { namespace orc {
@ -55,7 +67,7 @@ public:
JITCompileCallbackManager(JITTargetAddress ErrorHandlerAddress) JITCompileCallbackManager(JITTargetAddress ErrorHandlerAddress)
: ErrorHandlerAddress(ErrorHandlerAddress) {} : ErrorHandlerAddress(ErrorHandlerAddress) {}
virtual ~JITCompileCallbackManager() {} virtual ~JITCompileCallbackManager() = default;
/// @brief Execute the callback for the given trampoline id. Called by the JIT /// @brief Execute the callback for the given trampoline id. Called by the JIT
/// to compile functions on demand. /// to compile functions on demand.
@ -210,7 +222,7 @@ public:
/// @brief Map type for initializing the manager. See init. /// @brief Map type for initializing the manager. See init.
typedef StringMap<std::pair<JITTargetAddress, JITSymbolFlags>> StubInitsMap; typedef StringMap<std::pair<JITTargetAddress, JITSymbolFlags>> StubInitsMap;
virtual ~IndirectStubsManager() {} virtual ~IndirectStubsManager() = default;
/// @brief Create a single stub with the given name, target address and flags. /// @brief Create a single stub with the given name, target address and flags.
virtual Error createStub(StringRef StubName, JITTargetAddress StubAddr, virtual Error createStub(StringRef StubName, JITTargetAddress StubAddr,
@ -419,7 +431,7 @@ GlobalAlias *cloneGlobalAliasDecl(Module &Dst, const GlobalAlias &OrigA,
void cloneModuleFlagsMetadata(Module &Dst, const Module &Src, void cloneModuleFlagsMetadata(Module &Dst, const Module &Src,
ValueToValueMapTy &VMap); ValueToValueMapTy &VMap);
} // End namespace orc. } // end namespace orc
} // End namespace llvm. } // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_INDIRECTIONUTILS_H #endif // LLVM_EXECUTIONENGINE_ORC_INDIRECTIONUTILS_H

View File

@ -14,14 +14,20 @@
#ifndef LLVM_EXECUTIONENGINE_ORC_LAZYEMITTINGLAYER_H #ifndef LLVM_EXECUTIONENGINE_ORC_LAZYEMITTINGLAYER_H
#define LLVM_EXECUTIONENGINE_ORC_LAZYEMITTINGLAYER_H #define LLVM_EXECUTIONENGINE_ORC_LAZYEMITTINGLAYER_H
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ExecutionEngine/JITSymbol.h" #include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/IR/GlobalValue.h" #include "llvm/IR/GlobalValue.h"
#include "llvm/IR/Mangler.h" #include "llvm/IR/Mangler.h"
#include "llvm/IR/Module.h" #include "llvm/IR/Module.h"
#include "llvm/ADT/STLExtras.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
#include <list> #include <list>
#include <memory>
#include <string>
namespace llvm { namespace llvm {
namespace orc { namespace orc {
@ -39,8 +45,8 @@ public:
private: private:
class EmissionDeferredSet { class EmissionDeferredSet {
public: public:
EmissionDeferredSet() : EmitState(NotEmitted) {} EmissionDeferredSet() = default;
virtual ~EmissionDeferredSet() {} virtual ~EmissionDeferredSet() = default;
JITSymbol find(StringRef Name, bool ExportedSymbolsOnly, BaseLayerT &B) { JITSymbol find(StringRef Name, bool ExportedSymbolsOnly, BaseLayerT &B) {
switch (EmitState) { switch (EmitState) {
@ -106,7 +112,7 @@ private:
virtual BaseLayerHandleT emitToBaseLayer(BaseLayerT &BaseLayer) = 0; virtual BaseLayerHandleT emitToBaseLayer(BaseLayerT &BaseLayer) = 0;
private: private:
enum { NotEmitted, Emitting, Emitted } EmitState; enum { NotEmitted, Emitting, Emitted } EmitState = NotEmitted;
BaseLayerHandleT Handle; BaseLayerHandleT Handle;
}; };
@ -121,7 +127,6 @@ private:
Resolver(std::move(Resolver)) {} Resolver(std::move(Resolver)) {}
protected: protected:
const GlobalValue* searchGVs(StringRef Name, const GlobalValue* searchGVs(StringRef Name,
bool ExportedSymbolsOnly) const override { bool ExportedSymbolsOnly) const override {
// FIXME: We could clean all this up if we had a way to reliably demangle // FIXME: We could clean all this up if we had a way to reliably demangle
@ -277,7 +282,6 @@ public:
void emitAndFinalize(ModuleSetHandleT H) { void emitAndFinalize(ModuleSetHandleT H) {
(*H)->emitAndFinalize(BaseLayer); (*H)->emitAndFinalize(BaseLayer);
} }
}; };
template <typename BaseLayerT> template <typename BaseLayerT>
@ -293,7 +297,7 @@ LazyEmittingLayer<BaseLayerT>::EmissionDeferredSet::create(
std::move(Resolver)); std::move(Resolver));
} }
} // End namespace orc. } // end namespace orc
} // End namespace llvm. } // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_LAZYEMITTINGLAYER_H #endif // LLVM_EXECUTIONENGINE_ORC_LAZYEMITTINGLAYER_H

View File

@ -15,11 +15,22 @@
#define LLVM_EXECUTIONENGINE_ORC_OBJECTLINKINGLAYER_H #define LLVM_EXECUTIONENGINE_ORC_OBJECTLINKINGLAYER_H
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/JITSymbol.h" #include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/ExecutionEngine/RuntimeDyld.h"
#include "llvm/ExecutionEngine/SectionMemoryManager.h" #include "llvm/ExecutionEngine/SectionMemoryManager.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Support/Error.h"
#include <cassert>
#include <algorithm>
#include <functional>
#include <list> #include <list>
#include <memory> #include <memory>
#include <string>
#include <utility>
#include <vector>
namespace llvm { namespace llvm {
namespace orc { namespace orc {
@ -34,11 +45,11 @@ protected:
/// had been provided by this instance. Higher level layers are responsible /// had been provided by this instance. Higher level layers are responsible
/// for taking any action required to handle the missing symbols. /// for taking any action required to handle the missing symbols.
class LinkedObjectSet { class LinkedObjectSet {
LinkedObjectSet(const LinkedObjectSet&) = delete;
void operator=(const LinkedObjectSet&) = delete;
public: public:
LinkedObjectSet() = default; LinkedObjectSet() = default;
virtual ~LinkedObjectSet() {} LinkedObjectSet(const LinkedObjectSet&) = delete;
void operator=(const LinkedObjectSet&) = delete;
virtual ~LinkedObjectSet() = default;
virtual void finalize() = 0; virtual void finalize() = 0;
@ -59,6 +70,7 @@ protected:
SymEntry->second.getFlags()); SymEntry->second.getFlags());
return JITSymbol(SymEntry->second); return JITSymbol(SymEntry->second);
} }
protected: protected:
StringMap<JITEvaluatedSymbol> SymbolTable; StringMap<JITEvaluatedSymbol> SymbolTable;
bool Finalized = false; bool Finalized = false;
@ -71,7 +83,6 @@ public:
typedef LinkedObjectSetListT::iterator ObjSetHandleT; typedef LinkedObjectSetListT::iterator ObjSetHandleT;
}; };
/// @brief Default (no-op) action to perform when loading objects. /// @brief Default (no-op) action to perform when loading objects.
class DoNothingOnNotifyLoaded { class DoNothingOnNotifyLoaded {
public: public:
@ -89,12 +100,10 @@ public:
template <typename NotifyLoadedFtor = DoNothingOnNotifyLoaded> template <typename NotifyLoadedFtor = DoNothingOnNotifyLoaded>
class ObjectLinkingLayer : public ObjectLinkingLayerBase { class ObjectLinkingLayer : public ObjectLinkingLayerBase {
public: public:
/// @brief Functor for receiving finalization notifications. /// @brief Functor for receiving finalization notifications.
typedef std::function<void(ObjSetHandleT)> NotifyFinalizedFtor; typedef std::function<void(ObjSetHandleT)> NotifyFinalizedFtor;
private: private:
template <typename ObjSetT, typename MemoryManagerPtrT, template <typename ObjSetT, typename MemoryManagerPtrT,
typename SymbolResolverPtrT, typename FinalizerFtor> typename SymbolResolverPtrT, typename FinalizerFtor>
class ConcreteLinkedObjectSet : public LinkedObjectSet { class ConcreteLinkedObjectSet : public LinkedObjectSet {
@ -151,7 +160,6 @@ private:
} }
private: private:
void buildInitialSymbolTable(const ObjSetT &Objects) { void buildInitialSymbolTable(const ObjSetT &Objects) {
for (const auto &Obj : Objects) for (const auto &Obj : Objects)
for (auto &Symbol : getObject(*Obj).symbols()) { for (auto &Symbol : getObject(*Obj).symbols()) {
@ -212,7 +220,6 @@ private:
} }
public: public:
/// @brief LoadedObjectInfo list. Contains a list of owning pointers to /// @brief LoadedObjectInfo list. Contains a list of owning pointers to
/// RuntimeDyld::LoadedObjectInfo instances. /// RuntimeDyld::LoadedObjectInfo instances.
typedef std::vector<std::unique_ptr<RuntimeDyld::LoadedObjectInfo>> typedef std::vector<std::unique_ptr<RuntimeDyld::LoadedObjectInfo>>
@ -248,7 +255,6 @@ public:
ObjSetHandleT addObjectSet(ObjSetT Objects, ObjSetHandleT addObjectSet(ObjSetT Objects,
MemoryManagerPtrT MemMgr, MemoryManagerPtrT MemMgr,
SymbolResolverPtrT Resolver) { SymbolResolverPtrT Resolver) {
auto Finalizer = [&](ObjSetHandleT H, RuntimeDyld &RTDyld, auto Finalizer = [&](ObjSetHandleT H, RuntimeDyld &RTDyld,
const ObjSetT &Objs, const ObjSetT &Objs,
std::function<void()> LOSHandleLoad) { std::function<void()> LOSHandleLoad) {
@ -334,7 +340,6 @@ public:
} }
private: private:
static const object::ObjectFile& getObject(const object::ObjectFile &Obj) { static const object::ObjectFile& getObject(const object::ObjectFile &Obj) {
return Obj; return Obj;
} }
@ -351,7 +356,7 @@ private:
bool ProcessAllSections; bool ProcessAllSections;
}; };
} // End namespace orc. } // end namespace orc
} // End namespace llvm } // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_OBJECTLINKINGLAYER_H #endif // LLVM_EXECUTIONENGINE_ORC_OBJECTLINKINGLAYER_H

View File

@ -14,22 +14,24 @@
#ifndef LLVM_EXECUTIONENGINE_RTDYLDMEMORYMANAGER_H #ifndef LLVM_EXECUTIONENGINE_RTDYLDMEMORYMANAGER_H
#define LLVM_EXECUTIONENGINE_RTDYLDMEMORYMANAGER_H #define LLVM_EXECUTIONENGINE_RTDYLDMEMORYMANAGER_H
#include "RuntimeDyld.h" #include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm-c/ExecutionEngine.h" #include "llvm/ExecutionEngine/RuntimeDyld.h"
#include "llvm/Support/CBindingWrapping.h" #include "llvm/Support/CBindingWrapping.h"
#include "llvm/Support/Memory.h" #include "llvm-c/ExecutionEngine.h"
#include <cstddef>
#include <cstdint>
#include <string>
namespace llvm { namespace llvm {
class ExecutionEngine; class ExecutionEngine;
namespace object { namespace object {
class ObjectFile; class ObjectFile;
} } // end namespace object
class MCJITMemoryManager : public RuntimeDyld::MemoryManager { class MCJITMemoryManager : public RuntimeDyld::MemoryManager {
public: public:
// Don't hide the notifyObjectLoaded method from RuntimeDyld::MemoryManager. // Don't hide the notifyObjectLoaded method from RuntimeDyld::MemoryManager.
using RuntimeDyld::MemoryManager::notifyObjectLoaded; using RuntimeDyld::MemoryManager::notifyObjectLoaded;
@ -55,10 +57,10 @@ public:
// for the varying types of objects to be allocated. // for the varying types of objects to be allocated.
class RTDyldMemoryManager : public MCJITMemoryManager, class RTDyldMemoryManager : public MCJITMemoryManager,
public JITSymbolResolver { public JITSymbolResolver {
public:
RTDyldMemoryManager() = default;
RTDyldMemoryManager(const RTDyldMemoryManager&) = delete; RTDyldMemoryManager(const RTDyldMemoryManager&) = delete;
void operator=(const RTDyldMemoryManager&) = delete; void operator=(const RTDyldMemoryManager&) = delete;
public:
RTDyldMemoryManager() {}
~RTDyldMemoryManager() override; ~RTDyldMemoryManager() override;
/// Register EH frames in the current process. /// Register EH frames in the current process.
@ -143,7 +145,6 @@ public:
DEFINE_SIMPLE_CONVERSION_FUNCTIONS( DEFINE_SIMPLE_CONVERSION_FUNCTIONS(
RTDyldMemoryManager, LLVMMCJITMemoryManagerRef) RTDyldMemoryManager, LLVMMCJITMemoryManagerRef)
} // namespace llvm } // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_RTDYLDMEMORYMANAGER_H
#endif

View File

@ -14,33 +14,39 @@
#ifndef LLVM_EXECUTIONENGINE_RUNTIMEDYLD_H #ifndef LLVM_EXECUTIONENGINE_RUNTIMEDYLD_H
#define LLVM_EXECUTIONENGINE_RUNTIMEDYLD_H #define LLVM_EXECUTIONENGINE_RUNTIMEDYLD_H
#include "JITSymbol.h"
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/DebugInfo/DIContext.h" #include "llvm/DebugInfo/DIContext.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/Object/ObjectFile.h" #include "llvm/Object/ObjectFile.h"
#include "llvm/Support/Memory.h" #include "llvm/Support/Error.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <map> #include <map>
#include <memory> #include <memory>
#include <utility> #include <string>
#include <system_error>
namespace llvm { namespace llvm {
class StringRef;
namespace object { namespace object {
class ObjectFile;
template <typename T> class OwningBinary; template <typename T> class OwningBinary;
} } // end namespace object
/// Base class for errors originating in RuntimeDyld, e.g. missing relocation /// Base class for errors originating in RuntimeDyld, e.g. missing relocation
/// support. /// support.
class RuntimeDyldError : public ErrorInfo<RuntimeDyldError> { class RuntimeDyldError : public ErrorInfo<RuntimeDyldError> {
public: public:
static char ID; static char ID;
RuntimeDyldError(std::string ErrMsg) : ErrMsg(std::move(ErrMsg)) {} RuntimeDyldError(std::string ErrMsg) : ErrMsg(std::move(ErrMsg)) {}
void log(raw_ostream &OS) const override; void log(raw_ostream &OS) const override;
const std::string &getErrorMessage() const { return ErrMsg; } const std::string &getErrorMessage() const { return ErrMsg; }
std::error_code convertToErrorCode() const override; std::error_code convertToErrorCode() const override;
private: private:
std::string ErrMsg; std::string ErrMsg;
}; };
@ -51,18 +57,16 @@ class RuntimeDyldCheckerImpl;
class RuntimeDyld { class RuntimeDyld {
friend class RuntimeDyldCheckerImpl; friend class RuntimeDyldCheckerImpl;
RuntimeDyld(const RuntimeDyld &) = delete;
void operator=(const RuntimeDyld &) = delete;
protected: protected:
// Change the address associated with a section when resolving relocations. // Change the address associated with a section when resolving relocations.
// Any relocations already associated with the symbol will be re-resolved. // Any relocations already associated with the symbol will be re-resolved.
void reassignSectionAddress(unsigned SectionID, uint64_t Addr); void reassignSectionAddress(unsigned SectionID, uint64_t Addr);
public:
public:
/// \brief Information about the loaded object. /// \brief Information about the loaded object.
class LoadedObjectInfo : public llvm::LoadedObjectInfo { class LoadedObjectInfo : public llvm::LoadedObjectInfo {
friend class RuntimeDyldImpl; friend class RuntimeDyldImpl;
public: public:
typedef std::map<object::SectionRef, unsigned> ObjSectionToIDMap; typedef std::map<object::SectionRef, unsigned> ObjSectionToIDMap;
@ -91,6 +95,7 @@ public:
LoadedObjectInfoHelper(RuntimeDyldImpl &RTDyld, LoadedObjectInfoHelper(RuntimeDyldImpl &RTDyld,
LoadedObjectInfo::ObjSectionToIDMap ObjSecToIDMap) LoadedObjectInfo::ObjSectionToIDMap ObjSecToIDMap)
: LoadedObjectInfo(RTDyld, std::move(ObjSecToIDMap)) {} : LoadedObjectInfo(RTDyld, std::move(ObjSecToIDMap)) {}
std::unique_ptr<llvm::LoadedObjectInfo> clone() const override { std::unique_ptr<llvm::LoadedObjectInfo> clone() const override {
return llvm::make_unique<Derived>(static_cast<const Derived &>(*this)); return llvm::make_unique<Derived>(static_cast<const Derived &>(*this));
} }
@ -99,9 +104,10 @@ public:
/// \brief Memory Management. /// \brief Memory Management.
class MemoryManager { class MemoryManager {
friend class RuntimeDyld; friend class RuntimeDyld;
public: public:
MemoryManager() : FinalizationLocked(false) {} MemoryManager() = default;
virtual ~MemoryManager() {} virtual ~MemoryManager() = default;
/// Allocate a memory block of (at least) the given size suitable for /// Allocate a memory block of (at least) the given size suitable for
/// executable code. The SectionID is a unique identifier assigned by the /// executable code. The SectionID is a unique identifier assigned by the
@ -174,11 +180,14 @@ public:
private: private:
virtual void anchor(); virtual void anchor();
bool FinalizationLocked;
bool FinalizationLocked = false;
}; };
/// \brief Construct a RuntimeDyld instance. /// \brief Construct a RuntimeDyld instance.
RuntimeDyld(MemoryManager &MemMgr, JITSymbolResolver &Resolver); RuntimeDyld(MemoryManager &MemMgr, JITSymbolResolver &Resolver);
RuntimeDyld(const RuntimeDyld &) = delete;
void operator=(const RuntimeDyld &) = delete;
~RuntimeDyld(); ~RuntimeDyld();
/// Add the referenced object file to the list of objects to be loaded and /// Add the referenced object file to the list of objects to be loaded and

View File

@ -16,11 +16,15 @@
#define LLVM_EXECUTIONENGINE_SECTIONMEMORYMANAGER_H #define LLVM_EXECUTIONENGINE_SECTIONMEMORYMANAGER_H
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ExecutionEngine/RTDyldMemoryManager.h" #include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Memory.h" #include "llvm/Support/Memory.h"
#include <cstdint>
#include <string>
#include <system_error>
namespace llvm { namespace llvm {
/// This is a simple memory manager which implements the methods called by /// This is a simple memory manager which implements the methods called by
/// the RuntimeDyld class to allocate memory for section-based loading of /// the RuntimeDyld class to allocate memory for section-based loading of
/// objects, usually those generated by the MCJIT execution engine. /// objects, usually those generated by the MCJIT execution engine.
@ -35,11 +39,10 @@ namespace llvm {
/// MCJIT::finalizeObject or by calling SectionMemoryManager::finalizeMemory /// MCJIT::finalizeObject or by calling SectionMemoryManager::finalizeMemory
/// directly. Clients of MCJIT should call MCJIT::finalizeObject. /// directly. Clients of MCJIT should call MCJIT::finalizeObject.
class SectionMemoryManager : public RTDyldMemoryManager { class SectionMemoryManager : public RTDyldMemoryManager {
public:
SectionMemoryManager() = default;
SectionMemoryManager(const SectionMemoryManager&) = delete; SectionMemoryManager(const SectionMemoryManager&) = delete;
void operator=(const SectionMemoryManager&) = delete; void operator=(const SectionMemoryManager&) = delete;
public:
SectionMemoryManager() { }
~SectionMemoryManager() override; ~SectionMemoryManager() override;
/// \brief Allocates a memory block of (at least) the given size suitable for /// \brief Allocates a memory block of (at least) the given size suitable for
@ -118,6 +121,6 @@ private:
MemoryGroup RODataMem; MemoryGroup RODataMem;
}; };
} } // end namespace llvm
#endif // LLVM_EXECUTION_ENGINE_SECTION_MEMORY_MANAGER_H #endif // LLVM_EXECUTION_ENGINE_SECTION_MEMORY_MANAGER_H