Index: llvm/docs/tutorial/BuildingAJIT1.rst =================================================================== --- llvm/docs/tutorial/BuildingAJIT1.rst +++ llvm/docs/tutorial/BuildingAJIT1.rst @@ -139,7 +139,7 @@ KaleidoscopeJIT(JITTargetMachineBuilder JTMB, DataLayout DL) : ObjectLayer(ES, []() { return std::make_unique(); }), - CompileLayer(ES, ObjectLayer, ConcurrentIRCompiler(std::move(JTMB))), + CompileLayer(ES, ObjectLayer, ConcurrentIRCompiler(JTMB)), DL(std::move(DL)), Mangle(ES, this->DL), Ctx(std::make_unique()) { ES.getMainJITDylib().addGenerator( Index: llvm/docs/tutorial/BuildingAJIT2.rst =================================================================== --- llvm/docs/tutorial/BuildingAJIT2.rst +++ llvm/docs/tutorial/BuildingAJIT2.rst @@ -72,7 +72,7 @@ KaleidoscopeJIT(JITTargetMachineBuilder JTMB, DataLayout DL) : ObjectLayer(ES, []() { return std::make_unique(); }), - CompileLayer(ES, ObjectLayer, ConcurrentIRCompiler(std::move(JTMB))), + CompileLayer(ES, ObjectLayer, ConcurrentIRCompiler(JTMB)), TransformLayer(ES, CompileLayer, optimizeModule), DL(std::move(DL)), Mangle(ES, this->DL), Ctx(std::make_unique()) { Index: llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h =================================================================== --- llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h +++ llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h @@ -44,12 +44,12 @@ public: KaleidoscopeJIT(std::unique_ptr ES, - JITTargetMachineBuilder JTMB, DataLayout DL) + JITTargetMachineBuilder &JTMB, DataLayout DL) : ES(std::move(ES)), DL(std::move(DL)), Mangle(*this->ES, this->DL), ObjectLayer(*this->ES, []() { return std::make_unique(); }), CompileLayer(*this->ES, ObjectLayer, - std::make_unique(std::move(JTMB))), + std::make_unique(JTMB)), MainJD(this->ES->createBareJITDylib("
")) { MainJD.addGenerator( cantFail(DynamicLibrarySearchGenerator::GetForCurrentProcess( @@ -75,7 +75,7 @@ if (!DL) return DL.takeError(); - return std::make_unique(std::move(ES), std::move(JTMB), + return std::make_unique(std::move(ES), JTMB, std::move(*DL)); } Index: llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h =================================================================== --- llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h +++ llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h @@ -50,12 +50,12 @@ public: KaleidoscopeJIT(std::unique_ptr ES, - JITTargetMachineBuilder JTMB, DataLayout DL) + JITTargetMachineBuilder &JTMB, DataLayout DL) : ES(std::move(ES)), DL(std::move(DL)), Mangle(*this->ES, this->DL), ObjectLayer(*this->ES, []() { return std::make_unique(); }), CompileLayer(*this->ES, ObjectLayer, - std::make_unique(std::move(JTMB))), + std::make_unique(JTMB)), OptimizeLayer(*this->ES, CompileLayer, optimizeModule), MainJD(this->ES->createBareJITDylib("
")) { MainJD.addGenerator( @@ -82,7 +82,7 @@ if (!DL) return DL.takeError(); - return std::make_unique(std::move(ES), std::move(JTMB), + return std::make_unique(std::move(ES), JTMB, std::move(*DL)); } Index: llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h =================================================================== --- llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h +++ llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h @@ -60,13 +60,13 @@ public: KaleidoscopeJIT(std::unique_ptr ES, std::unique_ptr EPCIU, - JITTargetMachineBuilder JTMB, DataLayout DL) + JITTargetMachineBuilder &JTMB, DataLayout DL) : ES(std::move(ES)), EPCIU(std::move(EPCIU)), DL(std::move(DL)), Mangle(*this->ES, this->DL), ObjectLayer(*this->ES, []() { return std::make_unique(); }), CompileLayer(*this->ES, ObjectLayer, - std::make_unique(std::move(JTMB))), + std::make_unique(JTMB)), OptimizeLayer(*this->ES, CompileLayer, optimizeModule), CODLayer(*this->ES, OptimizeLayer, this->EPCIU->getLazyCallThroughManager(), @@ -109,7 +109,7 @@ return DL.takeError(); return std::make_unique(std::move(ES), std::move(*EPCIU), - std::move(JTMB), std::move(*DL)); + JTMB, std::move(*DL)); } const DataLayout &getDataLayout() const { return DL; } Index: llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h =================================================================== --- llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h +++ llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h @@ -147,13 +147,13 @@ public: KaleidoscopeJIT(std::unique_ptr ES, std::unique_ptr EPCIU, - JITTargetMachineBuilder JTMB, DataLayout DL) + JITTargetMachineBuilder &JTMB, DataLayout DL) : ES(std::move(ES)), EPCIU(std::move(EPCIU)), DL(std::move(DL)), Mangle(*this->ES, this->DL), ObjectLayer(*this->ES, []() { return std::make_unique(); }), CompileLayer(*this->ES, ObjectLayer, - std::make_unique(std::move(JTMB))), + std::make_unique(JTMB)), OptimizeLayer(*this->ES, CompileLayer, optimizeModule), ASTLayer(OptimizeLayer, this->DL), MainJD(this->ES->createBareJITDylib("
")) { @@ -194,7 +194,7 @@ return DL.takeError(); return std::make_unique(std::move(ES), std::move(*EPCIU), - std::move(JTMB), std::move(*DL)); + JTMB, std::move(*DL)); } const DataLayout &getDataLayout() const { return DL; } Index: llvm/examples/Kaleidoscope/include/KaleidoscopeJIT.h =================================================================== --- llvm/examples/Kaleidoscope/include/KaleidoscopeJIT.h +++ llvm/examples/Kaleidoscope/include/KaleidoscopeJIT.h @@ -44,12 +44,12 @@ public: KaleidoscopeJIT(std::unique_ptr ES, - JITTargetMachineBuilder JTMB, DataLayout DL) + const JITTargetMachineBuilder &JTMB, DataLayout DL) : ES(std::move(ES)), DL(std::move(DL)), Mangle(*this->ES, this->DL), ObjectLayer(*this->ES, []() { return std::make_unique(); }), CompileLayer(*this->ES, ObjectLayer, - std::make_unique(std::move(JTMB))), + std::make_unique(JTMB)), MainJD(this->ES->createBareJITDylib("
")) { MainJD.addGenerator( cantFail(DynamicLibrarySearchGenerator::GetForCurrentProcess( @@ -79,7 +79,7 @@ if (!DL) return DL.takeError(); - return std::make_unique(std::move(ES), std::move(JTMB), + return std::make_unique(std::move(ES), JTMB, std::move(*DL)); } Index: llvm/examples/OrcV2Examples/LLJITWithCustomObjectLinkingLayer/LLJITWithCustomObjectLinkingLayer.cpp =================================================================== --- llvm/examples/OrcV2Examples/LLJITWithCustomObjectLinkingLayer/LLJITWithCustomObjectLinkingLayer.cpp +++ llvm/examples/OrcV2Examples/LLJITWithCustomObjectLinkingLayer/LLJITWithCustomObjectLinkingLayer.cpp @@ -43,7 +43,7 @@ // Create an LLJIT instance with an ObjectLinkingLayer as the base layer. auto J = ExitOnErr( LLJITBuilder() - .setJITTargetMachineBuilder(std::move(JTMB)) + .setJITTargetMachineBuilder(JTMB) .setObjectLinkingLayerCreator( [&](ExecutionSession &ES, const Triple &TT) { return std::make_unique( Index: llvm/examples/OrcV2Examples/LLJITWithGDBRegistrationListener/LLJITWithGDBRegistrationListener.cpp =================================================================== --- llvm/examples/OrcV2Examples/LLJITWithGDBRegistrationListener/LLJITWithGDBRegistrationListener.cpp +++ llvm/examples/OrcV2Examples/LLJITWithGDBRegistrationListener/LLJITWithGDBRegistrationListener.cpp @@ -61,7 +61,7 @@ // register the GDBRegistrationListener with our RTDyldObjectLinkingLayer. auto J = ExitOnErr(LLJITBuilder() - .setJITTargetMachineBuilder(std::move(JTMB)) + .setJITTargetMachineBuilder(JTMB) .setObjectLinkingLayerCreator([&](ExecutionSession &ES, const Triple &TT) { auto GetMemMgr = []() { Index: llvm/examples/OrcV2Examples/LLJITWithObjectCache/LLJITWithObjectCache.cpp =================================================================== --- llvm/examples/OrcV2Examples/LLJITWithObjectCache/LLJITWithObjectCache.cpp +++ llvm/examples/OrcV2Examples/LLJITWithObjectCache/LLJITWithObjectCache.cpp @@ -54,7 +54,7 @@ auto J = ExitOnErr( LLJITBuilder() .setCompileFunctionCreator( - [&](JITTargetMachineBuilder JTMB) + [&](JITTargetMachineBuilder &JTMB) -> Expected> { auto TM = JTMB.createTargetMachine(); if (!TM) Index: llvm/examples/OrcV2Examples/LLJITWithObjectLinkingLayerPlugin/LLJITWithObjectLinkingLayerPlugin.cpp =================================================================== --- llvm/examples/OrcV2Examples/LLJITWithObjectLinkingLayerPlugin/LLJITWithObjectLinkingLayerPlugin.cpp +++ llvm/examples/OrcV2Examples/LLJITWithObjectLinkingLayerPlugin/LLJITWithObjectLinkingLayerPlugin.cpp @@ -205,7 +205,7 @@ // returning it. auto J = ExitOnErr( LLJITBuilder() - .setJITTargetMachineBuilder(std::move(JTMB)) + .setJITTargetMachineBuilder(JTMB) .setObjectLinkingLayerCreator( [&](ExecutionSession &ES, const Triple &TT) { // Create ObjectLinkingLayer. Index: llvm/examples/OrcV2Examples/LLJITWithRemoteDebugging/LLJITWithRemoteDebugging.cpp =================================================================== --- llvm/examples/OrcV2Examples/LLJITWithRemoteDebugging/LLJITWithRemoteDebugging.cpp +++ llvm/examples/OrcV2Examples/LLJITWithRemoteDebugging/LLJITWithRemoteDebugging.cpp @@ -198,13 +198,14 @@ // Create LLJIT and destroy it before disconnecting the target process. outs() << "Initializing LLJIT for remote executor\n"; - auto J = ExitOnErr(LLJITBuilder() - .setExecutorProcessControl(std::move(EPC)) - .setJITTargetMachineBuilder(std::move(JTMB)) - .setObjectLinkingLayerCreator([&](auto &ES, const auto &TT) { - return std::make_unique(ES); - }) - .create()); + auto J = ExitOnErr( + LLJITBuilder() + .setExecutorProcessControl(std::move(EPC)) + .setJITTargetMachineBuilder(JTMB) + .setObjectLinkingLayerCreator([&](auto &ES, const auto &TT) { + return std::make_unique(ES); + }) + .create()); // Add plugin for debug support. ExitOnErr(addDebugSupport(J->getObjLinkingLayer())); Index: llvm/examples/SpeculativeJIT/SpeculativeJIT.cpp =================================================================== --- llvm/examples/SpeculativeJIT/SpeculativeJIT.cpp +++ llvm/examples/SpeculativeJIT/SpeculativeJIT.cpp @@ -74,7 +74,7 @@ return ProcessSymbolsSearchGenerator.takeError(); std::unique_ptr SJ(new SpeculativeJIT( - std::move(ES), std::move(*DL), std::move(*JTMB), std::move(*LCTMgr), + std::move(ES), std::move(*DL), *JTMB, std::move(*LCTMgr), std::move(ISMBuilder), std::move(*ProcessSymbolsSearchGenerator))); return std::move(SJ); } @@ -102,14 +102,15 @@ SpeculativeJIT( std::unique_ptr ES, DataLayout DL, - orc::JITTargetMachineBuilder JTMB, + orc::JITTargetMachineBuilder &JTMB, std::unique_ptr LCTMgr, IndirectStubsManagerBuilderFunction ISMBuilder, std::unique_ptr ProcessSymbolsGenerator) : ES(std::move(ES)), DL(std::move(DL)), - MainJD(this->ES->createBareJITDylib("
")), LCTMgr(std::move(LCTMgr)), + MainJD(this->ES->createBareJITDylib("
")), + LCTMgr(std::move(LCTMgr)), CompileLayer(*this->ES, ObjLayer, - std::make_unique(std::move(JTMB))), + std::make_unique(JTMB)), S(Imps, *this->ES), SpeculateLayer(*this->ES, CompileLayer, S, Mangle, BlockFreqQuery()), CODLayer(*this->ES, SpeculateLayer, *this->LCTMgr, Index: llvm/include/llvm/ExecutionEngine/Orc/CompileUtils.h =================================================================== --- llvm/include/llvm/ExecutionEngine/Orc/CompileUtils.h +++ llvm/include/llvm/ExecutionEngine/Orc/CompileUtils.h @@ -81,7 +81,7 @@ /// compile. class ConcurrentIRCompiler : public IRCompileLayer::IRCompiler { public: - ConcurrentIRCompiler(JITTargetMachineBuilder JTMB, + ConcurrentIRCompiler(const JITTargetMachineBuilder &JTMB, ObjectCache *ObjCache = nullptr); void setObjectCache(ObjectCache *ObjCache) { this->ObjCache = ObjCache; } Index: llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h =================================================================== --- llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h +++ llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h @@ -256,7 +256,7 @@ using CompileFunctionCreator = std::function>( - JITTargetMachineBuilder JTMB)>; + JITTargetMachineBuilder &JTMB)>; using PlatformSetupFunction = std::function; @@ -298,8 +298,8 @@ /// /// If this method is not called, JITTargetMachineBuilder::detectHost will be /// used to construct a default target machine builder for the host platform. - SetterImpl &setJITTargetMachineBuilder(JITTargetMachineBuilder JTMB) { - impl().JTMB = std::move(JTMB); + SetterImpl &setJITTargetMachineBuilder(const JITTargetMachineBuilder &JTMB) { + impl().JTMB = JTMB; return impl(); } Index: llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp =================================================================== --- llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp +++ llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp @@ -80,10 +80,10 @@ ObjCache->notifyObjectCompiled(&M, ObjBuffer.getMemBufferRef()); } -ConcurrentIRCompiler::ConcurrentIRCompiler(JITTargetMachineBuilder JTMB, +ConcurrentIRCompiler::ConcurrentIRCompiler(const JITTargetMachineBuilder &JTMB, ObjectCache *ObjCache) : IRCompiler(irManglingOptionsFromTargetOptions(JTMB.getOptions())), - JTMB(std::move(JTMB)), ObjCache(ObjCache) {} + JTMB(JTMB), ObjCache(ObjCache) {} Expected> ConcurrentIRCompiler::operator()(Module &M) { Index: llvm/lib/ExecutionEngine/Orc/LLJIT.cpp =================================================================== --- llvm/lib/ExecutionEngine/Orc/LLJIT.cpp +++ llvm/lib/ExecutionEngine/Orc/LLJIT.cpp @@ -816,12 +816,12 @@ /// If there is a custom compile function creator set then use it. if (S.CreateCompileFunction) - return S.CreateCompileFunction(std::move(JTMB)); + return S.CreateCompileFunction(JTMB); // Otherwise default to creating a SimpleCompiler, or ConcurrentIRCompiler, // depending on the number of threads requested. if (S.NumCompileThreads > 0) - return std::make_unique(std::move(JTMB)); + return std::make_unique(JTMB); auto TM = JTMB.createTargetMachine(); if (!TM) Index: llvm/lib/ExecutionEngine/Orc/OrcV2CBindings.cpp =================================================================== --- llvm/lib/ExecutionEngine/Orc/OrcV2CBindings.cpp +++ llvm/lib/ExecutionEngine/Orc/OrcV2CBindings.cpp @@ -947,7 +947,7 @@ void LLVMOrcLLJITBuilderSetJITTargetMachineBuilder( LLVMOrcLLJITBuilderRef Builder, LLVMOrcJITTargetMachineBuilderRef JTMB) { - unwrap(Builder)->setJITTargetMachineBuilder(std::move(*unwrap(JTMB))); + unwrap(Builder)->setJITTargetMachineBuilder(*unwrap(JTMB)); LLVMOrcDisposeJITTargetMachineBuilder(JTMB); } Index: llvm/tools/lli/lli.cpp =================================================================== --- llvm/tools/lli/lli.cpp +++ llvm/tools/lli/lli.cpp @@ -897,19 +897,19 @@ CacheManager = std::make_unique(ObjectCacheDir); Builder.setCompileFunctionCreator( - [&](orc::JITTargetMachineBuilder JTMB) + [&](orc::JITTargetMachineBuilder &JTMB) -> Expected> { - if (LazyJITCompileThreads > 0) - return std::make_unique(std::move(JTMB), - CacheManager.get()); + if (LazyJITCompileThreads > 0) + return std::make_unique( + JTMB, CacheManager.get()); - auto TM = JTMB.createTargetMachine(); - if (!TM) - return TM.takeError(); + auto TM = JTMB.createTargetMachine(); + if (!TM) + return TM.takeError(); - return std::make_unique(std::move(*TM), - CacheManager.get()); - }); + return std::make_unique( + std::move(*TM), CacheManager.get()); + }); } // Set up LLJIT platform.