Skip to content

Commit

Permalink
[ExecutionEngine] Fix some Clang-tidy modernize-use-default, moderniz…
Browse files Browse the repository at this point in the history
…e-use-equals-delete and Include What You Use warnings; other minor fixes.

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

llvm-svn: 287126
  • Loading branch information
EugeneZelenko committed Nov 16, 2016
1 parent 95eae57 commit cecb018
Show file tree
Hide file tree
Showing 10 changed files with 147 additions and 92 deletions.
18 changes: 9 additions & 9 deletions llvm/include/llvm/ExecutionEngine/JITEventListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -60,8 +60,8 @@ class JITEventListener {
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
Expand Down Expand Up @@ -105,18 +105,18 @@ class JITEventListener {
static JITEventListener *createOProfileJITEventListener(
OProfileWrapper* AlternativeImpl);
#else

static JITEventListener *createOProfileJITEventListener() { return nullptr; }

static JITEventListener *createOProfileJITEventListener(
OProfileWrapper* AlternativeImpl) {
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
15 changes: 7 additions & 8 deletions llvm/include/llvm/ExecutionEngine/JITSymbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,27 @@
#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 {

class GlobalValue;

namespace object {
class BasicSymbolRef;
}
} // end namespace object

/// @brief Represents an address in the target process's address space.
typedef uint64_t JITTargetAddress;

/// @brief Flags for symbols in the JIT.
class JITSymbolFlags {
public:

typedef uint8_t UnderlyingType;

enum FlagNames : UnderlyingType {
Expand Down Expand Up @@ -86,7 +87,6 @@ class JITSymbolFlags {
/// @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) {}
Expand All @@ -112,7 +112,6 @@ class JITEvaluatedSymbol {
/// @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
Expand Down Expand Up @@ -165,7 +164,7 @@ class JITSymbol {
/// \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.
Expand Down Expand Up @@ -193,6 +192,6 @@ class JITSymbolResolver {
virtual void anchor();
};

} // End namespace llvm.
} // end namespace llvm

#endif // LLVM_EXECUTIONENGINE_JITSYMBOL_H
12 changes: 7 additions & 5 deletions llvm/include/llvm/ExecutionEngine/ObjectCache.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- ObjectCache.h - Class definition for the ObjectCache -----C++ -*-===//
//===-- ObjectCache.h - Class definition for the ObjectCache ----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
Expand All @@ -11,6 +11,7 @@
#define LLVM_EXECUTIONENGINE_OBJECTCACHE_H

#include "llvm/Support/MemoryBuffer.h"
#include <memory>

namespace llvm {

Expand All @@ -21,10 +22,11 @@ class Module;
/// have already been compiled and an object file is available.
class ObjectCache {
virtual void anchor();

public:
ObjectCache() { }
ObjectCache() = default;

virtual ~ObjectCache() { }
virtual ~ObjectCache() = default;

/// notifyObjectCompiled - Provides a pointer to compiled code for Module M.
virtual void notifyObjectCompiled(const Module *M, MemoryBufferRef Obj) = 0;
Expand All @@ -35,6 +37,6 @@ class ObjectCache {
virtual std::unique_ptr<MemoryBuffer> getObject(const Module* M) = 0;
};

}
} // end namespace llvm

#endif
#endif // LLVM_EXECUTIONENGINE_OBJECTCACHE_H
44 changes: 32 additions & 12 deletions llvm/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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:
Expand All @@ -66,7 +86,8 @@ class CompileOnDemandLayer {
ResourceOwner() = default;
ResourceOwner(const ResourceOwner&) = delete;
ResourceOwner& operator=(const ResourceOwner&) = delete;
virtual ~ResourceOwner() { }
virtual ~ResourceOwner() = default;

virtual ResourceT& getResource() const = 0;
};

Expand All @@ -75,7 +96,9 @@ class CompileOnDemandLayer {
public:
ResourceOwnerImpl(ResourcePtrT ResourcePtr)
: ResourcePtr(std::move(ResourcePtr)) {}

ResourceT& getResource() const override { return *ResourcePtr; }

private:
ResourcePtrT ResourcePtr;
};
Expand Down Expand Up @@ -161,7 +184,6 @@ class CompileOnDemandLayer {
typedef std::list<LogicalDylib> LogicalDylibList;

public:

/// @brief Handle to a set of loaded modules.
typedef typename LogicalDylibList::iterator ModuleSetHandleT;

Expand Down Expand Up @@ -258,9 +280,8 @@ class CompileOnDemandLayer {
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;
}
Expand All @@ -269,7 +290,6 @@ class CompileOnDemandLayer {
}

private:

template <typename ModulePtrT>
void addLogicalModule(LogicalDylib &LD, ModulePtrT SrcMPtr) {

Expand Down Expand Up @@ -547,7 +567,7 @@ class CompileOnDemandLayer {
bool CloneStubsIntoPartitions;
};

} // End namespace orc.
} // End namespace llvm.
} // end namespace orc
} // end namespace llvm

#endif // LLVM_EXECUTIONENGINE_ORC_COMPILEONDEMANDLAYER_H
24 changes: 18 additions & 6 deletions llvm/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -55,7 +67,7 @@ class JITCompileCallbackManager {
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.
Expand Down Expand Up @@ -210,7 +222,7 @@ class IndirectStubsManager {
/// @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,
Expand Down Expand Up @@ -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
22 changes: 13 additions & 9 deletions llvm/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -39,8 +45,8 @@ template <typename BaseLayerT> class LazyEmittingLayer {
private:
class EmissionDeferredSet {
public:
EmissionDeferredSet() : EmitState(NotEmitted) {}
virtual ~EmissionDeferredSet() {}
EmissionDeferredSet() = default;
virtual ~EmissionDeferredSet() = default;

JITSymbol find(StringRef Name, bool ExportedSymbolsOnly, BaseLayerT &B) {
switch (EmitState) {
Expand Down Expand Up @@ -106,7 +112,7 @@ template <typename BaseLayerT> class LazyEmittingLayer {
virtual BaseLayerHandleT emitToBaseLayer(BaseLayerT &BaseLayer) = 0;

private:
enum { NotEmitted, Emitting, Emitted } EmitState;
enum { NotEmitted, Emitting, Emitted } EmitState = NotEmitted;
BaseLayerHandleT Handle;
};

Expand All @@ -121,7 +127,6 @@ template <typename BaseLayerT> class LazyEmittingLayer {
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
Expand Down Expand Up @@ -277,7 +282,6 @@ template <typename BaseLayerT> class LazyEmittingLayer {
void emitAndFinalize(ModuleSetHandleT H) {
(*H)->emitAndFinalize(BaseLayer);
}

};

template <typename BaseLayerT>
Expand All @@ -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

0 comments on commit cecb018

Please sign in to comment.