mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 02:33:06 +01:00
[ORC] Add deprecation warnings to ORCv1 layers and utilities.
Summary: ORCv1 is deprecated. The current aim is to remove it before the LLVM 10.0 release. This patch adds deprecation attributes to the ORCv1 layers and utilities to warn clients of the change. Reviewers: dblaikie, sgraenitz, AlexDenisov Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64609 llvm-svn: 366344
This commit is contained in:
parent
b5b1a8e845
commit
92fa8af24d
@ -64,28 +64,30 @@ private:
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -105,13 +105,14 @@ public:
|
||||
},
|
||||
[](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));
|
||||
}),
|
||||
|
@ -113,14 +113,15 @@ public:
|
||||
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));
|
||||
}),
|
||||
|
@ -45,17 +45,16 @@ public:
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#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"
|
||||
@ -634,7 +635,13 @@ public:
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
@ -658,6 +665,10 @@ public:
|
||||
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)
|
||||
|
||||
|
@ -264,13 +264,26 @@ public:
|
||||
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)),
|
||||
@ -729,8 +742,24 @@ private:
|
||||
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
|
||||
|
@ -16,6 +16,7 @@
|
||||
#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"
|
||||
|
||||
|
@ -97,7 +97,14 @@ class LegacyCtorDtorRunner {
|
||||
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
|
||||
@ -128,6 +135,11 @@ private:
|
||||
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) {}
|
||||
@ -180,7 +192,14 @@ class LegacyLocalCXXRuntimeOverrides : public LocalCXXRuntimeOverridesBase {
|
||||
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));
|
||||
}
|
||||
@ -201,6 +220,13 @@ private:
|
||||
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);
|
||||
|
@ -63,8 +63,18 @@ public:
|
||||
|
||||
/// 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)) {}
|
||||
@ -122,8 +132,14 @@ private:
|
||||
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
|
||||
|
@ -56,9 +56,17 @@ class LegacyIRTransformLayer {
|
||||
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.
|
||||
@ -108,6 +116,11 @@ private:
|
||||
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
|
||||
|
||||
|
@ -24,7 +24,15 @@ namespace orc {
|
||||
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) {}
|
||||
@ -42,6 +50,12 @@ private:
|
||||
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>>
|
||||
@ -52,6 +66,17 @@ createLambdaResolver(DylibLookupFtorT DylibLookupFtor,
|
||||
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
|
||||
|
||||
|
@ -196,7 +196,14 @@ private:
|
||||
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) {
|
||||
@ -254,6 +261,10 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
template <typename BaseLayerT>
|
||||
LazyEmittingLayer<BaseLayerT>::LazyEmittingLayer(BaseLayerT &BaseLayer)
|
||||
: BaseLayer(BaseLayer) {}
|
||||
|
||||
} // end namespace orc
|
||||
} // end namespace llvm
|
||||
|
||||
|
@ -48,7 +48,16 @@ template <typename BaseLayerT, typename TransformFtor>
|
||||
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)) {}
|
||||
|
||||
@ -107,6 +116,11 @@ private:
|
||||
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
|
||||
|
||||
|
@ -353,17 +353,27 @@ public:
|
||||
|
||||
/// 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.
|
||||
///
|
||||
|
@ -13,9 +13,10 @@
|
||||
#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 {
|
||||
@ -312,7 +313,14 @@ public:
|
||||
///
|
||||
/// 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>;
|
||||
@ -417,11 +425,18 @@ public:
|
||||
|
||||
/// 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);
|
||||
@ -462,6 +477,7 @@ private:
|
||||
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);
|
||||
@ -522,6 +538,31 @@ private:
|
||||
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
|
||||
|
||||
|
22
include/llvm/ExecutionEngine/OrcV1Deprecation.h
Normal file
22
include/llvm/ExecutionEngine/OrcV1Deprecation.h
Normal file
@ -0,0 +1,22 @@
|
||||
//===------ 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
|
@ -211,28 +211,31 @@ public:
|
||||
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() {
|
||||
@ -308,7 +311,8 @@ public:
|
||||
|
||||
// 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);
|
||||
|
||||
@ -465,7 +469,7 @@ private:
|
||||
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");
|
||||
|
@ -127,7 +127,8 @@ void OrcMCJITReplacement::runStaticConstructorsDestructors(bool isDtors) {
|
||||
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();
|
||||
|
@ -232,24 +232,24 @@ public:
|
||||
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;
|
||||
|
@ -207,5 +207,14 @@ void RTDyldObjectLinkingLayer::onObjEmit(
|
||||
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.
|
||||
|
@ -83,18 +83,15 @@ namespace {
|
||||
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",
|
||||
@ -419,7 +416,8 @@ int main(int argc, char **argv, char * const *envp) {
|
||||
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())
|
||||
@ -665,6 +663,7 @@ int main(int argc, char **argv, char * const *envp) {
|
||||
// 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)))
|
||||
|
@ -22,7 +22,8 @@ struct MockBaseLayer {
|
||||
|
||||
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>()));
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ TEST(LegacyCompileOnDemandLayerTest, FindSymbol) {
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
|
@ -68,10 +68,11 @@ TEST(LegacyRTDyldObjectLinkingLayerTest, TestSetProcessAllSections) {
|
||||
|
||||
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);
|
||||
@ -130,13 +131,14 @@ TEST_F(LegacyRTDyldObjectLinkingLayerExecutionTest, NoDuplicateFinalization) {
|
||||
|
||||
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:
|
||||
@ -217,10 +219,11 @@ TEST_F(LegacyRTDyldObjectLinkingLayerExecutionTest, NoPrematureAllocation) {
|
||||
|
||||
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:
|
||||
@ -278,7 +281,7 @@ TEST_F(LegacyRTDyldObjectLinkingLayerExecutionTest, NoPrematureAllocation) {
|
||||
TEST_F(LegacyRTDyldObjectLinkingLayerExecutionTest, TestNotifyLoadedSignature) {
|
||||
ExecutionSession ES;
|
||||
LegacyRTDyldObjectLinkingLayer ObjLayer(
|
||||
ES,
|
||||
AcknowledgeORCv1Deprecation, ES,
|
||||
[](VModuleKey) {
|
||||
return LegacyRTDyldObjectLinkingLayer::Resources{
|
||||
nullptr, std::make_shared<NullResolver>()};
|
||||
|
@ -182,17 +182,19 @@ TEST(LegacyObjectTransformLayerTest, Main) {
|
||||
|
||||
// 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();
|
||||
@ -281,22 +283,25 @@ TEST(LegacyObjectTransformLayerTest, Main) {
|
||||
};
|
||||
|
||||
// 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.
|
||||
|
@ -127,7 +127,8 @@ TEST(RemoteObjectLayer, AddObject) {
|
||||
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(
|
||||
@ -144,9 +145,8 @@ TEST(RemoteObjectLayer, AddObject) {
|
||||
|
||||
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>(
|
||||
@ -181,7 +181,8 @@ TEST(RemoteObjectLayer, AddObjectFailure) {
|
||||
};
|
||||
|
||||
RPCEndpoint ClientEP(*Channels.first, true);
|
||||
RemoteObjectClientLayer<RPCEndpoint> Client(ClientEP, ReportError);
|
||||
RemoteObjectClientLayer<RPCEndpoint> Client(AcknowledgeORCv1Deprecation,
|
||||
ClientEP, ReportError);
|
||||
|
||||
RPCEndpoint ServerEP(*Channels.second, true);
|
||||
MockObjectLayer BaseLayer(
|
||||
@ -191,9 +192,8 @@ TEST(RemoteObjectLayer, AddObjectFailure) {
|
||||
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>(
|
||||
@ -233,7 +233,8 @@ TEST(RemoteObjectLayer, RemoveObject) {
|
||||
};
|
||||
|
||||
RPCEndpoint ClientEP(*Channels.first, true);
|
||||
RemoteObjectClientLayer<RPCEndpoint> Client(ClientEP, ReportError);
|
||||
RemoteObjectClientLayer<RPCEndpoint> Client(AcknowledgeORCv1Deprecation,
|
||||
ClientEP, ReportError);
|
||||
|
||||
RPCEndpoint ServerEP(*Channels.second, true);
|
||||
|
||||
@ -243,9 +244,8 @@ TEST(RemoteObjectLayer, RemoveObject) {
|
||||
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>(
|
||||
@ -283,7 +283,8 @@ TEST(RemoteObjectLayer, RemoveObjectFailure) {
|
||||
};
|
||||
|
||||
RPCEndpoint ClientEP(*Channels.first, true);
|
||||
RemoteObjectClientLayer<RPCEndpoint> Client(ClientEP, ReportError);
|
||||
RemoteObjectClientLayer<RPCEndpoint> Client(AcknowledgeORCv1Deprecation,
|
||||
ClientEP, ReportError);
|
||||
|
||||
RPCEndpoint ServerEP(*Channels.second, true);
|
||||
|
||||
@ -294,9 +295,8 @@ TEST(RemoteObjectLayer, RemoveObjectFailure) {
|
||||
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>(
|
||||
@ -339,7 +339,8 @@ TEST(RemoteObjectLayer, FindSymbol) {
|
||||
};
|
||||
|
||||
RPCEndpoint ClientEP(*Channels.first, true);
|
||||
RemoteObjectClientLayer<RPCEndpoint> Client(ClientEP, ReportError);
|
||||
RemoteObjectClientLayer<RPCEndpoint> Client(AcknowledgeORCv1Deprecation,
|
||||
ClientEP, ReportError);
|
||||
|
||||
RPCEndpoint ServerEP(*Channels.second, true);
|
||||
|
||||
@ -358,9 +359,8 @@ TEST(RemoteObjectLayer, FindSymbol) {
|
||||
};
|
||||
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>(
|
||||
@ -421,7 +421,8 @@ TEST(RemoteObjectLayer, FindSymbolIn) {
|
||||
};
|
||||
|
||||
RPCEndpoint ClientEP(*Channels.first, true);
|
||||
RemoteObjectClientLayer<RPCEndpoint> Client(ClientEP, ReportError);
|
||||
RemoteObjectClientLayer<RPCEndpoint> Client(AcknowledgeORCv1Deprecation,
|
||||
ClientEP, ReportError);
|
||||
|
||||
RPCEndpoint ServerEP(*Channels.second, true);
|
||||
|
||||
@ -447,9 +448,8 @@ TEST(RemoteObjectLayer, FindSymbolIn) {
|
||||
|
||||
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>(
|
||||
@ -496,7 +496,8 @@ TEST(RemoteObjectLayer, EmitAndFinalize) {
|
||||
};
|
||||
|
||||
RPCEndpoint ClientEP(*Channels.first, true);
|
||||
RemoteObjectClientLayer<RPCEndpoint> Client(ClientEP, ReportError);
|
||||
RemoteObjectClientLayer<RPCEndpoint> Client(AcknowledgeORCv1Deprecation,
|
||||
ClientEP, ReportError);
|
||||
|
||||
RPCEndpoint ServerEP(*Channels.second, true);
|
||||
|
||||
@ -506,9 +507,8 @@ TEST(RemoteObjectLayer, EmitAndFinalize) {
|
||||
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>(
|
||||
@ -547,7 +547,8 @@ TEST(RemoteObjectLayer, EmitAndFinalizeFailure) {
|
||||
};
|
||||
|
||||
RPCEndpoint ClientEP(*Channels.first, true);
|
||||
RemoteObjectClientLayer<RPCEndpoint> Client(ClientEP, ReportError);
|
||||
RemoteObjectClientLayer<RPCEndpoint> Client(AcknowledgeORCv1Deprecation,
|
||||
ClientEP, ReportError);
|
||||
|
||||
RPCEndpoint ServerEP(*Channels.second, true);
|
||||
|
||||
@ -556,9 +557,8 @@ TEST(RemoteObjectLayer, EmitAndFinalizeFailure) {
|
||||
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>(
|
||||
|
Loading…
Reference in New Issue
Block a user