public:
KaleidoscopeJIT()
: TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()),
- ObjectLayer(ES,
+ ObjectLayer(AcknowledgeORCv1Deprecation, ES,
[this](VModuleKey K) {
return LegacyRTDyldObjectLinkingLayer::Resources{
std::make_shared<SectionMemoryManager>(),
Resolvers[K]};
}),
- CompileLayer(ObjectLayer, SimpleCompiler(*TM)),
- OptimizeLayer(CompileLayer,
+ CompileLayer(AcknowledgeORCv1Deprecation, ObjectLayer,
+ SimpleCompiler(*TM)),
+ OptimizeLayer(AcknowledgeORCv1Deprecation, CompileLayer,
[this](std::unique_ptr<Module> M) {
return optimizeModule(std::move(M));
}),
CompileCallbackManager(cantFail(orc::createLocalCompileCallbackManager(
TM->getTargetTriple(), ES, 0))),
- CODLayer(ES, OptimizeLayer,
- [&](orc::VModuleKey K) { return Resolvers[K]; },
- [&](orc::VModuleKey K, std::shared_ptr<SymbolResolver> R) {
- Resolvers[K] = std::move(R);
- },
- [](Function &F) { return std::set<Function *>({&F}); },
- *CompileCallbackManager,
- orc::createLocalIndirectStubsManagerBuilder(
- TM->getTargetTriple())) {
+ CODLayer(
+ AcknowledgeORCv1Deprecation, ES, OptimizeLayer,
+ [&](orc::VModuleKey K) { return Resolvers[K]; },
+ [&](orc::VModuleKey K, std::shared_ptr<SymbolResolver> R) {
+ Resolvers[K] = std::move(R);
+ },
+ [](Function &F) { return std::set<Function *>({&F}); },
+ *CompileCallbackManager,
+ orc::createLocalIndirectStubsManagerBuilder(
+ TM->getTargetTriple())) {
llvm::sys::DynamicLibrary::LoadLibraryPermanently(nullptr);
}
},
[](Error Err) { cantFail(std::move(Err), "lookupFlags failed"); })),
TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()),
- ObjectLayer(ES,
+ ObjectLayer(AcknowledgeORCv1Deprecation, ES,
[this](VModuleKey K) {
return LegacyRTDyldObjectLinkingLayer::Resources{
std::make_shared<SectionMemoryManager>(), Resolver};
}),
- CompileLayer(ObjectLayer, SimpleCompiler(*TM)),
- OptimizeLayer(CompileLayer,
+ CompileLayer(AcknowledgeORCv1Deprecation, ObjectLayer,
+ SimpleCompiler(*TM)),
+ OptimizeLayer(AcknowledgeORCv1Deprecation, CompileLayer,
[this](std::unique_ptr<Module> M) {
return optimizeModule(std::move(M));
}),
TM(EngineBuilder().selectTarget(Triple(Remote.getTargetTriple()), "",
"", SmallVector<std::string, 0>())),
DL(TM->createDataLayout()),
- ObjectLayer(ES,
+ ObjectLayer(AcknowledgeORCv1Deprecation, ES,
[this](VModuleKey K) {
return LegacyRTDyldObjectLinkingLayer::Resources{
cantFail(this->Remote.createRemoteMemoryManager()),
Resolver};
}),
- CompileLayer(ObjectLayer, SimpleCompiler(*TM)),
- OptimizeLayer(CompileLayer,
+ CompileLayer(AcknowledgeORCv1Deprecation, ObjectLayer,
+ SimpleCompiler(*TM)),
+ OptimizeLayer(AcknowledgeORCv1Deprecation, CompileLayer,
[this](std::unique_ptr<Module> M) {
return optimizeModule(std::move(M));
}),
KaleidoscopeJIT()
: Resolver(createLegacyLookupResolver(
ES,
- [this](const std::string &Name) {
- return findMangledSymbol(Name);
- },
+ [this](const std::string &Name) { return findMangledSymbol(Name); },
[](Error Err) { cantFail(std::move(Err), "lookupFlags failed"); })),
TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()),
- ObjectLayer(ES,
+ ObjectLayer(AcknowledgeORCv1Deprecation, ES,
[this](VModuleKey) {
return ObjLayerT::Resources{
std::make_shared<SectionMemoryManager>(), Resolver};
}),
- CompileLayer(ObjectLayer, SimpleCompiler(*TM)) {
+ CompileLayer(AcknowledgeORCv1Deprecation, ObjectLayer,
+ SimpleCompiler(*TM)) {
llvm::sys::DynamicLibrary::LoadLibraryPermanently(nullptr);
}
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
+#include "llvm/ExecutionEngine/OrcV1Deprecation.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Module.h"
#include "llvm/Object/Binary.h"
}
// Use OrcMCJITReplacement instead of MCJIT. Off by default.
- void setUseOrcMCJITReplacement(bool UseOrcMCJITReplacement) {
+ LLVM_ATTRIBUTE_DEPRECATED(
+ inline void setUseOrcMCJITReplacement(bool UseOrcMCJITReplacement),
+ "ORCv1 utilities (including OrcMCJITReplacement) are deprecated. Please "
+ "use ORCv2/LLJIT instead (see docs/ORCv2.rst)");
+
+ void setUseOrcMCJITReplacement(ORCv1DeprecationAcknowledgement,
+ bool UseOrcMCJITReplacement) {
this->UseOrcMCJITReplacement = UseOrcMCJITReplacement;
}
ExecutionEngine *create(TargetMachine *TM);
};
+void EngineBuilder::setUseOrcMCJITReplacement(bool UseOrcMCJITReplacement) {
+ this->UseOrcMCJITReplacement = UseOrcMCJITReplacement;
+}
+
// Create wrappers for C Binding types (see CBindingWrapping.h).
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ExecutionEngine, LLVMExecutionEngineRef)
std::function<void(VModuleKey K, std::shared_ptr<SymbolResolver> R)>;
/// Construct a compile-on-demand layer instance.
- LegacyCompileOnDemandLayer(ExecutionSession &ES, BaseLayerT &BaseLayer,
- SymbolResolverGetter GetSymbolResolver,
- SymbolResolverSetter SetSymbolResolver,
- PartitioningFtor Partition,
- CompileCallbackMgrT &CallbackMgr,
- IndirectStubsManagerBuilderT CreateIndirectStubsManager,
- bool CloneStubsIntoPartitions = true)
+ LLVM_ATTRIBUTE_DEPRECATED(
+ LegacyCompileOnDemandLayer(
+ ExecutionSession &ES, BaseLayerT &BaseLayer,
+ SymbolResolverGetter GetSymbolResolver,
+ SymbolResolverSetter SetSymbolResolver, PartitioningFtor Partition,
+ CompileCallbackMgrT &CallbackMgr,
+ IndirectStubsManagerBuilderT CreateIndirectStubsManager,
+ bool CloneStubsIntoPartitions = true),
+ "ORCv1 layers (layers with the 'Legacy' prefix) are deprecated. Please "
+ "use "
+ "the ORCv2 LegacyCompileOnDemandLayer instead");
+
+ /// Legacy layer constructor with deprecation acknowledgement.
+ LegacyCompileOnDemandLayer(
+ ORCv1DeprecationAcknowledgement, ExecutionSession &ES,
+ BaseLayerT &BaseLayer, SymbolResolverGetter GetSymbolResolver,
+ SymbolResolverSetter SetSymbolResolver, PartitioningFtor Partition,
+ CompileCallbackMgrT &CallbackMgr,
+ IndirectStubsManagerBuilderT CreateIndirectStubsManager,
+ bool CloneStubsIntoPartitions = true)
: ES(ES), BaseLayer(BaseLayer),
GetSymbolResolver(std::move(GetSymbolResolver)),
SetSymbolResolver(std::move(SetSymbolResolver)),
bool CloneStubsIntoPartitions;
};
-} // end namespace orc
+template <typename BaseLayerT, typename CompileCallbackMgrT,
+ typename IndirectStubsMgrT>
+LegacyCompileOnDemandLayer<BaseLayerT, CompileCallbackMgrT, IndirectStubsMgrT>::
+ LegacyCompileOnDemandLayer(
+ ExecutionSession &ES, BaseLayerT &BaseLayer,
+ SymbolResolverGetter GetSymbolResolver,
+ SymbolResolverSetter SetSymbolResolver, PartitioningFtor Partition,
+ CompileCallbackMgrT &CallbackMgr,
+ IndirectStubsManagerBuilderT CreateIndirectStubsManager,
+ bool CloneStubsIntoPartitions)
+ : ES(ES), BaseLayer(BaseLayer),
+ GetSymbolResolver(std::move(GetSymbolResolver)),
+ SetSymbolResolver(std::move(SetSymbolResolver)),
+ Partition(std::move(Partition)), CompileCallbackMgr(CallbackMgr),
+ CreateIndirectStubsManager(std::move(CreateIndirectStubsManager)),
+ CloneStubsIntoPartitions(CloneStubsIntoPartitions) {}
+} // end namespace orc
} // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_COMPILEONDEMANDLAYER_H
#include "llvm/ADT/BitmaskEnum.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/ExecutionEngine/Orc/SymbolStringPool.h"
+#include "llvm/ExecutionEngine/OrcV1Deprecation.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/Debug.h"
public:
/// Construct a CtorDtorRunner for the given range using the given
/// name mangling function.
- LegacyCtorDtorRunner(std::vector<std::string> CtorDtorNames, VModuleKey K)
+ LLVM_ATTRIBUTE_DEPRECATED(
+ LegacyCtorDtorRunner(std::vector<std::string> CtorDtorNames,
+ VModuleKey K),
+ "ORCv1 utilities (utilities with the 'Legacy' prefix) are deprecated. "
+ "Please use the ORCv2 CtorDtorRunner utility instead");
+
+ LegacyCtorDtorRunner(ORCv1DeprecationAcknowledgement,
+ std::vector<std::string> CtorDtorNames, VModuleKey K)
: CtorDtorNames(std::move(CtorDtorNames)), K(K) {}
/// Run the recorded constructors/destructors through the given JIT
orc::VModuleKey K;
};
+template <typename JITLayerT>
+LegacyCtorDtorRunner<JITLayerT>::LegacyCtorDtorRunner(
+ std::vector<std::string> CtorDtorNames, VModuleKey K)
+ : CtorDtorNames(std::move(CtorDtorNames)), K(K) {}
+
class CtorDtorRunner {
public:
CtorDtorRunner(JITDylib &JD) : JD(JD) {}
public:
/// Create a runtime-overrides class.
template <typename MangleFtorT>
- LegacyLocalCXXRuntimeOverrides(const MangleFtorT &Mangle) {
+ LLVM_ATTRIBUTE_DEPRECATED(
+ LegacyLocalCXXRuntimeOverrides(const MangleFtorT &Mangle),
+ "ORCv1 utilities (utilities with the 'Legacy' prefix) are deprecated. "
+ "Please use the ORCv2 LocalCXXRuntimeOverrides utility instead");
+
+ template <typename MangleFtorT>
+ LegacyLocalCXXRuntimeOverrides(ORCv1DeprecationAcknowledgement,
+ const MangleFtorT &Mangle) {
addOverride(Mangle("__dso_handle"), toTargetAddress(&DSOHandleOverride));
addOverride(Mangle("__cxa_atexit"), toTargetAddress(&CXAAtExitOverride));
}
StringMap<JITTargetAddress> CXXRuntimeOverrides;
};
+template <typename MangleFtorT>
+LegacyLocalCXXRuntimeOverrides::LegacyLocalCXXRuntimeOverrides(
+ const MangleFtorT &Mangle) {
+ addOverride(Mangle("__dso_handle"), toTargetAddress(&DSOHandleOverride));
+ addOverride(Mangle("__cxa_atexit"), toTargetAddress(&CXAAtExitOverride));
+}
+
class LocalCXXRuntimeOverrides : public LocalCXXRuntimeOverridesBase {
public:
Error enable(JITDylib &JD, MangleAndInterner &Mangler);
/// Construct an LegacyIRCompileLayer with the given BaseLayer, which must
/// implement the ObjectLayer concept.
+ LLVM_ATTRIBUTE_DEPRECATED(
+ LegacyIRCompileLayer(
+ BaseLayerT &BaseLayer, CompileFtor Compile,
+ NotifyCompiledCallback NotifyCompiled = NotifyCompiledCallback()),
+ "ORCv1 layers (layers with the 'Legacy' prefix) are deprecated. Please "
+ "use "
+ "the ORCv2 IRCompileLayer instead");
+
+ /// Legacy layer constructor with deprecation acknowledgement.
LegacyIRCompileLayer(
- BaseLayerT &BaseLayer, CompileFtor Compile,
+ ORCv1DeprecationAcknowledgement, BaseLayerT &BaseLayer,
+ CompileFtor Compile,
NotifyCompiledCallback NotifyCompiled = NotifyCompiledCallback())
: BaseLayer(BaseLayer), Compile(std::move(Compile)),
NotifyCompiled(std::move(NotifyCompiled)) {}
NotifyCompiledCallback NotifyCompiled;
};
-} // end namespace orc
+template <typename BaseLayerT, typename CompileFtor>
+LegacyIRCompileLayer<BaseLayerT, CompileFtor>::LegacyIRCompileLayer(
+ BaseLayerT &BaseLayer, CompileFtor Compile,
+ NotifyCompiledCallback NotifyCompiled)
+ : BaseLayer(BaseLayer), Compile(std::move(Compile)),
+ NotifyCompiled(std::move(NotifyCompiled)) {}
+} // end namespace orc
} // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_IRCOMPILINGLAYER_H
public:
/// Construct an LegacyIRTransformLayer with the given BaseLayer
- LegacyIRTransformLayer(BaseLayerT &BaseLayer,
- TransformFtor Transform = TransformFtor())
- : BaseLayer(BaseLayer), Transform(std::move(Transform)) {}
+ LLVM_ATTRIBUTE_DEPRECATED(
+ LegacyIRTransformLayer(BaseLayerT &BaseLayer,
+ TransformFtor Transform = TransformFtor()),
+ "ORCv1 layers (layers with the 'Legacy' prefix) are deprecated. Please "
+ "use "
+ "the ORCv2 IRTransformLayer instead");
+
+ /// Legacy layer constructor with deprecation acknowledgement.
+ LegacyIRTransformLayer(ORCv1DeprecationAcknowledgement, BaseLayerT &BaseLayer,
+ TransformFtor Transform = TransformFtor())
+ : BaseLayer(BaseLayer), Transform(std::move(Transform)) {}
/// Apply the transform functor to the module, then add the module to
/// the layer below, along with the memory manager and symbol resolver.
TransformFtor Transform;
};
+template <typename BaseLayerT, typename TransformFtor>
+LegacyIRTransformLayer<BaseLayerT, TransformFtor>::LegacyIRTransformLayer(
+ BaseLayerT &BaseLayer, TransformFtor Transform)
+ : BaseLayer(BaseLayer), Transform(std::move(Transform)) {}
+
} // end namespace orc
} // end namespace llvm
template <typename DylibLookupFtorT, typename ExternalLookupFtorT>
class LambdaResolver : public LegacyJITSymbolResolver {
public:
- LambdaResolver(DylibLookupFtorT DylibLookupFtor,
+ LLVM_ATTRIBUTE_DEPRECATED(
+ LambdaResolver(DylibLookupFtorT DylibLookupFtor,
+ ExternalLookupFtorT ExternalLookupFtor),
+ "ORCv1 utilities (including resolvers) are deprecated and will be "
+ "removed "
+ "in the next release. Please use ORCv2 (see docs/ORCv2.rst)");
+
+ LambdaResolver(ORCv1DeprecationAcknowledgement,
+ DylibLookupFtorT DylibLookupFtor,
ExternalLookupFtorT ExternalLookupFtor)
: DylibLookupFtor(DylibLookupFtor),
ExternalLookupFtor(ExternalLookupFtor) {}
ExternalLookupFtorT ExternalLookupFtor;
};
+template <typename DylibLookupFtorT, typename ExternalLookupFtorT>
+LambdaResolver<DylibLookupFtorT, ExternalLookupFtorT>::LambdaResolver(
+ DylibLookupFtorT DylibLookupFtor, ExternalLookupFtorT ExternalLookupFtor)
+ : DylibLookupFtor(DylibLookupFtor), ExternalLookupFtor(ExternalLookupFtor) {
+}
+
template <typename DylibLookupFtorT,
typename ExternalLookupFtorT>
std::shared_ptr<LambdaResolver<DylibLookupFtorT, ExternalLookupFtorT>>
std::move(ExternalLookupFtor));
}
+template <typename DylibLookupFtorT, typename ExternalLookupFtorT>
+std::shared_ptr<LambdaResolver<DylibLookupFtorT, ExternalLookupFtorT>>
+createLambdaResolver(ORCv1DeprecationAcknowledgement,
+ DylibLookupFtorT DylibLookupFtor,
+ ExternalLookupFtorT ExternalLookupFtor) {
+ using LR = LambdaResolver<DylibLookupFtorT, ExternalLookupFtorT>;
+ return make_unique<LR>(AcknowledgeORCv1Deprecation,
+ std::move(DylibLookupFtor),
+ std::move(ExternalLookupFtor));
+}
+
} // end namespace orc
} // end namespace llvm
public:
/// Construct a lazy emitting layer.
- LazyEmittingLayer(BaseLayerT &BaseLayer) : BaseLayer(BaseLayer) {}
+ LLVM_ATTRIBUTE_DEPRECATED(
+ LazyEmittingLayer(BaseLayerT &BaseLayer),
+ "ORCv1 layers (including LazyEmittingLayer) are deprecated. Please use "
+ "ORCv2, where lazy emission is the default");
+
+ /// Construct a lazy emitting layer.
+ LazyEmittingLayer(ORCv1DeprecationAcknowledgement, BaseLayerT &BaseLayer)
+ : BaseLayer(BaseLayer) {}
/// Add the given module to the lazy emitting layer.
Error addModule(VModuleKey K, std::unique_ptr<Module> M) {
}
};
+template <typename BaseLayerT>
+LazyEmittingLayer<BaseLayerT>::LazyEmittingLayer(BaseLayerT &BaseLayer)
+ : BaseLayer(BaseLayer) {}
+
} // end namespace orc
} // end namespace llvm
class LegacyObjectTransformLayer {
public:
/// Construct an ObjectTransformLayer with the given BaseLayer
- LegacyObjectTransformLayer(BaseLayerT &BaseLayer,
+ LLVM_ATTRIBUTE_DEPRECATED(
+ LegacyObjectTransformLayer(BaseLayerT &BaseLayer,
+ TransformFtor Transform = TransformFtor()),
+ "ORCv1 layers (layers with the 'Legacy' prefix) are deprecated. Please "
+ "use "
+ "the ORCv2 ObjectTransformLayer instead");
+
+ /// Legacy layer constructor with deprecation acknowledgement.
+ LegacyObjectTransformLayer(ORCv1DeprecationAcknowledgement,
+ BaseLayerT &BaseLayer,
TransformFtor Transform = TransformFtor())
: BaseLayer(BaseLayer), Transform(std::move(Transform)) {}
TransformFtor Transform;
};
+template <typename BaseLayerT, typename TransformFtor>
+LegacyObjectTransformLayer<BaseLayerT, TransformFtor>::
+ LegacyObjectTransformLayer(BaseLayerT &BaseLayer, TransformFtor Transform)
+ : BaseLayer(BaseLayer), Transform(std::move(Transform)) {}
+
} // end namespace orc
} // end namespace llvm
/// Construct an ObjectLinkingLayer with the given NotifyLoaded,
/// and NotifyFinalized functors.
+ LLVM_ATTRIBUTE_DEPRECATED(
+ LegacyRTDyldObjectLinkingLayer(
+ ExecutionSession &ES, ResourcesGetter GetResources,
+ NotifyLoadedFtor NotifyLoaded = NotifyLoadedFtor(),
+ NotifyFinalizedFtor NotifyFinalized = NotifyFinalizedFtor(),
+ NotifyFreedFtor NotifyFreed = NotifyFreedFtor()),
+ "ORCv1 layers (layers with the 'Legacy' prefix) are deprecated. Please "
+ "use "
+ "ORCv2 (see docs/ORCv2.rst)");
+
+ // Legacy layer constructor with deprecation acknowledgement.
LegacyRTDyldObjectLinkingLayer(
- ExecutionSession &ES, ResourcesGetter GetResources,
+ ORCv1DeprecationAcknowledgement, ExecutionSession &ES,
+ ResourcesGetter GetResources,
NotifyLoadedFtor NotifyLoaded = NotifyLoadedFtor(),
NotifyFinalizedFtor NotifyFinalized = NotifyFinalizedFtor(),
NotifyFreedFtor NotifyFreed = NotifyFreedFtor())
: ES(ES), GetResources(std::move(GetResources)),
NotifyLoaded(std::move(NotifyLoaded)),
NotifyFinalized(std::move(NotifyFinalized)),
- NotifyFreed(std::move(NotifyFreed)),
- ProcessAllSections(false) {
- }
+ NotifyFreed(std::move(NotifyFreed)), ProcessAllSections(false) {}
/// Set the 'ProcessAllSections' flag.
///
#ifndef LLVM_EXECUTIONENGINE_ORC_REMOTEOBJECTLAYER_H
#define LLVM_EXECUTIONENGINE_ORC_REMOTEOBJECTLAYER_H
+#include "llvm/ExecutionEngine/Orc/Core.h"
+#include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
#include "llvm/ExecutionEngine/Orc/OrcRemoteTargetRPCAPI.h"
#include "llvm/Object/ObjectFile.h"
-#include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
#include <map>
namespace llvm {
///
/// The ReportError functor can be used locally log errors that are intended
/// to be sent sent
- RemoteObjectClientLayer(RPCEndpoint &Remote,
+ LLVM_ATTRIBUTE_DEPRECATED(
+ RemoteObjectClientLayer(RPCEndpoint &Remote,
+ std::function<void(Error)> ReportError),
+ "ORCv1 layers (including RemoteObjectClientLayer) are deprecated. Please "
+ "use "
+ "ORCv2 (see docs/ORCv2.rst)");
+
+ RemoteObjectClientLayer(ORCv1DeprecationAcknowledgement, RPCEndpoint &Remote,
std::function<void(Error)> ReportError)
: RemoteObjectLayer<RPCEndpoint>(Remote, std::move(ReportError)) {
using ThisT = RemoteObjectClientLayer<RPCEndpoint>;
/// Create a RemoteObjectServerLayer with the given base layer (which must be
/// an object layer), RPC endpoint, and error reporter function.
- RemoteObjectServerLayer(BaseLayerT &BaseLayer,
- RPCEndpoint &Remote,
+ LLVM_ATTRIBUTE_DEPRECATED(
+ RemoteObjectServerLayer(BaseLayerT &BaseLayer, RPCEndpoint &Remote,
+ std::function<void(Error)> ReportError),
+ "ORCv1 layers (including RemoteObjectServerLayer) are deprecated. Please "
+ "use "
+ "ORCv2 (see docs/ORCv2.rst)");
+
+ RemoteObjectServerLayer(ORCv1DeprecationAcknowledgement,
+ BaseLayerT &BaseLayer, RPCEndpoint &Remote,
std::function<void(Error)> ReportError)
- : RemoteObjectLayer<RPCEndpoint>(Remote, std::move(ReportError)),
- BaseLayer(BaseLayer), HandleIdMgr(1) {
+ : RemoteObjectLayer<RPCEndpoint>(Remote, std::move(ReportError)),
+ BaseLayer(BaseLayer), HandleIdMgr(1) {
using ThisT = RemoteObjectServerLayer<BaseLayerT, RPCEndpoint>;
Remote.template addHandler<AddObject>(*this, &ThisT::addObject);
assert(!BaseLayerHandles.count(Id) && "Id already in use?");
auto Resolver = createLambdaResolver(
+ AcknowledgeORCv1Deprecation,
[this, Id](const std::string &Name) { return lookup(Id, Name); },
[this, Id](const std::string &Name) {
return lookupInLogicalDylib(Id, Name);
std::map<ObjHandleT, typename BaseLayerT::ObjHandleT> BaseLayerHandles;
};
+template <typename RPCEndpoint>
+RemoteObjectClientLayer<RPCEndpoint>::RemoteObjectClientLayer(
+ RPCEndpoint &Remote, std::function<void(Error)> ReportError)
+ : RemoteObjectLayer<RPCEndpoint>(Remote, std::move(ReportError)) {
+ using ThisT = RemoteObjectClientLayer<RPCEndpoint>;
+ Remote.template addHandler<Lookup>(*this, &ThisT::lookup);
+ Remote.template addHandler<LookupInLogicalDylib>(
+ *this, &ThisT::lookupInLogicalDylib);
+}
+
+template <typename BaseLayerT, typename RPCEndpoint>
+RemoteObjectServerLayer<BaseLayerT, RPCEndpoint>::RemoteObjectServerLayer(
+ BaseLayerT &BaseLayer, RPCEndpoint &Remote,
+ std::function<void(Error)> ReportError)
+ : RemoteObjectLayer<RPCEndpoint>(Remote, std::move(ReportError)),
+ BaseLayer(BaseLayer), HandleIdMgr(1) {
+ using ThisT = RemoteObjectServerLayer<BaseLayerT, RPCEndpoint>;
+
+ Remote.template addHandler<AddObject>(*this, &ThisT::addObject);
+ Remote.template addHandler<RemoveObject>(*this, &ThisT::removeObject);
+ Remote.template addHandler<FindSymbol>(*this, &ThisT::findSymbol);
+ Remote.template addHandler<FindSymbolIn>(*this, &ThisT::findSymbolIn);
+ Remote.template addHandler<EmitAndFinalize>(*this, &ThisT::emitAndFinalize);
+}
+
} // end namespace orc
} // end namespace llvm
--- /dev/null
+//===------ OrcV1Deprecation.h - Memory manager for MC-JIT ------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Tag for suppressing ORCv1 deprecation warnings.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_EXECUTIONENGINE_ORCV1DEPRECATION_H
+#define LLVM_EXECUTIONENGINE_ORCV1DEPRECATION_H
+
+namespace llvm {
+
+enum ORCv1DeprecationAcknowledgement { AcknowledgeORCv1Deprecation };
+
+} // namespace llvm
+
+#endif // LLVM_EXECUTIONENGINE_ORCV1DEPRECATION_H
IndirectStubsManagerBuilder IndirectStubsMgrBuilder)
: CCMgr(createCompileCallbackManager(TM, ES)), DL(TM.createDataLayout()),
IndirectStubsMgr(IndirectStubsMgrBuilder()),
- ObjectLayer(ES,
- [this](orc::VModuleKey K) {
- auto ResolverI = Resolvers.find(K);
- assert(ResolverI != Resolvers.end() &&
- "No resolver for module K");
- auto Resolver = std::move(ResolverI->second);
- Resolvers.erase(ResolverI);
- return ObjLayerT::Resources{
- std::make_shared<SectionMemoryManager>(), Resolver};
- },
- nullptr,
- [this](orc::VModuleKey K, const object::ObjectFile &Obj,
- const RuntimeDyld::LoadedObjectInfo &LoadedObjInfo) {
- this->notifyFinalized(K, Obj, LoadedObjInfo);
- },
- [this](orc::VModuleKey K, const object::ObjectFile &Obj) {
- this->notifyFreed(K, Obj);
- }),
- CompileLayer(ObjectLayer, orc::SimpleCompiler(TM)),
+ ObjectLayer(
+ AcknowledgeORCv1Deprecation, ES,
+ [this](orc::VModuleKey K) {
+ auto ResolverI = Resolvers.find(K);
+ assert(ResolverI != Resolvers.end() &&
+ "No resolver for module K");
+ auto Resolver = std::move(ResolverI->second);
+ Resolvers.erase(ResolverI);
+ return ObjLayerT::Resources{
+ std::make_shared<SectionMemoryManager>(), Resolver};
+ },
+ nullptr,
+ [this](orc::VModuleKey K, const object::ObjectFile &Obj,
+ const RuntimeDyld::LoadedObjectInfo &LoadedObjInfo) {
+ this->notifyFinalized(K, Obj, LoadedObjInfo);
+ },
+ [this](orc::VModuleKey K, const object::ObjectFile &Obj) {
+ this->notifyFreed(K, Obj);
+ }),
+ CompileLayer(AcknowledgeORCv1Deprecation, ObjectLayer,
+ orc::SimpleCompiler(TM)),
CODLayer(createCODLayer(ES, CompileLayer, CCMgr.get(),
std::move(IndirectStubsMgrBuilder), Resolvers)),
CXXRuntimeOverrides(
+ AcknowledgeORCv1Deprecation,
[this](const std::string &S) { return mangle(S); }) {}
Error shutdown() {
// Run the static constructors, and save the static destructor runner for
// execution when the JIT is torn down.
- orc::LegacyCtorDtorRunner<OrcCBindingsStack> CtorRunner(std::move(CtorNames), K);
+ orc::LegacyCtorDtorRunner<OrcCBindingsStack> CtorRunner(
+ AcknowledgeORCv1Deprecation, std::move(CtorNames), K);
if (auto Err = CtorRunner.runViaLayer(*this))
return std::move(Err);
return nullptr;
return llvm::make_unique<CODLayerT>(
- ES, CompileLayer,
+ AcknowledgeORCv1Deprecation, ES, CompileLayer,
[&Resolvers](orc::VModuleKey K) {
auto ResolverI = Resolvers.find(K);
assert(ResolverI != Resolvers.end() && "No resolver for module K");
auto &CtorDtorsMap = isDtors ? UnexecutedDestructors : UnexecutedConstructors;
for (auto &KV : CtorDtorsMap)
- cantFail(LegacyCtorDtorRunner<LazyEmitLayerT>(std::move(KV.second), KV.first)
+ cantFail(LegacyCtorDtorRunner<LazyEmitLayerT>(
+ AcknowledgeORCv1Deprecation, std::move(KV.second), KV.first)
.runViaLayer(LazyEmitLayer));
CtorDtorsMap.clear();
OrcMCJITReplacement(std::shared_ptr<MCJITMemoryManager> MemMgr,
std::shared_ptr<LegacyJITSymbolResolver> ClientResolver,
std::unique_ptr<TargetMachine> TM)
- : ExecutionEngine(TM->createDataLayout()),
- TM(std::move(TM)),
+ : ExecutionEngine(TM->createDataLayout()), TM(std::move(TM)),
MemMgr(
std::make_shared<MCJITReplacementMemMgr>(*this, std::move(MemMgr))),
Resolver(std::make_shared<LinkingORCResolver>(*this)),
ClientResolver(std::move(ClientResolver)), NotifyObjectLoaded(*this),
NotifyFinalized(*this),
ObjectLayer(
- ES,
+ AcknowledgeORCv1Deprecation, ES,
[this](VModuleKey K) {
return ObjectLayerT::Resources{this->MemMgr, this->Resolver};
},
NotifyObjectLoaded, NotifyFinalized),
- CompileLayer(ObjectLayer, SimpleCompiler(*this->TM),
+ CompileLayer(AcknowledgeORCv1Deprecation, ObjectLayer,
+ SimpleCompiler(*this->TM),
[this](VModuleKey K, std::unique_ptr<Module> M) {
Modules.push_back(std::move(M));
}),
- LazyEmitLayer(CompileLayer) {}
+ LazyEmitLayer(AcknowledgeORCv1Deprecation, CompileLayer) {}
static void Register() {
OrcMCJITReplacementCtor = createOrcMCJITReplacement;
NotifyEmitted(K, std::move(ObjBuffer));
}
+LegacyRTDyldObjectLinkingLayer::LegacyRTDyldObjectLinkingLayer(
+ ExecutionSession &ES, ResourcesGetter GetResources,
+ NotifyLoadedFtor NotifyLoaded, NotifyFinalizedFtor NotifyFinalized,
+ NotifyFreedFtor NotifyFreed)
+ : ES(ES), GetResources(std::move(GetResources)),
+ NotifyLoaded(std::move(NotifyLoaded)),
+ NotifyFinalized(std::move(NotifyFinalized)),
+ NotifyFreed(std::move(NotifyFreed)), ProcessAllSections(false) {}
+
} // End namespace orc.
} // End namespace llvm.
cl::desc("Force interpretation: disable JIT"),
cl::init(false));
- cl::opt<JITKind> UseJITKind("jit-kind",
- cl::desc("Choose underlying JIT kind."),
- cl::init(JITKind::MCJIT),
- cl::values(
- clEnumValN(JITKind::MCJIT, "mcjit",
- "MCJIT"),
- clEnumValN(JITKind::OrcMCJITReplacement,
- "orc-mcjit",
- "Orc-based MCJIT replacement"),
- clEnumValN(JITKind::OrcLazy,
- "orc-lazy",
- "Orc-based lazy JIT.")));
+ cl::opt<JITKind> UseJITKind(
+ "jit-kind", cl::desc("Choose underlying JIT kind."),
+ cl::init(JITKind::MCJIT),
+ cl::values(clEnumValN(JITKind::MCJIT, "mcjit", "MCJIT"),
+ clEnumValN(JITKind::OrcMCJITReplacement, "orc-mcjit",
+ "Orc-based MCJIT replacement "
+ "(deprecated)"),
+ clEnumValN(JITKind::OrcLazy, "orc-lazy",
+ "Orc-based lazy JIT.")));
cl::opt<unsigned>
LazyJITCompileThreads("compile-threads",
builder.setEngineKind(ForceInterpreter
? EngineKind::Interpreter
: EngineKind::JIT);
- builder.setUseOrcMCJITReplacement(UseJITKind == JITKind::OrcMCJITReplacement);
+ builder.setUseOrcMCJITReplacement(AcknowledgeORCv1Deprecation,
+ UseJITKind == JITKind::OrcMCJITReplacement);
// If we are supposed to override the target triple, do so now.
if (!TargetTriple.empty())
// Forward MCJIT's symbol resolution calls to the remote.
static_cast<ForwardingMemoryManager *>(RTDyldMM)->setResolver(
orc::createLambdaResolver(
+ AcknowledgeORCv1Deprecation,
[](const std::string &Name) { return nullptr; },
[&](const std::string &Name) {
if (auto Addr = ExitOnErr(R->getSymbolAddress(Name)))
TEST(LazyEmittingLayerTest, Empty) {
MockBaseLayer M;
- llvm::orc::LazyEmittingLayer<MockBaseLayer> L(M);
+ llvm::orc::LazyEmittingLayer<MockBaseLayer> L(
+ llvm::AcknowledgeORCv1Deprecation, M);
cantFail(
L.addModule(llvm::orc::VModuleKey(), std::unique_ptr<llvm::Module>()));
}
};
llvm::orc::LegacyCompileOnDemandLayer<decltype(TestBaseLayer)> COD(
- ES, TestBaseLayer, GetResolver, SetResolver,
+ AcknowledgeORCv1Deprecation, ES, TestBaseLayer, GetResolver, SetResolver,
[](Function &F) { return std::set<Function *>{&F}; }, CallbackMgr,
[] { return llvm::make_unique<DummyStubsManager>(); }, true);
ExecutionSession ES;
- LegacyRTDyldObjectLinkingLayer ObjLayer(ES, [&MM](VModuleKey) {
- return LegacyRTDyldObjectLinkingLayer::Resources{
- MM, std::make_shared<NullResolver>()};
- });
+ LegacyRTDyldObjectLinkingLayer ObjLayer(
+ AcknowledgeORCv1Deprecation, ES, [&MM](VModuleKey) {
+ return LegacyRTDyldObjectLinkingLayer::Resources{
+ MM, std::make_shared<NullResolver>()};
+ });
LLVMContext Context;
auto M = llvm::make_unique<Module>("", Context);
std::map<orc::VModuleKey, std::shared_ptr<orc::SymbolResolver>> Resolvers;
- LegacyRTDyldObjectLinkingLayer ObjLayer(ES, [&](VModuleKey K) {
- auto I = Resolvers.find(K);
- assert(I != Resolvers.end() && "Missing resolver");
- auto R = std::move(I->second);
- Resolvers.erase(I);
- return LegacyRTDyldObjectLinkingLayer::Resources{MM, std::move(R)};
- });
+ LegacyRTDyldObjectLinkingLayer ObjLayer(
+ AcknowledgeORCv1Deprecation, ES, [&](VModuleKey K) {
+ auto I = Resolvers.find(K);
+ assert(I != Resolvers.end() && "Missing resolver");
+ auto R = std::move(I->second);
+ Resolvers.erase(I);
+ return LegacyRTDyldObjectLinkingLayer::Resources{MM, std::move(R)};
+ });
SimpleCompiler Compile(*TM);
// Create a pair of modules that will trigger recursive finalization:
auto MM = std::make_shared<SectionMemoryManagerWrapper>();
- LegacyRTDyldObjectLinkingLayer ObjLayer(ES, [&MM](VModuleKey K) {
- return LegacyRTDyldObjectLinkingLayer::Resources{
- MM, std::make_shared<NullResolver>()};
- });
+ LegacyRTDyldObjectLinkingLayer ObjLayer(
+ AcknowledgeORCv1Deprecation, ES, [&MM](VModuleKey K) {
+ return LegacyRTDyldObjectLinkingLayer::Resources{
+ MM, std::make_shared<NullResolver>()};
+ });
SimpleCompiler Compile(*TM);
// Create a pair of unrelated modules:
TEST_F(LegacyRTDyldObjectLinkingLayerExecutionTest, TestNotifyLoadedSignature) {
ExecutionSession ES;
LegacyRTDyldObjectLinkingLayer ObjLayer(
- ES,
+ AcknowledgeORCv1Deprecation, ES,
[](VModuleKey) {
return LegacyRTDyldObjectLinkingLayer::Resources{
nullptr, std::make_shared<NullResolver>()};
// Create one object transform layer using a transform (as a functor)
// that allocates new objects, and deals in unique pointers.
- LegacyObjectTransformLayer<MockBaseLayer, AllocatingTransform> T1(M);
+ LegacyObjectTransformLayer<MockBaseLayer, AllocatingTransform> T1(
+ llvm::AcknowledgeORCv1Deprecation, M);
// Create a second object transform layer using a transform (as a lambda)
// that mutates objects in place, and deals in naked pointers
LegacyObjectTransformLayer<MockBaseLayer,
- std::function<std::shared_ptr<MockObjectFile>(
- std::shared_ptr<MockObjectFile>)>>
- T2(M, [](std::shared_ptr<MockObjectFile> Obj) {
- ++(*Obj);
- return Obj;
- });
+ std::function<std::shared_ptr<MockObjectFile>(
+ std::shared_ptr<MockObjectFile>)>>
+ T2(llvm::AcknowledgeORCv1Deprecation, M,
+ [](std::shared_ptr<MockObjectFile> Obj) {
+ ++(*Obj);
+ return Obj;
+ });
// Test addObject with T1 (allocating)
auto K1 = ES.allocateVModule();
};
// Construct the jit layers.
- LegacyRTDyldObjectLinkingLayer BaseLayer(ES, [](VModuleKey) {
- return LegacyRTDyldObjectLinkingLayer::Resources{
- std::make_shared<llvm::SectionMemoryManager>(),
- std::make_shared<NullResolver>()};
- });
+ LegacyRTDyldObjectLinkingLayer BaseLayer(
+ llvm::AcknowledgeORCv1Deprecation, ES, [](VModuleKey) {
+ return LegacyRTDyldObjectLinkingLayer::Resources{
+ std::make_shared<llvm::SectionMemoryManager>(),
+ std::make_shared<NullResolver>()};
+ });
auto IdentityTransform = [](std::unique_ptr<llvm::MemoryBuffer> Obj) {
return Obj;
};
LegacyObjectTransformLayer<decltype(BaseLayer), decltype(IdentityTransform)>
- TransformLayer(BaseLayer, IdentityTransform);
+ TransformLayer(llvm::AcknowledgeORCv1Deprecation, BaseLayer,
+ IdentityTransform);
auto NullCompiler = [](llvm::Module &) {
return std::unique_ptr<llvm::MemoryBuffer>(nullptr);
};
LegacyIRCompileLayer<decltype(TransformLayer), decltype(NullCompiler)>
- CompileLayer(TransformLayer, NullCompiler);
+ CompileLayer(llvm::AcknowledgeORCv1Deprecation, TransformLayer,
+ NullCompiler);
// Make sure that the calls from LegacyIRCompileLayer to LegacyObjectTransformLayer
// compile.
std::copy(ObjBytes.begin(), ObjBytes.end(), ObjContents.begin());
RPCEndpoint ClientEP(*Channels.first, true);
- RemoteObjectClientLayer<RPCEndpoint> Client(ClientEP, ReportError);
+ RemoteObjectClientLayer<RPCEndpoint> Client(AcknowledgeORCv1Deprecation,
+ ClientEP, ReportError);
RPCEndpoint ServerEP(*Channels.second, true);
MockObjectLayer BaseLayer(
return 1;
});
- RemoteObjectServerLayer<MockObjectLayer, RPCEndpoint> Server(BaseLayer,
- ServerEP,
- ReportError);
+ RemoteObjectServerLayer<MockObjectLayer, RPCEndpoint> Server(
+ AcknowledgeORCv1Deprecation, BaseLayer, ServerEP, ReportError);
bool Finished = false;
ServerEP.addHandler<remote::utils::TerminateSession>(
};
RPCEndpoint ClientEP(*Channels.first, true);
- RemoteObjectClientLayer<RPCEndpoint> Client(ClientEP, ReportError);
+ RemoteObjectClientLayer<RPCEndpoint> Client(AcknowledgeORCv1Deprecation,
+ ClientEP, ReportError);
RPCEndpoint ServerEP(*Channels.second, true);
MockObjectLayer BaseLayer(
return make_error<StringError>("AddObjectFailure - Test Message",
inconvertibleErrorCode());
});
- RemoteObjectServerLayer<MockObjectLayer, RPCEndpoint> Server(BaseLayer,
- ServerEP,
- ReportError);
+ RemoteObjectServerLayer<MockObjectLayer, RPCEndpoint> Server(
+ AcknowledgeORCv1Deprecation, BaseLayer, ServerEP, ReportError);
bool Finished = false;
ServerEP.addHandler<remote::utils::TerminateSession>(
};
RPCEndpoint ClientEP(*Channels.first, true);
- RemoteObjectClientLayer<RPCEndpoint> Client(ClientEP, ReportError);
+ RemoteObjectClientLayer<RPCEndpoint> Client(AcknowledgeORCv1Deprecation,
+ ClientEP, ReportError);
RPCEndpoint ServerEP(*Channels.second, true);
SymTab[1] = MockObjectLayer::LookupFn();
return 1;
});
- RemoteObjectServerLayer<MockObjectLayer, RPCEndpoint> Server(BaseLayer,
- ServerEP,
- ReportError);
+ RemoteObjectServerLayer<MockObjectLayer, RPCEndpoint> Server(
+ AcknowledgeORCv1Deprecation, BaseLayer, ServerEP, ReportError);
bool Finished = false;
ServerEP.addHandler<remote::utils::TerminateSession>(
};
RPCEndpoint ClientEP(*Channels.first, true);
- RemoteObjectClientLayer<RPCEndpoint> Client(ClientEP, ReportError);
+ RemoteObjectClientLayer<RPCEndpoint> Client(AcknowledgeORCv1Deprecation,
+ ClientEP, ReportError);
RPCEndpoint ServerEP(*Channels.second, true);
MockObjectLayer::SymbolLookupTable &SymTab) {
return 42;
});
- RemoteObjectServerLayer<MockObjectLayer, RPCEndpoint> Server(BaseLayer,
- ServerEP,
- ReportError);
+ RemoteObjectServerLayer<MockObjectLayer, RPCEndpoint> Server(
+ AcknowledgeORCv1Deprecation, BaseLayer, ServerEP, ReportError);
bool Finished = false;
ServerEP.addHandler<remote::utils::TerminateSession>(
};
RPCEndpoint ClientEP(*Channels.first, true);
- RemoteObjectClientLayer<RPCEndpoint> Client(ClientEP, ReportError);
+ RemoteObjectClientLayer<RPCEndpoint> Client(AcknowledgeORCv1Deprecation,
+ ClientEP, ReportError);
RPCEndpoint ServerEP(*Channels.second, true);
};
return 42;
});
- RemoteObjectServerLayer<MockObjectLayer, RPCEndpoint> Server(BaseLayer,
- ServerEP,
- ReportError);
+ RemoteObjectServerLayer<MockObjectLayer, RPCEndpoint> Server(
+ AcknowledgeORCv1Deprecation, BaseLayer, ServerEP, ReportError);
bool Finished = false;
ServerEP.addHandler<remote::utils::TerminateSession>(
};
RPCEndpoint ClientEP(*Channels.first, true);
- RemoteObjectClientLayer<RPCEndpoint> Client(ClientEP, ReportError);
+ RemoteObjectClientLayer<RPCEndpoint> Client(AcknowledgeORCv1Deprecation,
+ ClientEP, ReportError);
RPCEndpoint ServerEP(*Channels.second, true);
return 42;
});
- RemoteObjectServerLayer<MockObjectLayer, RPCEndpoint> Server(BaseLayer,
- ServerEP,
- ReportError);
+ RemoteObjectServerLayer<MockObjectLayer, RPCEndpoint> Server(
+ AcknowledgeORCv1Deprecation, BaseLayer, ServerEP, ReportError);
bool Finished = false;
ServerEP.addHandler<remote::utils::TerminateSession>(
};
RPCEndpoint ClientEP(*Channels.first, true);
- RemoteObjectClientLayer<RPCEndpoint> Client(ClientEP, ReportError);
+ RemoteObjectClientLayer<RPCEndpoint> Client(AcknowledgeORCv1Deprecation,
+ ClientEP, ReportError);
RPCEndpoint ServerEP(*Channels.second, true);
SymTab[1] = MockObjectLayer::LookupFn();
return 1;
});
- RemoteObjectServerLayer<MockObjectLayer, RPCEndpoint> Server(BaseLayer,
- ServerEP,
- ReportError);
+ RemoteObjectServerLayer<MockObjectLayer, RPCEndpoint> Server(
+ AcknowledgeORCv1Deprecation, BaseLayer, ServerEP, ReportError);
bool Finished = false;
ServerEP.addHandler<remote::utils::TerminateSession>(
};
RPCEndpoint ClientEP(*Channels.first, true);
- RemoteObjectClientLayer<RPCEndpoint> Client(ClientEP, ReportError);
+ RemoteObjectClientLayer<RPCEndpoint> Client(AcknowledgeORCv1Deprecation,
+ ClientEP, ReportError);
RPCEndpoint ServerEP(*Channels.second, true);
MockObjectLayer::SymbolLookupTable &SymTab) {
return 1;
});
- RemoteObjectServerLayer<MockObjectLayer, RPCEndpoint> Server(BaseLayer,
- ServerEP,
- ReportError);
+ RemoteObjectServerLayer<MockObjectLayer, RPCEndpoint> Server(
+ AcknowledgeORCv1Deprecation, BaseLayer, ServerEP, ReportError);
bool Finished = false;
ServerEP.addHandler<remote::utils::TerminateSession>(