[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 "llvm/Config/llvm-config.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/Support/DataTypes.h"
#include <cstdint>
#include <vector>
namespace llvm {
class Function;
class IntelJITEventsWrapper;
class MachineFunction;
class OProfileWrapper;
class IntelJITEventsWrapper;
namespace object {
class ObjectFile;
}
} // end namespace object
/// JITEvent_EmittedFunctionDetails - Helper struct for containing information
/// about a generated machine code function.
@ -60,8 +60,8 @@ public:
typedef JITEvent_EmittedFunctionDetails EmittedFunctionDetails;
public:
JITEventListener() {}
virtual ~JITEventListener() {}
JITEventListener() = default;
virtual ~JITEventListener() = default;
/// NotifyObjectEmitted - Called after an object has been successfully
/// emitted to memory. NotifyFunctionEmitted will not be called for
@ -105,7 +105,6 @@ public:
static JITEventListener *createOProfileJITEventListener(
OProfileWrapper* AlternativeImpl);
#else
static JITEventListener *createOProfileJITEventListener() { return nullptr; }
static JITEventListener *createOProfileJITEventListener(
@ -113,10 +112,11 @@ public:
return nullptr;
}
#endif // USE_OPROFILE
private:
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
#define LLVM_EXECUTIONENGINE_JITSYMBOL_H
#include "llvm/Support/DataTypes.h"
#include <string>
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <string>
namespace llvm {
@ -25,7 +27,7 @@ class GlobalValue;
namespace object {
class BasicSymbolRef;
}
} // end namespace object
/// @brief Represents an address in the target process's address space.
typedef uint64_t JITTargetAddress;
@ -33,7 +35,6 @@ typedef uint64_t JITTargetAddress;
/// @brief Flags for symbols in the JIT.
class JITSymbolFlags {
public:
typedef uint8_t UnderlyingType;
enum FlagNames : UnderlyingType {
@ -86,7 +87,6 @@ private:
/// @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) {}
@ -112,7 +112,6 @@ private:
/// @brief Represents a symbol in the JIT.
class JITSymbol {
public:
typedef std::function<JITTargetAddress()> GetAddressFtor;
/// @brief Create a 'null' symbol that represents failure to find a symbol
@ -165,7 +164,7 @@ private:
/// \brief Symbol resolution.
class JITSymbolResolver {
public:
virtual ~JITSymbolResolver() {}
virtual ~JITSymbolResolver() = default;
/// This method returns the address of the specified symbol if it exists
/// within the logical dynamic library represented by this JITSymbolResolver.
@ -193,6 +192,6 @@ private:
virtual void anchor();
};
} // End namespace llvm.
} // end namespace llvm
#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
//
@ -11,6 +11,7 @@
#define LLVM_EXECUTIONENGINE_OBJECTCACHE_H
#include "llvm/Support/MemoryBuffer.h"
#include <memory>
namespace llvm {
@ -21,10 +22,11 @@ class Module;
/// have already been compiled and an object file is available.
class ObjectCache {
virtual void anchor();
public:
ObjectCache() { }
virtual ~ObjectCache() { }
public:
ObjectCache() = default;
virtual ~ObjectCache() = default;
/// notifyObjectCompiled - Provides a pointer to compiled code for Module M.
virtual void notifyObjectCompiled(const Module *M, MemoryBufferRef Obj) = 0;
@ -35,6 +37,6 @@ public:
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
#define LLVM_EXECUTIONENGINE_ORC_COMPILEONDEMANDLAYER_H
#include "IndirectionUtils.h"
#include "LambdaResolver.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Debug.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/ADT/StringRef.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 <memory>
#include <set>
#include <string>
#include <utility>
#include <vector>
namespace llvm {
namespace orc {
@ -40,11 +60,11 @@ template <typename BaseLayerT,
typename IndirectStubsMgrT = IndirectStubsManager>
class CompileOnDemandLayer {
private:
template <typename MaterializerFtor>
class LambdaMaterializer final : public ValueMaterializer {
public:
LambdaMaterializer(MaterializerFtor M) : M(std::move(M)) {}
Value *materialize(Value *V) final { return M(V); }
private:
@ -66,7 +86,8 @@ private:
ResourceOwner() = default;
ResourceOwner(const ResourceOwner&) = delete;
ResourceOwner& operator=(const ResourceOwner&) = delete;
virtual ~ResourceOwner() { }
virtual ~ResourceOwner() = default;
virtual ResourceT& getResource() const = 0;
};
@ -75,7 +96,9 @@ private:
public:
ResourceOwnerImpl(ResourcePtrT ResourcePtr)
: ResourcePtr(std::move(ResourcePtr)) {}
ResourceT& getResource() const override { return *ResourcePtr; }
private:
ResourcePtrT ResourcePtr;
};
@ -161,7 +184,6 @@ private:
typedef std::list<LogicalDylib> LogicalDylibList;
public:
/// @brief Handle to a set of loaded modules.
typedef typename LogicalDylibList::iterator ModuleSetHandleT;
@ -258,9 +280,8 @@ public:
if (auto LMResources = LDI->getLogicalModuleResourcesForSymbol(FuncName, false)) {
Module &SrcM = LMResources->SourceModule->getResource();
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;
}
else
return true;
}
@ -269,7 +290,6 @@ public:
}
private:
template <typename ModulePtrT>
void addLogicalModule(LogicalDylib &LD, ModulePtrT SrcMPtr) {
@ -547,7 +567,7 @@ private:
bool CloneStubsIntoPartitions;
};
} // End namespace orc.
} // End namespace llvm.
} // end namespace orc
} // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_COMPILEONDEMANDLAYER_H

View File

@ -14,14 +14,26 @@
#ifndef 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/RuntimeDyld.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 "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 orc {
@ -55,7 +67,7 @@ public:
JITCompileCallbackManager(JITTargetAddress ErrorHandlerAddress)
: ErrorHandlerAddress(ErrorHandlerAddress) {}
virtual ~JITCompileCallbackManager() {}
virtual ~JITCompileCallbackManager() = default;
/// @brief Execute the callback for the given trampoline id. Called by the JIT
/// to compile functions on demand.
@ -210,7 +222,7 @@ public:
/// @brief Map type for initializing the manager. See init.
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.
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,
ValueToValueMapTy &VMap);
} // End namespace orc.
} // End namespace llvm.
} // end namespace orc
} // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_INDIRECTIONUTILS_H

View File

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

View File

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

View File

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

View File

@ -14,33 +14,39 @@
#ifndef LLVM_EXECUTIONENGINE_RUNTIMEDYLD_H
#define LLVM_EXECUTIONENGINE_RUNTIMEDYLD_H
#include "JITSymbol.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/DebugInfo/DIContext.h"
#include "llvm/ExecutionEngine/JITSymbol.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 <memory>
#include <utility>
#include <string>
#include <system_error>
namespace llvm {
class StringRef;
namespace object {
class ObjectFile;
template <typename T> class OwningBinary;
}
} // end namespace object
/// Base class for errors originating in RuntimeDyld, e.g. missing relocation
/// support.
class RuntimeDyldError : public ErrorInfo<RuntimeDyldError> {
public:
static char ID;
RuntimeDyldError(std::string ErrMsg) : ErrMsg(std::move(ErrMsg)) {}
void log(raw_ostream &OS) const override;
const std::string &getErrorMessage() const { return ErrMsg; }
std::error_code convertToErrorCode() const override;
private:
std::string ErrMsg;
};
@ -51,18 +57,16 @@ class RuntimeDyldCheckerImpl;
class RuntimeDyld {
friend class RuntimeDyldCheckerImpl;
RuntimeDyld(const RuntimeDyld &) = delete;
void operator=(const RuntimeDyld &) = delete;
protected:
// Change the address associated with a section when resolving relocations.
// Any relocations already associated with the symbol will be re-resolved.
void reassignSectionAddress(unsigned SectionID, uint64_t Addr);
public:
public:
/// \brief Information about the loaded object.
class LoadedObjectInfo : public llvm::LoadedObjectInfo {
friend class RuntimeDyldImpl;
public:
typedef std::map<object::SectionRef, unsigned> ObjSectionToIDMap;
@ -91,6 +95,7 @@ public:
LoadedObjectInfoHelper(RuntimeDyldImpl &RTDyld,
LoadedObjectInfo::ObjSectionToIDMap ObjSecToIDMap)
: LoadedObjectInfo(RTDyld, std::move(ObjSecToIDMap)) {}
std::unique_ptr<llvm::LoadedObjectInfo> clone() const override {
return llvm::make_unique<Derived>(static_cast<const Derived &>(*this));
}
@ -99,9 +104,10 @@ public:
/// \brief Memory Management.
class MemoryManager {
friend class RuntimeDyld;
public:
MemoryManager() : FinalizationLocked(false) {}
virtual ~MemoryManager() {}
MemoryManager() = default;
virtual ~MemoryManager() = default;
/// Allocate a memory block of (at least) the given size suitable for
/// executable code. The SectionID is a unique identifier assigned by the
@ -174,11 +180,14 @@ public:
private:
virtual void anchor();
bool FinalizationLocked;
bool FinalizationLocked = false;
};
/// \brief Construct a RuntimeDyld instance.
RuntimeDyld(MemoryManager &MemMgr, JITSymbolResolver &Resolver);
RuntimeDyld(const RuntimeDyld &) = delete;
void operator=(const RuntimeDyld &) = delete;
~RuntimeDyld();
/// 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
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Memory.h"
#include <cstdint>
#include <string>
#include <system_error>
namespace llvm {
/// This is a simple memory manager which implements the methods called by
/// the RuntimeDyld class to allocate memory for section-based loading of
/// objects, usually those generated by the MCJIT execution engine.
@ -35,11 +39,10 @@ namespace llvm {
/// MCJIT::finalizeObject or by calling SectionMemoryManager::finalizeMemory
/// directly. Clients of MCJIT should call MCJIT::finalizeObject.
class SectionMemoryManager : public RTDyldMemoryManager {
public:
SectionMemoryManager() = default;
SectionMemoryManager(const SectionMemoryManager&) = delete;
void operator=(const SectionMemoryManager&) = delete;
public:
SectionMemoryManager() { }
~SectionMemoryManager() override;
/// \brief Allocates a memory block of (at least) the given size suitable for
@ -118,6 +121,6 @@ private:
MemoryGroup RODataMem;
};
}
} // end namespace llvm
#endif // LLVM_EXECUTION_ENGINE_SECTION_MEMORY_MANAGER_H