llvm.org GIT mirror llvm / 19f0f50
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366344 91177308-0d34-0410-b5e6-96231b3b80d8 Lang Hames 3 months ago
26 changed file(s) with 400 addition(s) and 156 deletion(s). Raw diff Collapse all Expand all
6363 public:
6464 KaleidoscopeJIT()
6565 : TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()),
66 ObjectLayer(ES,
66 ObjectLayer(AcknowledgeORCv1Deprecation, ES,
6767 [this](VModuleKey K) {
6868 return LegacyRTDyldObjectLinkingLayer::Resources{
6969 std::make_shared(),
7070 Resolvers[K]};
7171 }),
72 CompileLayer(ObjectLayer, SimpleCompiler(*TM)),
73 OptimizeLayer(CompileLayer,
72 CompileLayer(AcknowledgeORCv1Deprecation, ObjectLayer,
73 SimpleCompiler(*TM)),
74 OptimizeLayer(AcknowledgeORCv1Deprecation, CompileLayer,
7475 [this](std::unique_ptr M) {
7576 return optimizeModule(std::move(M));
7677 }),
7778 CompileCallbackManager(cantFail(orc::createLocalCompileCallbackManager(
7879 TM->getTargetTriple(), ES, 0))),
79 CODLayer(ES, OptimizeLayer,
80 [&](orc::VModuleKey K) { return Resolvers[K]; },
81 [&](orc::VModuleKey K, std::shared_ptr R) {
82 Resolvers[K] = std::move(R);
83 },
84 [](Function &F) { return std::set({&F}); },
85 *CompileCallbackManager,
86 orc::createLocalIndirectStubsManagerBuilder(
87 TM->getTargetTriple())) {
80 CODLayer(
81 AcknowledgeORCv1Deprecation, ES, OptimizeLayer,
82 [&](orc::VModuleKey K) { return Resolvers[K]; },
83 [&](orc::VModuleKey K, std::shared_ptr R) {
84 Resolvers[K] = std::move(R);
85 },
86 [](Function &F) { return std::set({&F}); },
87 *CompileCallbackManager,
88 orc::createLocalIndirectStubsManagerBuilder(
89 TM->getTargetTriple())) {
8890 llvm::sys::DynamicLibrary::LoadLibraryPermanently(nullptr);
8991 }
9092
104104 },
105105 [](Error Err) { cantFail(std::move(Err), "lookupFlags failed"); })),
106106 TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()),
107 ObjectLayer(ES,
107 ObjectLayer(AcknowledgeORCv1Deprecation, ES,
108108 [this](VModuleKey K) {
109109 return LegacyRTDyldObjectLinkingLayer::Resources{
110110 std::make_shared(), Resolver};
111111 }),
112 CompileLayer(ObjectLayer, SimpleCompiler(*TM)),
113 OptimizeLayer(CompileLayer,
112 CompileLayer(AcknowledgeORCv1Deprecation, ObjectLayer,
113 SimpleCompiler(*TM)),
114 OptimizeLayer(AcknowledgeORCv1Deprecation, CompileLayer,
114115 [this](std::unique_ptr M) {
115116 return optimizeModule(std::move(M));
116117 }),
112112 TM(EngineBuilder().selectTarget(Triple(Remote.getTargetTriple()), "",
113113 "", SmallVector())),
114114 DL(TM->createDataLayout()),
115 ObjectLayer(ES,
115 ObjectLayer(AcknowledgeORCv1Deprecation, ES,
116116 [this](VModuleKey K) {
117117 return LegacyRTDyldObjectLinkingLayer::Resources{
118118 cantFail(this->Remote.createRemoteMemoryManager()),
119119 Resolver};
120120 }),
121 CompileLayer(ObjectLayer, SimpleCompiler(*TM)),
122 OptimizeLayer(CompileLayer,
121 CompileLayer(AcknowledgeORCv1Deprecation, ObjectLayer,
122 SimpleCompiler(*TM)),
123 OptimizeLayer(AcknowledgeORCv1Deprecation, CompileLayer,
123124 [this](std::unique_ptr M) {
124125 return optimizeModule(std::move(M));
125126 }),
4444 KaleidoscopeJIT()
4545 : Resolver(createLegacyLookupResolver(
4646 ES,
47 [this](const std::string &Name) {
48 return findMangledSymbol(Name);
49 },
47 [this](const std::string &Name) { return findMangledSymbol(Name); },
5048 [](Error Err) { cantFail(std::move(Err), "lookupFlags failed"); })),
5149 TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()),
52 ObjectLayer(ES,
50 ObjectLayer(AcknowledgeORCv1Deprecation, ES,
5351 [this](VModuleKey) {
5452 return ObjLayerT::Resources{
5553 std::make_shared(), Resolver};
5654 }),
57 CompileLayer(ObjectLayer, SimpleCompiler(*TM)) {
55 CompileLayer(AcknowledgeORCv1Deprecation, ObjectLayer,
56 SimpleCompiler(*TM)) {
5857 llvm::sys::DynamicLibrary::LoadLibraryPermanently(nullptr);
5958 }
6059
2020 #include "llvm/ADT/StringMap.h"
2121 #include "llvm/ADT/StringRef.h"
2222 #include "llvm/ExecutionEngine/JITSymbol.h"
23 #include "llvm/ExecutionEngine/OrcV1Deprecation.h"
2324 #include "llvm/IR/DataLayout.h"
2425 #include "llvm/IR/Module.h"
2526 #include "llvm/Object/Binary.h"
633634 }
634635
635636 // Use OrcMCJITReplacement instead of MCJIT. Off by default.
636 void setUseOrcMCJITReplacement(bool UseOrcMCJITReplacement) {
637 LLVM_ATTRIBUTE_DEPRECATED(
638 inline void setUseOrcMCJITReplacement(bool UseOrcMCJITReplacement),
639 "ORCv1 utilities (including OrcMCJITReplacement) are deprecated. Please "
640 "use ORCv2/LLJIT instead (see docs/ORCv2.rst)");
641
642 void setUseOrcMCJITReplacement(ORCv1DeprecationAcknowledgement,
643 bool UseOrcMCJITReplacement) {
637644 this->UseOrcMCJITReplacement = UseOrcMCJITReplacement;
638645 }
639646
657664 ExecutionEngine *create(TargetMachine *TM);
658665 };
659666
667 void EngineBuilder::setUseOrcMCJITReplacement(bool UseOrcMCJITReplacement) {
668 this->UseOrcMCJITReplacement = UseOrcMCJITReplacement;
669 }
670
660671 // Create wrappers for C Binding types (see CBindingWrapping.h).
661672 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ExecutionEngine, LLVMExecutionEngineRef)
662673
263263 std::function R)>;
264264
265265 /// Construct a compile-on-demand layer instance.
266 LegacyCompileOnDemandLayer(ExecutionSession &ES, BaseLayerT &BaseLayer,
267 SymbolResolverGetter GetSymbolResolver,
268 SymbolResolverSetter SetSymbolResolver,
269 PartitioningFtor Partition,
270 CompileCallbackMgrT &CallbackMgr,
271 IndirectStubsManagerBuilderT CreateIndirectStubsManager,
272 bool CloneStubsIntoPartitions = true)
266 LLVM_ATTRIBUTE_DEPRECATED(
267 LegacyCompileOnDemandLayer(
268 ExecutionSession &ES, BaseLayerT &BaseLayer,
269 SymbolResolverGetter GetSymbolResolver,
270 SymbolResolverSetter SetSymbolResolver, PartitioningFtor Partition,
271 CompileCallbackMgrT &CallbackMgr,
272 IndirectStubsManagerBuilderT CreateIndirectStubsManager,
273 bool CloneStubsIntoPartitions = true),
274 "ORCv1 layers (layers with the 'Legacy' prefix) are deprecated. Please "
275 "use "
276 "the ORCv2 LegacyCompileOnDemandLayer instead");
277
278 /// Legacy layer constructor with deprecation acknowledgement.
279 LegacyCompileOnDemandLayer(
280 ORCv1DeprecationAcknowledgement, ExecutionSession &ES,
281 BaseLayerT &BaseLayer, SymbolResolverGetter GetSymbolResolver,
282 SymbolResolverSetter SetSymbolResolver, PartitioningFtor Partition,
283 CompileCallbackMgrT &CallbackMgr,
284 IndirectStubsManagerBuilderT CreateIndirectStubsManager,
285 bool CloneStubsIntoPartitions = true)
273286 : ES(ES), BaseLayer(BaseLayer),
274287 GetSymbolResolver(std::move(GetSymbolResolver)),
275288 SetSymbolResolver(std::move(SetSymbolResolver)),
728741 bool CloneStubsIntoPartitions;
729742 };
730743
744 template
745 typename IndirectStubsMgrT>
746 LegacyCompileOnDemandLayer::
747 LegacyCompileOnDemandLayer(
748 ExecutionSession &ES, BaseLayerT &BaseLayer,
749 SymbolResolverGetter GetSymbolResolver,
750 SymbolResolverSetter SetSymbolResolver, PartitioningFtor Partition,
751 CompileCallbackMgrT &CallbackMgr,
752 IndirectStubsManagerBuilderT CreateIndirectStubsManager,
753 bool CloneStubsIntoPartitions)
754 : ES(ES), BaseLayer(BaseLayer),
755 GetSymbolResolver(std::move(GetSymbolResolver)),
756 SetSymbolResolver(std::move(SetSymbolResolver)),
757 Partition(std::move(Partition)), CompileCallbackMgr(CallbackMgr),
758 CreateIndirectStubsManager(std::move(CreateIndirectStubsManager)),
759 CloneStubsIntoPartitions(CloneStubsIntoPartitions) {}
760
731761 } // end namespace orc
732
733762 } // end namespace llvm
734763
735764 #endif // LLVM_EXECUTIONENGINE_ORC_COMPILEONDEMANDLAYER_H
1515 #include "llvm/ADT/BitmaskEnum.h"
1616 #include "llvm/ExecutionEngine/JITSymbol.h"
1717 #include "llvm/ExecutionEngine/Orc/SymbolStringPool.h"
18 #include "llvm/ExecutionEngine/OrcV1Deprecation.h"
1819 #include "llvm/IR/Module.h"
1920 #include "llvm/Support/Debug.h"
2021
9696 public:
9797 /// Construct a CtorDtorRunner for the given range using the given
9898 /// name mangling function.
99 LegacyCtorDtorRunner(std::vector CtorDtorNames, VModuleKey K)
99 LLVM_ATTRIBUTE_DEPRECATED(
100 LegacyCtorDtorRunner(std::vector CtorDtorNames,
101 VModuleKey K),
102 "ORCv1 utilities (utilities with the 'Legacy' prefix) are deprecated. "
103 "Please use the ORCv2 CtorDtorRunner utility instead");
104
105 LegacyCtorDtorRunner(ORCv1DeprecationAcknowledgement,
106 std::vector CtorDtorNames, VModuleKey K)
100107 : CtorDtorNames(std::move(CtorDtorNames)), K(K) {}
101108
102109 /// Run the recorded constructors/destructors through the given JIT
127134 orc::VModuleKey K;
128135 };
129136
137 template
138 LegacyCtorDtorRunner::LegacyCtorDtorRunner(
139 std::vector CtorDtorNames, VModuleKey K)
140 : CtorDtorNames(std::move(CtorDtorNames)), K(K) {}
141
130142 class CtorDtorRunner {
131143 public:
132144 CtorDtorRunner(JITDylib &JD) : JD(JD) {}
179191 public:
180192 /// Create a runtime-overrides class.
181193 template
182 LegacyLocalCXXRuntimeOverrides(const MangleFtorT &Mangle) {
194 LLVM_ATTRIBUTE_DEPRECATED(
195 LegacyLocalCXXRuntimeOverrides(const MangleFtorT &Mangle),
196 "ORCv1 utilities (utilities with the 'Legacy' prefix) are deprecated. "
197 "Please use the ORCv2 LocalCXXRuntimeOverrides utility instead");
198
199 template
200 LegacyLocalCXXRuntimeOverrides(ORCv1DeprecationAcknowledgement,
201 const MangleFtorT &Mangle) {
183202 addOverride(Mangle("__dso_handle"), toTargetAddress(&DSOHandleOverride));
184203 addOverride(Mangle("__cxa_atexit"), toTargetAddress(&CXAAtExitOverride));
185204 }
199218
200219 StringMap CXXRuntimeOverrides;
201220 };
221
222 template
223 LegacyLocalCXXRuntimeOverrides::LegacyLocalCXXRuntimeOverrides(
224 const MangleFtorT &Mangle) {
225 addOverride(Mangle("__dso_handle"), toTargetAddress(&DSOHandleOverride));
226 addOverride(Mangle("__cxa_atexit"), toTargetAddress(&CXAAtExitOverride));
227 }
202228
203229 class LocalCXXRuntimeOverrides : public LocalCXXRuntimeOverridesBase {
204230 public:
6262
6363 /// Construct an LegacyIRCompileLayer with the given BaseLayer, which must
6464 /// implement the ObjectLayer concept.
65 LLVM_ATTRIBUTE_DEPRECATED(
66 LegacyIRCompileLayer(
67 BaseLayerT &BaseLayer, CompileFtor Compile,
68 NotifyCompiledCallback NotifyCompiled = NotifyCompiledCallback()),
69 "ORCv1 layers (layers with the 'Legacy' prefix) are deprecated. Please "
70 "use "
71 "the ORCv2 IRCompileLayer instead");
72
73 /// Legacy layer constructor with deprecation acknowledgement.
6574 LegacyIRCompileLayer(
66 BaseLayerT &BaseLayer, CompileFtor Compile,
75 ORCv1DeprecationAcknowledgement, BaseLayerT &BaseLayer,
76 CompileFtor Compile,
6777 NotifyCompiledCallback NotifyCompiled = NotifyCompiledCallback())
6878 : BaseLayer(BaseLayer), Compile(std::move(Compile)),
6979 NotifyCompiled(std::move(NotifyCompiled)) {}
121131 NotifyCompiledCallback NotifyCompiled;
122132 };
123133
134 template
135 LegacyIRCompileLayer::LegacyIRCompileLayer(
136 BaseLayerT &BaseLayer, CompileFtor Compile,
137 NotifyCompiledCallback NotifyCompiled)
138 : BaseLayer(BaseLayer), Compile(std::move(Compile)),
139 NotifyCompiled(std::move(NotifyCompiled)) {}
140
124141 } // end namespace orc
125
126142 } // end namespace llvm
127143
128144 #endif // LLVM_EXECUTIONENGINE_ORC_IRCOMPILINGLAYER_H
5555 public:
5656
5757 /// Construct an LegacyIRTransformLayer with the given BaseLayer
58 LegacyIRTransformLayer(BaseLayerT &BaseLayer,
59 TransformFtor Transform = TransformFtor())
60 : BaseLayer(BaseLayer), Transform(std::move(Transform)) {}
58 LLVM_ATTRIBUTE_DEPRECATED(
59 LegacyIRTransformLayer(BaseLayerT &BaseLayer,
60 TransformFtor Transform = TransformFtor()),
61 "ORCv1 layers (layers with the 'Legacy' prefix) are deprecated. Please "
62 "use "
63 "the ORCv2 IRTransformLayer instead");
64
65 /// Legacy layer constructor with deprecation acknowledgement.
66 LegacyIRTransformLayer(ORCv1DeprecationAcknowledgement, BaseLayerT &BaseLayer,
67 TransformFtor Transform = TransformFtor())
68 : BaseLayer(BaseLayer), Transform(std::move(Transform)) {}
6169
6270 /// Apply the transform functor to the module, then add the module to
6371 /// the layer below, along with the memory manager and symbol resolver.
107115 TransformFtor Transform;
108116 };
109117
118 template
119 LegacyIRTransformLayer::LegacyIRTransformLayer(
120 BaseLayerT &BaseLayer, TransformFtor Transform)
121 : BaseLayer(BaseLayer), Transform(std::move(Transform)) {}
122
110123 } // end namespace orc
111124 } // end namespace llvm
112125
2323 template
2424 class LambdaResolver : public LegacyJITSymbolResolver {
2525 public:
26 LambdaResolver(DylibLookupFtorT DylibLookupFtor,
26 LLVM_ATTRIBUTE_DEPRECATED(
27 LambdaResolver(DylibLookupFtorT DylibLookupFtor,
28 ExternalLookupFtorT ExternalLookupFtor),
29 "ORCv1 utilities (including resolvers) are deprecated and will be "
30 "removed "
31 "in the next release. Please use ORCv2 (see docs/ORCv2.rst)");
32
33 LambdaResolver(ORCv1DeprecationAcknowledgement,
34 DylibLookupFtorT DylibLookupFtor,
2735 ExternalLookupFtorT ExternalLookupFtor)
2836 : DylibLookupFtor(DylibLookupFtor),
2937 ExternalLookupFtor(ExternalLookupFtor) {}
4149 ExternalLookupFtorT ExternalLookupFtor;
4250 };
4351
52 template
53 LambdaResolver::LambdaResolver(
54 DylibLookupFtorT DylibLookupFtor, ExternalLookupFtorT ExternalLookupFtor)
55 : DylibLookupFtor(DylibLookupFtor), ExternalLookupFtor(ExternalLookupFtor) {
56 }
57
4458 template
4559 typename ExternalLookupFtorT>
4660 std::shared_ptr>
5165 std::move(ExternalLookupFtor));
5266 }
5367
68 template
69 std::shared_ptr>
70 createLambdaResolver(ORCv1DeprecationAcknowledgement,
71 DylibLookupFtorT DylibLookupFtor,
72 ExternalLookupFtorT ExternalLookupFtor) {
73 using LR = LambdaResolver;
74 return make_unique(AcknowledgeORCv1Deprecation,
75 std::move(DylibLookupFtor),
76 std::move(ExternalLookupFtor));
77 }
78
5479 } // end namespace orc
5580 } // end namespace llvm
5681
195195 public:
196196
197197 /// Construct a lazy emitting layer.
198 LazyEmittingLayer(BaseLayerT &BaseLayer) : BaseLayer(BaseLayer) {}
198 LLVM_ATTRIBUTE_DEPRECATED(
199 LazyEmittingLayer(BaseLayerT &BaseLayer),
200 "ORCv1 layers (including LazyEmittingLayer) are deprecated. Please use "
201 "ORCv2, where lazy emission is the default");
202
203 /// Construct a lazy emitting layer.
204 LazyEmittingLayer(ORCv1DeprecationAcknowledgement, BaseLayerT &BaseLayer)
205 : BaseLayer(BaseLayer) {}
199206
200207 /// Add the given module to the lazy emitting layer.
201208 Error addModule(VModuleKey K, std::unique_ptr M) {
253260 }
254261 };
255262
263 template
264 LazyEmittingLayer::LazyEmittingLayer(BaseLayerT &BaseLayer)
265 : BaseLayer(BaseLayer) {}
266
256267 } // end namespace orc
257268 } // end namespace llvm
258269
4747 class LegacyObjectTransformLayer {
4848 public:
4949 /// Construct an ObjectTransformLayer with the given BaseLayer
50 LegacyObjectTransformLayer(BaseLayerT &BaseLayer,
50 LLVM_ATTRIBUTE_DEPRECATED(
51 LegacyObjectTransformLayer(BaseLayerT &BaseLayer,
52 TransformFtor Transform = TransformFtor()),
53 "ORCv1 layers (layers with the 'Legacy' prefix) are deprecated. Please "
54 "use "
55 "the ORCv2 ObjectTransformLayer instead");
56
57 /// Legacy layer constructor with deprecation acknowledgement.
58 LegacyObjectTransformLayer(ORCv1DeprecationAcknowledgement,
59 BaseLayerT &BaseLayer,
5160 TransformFtor Transform = TransformFtor())
5261 : BaseLayer(BaseLayer), Transform(std::move(Transform)) {}
5362
106115 TransformFtor Transform;
107116 };
108117
118 template
119 LegacyObjectTransformLayer::
120 LegacyObjectTransformLayer(BaseLayerT &BaseLayer, TransformFtor Transform)
121 : BaseLayer(BaseLayer), Transform(std::move(Transform)) {}
122
109123 } // end namespace orc
110124 } // end namespace llvm
111125
352352
353353 /// Construct an ObjectLinkingLayer with the given NotifyLoaded,
354354 /// and NotifyFinalized functors.
355 LLVM_ATTRIBUTE_DEPRECATED(
356 LegacyRTDyldObjectLinkingLayer(
357 ExecutionSession &ES, ResourcesGetter GetResources,
358 NotifyLoadedFtor NotifyLoaded = NotifyLoadedFtor(),
359 NotifyFinalizedFtor NotifyFinalized = NotifyFinalizedFtor(),
360 NotifyFreedFtor NotifyFreed = NotifyFreedFtor()),
361 "ORCv1 layers (layers with the 'Legacy' prefix) are deprecated. Please "
362 "use "
363 "ORCv2 (see docs/ORCv2.rst)");
364
365 // Legacy layer constructor with deprecation acknowledgement.
355366 LegacyRTDyldObjectLinkingLayer(
356 ExecutionSession &ES, ResourcesGetter GetResources,
367 ORCv1DeprecationAcknowledgement, ExecutionSession &ES,
368 ResourcesGetter GetResources,
357369 NotifyLoadedFtor NotifyLoaded = NotifyLoadedFtor(),
358370 NotifyFinalizedFtor NotifyFinalized = NotifyFinalizedFtor(),
359371 NotifyFreedFtor NotifyFreed = NotifyFreedFtor())
360372 : ES(ES), GetResources(std::move(GetResources)),
361373 NotifyLoaded(std::move(NotifyLoaded)),
362374 NotifyFinalized(std::move(NotifyFinalized)),
363 NotifyFreed(std::move(NotifyFreed)),
364 ProcessAllSections(false) {
365 }
375 NotifyFreed(std::move(NotifyFreed)), ProcessAllSections(false) {}
366376
367377 /// Set the 'ProcessAllSections' flag.
368378 ///
1212 #ifndef LLVM_EXECUTIONENGINE_ORC_REMOTEOBJECTLAYER_H
1313 #define LLVM_EXECUTIONENGINE_ORC_REMOTEOBJECTLAYER_H
1414
15 #include "llvm/ExecutionEngine/Orc/Core.h"
16 #include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
1517 #include "llvm/ExecutionEngine/Orc/OrcRemoteTargetRPCAPI.h"
1618 #include "llvm/Object/ObjectFile.h"
17 #include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
1819 #include
1920
2021 namespace llvm {
311312 ///
312313 /// The ReportError functor can be used locally log errors that are intended
313314 /// to be sent sent
314 RemoteObjectClientLayer(RPCEndpoint &Remote,
315 LLVM_ATTRIBUTE_DEPRECATED(
316 RemoteObjectClientLayer(RPCEndpoint &Remote,
317 std::function ReportError),
318 "ORCv1 layers (including RemoteObjectClientLayer) are deprecated. Please "
319 "use "
320 "ORCv2 (see docs/ORCv2.rst)");
321
322 RemoteObjectClientLayer(ORCv1DeprecationAcknowledgement, RPCEndpoint &Remote,
315323 std::function ReportError)
316324 : RemoteObjectLayer(Remote, std::move(ReportError)) {
317325 using ThisT = RemoteObjectClientLayer;
416424
417425 /// Create a RemoteObjectServerLayer with the given base layer (which must be
418426 /// an object layer), RPC endpoint, and error reporter function.
419 RemoteObjectServerLayer(BaseLayerT &BaseLayer,
420 RPCEndpoint &Remote,
427 LLVM_ATTRIBUTE_DEPRECATED(
428 RemoteObjectServerLayer(BaseLayerT &BaseLayer, RPCEndpoint &Remote,
429 std::function ReportError),
430 "ORCv1 layers (including RemoteObjectServerLayer) are deprecated. Please "
431 "use "
432 "ORCv2 (see docs/ORCv2.rst)");
433
434 RemoteObjectServerLayer(ORCv1DeprecationAcknowledgement,
435 BaseLayerT &BaseLayer, RPCEndpoint &Remote,
421436 std::function ReportError)
422 : RemoteObjectLayer(Remote, std::move(ReportError)),
423 BaseLayer(BaseLayer), HandleIdMgr(1) {
437 : RemoteObjectLayer(Remote, std::move(ReportError)),
438 BaseLayer(BaseLayer), HandleIdMgr(1) {
424439 using ThisT = RemoteObjectServerLayer;
425440
426441 Remote.template addHandler(*this, &ThisT::addObject);
461476 assert(!BaseLayerHandles.count(Id) && "Id already in use?");
462477
463478 auto Resolver = createLambdaResolver(
479 AcknowledgeORCv1Deprecation,
464480 [this, Id](const std::string &Name) { return lookup(Id, Name); },
465481 [this, Id](const std::string &Name) {
466482 return lookupInLogicalDylib(Id, Name);
521537 std::map BaseLayerHandles;
522538 };
523539
540 template
541 RemoteObjectClientLayer::RemoteObjectClientLayer(
542 RPCEndpoint &Remote, std::function ReportError)
543 : RemoteObjectLayer(Remote, std::move(ReportError)) {
544 using ThisT = RemoteObjectClientLayer;
545 Remote.template addHandler(*this, &ThisT::lookup);
546 Remote.template addHandler(
547 *this, &ThisT::lookupInLogicalDylib);
548 }
549
550 template
551 RemoteObjectServerLayer::RemoteObjectServerLayer(
552 BaseLayerT &BaseLayer, RPCEndpoint &Remote,
553 std::function ReportError)
554 : RemoteObjectLayer(Remote, std::move(ReportError)),
555 BaseLayer(BaseLayer), HandleIdMgr(1) {
556 using ThisT = RemoteObjectServerLayer;
557
558 Remote.template addHandler(*this, &ThisT::addObject);
559 Remote.template addHandler(*this, &ThisT::removeObject);
560 Remote.template addHandler(*this, &ThisT::findSymbol);
561 Remote.template addHandler(*this, &ThisT::findSymbolIn);
562 Remote.template addHandler(*this, &ThisT::emitAndFinalize);
563 }
564
524565 } // end namespace orc
525566 } // end namespace llvm
526567
0 //===------ OrcV1Deprecation.h - Memory manager for MC-JIT ------*- C++ -*-===//
1 //
2 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3 // See https://llvm.org/LICENSE.txt for license information.
4 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // Tag for suppressing ORCv1 deprecation warnings.
9 //
10 //===----------------------------------------------------------------------===//
11
12 #ifndef LLVM_EXECUTIONENGINE_ORCV1DEPRECATION_H
13 #define LLVM_EXECUTIONENGINE_ORCV1DEPRECATION_H
14
15 namespace llvm {
16
17 enum ORCv1DeprecationAcknowledgement { AcknowledgeORCv1Deprecation };
18
19 } // namespace llvm
20
21 #endif // LLVM_EXECUTIONENGINE_ORCV1DEPRECATION_H
210210 IndirectStubsManagerBuilder IndirectStubsMgrBuilder)
211211 : CCMgr(createCompileCallbackManager(TM, ES)), DL(TM.createDataLayout()),
212212 IndirectStubsMgr(IndirectStubsMgrBuilder()),
213 ObjectLayer(ES,
214 [this](orc::VModuleKey K) {
215 auto ResolverI = Resolvers.find(K);
216 assert(ResolverI != Resolvers.end() &&
217 "No resolver for module K");
218 auto Resolver = std::move(ResolverI->second);
219 Resolvers.erase(ResolverI);
220 return ObjLayerT::Resources{
221 std::make_shared(), Resolver};
222 },
223 nullptr,
224 [this](orc::VModuleKey K, const object::ObjectFile &Obj,
225 const RuntimeDyld::LoadedObjectInfo &LoadedObjInfo) {
226 this->notifyFinalized(K, Obj, LoadedObjInfo);
227 },
228 [this](orc::VModuleKey K, const object::ObjectFile &Obj) {
229 this->notifyFreed(K, Obj);
230 }),
231 CompileLayer(ObjectLayer, orc::SimpleCompiler(TM)),
213 ObjectLayer(
214 AcknowledgeORCv1Deprecation, ES,
215 [this](orc::VModuleKey K) {
216 auto ResolverI = Resolvers.find(K);
217 assert(ResolverI != Resolvers.end() &&
218 "No resolver for module K");
219 auto Resolver = std::move(ResolverI->second);
220 Resolvers.erase(ResolverI);
221 return ObjLayerT::Resources{
222 std::make_shared(), Resolver};
223 },
224 nullptr,
225 [this](orc::VModuleKey K, const object::ObjectFile &Obj,
226 const RuntimeDyld::LoadedObjectInfo &LoadedObjInfo) {
227 this->notifyFinalized(K, Obj, LoadedObjInfo);
228 },
229 [this](orc::VModuleKey K, const object::ObjectFile &Obj) {
230 this->notifyFreed(K, Obj);
231 }),
232 CompileLayer(AcknowledgeORCv1Deprecation, ObjectLayer,
233 orc::SimpleCompiler(TM)),
232234 CODLayer(createCODLayer(ES, CompileLayer, CCMgr.get(),
233235 std::move(IndirectStubsMgrBuilder), Resolvers)),
234236 CXXRuntimeOverrides(
237 AcknowledgeORCv1Deprecation,
235238 [this](const std::string &S) { return mangle(S); }) {}
236239
237240 Error shutdown() {
307310
308311 // Run the static constructors, and save the static destructor runner for
309312 // execution when the JIT is torn down.
310 orc::LegacyCtorDtorRunner CtorRunner(std::move(CtorNames), K);
313 orc::LegacyCtorDtorRunner CtorRunner(
314 AcknowledgeORCv1Deprecation, std::move(CtorNames), K);
311315 if (auto Err = CtorRunner.runViaLayer(*this))
312316 return std::move(Err);
313317
464468 return nullptr;
465469
466470 return llvm::make_unique(
467 ES, CompileLayer,
471 AcknowledgeORCv1Deprecation, ES, CompileLayer,
468472 [&Resolvers](orc::VModuleKey K) {
469473 auto ResolverI = Resolvers.find(K);
470474 assert(ResolverI != Resolvers.end() && "No resolver for module K");
126126 auto &CtorDtorsMap = isDtors ? UnexecutedDestructors : UnexecutedConstructors;
127127
128128 for (auto &KV : CtorDtorsMap)
129 cantFail(LegacyCtorDtorRunner(std::move(KV.second), KV.first)
129 cantFail(LegacyCtorDtorRunner(
130 AcknowledgeORCv1Deprecation, std::move(KV.second), KV.first)
130131 .runViaLayer(LazyEmitLayer));
131132
132133 CtorDtorsMap.clear();
231231 OrcMCJITReplacement(std::shared_ptr MemMgr,
232232 std::shared_ptr ClientResolver,
233233 std::unique_ptr TM)
234 : ExecutionEngine(TM->createDataLayout()),
235 TM(std::move(TM)),
234 : ExecutionEngine(TM->createDataLayout()), TM(std::move(TM)),
236235 MemMgr(
237236 std::make_shared(*this, std::move(MemMgr))),
238237 Resolver(std::make_shared(*this)),
239238 ClientResolver(std::move(ClientResolver)), NotifyObjectLoaded(*this),
240239 NotifyFinalized(*this),
241240 ObjectLayer(
242 ES,
241 AcknowledgeORCv1Deprecation, ES,
243242 [this](VModuleKey K) {
244243 return ObjectLayerT::Resources{this->MemMgr, this->Resolver};
245244 },
246245 NotifyObjectLoaded, NotifyFinalized),
247 CompileLayer(ObjectLayer, SimpleCompiler(*this->TM),
246 CompileLayer(AcknowledgeORCv1Deprecation, ObjectLayer,
247 SimpleCompiler(*this->TM),
248248 [this](VModuleKey K, std::unique_ptr M) {
249249 Modules.push_back(std::move(M));
250250 }),
251 LazyEmitLayer(CompileLayer) {}
251 LazyEmitLayer(AcknowledgeORCv1Deprecation, CompileLayer) {}
252252
253253 static void Register() {
254254 OrcMCJITReplacementCtor = createOrcMCJITReplacement;
206206 NotifyEmitted(K, std::move(ObjBuffer));
207207 }
208208
209 LegacyRTDyldObjectLinkingLayer::LegacyRTDyldObjectLinkingLayer(
210 ExecutionSession &ES, ResourcesGetter GetResources,
211 NotifyLoadedFtor NotifyLoaded, NotifyFinalizedFtor NotifyFinalized,
212 NotifyFreedFtor NotifyFreed)
213 : ES(ES), GetResources(std::move(GetResources)),
214 NotifyLoaded(std::move(NotifyLoaded)),
215 NotifyFinalized(std::move(NotifyFinalized)),
216 NotifyFreed(std::move(NotifyFreed)), ProcessAllSections(false) {}
217
209218 } // End namespace orc.
210219 } // End namespace llvm.
8282 cl::desc("Force interpretation: disable JIT"),
8383 cl::init(false));
8484
85 cl::opt UseJITKind("jit-kind",
86 cl::desc("Choose underlying JIT kind."),
87 cl::init(JITKind::MCJIT),
88 cl::values(
89 clEnumValN(JITKind::MCJIT, "mcjit",
90 "MCJIT"),
91 clEnumValN(JITKind::OrcMCJITReplacement,
92 "orc-mcjit",
93 "Orc-based MCJIT replacement"),
94 clEnumValN(JITKind::OrcLazy,
95 "orc-lazy",
96 "Orc-based lazy JIT.")));
85 cl::opt UseJITKind(
86 "jit-kind", cl::desc("Choose underlying JIT kind."),
87 cl::init(JITKind::MCJIT),
88 cl::values(clEnumValN(JITKind::MCJIT, "mcjit", "MCJIT"),
89 clEnumValN(JITKind::OrcMCJITReplacement, "orc-mcjit",
90 "Orc-based MCJIT replacement "
91 "(deprecated)"),
92 clEnumValN(JITKind::OrcLazy, "orc-lazy",
93 "Orc-based lazy JIT.")));
9794
9895 cl::opt
9996 LazyJITCompileThreads("compile-threads",
418415 builder.setEngineKind(ForceInterpreter
419416 ? EngineKind::Interpreter
420417 : EngineKind::JIT);
421 builder.setUseOrcMCJITReplacement(UseJITKind == JITKind::OrcMCJITReplacement);
418 builder.setUseOrcMCJITReplacement(AcknowledgeORCv1Deprecation,
419 UseJITKind == JITKind::OrcMCJITReplacement);
422420
423421 // If we are supposed to override the target triple, do so now.
424422 if (!TargetTriple.empty())
664662 // Forward MCJIT's symbol resolution calls to the remote.
665663 static_cast(RTDyldMM)->setResolver(
666664 orc::createLambdaResolver(
665 AcknowledgeORCv1Deprecation,
667666 [](const std::string &Name) { return nullptr; },
668667 [&](const std::string &Name) {
669668 if (auto Addr = ExitOnErr(R->getSymbolAddress(Name)))
2121
2222 TEST(LazyEmittingLayerTest, Empty) {
2323 MockBaseLayer M;
24 llvm::orc::LazyEmittingLayer L(M);
24 llvm::orc::LazyEmittingLayer L(
25 llvm::AcknowledgeORCv1Deprecation, M);
2526 cantFail(
2627 L.addModule(llvm::orc::VModuleKey(), std::unique_ptr()));
2728 }
7575 };
7676
7777 llvm::orc::LegacyCompileOnDemandLayer COD(
78 ES, TestBaseLayer, GetResolver, SetResolver,
78 AcknowledgeORCv1Deprecation, ES, TestBaseLayer, GetResolver, SetResolver,
7979 [](Function &F) { return std::set{&F}; }, CallbackMgr,
8080 [] { return llvm::make_unique(); }, true);
8181
6767
6868 ExecutionSession ES;
6969
70 LegacyRTDyldObjectLinkingLayer ObjLayer(ES, [&MM](VModuleKey) {
71 return LegacyRTDyldObjectLinkingLayer::Resources{
72 MM, std::make_shared()};
73 });
70 LegacyRTDyldObjectLinkingLayer ObjLayer(
71 AcknowledgeORCv1Deprecation, ES, [&MM](VModuleKey) {
72 return LegacyRTDyldObjectLinkingLayer::Resources{
73 MM, std::make_shared()};
74 });
7475
7576 LLVMContext Context;
7677 auto M = llvm::make_unique("", Context);
129130
130131 std::map> Resolvers;
131132
132 LegacyRTDyldObjectLinkingLayer ObjLayer(ES, [&](VModuleKey K) {
133 auto I = Resolvers.find(K);
134 assert(I != Resolvers.end() && "Missing resolver");
135 auto R = std::move(I->second);
136 Resolvers.erase(I);
137 return LegacyRTDyldObjectLinkingLayer::Resources{MM, std::move(R)};
138 });
133 LegacyRTDyldObjectLinkingLayer ObjLayer(
134 AcknowledgeORCv1Deprecation, ES, [&](VModuleKey K) {
135 auto I = Resolvers.find(K);
136 assert(I != Resolvers.end() && "Missing resolver");
137 auto R = std::move(I->second);
138 Resolvers.erase(I);
139 return LegacyRTDyldObjectLinkingLayer::Resources{MM, std::move(R)};
140 });
139141 SimpleCompiler Compile(*TM);
140142
141143 // Create a pair of modules that will trigger recursive finalization:
216218
217219 auto MM = std::make_shared();
218220
219 LegacyRTDyldObjectLinkingLayer ObjLayer(ES, [&MM](VModuleKey K) {
220 return LegacyRTDyldObjectLinkingLayer::Resources{
221 MM, std::make_shared()};
222 });
221 LegacyRTDyldObjectLinkingLayer ObjLayer(
222 AcknowledgeORCv1Deprecation, ES, [&MM](VModuleKey K) {
223 return LegacyRTDyldObjectLinkingLayer::Resources{
224 MM, std::make_shared()};
225 });
223226 SimpleCompiler Compile(*TM);
224227
225228 // Create a pair of unrelated modules:
277280 TEST_F(LegacyRTDyldObjectLinkingLayerExecutionTest, TestNotifyLoadedSignature) {
278281 ExecutionSession ES;
279282 LegacyRTDyldObjectLinkingLayer ObjLayer(
280 ES,
283 AcknowledgeORCv1Deprecation, ES,
281284 [](VModuleKey) {
282285 return LegacyRTDyldObjectLinkingLayer::Resources{
283286 nullptr, std::make_shared()};
181181
182182 // Create one object transform layer using a transform (as a functor)
183183 // that allocates new objects, and deals in unique pointers.
184 LegacyObjectTransformLayer T1(M);
184 LegacyObjectTransformLayer T1(
185 llvm::AcknowledgeORCv1Deprecation, M);
185186
186187 // Create a second object transform layer using a transform (as a lambda)
187188 // that mutates objects in place, and deals in naked pointers
188189 LegacyObjectTransformLayer
189 std::function(
190 std::shared_ptr)>>
191 T2(M, [](std::shared_ptr Obj) {
192 ++(*Obj);
193 return Obj;
194 });
190 std::function(
191 std::shared_ptr)>>
192 T2(llvm::AcknowledgeORCv1Deprecation, M,
193 [](std::shared_ptr Obj) {
194 ++(*Obj);
195 return Obj;
196 });
195197
196198 // Test addObject with T1 (allocating)
197199 auto K1 = ES.allocateVModule();
280282 };
281283
282284 // Construct the jit layers.
283 LegacyRTDyldObjectLinkingLayer BaseLayer(ES, [](VModuleKey) {
284 return LegacyRTDyldObjectLinkingLayer::Resources{
285 std::make_shared(),
286 std::make_shared()};
287 });
285 LegacyRTDyldObjectLinkingLayer BaseLayer(
286 llvm::AcknowledgeORCv1Deprecation, ES, [](VModuleKey) {
287 return LegacyRTDyldObjectLinkingLayer::Resources{
288 std::make_shared(),
289 std::make_shared()};
290 });
288291
289292 auto IdentityTransform = [](std::unique_ptr Obj) {
290293 return Obj;
291294 };
292295 LegacyObjectTransformLayer
293 TransformLayer(BaseLayer, IdentityTransform);
296 TransformLayer(llvm::AcknowledgeORCv1Deprecation, BaseLayer,
297 IdentityTransform);
294298 auto NullCompiler = [](llvm::Module &) {
295299 return std::unique_ptr(nullptr);
296300 };
297301 LegacyIRCompileLayer
298 CompileLayer(TransformLayer, NullCompiler);
302 CompileLayer(llvm::AcknowledgeORCv1Deprecation, TransformLayer,
303 NullCompiler);
299304
300305 // Make sure that the calls from LegacyIRCompileLayer to LegacyObjectTransformLayer
301306 // compile.
126126 std::copy(ObjBytes.begin(), ObjBytes.end(), ObjContents.begin());
127127
128128 RPCEndpoint ClientEP(*Channels.first, true);
129 RemoteObjectClientLayer Client(ClientEP, ReportError);
129 RemoteObjectClientLayer Client(AcknowledgeORCv1Deprecation,
130 ClientEP, ReportError);
130131
131132 RPCEndpoint ServerEP(*Channels.second, true);
132133 MockObjectLayer BaseLayer(
143144
144145 return 1;
145146 });
146 RemoteObjectServerLayer Server(BaseLayer,
147 ServerEP,
148 ReportError);
147 RemoteObjectServerLayer Server(
148 AcknowledgeORCv1Deprecation, BaseLayer, ServerEP, ReportError);
149149
150150 bool Finished = false;
151151 ServerEP.addHandler(
180180 };
181181
182182 RPCEndpoint ClientEP(*Channels.first, true);
183 RemoteObjectClientLayer Client(ClientEP, ReportError);
183 RemoteObjectClientLayer Client(AcknowledgeORCv1Deprecation,
184 ClientEP, ReportError);
184185
185186 RPCEndpoint ServerEP(*Channels.second, true);
186187 MockObjectLayer BaseLayer(
190191 return make_error("AddObjectFailure - Test Message",
191192 inconvertibleErrorCode());
192193 });
193 RemoteObjectServerLayer Server(BaseLayer,
194 ServerEP,
195 ReportError);
194 RemoteObjectServerLayer Server(
195 AcknowledgeORCv1Deprecation, BaseLayer, ServerEP, ReportError);
196196
197197 bool Finished = false;
198198 ServerEP.addHandler(
232232 };
233233
234234 RPCEndpoint ClientEP(*Channels.first, true);
235 RemoteObjectClientLayer Client(ClientEP, ReportError);
235 RemoteObjectClientLayer Client(AcknowledgeORCv1Deprecation,
236 ClientEP, ReportError);
236237
237238 RPCEndpoint ServerEP(*Channels.second, true);
238239
242243 SymTab[1] = MockObjectLayer::LookupFn();
243244 return 1;
244245 });
245 RemoteObjectServerLayer Server(BaseLayer,
246 ServerEP,
247 ReportError);
246 RemoteObjectServerLayer Server(
247 AcknowledgeORCv1Deprecation, BaseLayer, ServerEP, ReportError);
248248
249249 bool Finished = false;
250250 ServerEP.addHandler(
282282 };
283283
284284 RPCEndpoint ClientEP(*Channels.first, true);
285 RemoteObjectClientLayer Client(ClientEP, ReportError);
285 RemoteObjectClientLayer Client(AcknowledgeORCv1Deprecation,
286 ClientEP, ReportError);
286287
287288 RPCEndpoint ServerEP(*Channels.second, true);
288289
293294 MockObjectLayer::SymbolLookupTable &SymTab) {
294295 return 42;
295296 });
296 RemoteObjectServerLayer Server(BaseLayer,
297 ServerEP,
298 ReportError);
297 RemoteObjectServerLayer Server(
298 AcknowledgeORCv1Deprecation, BaseLayer, ServerEP, ReportError);
299299
300300 bool Finished = false;
301301 ServerEP.addHandler(
338338 };
339339
340340 RPCEndpoint ClientEP(*Channels.first, true);
341 RemoteObjectClientLayer Client(ClientEP, ReportError);
341 RemoteObjectClientLayer Client(AcknowledgeORCv1Deprecation,
342 ClientEP, ReportError);
342343
343344 RPCEndpoint ServerEP(*Channels.second, true);
344345
357358 };
358359 return 42;
359360 });
360 RemoteObjectServerLayer Server(BaseLayer,
361 ServerEP,
362 ReportError);
361 RemoteObjectServerLayer Server(
362 AcknowledgeORCv1Deprecation, BaseLayer, ServerEP, ReportError);
363363
364364 bool Finished = false;
365365 ServerEP.addHandler(
420420 };
421421
422422 RPCEndpoint ClientEP(*Channels.first, true);
423 RemoteObjectClientLayer Client(ClientEP, ReportError);
423 RemoteObjectClientLayer Client(AcknowledgeORCv1Deprecation,
424 ClientEP, ReportError);
424425
425426 RPCEndpoint ServerEP(*Channels.second, true);
426427
446447
447448 return 42;
448449 });
449 RemoteObjectServerLayer Server(BaseLayer,
450 ServerEP,
451 ReportError);
450 RemoteObjectServerLayer Server(
451 AcknowledgeORCv1Deprecation, BaseLayer, ServerEP, ReportError);
452452
453453 bool Finished = false;
454454 ServerEP.addHandler(
495495 };
496496
497497 RPCEndpoint ClientEP(*Channels.first, true);
498 RemoteObjectClientLayer Client(ClientEP, ReportError);
498 RemoteObjectClientLayer Client(AcknowledgeORCv1Deprecation,
499 ClientEP, ReportError);
499500
500501 RPCEndpoint ServerEP(*Channels.second, true);
501502
505506 SymTab[1] = MockObjectLayer::LookupFn();
506507 return 1;
507508 });
508 RemoteObjectServerLayer Server(BaseLayer,
509 ServerEP,
510 ReportError);
509 RemoteObjectServerLayer Server(
510 AcknowledgeORCv1Deprecation, BaseLayer, ServerEP, ReportError);
511511
512512 bool Finished = false;
513513 ServerEP.addHandler(
546546 };
547547
548548 RPCEndpoint ClientEP(*Channels.first, true);
549 RemoteObjectClientLayer Client(ClientEP, ReportError);
549 RemoteObjectClientLayer Client(AcknowledgeORCv1Deprecation,
550 ClientEP, ReportError);
550551
551552 RPCEndpoint ServerEP(*Channels.second, true);
552553
555556 MockObjectLayer::SymbolLookupTable &SymTab) {
556557 return 1;
557558 });
558 RemoteObjectServerLayer Server(BaseLayer,
559 ServerEP,
560 ReportError);
559 RemoteObjectServerLayer Server(
560 AcknowledgeORCv1Deprecation, BaseLayer, ServerEP, ReportError);
561561
562562 bool Finished = false;
563563 ServerEP.addHandler(