diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h b/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h index eb2d21c50b9..783c352cf05 100644 --- a/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h +++ b/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h @@ -18,10 +18,10 @@ #include "llvm/ExecutionEngine/Orc/CompileUtils.h" #include "llvm/ExecutionEngine/Orc/Core.h" #include "llvm/ExecutionEngine/Orc/ExecutionUtils.h" +#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h" #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h" #include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h" #include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h" -#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h" #include "llvm/ExecutionEngine/SectionMemoryManager.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/LLVMContext.h" @@ -32,7 +32,7 @@ namespace orc { class KaleidoscopeJIT { private: - std::unique_ptr TPC; + std::unique_ptr EPC; std::unique_ptr ES; DataLayout DL; @@ -44,10 +44,10 @@ private: JITDylib &MainJD; public: - KaleidoscopeJIT(std::unique_ptr TPC, + KaleidoscopeJIT(std::unique_ptr EPC, std::unique_ptr ES, JITTargetMachineBuilder JTMB, DataLayout DL) - : TPC(std::move(TPC)), ES(std::move(ES)), DL(std::move(DL)), + : EPC(std::move(EPC)), ES(std::move(ES)), DL(std::move(DL)), Mangle(*this->ES, this->DL), ObjectLayer(*this->ES, []() { return std::make_unique(); }), @@ -66,19 +66,19 @@ public: static Expected> Create() { auto SSP = std::make_shared(); - auto TPC = SelfTargetProcessControl::Create(SSP); - if (!TPC) - return TPC.takeError(); + auto EPC = SelfExecutorProcessControl::Create(SSP); + if (!EPC) + return EPC.takeError(); auto ES = std::make_unique(std::move(SSP)); - JITTargetMachineBuilder JTMB((*TPC)->getTargetTriple()); + JITTargetMachineBuilder JTMB((*EPC)->getTargetTriple()); auto DL = JTMB.getDefaultDataLayoutForTarget(); if (!DL) return DL.takeError(); - return std::make_unique(std::move(*TPC), std::move(ES), + return std::make_unique(std::move(*EPC), std::move(ES), std::move(JTMB), std::move(*DL)); } diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h b/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h index 517b2d3f8d9..363c74882b8 100644 --- a/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h +++ b/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h @@ -18,11 +18,11 @@ #include "llvm/ExecutionEngine/Orc/CompileUtils.h" #include "llvm/ExecutionEngine/Orc/Core.h" #include "llvm/ExecutionEngine/Orc/ExecutionUtils.h" +#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h" #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h" #include "llvm/ExecutionEngine/Orc/IRTransformLayer.h" #include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h" #include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h" -#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h" #include "llvm/ExecutionEngine/SectionMemoryManager.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/LLVMContext.h" @@ -37,7 +37,7 @@ namespace orc { class KaleidoscopeJIT { private: - std::unique_ptr TPC; + std::unique_ptr EPC; std::unique_ptr ES; DataLayout DL; @@ -50,10 +50,10 @@ private: JITDylib &MainJD; public: - KaleidoscopeJIT(std::unique_ptr TPC, + KaleidoscopeJIT(std::unique_ptr EPC, std::unique_ptr ES, JITTargetMachineBuilder JTMB, DataLayout DL) - : TPC(std::move(TPC)), ES(std::move(ES)), DL(std::move(DL)), + : EPC(std::move(EPC)), ES(std::move(ES)), DL(std::move(DL)), Mangle(*this->ES, this->DL), ObjectLayer(*this->ES, []() { return std::make_unique(); }), @@ -73,19 +73,19 @@ public: static Expected> Create() { auto SSP = std::make_shared(); - auto TPC = SelfTargetProcessControl::Create(SSP); - if (!TPC) - return TPC.takeError(); + auto EPC = SelfExecutorProcessControl::Create(SSP); + if (!EPC) + return EPC.takeError(); auto ES = std::make_unique(std::move(SSP)); - JITTargetMachineBuilder JTMB((*TPC)->getTargetTriple()); + JITTargetMachineBuilder JTMB((*EPC)->getTargetTriple()); auto DL = JTMB.getDefaultDataLayoutForTarget(); if (!DL) return DL.takeError(); - return std::make_unique(std::move(*TPC), std::move(ES), + return std::make_unique(std::move(*EPC), std::move(ES), std::move(JTMB), std::move(*DL)); } diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h b/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h index 675c938392e..0aba5666995 100644 --- a/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h +++ b/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h @@ -18,13 +18,13 @@ #include "llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h" #include "llvm/ExecutionEngine/Orc/CompileUtils.h" #include "llvm/ExecutionEngine/Orc/Core.h" +#include "llvm/ExecutionEngine/Orc/EPCIndirectionUtils.h" #include "llvm/ExecutionEngine/Orc/ExecutionUtils.h" +#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h" #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h" #include "llvm/ExecutionEngine/Orc/IRTransformLayer.h" #include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h" #include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h" -#include "llvm/ExecutionEngine/Orc/TPCIndirectionUtils.h" -#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h" #include "llvm/ExecutionEngine/SectionMemoryManager.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/LLVMContext.h" @@ -39,9 +39,9 @@ namespace orc { class KaleidoscopeJIT { private: - std::unique_ptr TPC; + std::unique_ptr EPC; std::unique_ptr ES; - std::unique_ptr TPCIU; + std::unique_ptr EPCIU; DataLayout DL; MangleAndInterner Mangle; @@ -59,11 +59,11 @@ private: } public: - KaleidoscopeJIT(std::unique_ptr TPC, + KaleidoscopeJIT(std::unique_ptr EPC, std::unique_ptr ES, - std::unique_ptr TPCIU, + std::unique_ptr EPCIU, JITTargetMachineBuilder JTMB, DataLayout DL) - : TPC(std::move(TPC)), ES(std::move(ES)), TPCIU(std::move(TPCIU)), + : EPC(std::move(EPC)), ES(std::move(ES)), EPCIU(std::move(EPCIU)), DL(std::move(DL)), Mangle(*this->ES, this->DL), ObjectLayer(*this->ES, []() { return std::make_unique(); }), @@ -71,8 +71,8 @@ public: std::make_unique(std::move(JTMB))), OptimizeLayer(*this->ES, CompileLayer, optimizeModule), CODLayer(*this->ES, OptimizeLayer, - this->TPCIU->getLazyCallThroughManager(), - [this] { return this->TPCIU->createIndirectStubsManager(); }), + this->EPCIU->getLazyCallThroughManager(), + [this] { return this->EPCIU->createIndirectStubsManager(); }), MainJD(this->ES->createBareJITDylib("
")) { MainJD.addGenerator( cantFail(DynamicLibrarySearchGenerator::GetForCurrentProcess( @@ -82,36 +82,36 @@ public: ~KaleidoscopeJIT() { if (auto Err = ES->endSession()) ES->reportError(std::move(Err)); - if (auto Err = TPCIU->cleanup()) + if (auto Err = EPCIU->cleanup()) ES->reportError(std::move(Err)); } static Expected> Create() { auto SSP = std::make_shared(); - auto TPC = SelfTargetProcessControl::Create(SSP); - if (!TPC) - return TPC.takeError(); + auto EPC = SelfExecutorProcessControl::Create(SSP); + if (!EPC) + return EPC.takeError(); auto ES = std::make_unique(std::move(SSP)); - auto TPCIU = TPCIndirectionUtils::Create(**TPC); - if (!TPCIU) - return TPCIU.takeError(); + auto EPCIU = EPCIndirectionUtils::Create(**EPC); + if (!EPCIU) + return EPCIU.takeError(); - (*TPCIU)->createLazyCallThroughManager( + (*EPCIU)->createLazyCallThroughManager( *ES, pointerToJITTargetAddress(&handleLazyCallThroughError)); - if (auto Err = setUpInProcessLCTMReentryViaTPCIU(**TPCIU)) + if (auto Err = setUpInProcessLCTMReentryViaEPCIU(**EPCIU)) return std::move(Err); - JITTargetMachineBuilder JTMB((*TPC)->getTargetTriple()); + JITTargetMachineBuilder JTMB((*EPC)->getTargetTriple()); auto DL = JTMB.getDefaultDataLayoutForTarget(); if (!DL) return DL.takeError(); - return std::make_unique(std::move(*TPC), std::move(ES), - std::move(*TPCIU), std::move(JTMB), + return std::make_unique(std::move(*EPC), std::move(ES), + std::move(*EPCIU), std::move(JTMB), std::move(*DL)); } diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h b/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h index e22dc551272..6b2f6a543bb 100644 --- a/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h +++ b/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h @@ -18,13 +18,13 @@ #include "llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h" #include "llvm/ExecutionEngine/Orc/CompileUtils.h" #include "llvm/ExecutionEngine/Orc/Core.h" +#include "llvm/ExecutionEngine/Orc/EPCIndirectionUtils.h" #include "llvm/ExecutionEngine/Orc/ExecutionUtils.h" +#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h" #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h" #include "llvm/ExecutionEngine/Orc/IRTransformLayer.h" #include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h" #include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h" -#include "llvm/ExecutionEngine/Orc/TPCIndirectionUtils.h" -#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h" #include "llvm/ExecutionEngine/SectionMemoryManager.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/LLVMContext.h" @@ -126,9 +126,9 @@ void KaleidoscopeASTMaterializationUnit::materialize( class KaleidoscopeJIT { private: - std::unique_ptr TPC; + std::unique_ptr EPC; std::unique_ptr ES; - std::unique_ptr TPCIU; + std::unique_ptr EPCIU; DataLayout DL; MangleAndInterner Mangle; @@ -146,11 +146,11 @@ private: } public: - KaleidoscopeJIT(std::unique_ptr TPC, + KaleidoscopeJIT(std::unique_ptr EPC, std::unique_ptr ES, - std::unique_ptr TPCIU, + std::unique_ptr EPCIU, JITTargetMachineBuilder JTMB, DataLayout DL) - : TPC(std::move(TPC)), ES(std::move(ES)), TPCIU(std::move(TPCIU)), + : EPC(std::move(EPC)), ES(std::move(ES)), EPCIU(std::move(EPCIU)), DL(std::move(DL)), Mangle(*this->ES, this->DL), ObjectLayer(*this->ES, []() { return std::make_unique(); }), @@ -167,36 +167,36 @@ public: ~KaleidoscopeJIT() { if (auto Err = ES->endSession()) ES->reportError(std::move(Err)); - if (auto Err = TPCIU->cleanup()) + if (auto Err = EPCIU->cleanup()) ES->reportError(std::move(Err)); } static Expected> Create() { auto SSP = std::make_shared(); - auto TPC = SelfTargetProcessControl::Create(SSP); - if (!TPC) - return TPC.takeError(); + auto EPC = SelfExecutorProcessControl::Create(SSP); + if (!EPC) + return EPC.takeError(); auto ES = std::make_unique(std::move(SSP)); - auto TPCIU = TPCIndirectionUtils::Create(**TPC); - if (!TPCIU) - return TPCIU.takeError(); + auto EPCIU = EPCIndirectionUtils::Create(**EPC); + if (!EPCIU) + return EPCIU.takeError(); - (*TPCIU)->createLazyCallThroughManager( + (*EPCIU)->createLazyCallThroughManager( *ES, pointerToJITTargetAddress(&handleLazyCallThroughError)); - if (auto Err = setUpInProcessLCTMReentryViaTPCIU(**TPCIU)) + if (auto Err = setUpInProcessLCTMReentryViaEPCIU(**EPCIU)) return std::move(Err); - JITTargetMachineBuilder JTMB((*TPC)->getTargetTriple()); + JITTargetMachineBuilder JTMB((*EPC)->getTargetTriple()); auto DL = JTMB.getDefaultDataLayoutForTarget(); if (!DL) return DL.takeError(); - return std::make_unique(std::move(*TPC), std::move(ES), - std::move(*TPCIU), std::move(JTMB), + return std::make_unique(std::move(*EPC), std::move(ES), + std::move(*EPCIU), std::move(JTMB), std::move(*DL)); } diff --git a/examples/Kaleidoscope/include/KaleidoscopeJIT.h b/examples/Kaleidoscope/include/KaleidoscopeJIT.h index eb2d21c50b9..783c352cf05 100644 --- a/examples/Kaleidoscope/include/KaleidoscopeJIT.h +++ b/examples/Kaleidoscope/include/KaleidoscopeJIT.h @@ -18,10 +18,10 @@ #include "llvm/ExecutionEngine/Orc/CompileUtils.h" #include "llvm/ExecutionEngine/Orc/Core.h" #include "llvm/ExecutionEngine/Orc/ExecutionUtils.h" +#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h" #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h" #include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h" #include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h" -#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h" #include "llvm/ExecutionEngine/SectionMemoryManager.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/LLVMContext.h" @@ -32,7 +32,7 @@ namespace orc { class KaleidoscopeJIT { private: - std::unique_ptr TPC; + std::unique_ptr EPC; std::unique_ptr ES; DataLayout DL; @@ -44,10 +44,10 @@ private: JITDylib &MainJD; public: - KaleidoscopeJIT(std::unique_ptr TPC, + KaleidoscopeJIT(std::unique_ptr EPC, std::unique_ptr ES, JITTargetMachineBuilder JTMB, DataLayout DL) - : TPC(std::move(TPC)), ES(std::move(ES)), DL(std::move(DL)), + : EPC(std::move(EPC)), ES(std::move(ES)), DL(std::move(DL)), Mangle(*this->ES, this->DL), ObjectLayer(*this->ES, []() { return std::make_unique(); }), @@ -66,19 +66,19 @@ public: static Expected> Create() { auto SSP = std::make_shared(); - auto TPC = SelfTargetProcessControl::Create(SSP); - if (!TPC) - return TPC.takeError(); + auto EPC = SelfExecutorProcessControl::Create(SSP); + if (!EPC) + return EPC.takeError(); auto ES = std::make_unique(std::move(SSP)); - JITTargetMachineBuilder JTMB((*TPC)->getTargetTriple()); + JITTargetMachineBuilder JTMB((*EPC)->getTargetTriple()); auto DL = JTMB.getDefaultDataLayoutForTarget(); if (!DL) return DL.takeError(); - return std::make_unique(std::move(*TPC), std::move(ES), + return std::make_unique(std::move(*EPC), std::move(ES), std::move(JTMB), std::move(*DL)); } diff --git a/examples/OrcV2Examples/LLJITWithRemoteDebugging/RemoteJITUtils.cpp b/examples/OrcV2Examples/LLJITWithRemoteDebugging/RemoteJITUtils.cpp index abce14de0fe..8e4a2835566 100644 --- a/examples/OrcV2Examples/LLJITWithRemoteDebugging/RemoteJITUtils.cpp +++ b/examples/OrcV2Examples/LLJITWithRemoteDebugging/RemoteJITUtils.cpp @@ -9,10 +9,10 @@ #include "RemoteJITUtils.h" #include "llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h" -#include "llvm/ExecutionEngine/Orc/OrcRPCTargetProcessControl.h" +#include "llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h" +#include "llvm/ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.h" +#include "llvm/ExecutionEngine/Orc/OrcRPCExecutorProcessControl.h" #include "llvm/ExecutionEngine/Orc/Shared/RPCUtils.h" -#include "llvm/ExecutionEngine/Orc/TPCDebugObjectRegistrar.h" -#include "llvm/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.h" #include "llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" @@ -31,25 +31,25 @@ using namespace llvm::orc; namespace llvm { namespace orc { -class RemoteTargetProcessControl - : public OrcRPCTargetProcessControlBase< +class RemoteExecutorProcessControl + : public OrcRPCExecutorProcessControlBase< shared::MultiThreadedRPCEndpoint> { public: using RPCChannel = JITLinkExecutor::RPCChannel; using RPCEndpoint = shared::MultiThreadedRPCEndpoint; private: - using ThisT = RemoteTargetProcessControl; - using BaseT = OrcRPCTargetProcessControlBase; - using MemoryAccess = OrcRPCTPCMemoryAccess; - using MemoryManager = OrcRPCTPCJITLinkMemoryManager; + using ThisT = RemoteExecutorProcessControl; + using BaseT = OrcRPCExecutorProcessControlBase; + using MemoryAccess = OrcRPCEPCMemoryAccess; + using MemoryManager = OrcRPCEPCJITLinkMemoryManager; public: - using BaseT::initializeORCRPCTPCBase; + using BaseT::initializeORCRPCEPCBase; - RemoteTargetProcessControl(ExecutionSession &ES, - std::unique_ptr Channel, - std::unique_ptr Endpoint); + RemoteExecutorProcessControl(ExecutionSession &ES, + std::unique_ptr Channel, + std::unique_ptr Endpoint); void initializeMemoryManagement(); Error disconnect() override; @@ -63,7 +63,7 @@ private: std::thread ListenerThread; }; -RemoteTargetProcessControl::RemoteTargetProcessControl( +RemoteExecutorProcessControl::RemoteExecutorProcessControl( ExecutionSession &ES, std::unique_ptr Channel, std::unique_ptr Endpoint) : BaseT(ES.getSymbolStringPool(), *Endpoint, @@ -80,7 +80,7 @@ RemoteTargetProcessControl::RemoteTargetProcessControl( }); } -void RemoteTargetProcessControl::initializeMemoryManagement() { +void RemoteExecutorProcessControl::initializeMemoryManagement() { OwnedMemAccess = std::make_unique(*this); OwnedMemMgr = std::make_unique(*this); @@ -89,7 +89,7 @@ void RemoteTargetProcessControl::initializeMemoryManagement() { MemMgr = OwnedMemMgr.get(); } -Error RemoteTargetProcessControl::disconnect() { +Error RemoteExecutorProcessControl::disconnect() { std::promise P; auto F = P.get_future(); auto Err = closeConnection([&](Error Err) -> Error { @@ -109,11 +109,11 @@ JITLinkExecutor::~JITLinkExecutor() = default; Expected> JITLinkExecutor::operator()(ExecutionSession &ES, const Triple &TT) { - return std::make_unique(ES, TPC->getMemMgr()); + return std::make_unique(ES, EPC->getMemMgr()); } Error JITLinkExecutor::addDebugSupport(ObjectLayer &ObjLayer) { - auto Registrar = createJITLoaderGDBRegistrar(*TPC); + auto Registrar = createJITLoaderGDBRegistrar(*EPC); if (!Registrar) return Registrar.takeError(); @@ -126,18 +126,18 @@ Error JITLinkExecutor::addDebugSupport(ObjectLayer &ObjLayer) { Expected> JITLinkExecutor::loadDylib(StringRef RemotePath) { - if (auto Handle = TPC->loadDylib(RemotePath.data())) - return std::make_unique(*TPC, *Handle); + if (auto Handle = EPC->loadDylib(RemotePath.data())) + return std::make_unique(*EPC, *Handle); else return Handle.takeError(); } Expected JITLinkExecutor::runAsMain(JITEvaluatedSymbol MainSym, ArrayRef Args) { - return TPC->runAsMain(MainSym.getAddress(), Args); + return EPC->runAsMain(MainSym.getAddress(), Args); } -Error JITLinkExecutor::disconnect() { return TPC->disconnect(); } +Error JITLinkExecutor::disconnect() { return EPC->disconnect(); } static std::string defaultPath(const char *HostArgv0, StringRef ExecutorName) { // This just needs to be some symbol in the binary; C++ doesn't @@ -173,8 +173,8 @@ JITLinkExecutor::CreateLocal(std::string ExecutablePath) { } TCPSocketJITLinkExecutor::TCPSocketJITLinkExecutor( - std::unique_ptr TPC) { - this->TPC = std::move(TPC); + std::unique_ptr EPC) { + this->EPC = std::move(EPC); } #ifndef LLVM_ON_UNIX @@ -249,16 +249,16 @@ Error ChildProcessJITLinkExecutor::launch(ExecutionSession &ES) { auto Channel = std::make_unique(FromExecutor[ReadEnd], ToExecutor[WriteEnd]); - auto Endpoint = - std::make_unique(*Channel, true); + auto Endpoint = std::make_unique( + *Channel, true); - TPC = std::make_unique(ES, std::move(Channel), - std::move(Endpoint)); + EPC = std::make_unique(ES, std::move(Channel), + std::move(Endpoint)); - if (auto Err = TPC->initializeORCRPCTPCBase()) - return joinErrors(std::move(Err), TPC->disconnect()); + if (auto Err = EPC->initializeORCRPCEPCBase()) + return joinErrors(std::move(Err), EPC->disconnect()); - TPC->initializeMemoryManagement(); + EPC->initializeMemoryManagement(); shared::registerStringError(); return Error::success(); @@ -328,20 +328,20 @@ JITLinkExecutor::ConnectTCPSocket(StringRef NetworkAddress, return CreateErr(toString(SockFD.takeError())); auto Channel = std::make_unique(*SockFD, *SockFD); - auto Endpoint = - std::make_unique(*Channel, true); + auto Endpoint = std::make_unique( + *Channel, true); - auto TPC = std::make_unique( + auto EPC = std::make_unique( ES, std::move(Channel), std::move(Endpoint)); - if (auto Err = TPC->initializeORCRPCTPCBase()) - return joinErrors(std::move(Err), TPC->disconnect()); + if (auto Err = EPC->initializeORCRPCEPCBase()) + return joinErrors(std::move(Err), EPC->disconnect()); - TPC->initializeMemoryManagement(); + EPC->initializeMemoryManagement(); shared::registerStringError(); return std::unique_ptr( - new TCPSocketJITLinkExecutor(std::move(TPC))); + new TCPSocketJITLinkExecutor(std::move(EPC))); } #endif diff --git a/examples/OrcV2Examples/LLJITWithRemoteDebugging/RemoteJITUtils.h b/examples/OrcV2Examples/LLJITWithRemoteDebugging/RemoteJITUtils.h index e629c0e036f..baa376003a6 100644 --- a/examples/OrcV2Examples/LLJITWithRemoteDebugging/RemoteJITUtils.h +++ b/examples/OrcV2Examples/LLJITWithRemoteDebugging/RemoteJITUtils.h @@ -6,7 +6,8 @@ // //===----------------------------------------------------------------------===// // -// Utilities for TargetProcessControl-based remote JITing with Orc and JITLink. +// Utilities for ExecutorProcessControl-based remote JITing with Orc and +// JITLink. // //===----------------------------------------------------------------------===// @@ -36,7 +37,7 @@ namespace llvm { namespace orc { class ChildProcessJITLinkExecutor; -class RemoteTargetProcessControl; +class RemoteExecutorProcessControl; class TCPSocketJITLinkExecutor; class JITLinkExecutor { @@ -73,7 +74,7 @@ public: virtual ~JITLinkExecutor(); protected: - std::unique_ptr TPC; + std::unique_ptr EPC; JITLinkExecutor(); }; @@ -100,7 +101,7 @@ private: /// JITLinkExecutor connected through a TCP socket. class TCPSocketJITLinkExecutor : public JITLinkExecutor { private: - TCPSocketJITLinkExecutor(std::unique_ptr TPC); + TCPSocketJITLinkExecutor(std::unique_ptr EPC); friend class JITLinkExecutor; }; diff --git a/examples/OrcV2Examples/LLJITWithTargetProcessControl/LLJITWithTargetProcessControl.cpp b/examples/OrcV2Examples/LLJITWithTargetProcessControl/LLJITWithTargetProcessControl.cpp index 4e36631ef97..953d90e4c06 100644 --- a/examples/OrcV2Examples/LLJITWithTargetProcessControl/LLJITWithTargetProcessControl.cpp +++ b/examples/OrcV2Examples/LLJITWithTargetProcessControl/LLJITWithTargetProcessControl.cpp @@ -1,4 +1,4 @@ -//===--- LLJITWithLazyReexports.cpp - LLJIT example with custom laziness --===// +//===- LLJITWithExecutorProcessControl.cpp - LLJIT example with EPC utils -===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -22,12 +22,12 @@ #include "llvm/ADT/StringMap.h" #include "llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h" +#include "llvm/ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.h" +#include "llvm/ExecutionEngine/Orc/EPCIndirectionUtils.h" +#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h" #include "llvm/ExecutionEngine/Orc/LLJIT.h" #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h" #include "llvm/ExecutionEngine/Orc/OrcABISupport.h" -#include "llvm/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.h" -#include "llvm/ExecutionEngine/Orc/TPCIndirectionUtils.h" -#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h" #include "llvm/Support/InitLLVM.h" #include "llvm/Support/TargetSelect.h" #include "llvm/Support/raw_ostream.h" @@ -105,8 +105,8 @@ static void *reenter(void *Ctx, void *TrampolineAddr) { std::promise LandingAddressP; auto LandingAddressF = LandingAddressP.get_future(); - auto *TPCIU = static_cast(Ctx); - TPCIU->getLazyCallThroughManager().resolveTrampolineLandingAddress( + auto *EPCIU = static_cast(Ctx); + EPCIU->getLazyCallThroughManager().resolveTrampolineLandingAddress( pointerToJITTargetAddress(TrampolineAddr), [&](JITTargetAddress LandingAddress) { LandingAddressP.set_value( @@ -135,8 +135,8 @@ int main(int argc, char *argv[]) { // (1) Create LLJIT instance. auto SSP = std::make_shared(); - auto TPC = ExitOnErr(SelfTargetProcessControl::Create(std::move(SSP))); - auto J = ExitOnErr(LLJITBuilder().setTargetProcessControl(*TPC).create()); + auto EPC = ExitOnErr(SelfExecutorProcessControl::Create(std::move(SSP))); + auto J = ExitOnErr(LLJITBuilder().setExecutorProcessControl(*EPC).create()); // (2) Install transform to print modules as they are compiled: J->getIRTransformLayer().setTransform( @@ -147,14 +147,14 @@ int main(int argc, char *argv[]) { }); // (3) Create stubs and call-through managers: - auto TPCIU = ExitOnErr(TPCIndirectionUtils::Create(*TPC)); - ExitOnErr(TPCIU->writeResolverBlock(pointerToJITTargetAddress(&reenter), - pointerToJITTargetAddress(TPCIU.get()))); - TPCIU->createLazyCallThroughManager( + auto EPCIU = ExitOnErr(EPCIndirectionUtils::Create(*EPC)); + ExitOnErr(EPCIU->writeResolverBlock(pointerToJITTargetAddress(&reenter), + pointerToJITTargetAddress(EPCIU.get()))); + EPCIU->createLazyCallThroughManager( J->getExecutionSession(), pointerToJITTargetAddress(&reportErrorAndExit)); - auto ISM = TPCIU->createIndirectStubsManager(); + auto ISM = EPCIU->createIndirectStubsManager(); J->getMainJITDylib().addGenerator( - ExitOnErr(TPCDynamicLibrarySearchGenerator::GetForTargetProcess(*TPC))); + ExitOnErr(EPCDynamicLibrarySearchGenerator::GetForTargetProcess(*EPC))); // (4) Add modules. ExitOnErr(J->addIRModule(ExitOnErr(parseExampleModule(FooMod, "foo-mod")))); @@ -171,7 +171,7 @@ int main(int argc, char *argv[]) { {Mangle("bar_body"), JITSymbolFlags::Exported | JITSymbolFlags::Callable}}}); ExitOnErr(J->getMainJITDylib().define( - lazyReexports(TPCIU->getLazyCallThroughManager(), *ISM, + lazyReexports(EPCIU->getLazyCallThroughManager(), *ISM, J->getMainJITDylib(), std::move(ReExports)))); // (6) Dump the ExecutionSession state. diff --git a/include/llvm-c/LLJIT.h b/include/llvm-c/LLJIT.h index d8156ccc1f5..bd98cfbab83 100644 --- a/include/llvm-c/LLJIT.h +++ b/include/llvm-c/LLJIT.h @@ -208,7 +208,7 @@ LLVMErrorRef LLVMOrcLLJITAddLLVMIRModuleWithRT(LLVMOrcLLJITRef J, * This operation does not take ownership of the Name argument. */ LLVMErrorRef LLVMOrcLLJITLookup(LLVMOrcLLJITRef J, - LLVMOrcJITTargetAddress *Result, + LLVMOrcExecutorAddress *Result, const char *Name); /** diff --git a/include/llvm-c/Orc.h b/include/llvm-c/Orc.h index 75af7320ce2..1d26d7ca303 100644 --- a/include/llvm-c/Orc.h +++ b/include/llvm-c/Orc.h @@ -34,10 +34,15 @@ LLVM_C_EXTERN_C_BEGIN /** - * Represents an address in the target process. + * Represents an address in the executor process. */ typedef uint64_t LLVMOrcJITTargetAddress; +/** + * Represents an address in the executor process. + */ +typedef uint64_t LLVMOrcExecutorAddress; + /** * Represents generic linkage flags for a symbol definition. */ @@ -65,7 +70,7 @@ typedef struct { * Represents an evaluated symbol address and flags. */ typedef struct { - LLVMOrcJITTargetAddress Address; + LLVMOrcExecutorAddress Address; LLVMJITSymbolFlags Flags; } LLVMJITEvaluatedSymbol; diff --git a/include/llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h b/include/llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h index 2e332130d26..455f5a8287f 100644 --- a/include/llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h +++ b/include/llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h @@ -16,8 +16,8 @@ #include "llvm/ADT/Triple.h" #include "llvm/ExecutionEngine/JITLink/JITLink.h" #include "llvm/ExecutionEngine/Orc/Core.h" +#include "llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h" #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h" -#include "llvm/ExecutionEngine/Orc/TPCDebugObjectRegistrar.h" #include "llvm/Support/Error.h" #include "llvm/Support/Memory.h" #include "llvm/Support/MemoryBufferRef.h" diff --git a/include/llvm/ExecutionEngine/Orc/TPCDebugObjectRegistrar.h b/include/llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h similarity index 54% rename from include/llvm/ExecutionEngine/Orc/TPCDebugObjectRegistrar.h rename to include/llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h index 7995b0cb35d..dc42c74a612 100644 --- a/include/llvm/ExecutionEngine/Orc/TPCDebugObjectRegistrar.h +++ b/include/llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h @@ -1,4 +1,4 @@ -//===- TPCDebugObjectRegistrar.h - TPC-based debug registration -*- C++ -*-===// +//===- EPCDebugObjectRegistrar.h - EPC-based debug registration -*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,15 +6,15 @@ // //===----------------------------------------------------------------------===// // -// TargetProcessControl based registration of debug objects. +// ExecutorProcessControl based registration of debug objects. // //===----------------------------------------------------------------------===// -#ifndef LLVM_EXECUTIONENGINE_ORC_TPCDEBUGOBJECTREGISTRAR_H -#define LLVM_EXECUTIONENGINE_ORC_TPCDEBUGOBJECTREGISTRAR_H +#ifndef LLVM_EXECUTIONENGINE_ORC_EPCDEBUGOBJECTREGISTRAR_H +#define LLVM_EXECUTIONENGINE_ORC_EPCDEBUGOBJECTREGISTRAR_H #include "llvm/ExecutionEngine/JITSymbol.h" -#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h" +#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h" #include "llvm/Support/Error.h" #include "llvm/Support/Memory.h" @@ -27,38 +27,38 @@ using namespace llvm::orc::shared; namespace llvm { namespace orc { -/// Abstract interface for registering debug objects in the target process. +/// Abstract interface for registering debug objects in the executor process. class DebugObjectRegistrar { public: virtual Error registerDebugObject(sys::MemoryBlock) = 0; virtual ~DebugObjectRegistrar() {} }; -/// Use TargetProcessControl to register debug objects locally or in a remote -/// target process. -class TPCDebugObjectRegistrar : public DebugObjectRegistrar { +/// Use ExecutorProcessControl to register debug objects locally or in a remote +/// executor process. +class EPCDebugObjectRegistrar : public DebugObjectRegistrar { public: - TPCDebugObjectRegistrar(TargetProcessControl &TPC, + EPCDebugObjectRegistrar(ExecutorProcessControl &EPC, JITTargetAddress RegisterFn) - : TPC(TPC), RegisterFn(RegisterFn) {} + : EPC(EPC), RegisterFn(RegisterFn) {} Error registerDebugObject(sys::MemoryBlock TargetMem) override { return WrapperFunction::call( - TPCCaller(TPC, RegisterFn), pointerToJITTargetAddress(TargetMem.base()), + EPCCaller(EPC, RegisterFn), pointerToJITTargetAddress(TargetMem.base()), static_cast(TargetMem.allocatedSize())); } private: - TargetProcessControl &TPC; + ExecutorProcessControl &EPC; JITTargetAddress RegisterFn; }; -/// Create a TargetProcessControl-based DebugObjectRegistrar that emits debug +/// Create a ExecutorProcessControl-based DebugObjectRegistrar that emits debug /// objects to the GDB JIT interface. -Expected> -createJITLoaderGDBRegistrar(TargetProcessControl &TPC); +Expected> +createJITLoaderGDBRegistrar(ExecutorProcessControl &EPC); } // end namespace orc } // end namespace llvm -#endif // LLVM_EXECUTIONENGINE_ORC_TDEBUGOBJECTREGISTRAR_H +#endif // LLVM_EXECUTIONENGINE_ORC_EPCDEBUGOBJECTREGISTRAR_H diff --git a/include/llvm/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.h b/include/llvm/ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.h similarity index 63% rename from include/llvm/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.h rename to include/llvm/ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.h index ed4f6080bb4..08b5ab05ba7 100644 --- a/include/llvm/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.h +++ b/include/llvm/ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.h @@ -1,4 +1,4 @@ -//===------------ TPCDynamicLibrarySearchGenerator.h ------------*- C++ -*-===// +//===------------ EPCDynamicLibrarySearchGenerator.h ------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,21 +6,21 @@ // //===----------------------------------------------------------------------===// // -// Support loading and searching of dynamic libraries in a target process via -// the TargetProcessControl class. +// Support loading and searching of dynamic libraries in an executor process +// via the ExecutorProcessControl class. // //===----------------------------------------------------------------------===// -#ifndef LLVM_EXECUTIONENGINE_ORC_TPCDYNAMICLIBRARYSEARCHGENERATOR_H -#define LLVM_EXECUTIONENGINE_ORC_TPCDYNAMICLIBRARYSEARCHGENERATOR_H +#ifndef LLVM_EXECUTIONENGINE_ORC_EPCDYNAMICLIBRARYSEARCHGENERATOR_H +#define LLVM_EXECUTIONENGINE_ORC_EPCDYNAMICLIBRARYSEARCHGENERATOR_H #include "llvm/ADT/FunctionExtras.h" -#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h" +#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h" namespace llvm { namespace orc { -class TPCDynamicLibrarySearchGenerator : public DefinitionGenerator { +class EPCDynamicLibrarySearchGenerator : public DefinitionGenerator { public: using SymbolPredicate = unique_function; @@ -30,24 +30,24 @@ public: /// If the Allow predicate is given then only symbols matching the predicate /// will be searched for. If the predicate is not given then all symbols will /// be searched for. - TPCDynamicLibrarySearchGenerator(TargetProcessControl &TPC, + EPCDynamicLibrarySearchGenerator(ExecutorProcessControl &EPC, tpctypes::DylibHandle H, SymbolPredicate Allow = SymbolPredicate()) - : TPC(TPC), H(H), Allow(std::move(Allow)) {} + : EPC(EPC), H(H), Allow(std::move(Allow)) {} /// Permanently loads the library at the given path and, on success, returns /// a DynamicLibrarySearchGenerator that will search it for symbol definitions /// in the library. On failure returns the reason the library failed to load. - static Expected> - Load(TargetProcessControl &TPC, const char *LibraryPath, + static Expected> + Load(ExecutorProcessControl &EPC, const char *LibraryPath, SymbolPredicate Allow = SymbolPredicate()); - /// Creates a TPCDynamicLibrarySearchGenerator that searches for symbols in + /// Creates a EPCDynamicLibrarySearchGenerator that searches for symbols in /// the target process. - static Expected> - GetForTargetProcess(TargetProcessControl &TPC, + static Expected> + GetForTargetProcess(ExecutorProcessControl &EPC, SymbolPredicate Allow = SymbolPredicate()) { - return Load(TPC, nullptr, std::move(Allow)); + return Load(EPC, nullptr, std::move(Allow)); } Error tryToGenerate(LookupState &LS, LookupKind K, JITDylib &JD, @@ -55,7 +55,7 @@ public: const SymbolLookupSet &Symbols) override; private: - TargetProcessControl &TPC; + ExecutorProcessControl &EPC; tpctypes::DylibHandle H; SymbolPredicate Allow; }; @@ -63,4 +63,4 @@ private: } // end namespace orc } // end namespace llvm -#endif // LLVM_EXECUTIONENGINE_ORC_TPCDYNAMICLIBRARYSEARCHGENERATOR_H +#endif // LLVM_EXECUTIONENGINE_ORC_EPCDYNAMICLIBRARYSEARCHGENERATOR_H diff --git a/include/llvm/ExecutionEngine/Orc/TPCEHFrameRegistrar.h b/include/llvm/ExecutionEngine/Orc/EPCEHFrameRegistrar.h similarity index 59% rename from include/llvm/ExecutionEngine/Orc/TPCEHFrameRegistrar.h rename to include/llvm/ExecutionEngine/Orc/EPCEHFrameRegistrar.h index 519f818907f..f230cfcac41 100644 --- a/include/llvm/ExecutionEngine/Orc/TPCEHFrameRegistrar.h +++ b/include/llvm/ExecutionEngine/Orc/EPCEHFrameRegistrar.h @@ -1,4 +1,4 @@ -//===-- TPCEHFrameRegistrar.h - TPC based eh-frame registration -*- C++ -*-===// +//===-- EPCEHFrameRegistrar.h - EPC based eh-frame registration -*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,35 +6,35 @@ // //===----------------------------------------------------------------------===// // -// TargetProcessControl based eh-frame registration. +// ExecutorProcessControl based eh-frame registration. // //===----------------------------------------------------------------------===// -#ifndef LLVM_EXECUTIONENGINE_ORC_TPCEHFRAMEREGISTRAR_H -#define LLVM_EXECUTIONENGINE_ORC_TPCEHFRAMEREGISTRAR_H +#ifndef LLVM_EXECUTIONENGINE_ORC_EPCEHFRAMEREGISTRAR_H +#define LLVM_EXECUTIONENGINE_ORC_EPCEHFRAMEREGISTRAR_H #include "llvm/ExecutionEngine/JITLink/EHFrameSupport.h" -#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h" +#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h" namespace llvm { namespace orc { /// Register/Deregisters EH frames in a remote process via a -/// TargetProcessControl instance. -class TPCEHFrameRegistrar : public jitlink::EHFrameRegistrar { +/// ExecutorProcessControl instance. +class EPCEHFrameRegistrar : public jitlink::EHFrameRegistrar { public: - /// Create from a TargetProcessControl instance alone. This will use - /// the TPC's lookupSymbols method to find the registration/deregistration + /// Create from a ExecutorProcessControl instance alone. This will use + /// the EPC's lookupSymbols method to find the registration/deregistration /// funciton addresses by name. - static Expected> - Create(TargetProcessControl &TPC); + static Expected> + Create(ExecutorProcessControl &EPC); - /// Create a TPCEHFrameRegistrar with the given TargetProcessControl + /// Create a EPCEHFrameRegistrar with the given ExecutorProcessControl /// object and registration/deregistration function addresses. - TPCEHFrameRegistrar(TargetProcessControl &TPC, + EPCEHFrameRegistrar(ExecutorProcessControl &EPC, JITTargetAddress RegisterEHFrameWrapperFnAddr, JITTargetAddress DeregisterEHFRameWrapperFnAddr) - : TPC(TPC), RegisterEHFrameWrapperFnAddr(RegisterEHFrameWrapperFnAddr), + : EPC(EPC), RegisterEHFrameWrapperFnAddr(RegisterEHFrameWrapperFnAddr), DeregisterEHFrameWrapperFnAddr(DeregisterEHFRameWrapperFnAddr) {} Error registerEHFrames(JITTargetAddress EHFrameSectionAddr, @@ -43,7 +43,7 @@ public: size_t EHFrameSectionSize) override; private: - TargetProcessControl &TPC; + ExecutorProcessControl &EPC; JITTargetAddress RegisterEHFrameWrapperFnAddr; JITTargetAddress DeregisterEHFrameWrapperFnAddr; }; @@ -51,4 +51,4 @@ private: } // end namespace orc } // end namespace llvm -#endif // LLVM_EXECUTIONENGINE_ORC_TPCEHFRAMEREGISTRAR_H +#endif // LLVM_EXECUTIONENGINE_ORC_EPCEHFRAMEREGISTRAR_H diff --git a/include/llvm/ExecutionEngine/Orc/TPCIndirectionUtils.h b/include/llvm/ExecutionEngine/Orc/EPCIndirectionUtils.h similarity index 78% rename from include/llvm/ExecutionEngine/Orc/TPCIndirectionUtils.h rename to include/llvm/ExecutionEngine/Orc/EPCIndirectionUtils.h index e7abd7fb90d..64f16d507c9 100644 --- a/include/llvm/ExecutionEngine/Orc/TPCIndirectionUtils.h +++ b/include/llvm/ExecutionEngine/Orc/EPCIndirectionUtils.h @@ -1,4 +1,4 @@ -//===--- TPCIndirectionUtils.h - TPC based indirection utils ----*- C++ -*-===// +//===--- EPCIndirectionUtils.h - EPC based indirection utils ----*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,12 +7,12 @@ //===----------------------------------------------------------------------===// // // Indirection utilities (stubs, trampolines, lazy call-throughs) that use the -// TargetProcessControl API to interact with the target process. +// ExecutorProcessControl API to interact with the executor process. // //===----------------------------------------------------------------------===// -#ifndef LLVM_EXECUTIONENGINE_ORC_TPCINDIRECTIONUTILS_H -#define LLVM_EXECUTIONENGINE_ORC_TPCINDIRECTIONUTILS_H +#ifndef LLVM_EXECUTIONENGINE_ORC_EPCINDIRECTIONUTILS_H +#define LLVM_EXECUTIONENGINE_ORC_EPCINDIRECTIONUTILS_H #include "llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h" #include "llvm/ExecutionEngine/Orc/IndirectionUtils.h" @@ -23,12 +23,12 @@ namespace llvm { namespace orc { -class TargetProcessControl; +class ExecutorProcessControl; -/// Provides TargetProcessControl based indirect stubs, trampoline pool and +/// Provides ExecutorProcessControl based indirect stubs, trampoline pool and /// lazy call through manager. -class TPCIndirectionUtils { - friend class TPCIndirectionUtilsAccess; +class EPCIndirectionUtils { + friend class EPCIndirectionUtilsAccess; public: /// ABI support base class. Used to write resolver, stub, and trampoline @@ -79,15 +79,15 @@ public: /// Create using the given ABI class. template - static std::unique_ptr - CreateWithABI(TargetProcessControl &TPC); + static std::unique_ptr + CreateWithABI(ExecutorProcessControl &EPC); - /// Create based on the TargetProcessControl triple. - static Expected> - Create(TargetProcessControl &TPC); + /// Create based on the ExecutorProcessControl triple. + static Expected> + Create(ExecutorProcessControl &EPC); - /// Return a reference to the TargetProcessControl object. - TargetProcessControl &getTargetProcessControl() const { return TPC; } + /// Return a reference to the ExecutorProcessControl object. + ExecutorProcessControl &getExecutorProcessControl() const { return EPC; } /// Return a reference to the ABISupport object for this instance. ABISupport &getABISupport() const { return *ABI; } @@ -96,7 +96,7 @@ public: /// prior to destruction of the class. Error cleanup(); - /// Write resolver code to the target process and return its address. + /// Write resolver code to the executor process and return its address. /// This must be called before any call to createTrampolinePool or /// createLazyCallThroughManager. Expected @@ -107,10 +107,10 @@ public: /// writeResolverBlock method has not previously been called. JITTargetAddress getResolverBlockAddress() const { return ResolverBlockAddr; } - /// Create an IndirectStubsManager for the target process. + /// Create an IndirectStubsManager for the executor process. std::unique_ptr createIndirectStubsManager(); - /// Create a TrampolinePool for the target process. + /// Create a TrampolinePool for the executor process. TrampolinePool &getTrampolinePool(); /// Create a LazyCallThroughManager. @@ -119,7 +119,7 @@ public: createLazyCallThroughManager(ExecutionSession &ES, JITTargetAddress ErrorHandlerAddr); - /// Create a LazyCallThroughManager for the target process. + /// Create a LazyCallThroughManager for the executor process. LazyCallThroughManager &getLazyCallThroughManager() { assert(LCTM && "createLazyCallThroughManager must be called first"); return *LCTM; @@ -139,14 +139,14 @@ private: using IndirectStubInfoVector = std::vector; - /// Create a TPCIndirectionUtils instance. - TPCIndirectionUtils(TargetProcessControl &TPC, + /// Create an EPCIndirectionUtils instance. + EPCIndirectionUtils(ExecutorProcessControl &EPC, std::unique_ptr ABI); Expected getIndirectStubs(unsigned NumStubs); - std::mutex TPCUIMutex; - TargetProcessControl &TPC; + std::mutex EPCUIMutex; + ExecutorProcessControl &EPC; std::unique_ptr ABI; JITTargetAddress ResolverBlockAddr; std::unique_ptr ResolverBlock; @@ -157,23 +157,23 @@ private: std::vector> IndirectStubAllocs; }; -/// This will call writeResolver on the given TPCIndirectionUtils instance +/// This will call writeResolver on the given EPCIndirectionUtils instance /// to set up re-entry via a function that will directly return the trampoline /// landing address. /// -/// The TPCIndirectionUtils' LazyCallThroughManager must have been previously -/// created via TPCIndirectionUtils::createLazyCallThroughManager. +/// The EPCIndirectionUtils' LazyCallThroughManager must have been previously +/// created via EPCIndirectionUtils::createLazyCallThroughManager. /// -/// The TPCIndirectionUtils' writeResolver method must not have been previously +/// The EPCIndirectionUtils' writeResolver method must not have been previously /// called. /// /// This function is experimental and likely subject to revision. -Error setUpInProcessLCTMReentryViaTPCIU(TPCIndirectionUtils &TPCIU); +Error setUpInProcessLCTMReentryViaEPCIU(EPCIndirectionUtils &EPCIU); namespace detail { template -class ABISupportImpl : public TPCIndirectionUtils::ABISupport { +class ABISupportImpl : public EPCIndirectionUtils::ABISupport { public: ABISupportImpl() : ABISupport(ORCABI::PointerSize, ORCABI::TrampolineSize, @@ -210,13 +210,13 @@ public: } // end namespace detail template -std::unique_ptr -TPCIndirectionUtils::CreateWithABI(TargetProcessControl &TPC) { - return std::unique_ptr(new TPCIndirectionUtils( - TPC, std::make_unique>())); +std::unique_ptr +EPCIndirectionUtils::CreateWithABI(ExecutorProcessControl &EPC) { + return std::unique_ptr(new EPCIndirectionUtils( + EPC, std::make_unique>())); } } // end namespace orc } // end namespace llvm -#endif // LLVM_EXECUTIONENGINE_ORC_TPCINDIRECTIONUTILS_H +#endif // LLVM_EXECUTIONENGINE_ORC_EPCINDIRECTIONUTILS_H diff --git a/include/llvm/ExecutionEngine/Orc/TargetProcessControl.h b/include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h similarity index 86% rename from include/llvm/ExecutionEngine/Orc/TargetProcessControl.h rename to include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h index a39495f5382..7969a8398c9 100644 --- a/include/llvm/ExecutionEngine/Orc/TargetProcessControl.h +++ b/include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h @@ -1,4 +1,4 @@ -//===--- TargetProcessControl.h - Target process control APIs ---*- C++ -*-===// +//===- ExecutorProcessControl.h - Executor process control APIs -*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,12 +6,12 @@ // //===----------------------------------------------------------------------===// // -// Utilities for interacting with target processes. +// Utilities for interacting with the executor processes. // //===----------------------------------------------------------------------===// -#ifndef LLVM_EXECUTIONENGINE_ORC_TARGETPROCESSCONTROL_H -#define LLVM_EXECUTIONENGINE_ORC_TARGETPROCESSCONTROL_H +#ifndef LLVM_EXECUTIONENGINE_ORC_EXECUTORPROCESSCONTROL_H +#define LLVM_EXECUTIONENGINE_ORC_EXECUTORPROCESSCONTROL_H #include "llvm/ADT/Optional.h" #include "llvm/ADT/StringRef.h" @@ -29,8 +29,8 @@ namespace llvm { namespace orc { -/// TargetProcessControl supports interaction with a JIT target process. -class TargetProcessControl { +/// ExecutorProcessControl supports interaction with a JIT target process. +class ExecutorProcessControl { public: /// APIs for manipulating memory in the target process. class MemoryAccess { @@ -99,7 +99,7 @@ public: const SymbolLookupSet &Symbols; }; - virtual ~TargetProcessControl(); + virtual ~ExecutorProcessControl(); /// Intern a symbol name in the SymbolStringPool. SymbolStringPtr intern(StringRef SymName) { return SSP->intern(SymName); } @@ -153,7 +153,7 @@ public: virtual Error disconnect() = 0; protected: - TargetProcessControl(std::shared_ptr SSP) + ExecutorProcessControl(std::shared_ptr SSP) : SSP(std::move(SSP)) {} std::shared_ptr SSP; @@ -163,33 +163,34 @@ protected: jitlink::JITLinkMemoryManager *MemMgr = nullptr; }; -/// Call a wrapper function via TargetProcessControl::runWrapper. -class TPCCaller { +/// Call a wrapper function via ExecutorProcessControl::runWrapper. +class EPCCaller { public: - TPCCaller(TargetProcessControl &TPC, JITTargetAddress WrapperFnAddr) - : TPC(TPC), WrapperFnAddr(WrapperFnAddr) {} + EPCCaller(ExecutorProcessControl &EPC, JITTargetAddress WrapperFnAddr) + : EPC(EPC), WrapperFnAddr(WrapperFnAddr) {} Expected operator()(const char *ArgData, size_t ArgSize) const { - return TPC.runWrapper(WrapperFnAddr, ArrayRef(ArgData, ArgSize)); + return EPC.runWrapper(WrapperFnAddr, ArrayRef(ArgData, ArgSize)); } private: - TargetProcessControl &TPC; + ExecutorProcessControl &EPC; JITTargetAddress WrapperFnAddr; }; -/// A TargetProcessControl implementation targeting the current process. -class SelfTargetProcessControl : public TargetProcessControl, - private TargetProcessControl::MemoryAccess { +/// A ExecutorProcessControl implementation targeting the current process. +class SelfExecutorProcessControl + : public ExecutorProcessControl, + private ExecutorProcessControl::MemoryAccess { public: - SelfTargetProcessControl( + SelfExecutorProcessControl( std::shared_ptr SSP, Triple TargetTriple, unsigned PageSize, std::unique_ptr MemMgr); - /// Create a SelfTargetProcessControl with the given memory manager. + /// Create a SelfExecutorProcessControl with the given memory manager. /// If no memory manager is given a jitlink::InProcessMemoryManager will /// be used by default. - static Expected> + static Expected> Create(std::shared_ptr SSP, std::unique_ptr MemMgr = nullptr); @@ -230,4 +231,4 @@ private: } // end namespace orc } // end namespace llvm -#endif // LLVM_EXECUTIONENGINE_ORC_TARGETPROCESSCONTROL_H +#endif // LLVM_EXECUTIONENGINE_ORC_EXECUTORPROCESSCONTROL_H diff --git a/include/llvm/ExecutionEngine/Orc/LLJIT.h b/include/llvm/ExecutionEngine/Orc/LLJIT.h index 6eb3d0c3f96..50a2d95624c 100644 --- a/include/llvm/ExecutionEngine/Orc/LLJIT.h +++ b/include/llvm/ExecutionEngine/Orc/LLJIT.h @@ -29,7 +29,7 @@ namespace orc { class LLJITBuilderState; class LLLazyJITBuilderState; class ObjectTransformLayer; -class TargetProcessControl; +class ExecutorProcessControl; /// A pre-fabricated ORC JIT stack that can serve as an alternative to MCJIT. /// @@ -267,7 +267,7 @@ public: CompileFunctionCreator CreateCompileFunction; PlatformSetupFunction SetUpPlatform; unsigned NumCompileThreads = 0; - TargetProcessControl *TPC = nullptr; + ExecutorProcessControl *EPC = nullptr; /// Called prior to JIT class construcion to fix up defaults. Error prepareForConstruction(); @@ -350,14 +350,14 @@ public: return impl(); } - /// Set a TargetProcessControl object. + /// Set an ExecutorProcessControl object. /// /// If the platform uses ObjectLinkingLayer by default and no - /// ObjectLinkingLayerCreator has been set then the TargetProcessControl + /// ObjectLinkingLayerCreator has been set then the ExecutorProcessControl /// object will be used to supply the memory manager for the /// ObjectLinkingLayer. - SetterImpl &setTargetProcessControl(TargetProcessControl &TPC) { - impl().TPC = &TPC; + SetterImpl &setExecutorProcessControl(ExecutorProcessControl &EPC) { + impl().EPC = &EPC; return impl(); } diff --git a/include/llvm/ExecutionEngine/Orc/OrcRPCTargetProcessControl.h b/include/llvm/ExecutionEngine/Orc/OrcRPCExecutorProcessControl.h similarity index 90% rename from include/llvm/ExecutionEngine/Orc/OrcRPCTargetProcessControl.h rename to include/llvm/ExecutionEngine/Orc/OrcRPCExecutorProcessControl.h index d42c5c4d6dd..0b5ee262bb7 100644 --- a/include/llvm/ExecutionEngine/Orc/OrcRPCTargetProcessControl.h +++ b/include/llvm/ExecutionEngine/Orc/OrcRPCExecutorProcessControl.h @@ -1,4 +1,4 @@ -//===--- OrcRPCTargetProcessControl.h - Remote target control ---*- C++ -*-===// +//===-- OrcRPCExecutorProcessControl.h - Remote target control --*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,17 +6,17 @@ // //===----------------------------------------------------------------------===// // -// Utilities for interacting with target processes. +// Executor control via ORC RPC. // //===----------------------------------------------------------------------===// -#ifndef LLVM_EXECUTIONENGINE_ORC_ORCRPCTARGETPROCESSCONTROL_H -#define LLVM_EXECUTIONENGINE_ORC_ORCRPCTARGETPROCESSCONTROL_H +#ifndef LLVM_EXECUTIONENGINE_ORC_ORCRPCEXECUTORPROCESSCONTROL_H +#define LLVM_EXECUTIONENGINE_ORC_ORCRPCEXECUTORPROCESSCONTROL_H +#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h" #include "llvm/ExecutionEngine/Orc/Shared/RPCUtils.h" #include "llvm/ExecutionEngine/Orc/Shared/RawByteChannel.h" #include "llvm/ExecutionEngine/Orc/TargetProcess/OrcRPCTPCServer.h" -#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h" #include "llvm/Support/MSVCErrorWorkarounds.h" namespace llvm { @@ -24,8 +24,8 @@ namespace orc { /// JITLinkMemoryManager implementation for a process connected via an ORC RPC /// endpoint. -template -class OrcRPCTPCJITLinkMemoryManager : public jitlink::JITLinkMemoryManager { +template +class OrcRPCEPCJITLinkMemoryManager : public jitlink::JITLinkMemoryManager { private: struct HostAlloc { std::unique_ptr Mem; @@ -43,7 +43,7 @@ private: public: class OrcRPCAllocation : public Allocation { public: - OrcRPCAllocation(OrcRPCTPCJITLinkMemoryManager &Parent, + OrcRPCAllocation(OrcRPCEPCJITLinkMemoryManager &Parent, HostAllocMap HostAllocs, TargetAllocMap TargetAllocs) : Parent(Parent), HostAllocs(std::move(HostAllocs)), TargetAllocs(std::move(TargetAllocs)) { @@ -140,12 +140,12 @@ public: } private: - OrcRPCTPCJITLinkMemoryManager &Parent; + OrcRPCEPCJITLinkMemoryManager &Parent; HostAllocMap HostAllocs; TargetAllocMap TargetAllocs; }; - OrcRPCTPCJITLinkMemoryManager(OrcRPCTPCImplT &Parent) : Parent(Parent) {} + OrcRPCEPCJITLinkMemoryManager(OrcRPCEPCImplT &Parent) : Parent(Parent) {} Expected> allocate(const jitlink::JITLinkDylib *JD, @@ -216,19 +216,19 @@ public: private: void reportError(Error Err) { Parent.reportError(std::move(Err)); } - decltype(std::declval().getEndpoint()) getEndpoint() { + decltype(std::declval().getEndpoint()) getEndpoint() { return Parent.getEndpoint(); } - OrcRPCTPCImplT &Parent; + OrcRPCEPCImplT &Parent; }; -/// TargetProcessControl::MemoryAccess implementation for a process connected +/// ExecutorProcessControl::MemoryAccess implementation for a process connected /// via an ORC RPC endpoint. -template -class OrcRPCTPCMemoryAccess : public TargetProcessControl::MemoryAccess { +template +class OrcRPCEPCMemoryAccess : public ExecutorProcessControl::MemoryAccess { public: - OrcRPCTPCMemoryAccess(OrcRPCTPCImplT &Parent) : Parent(Parent) {} + OrcRPCEPCMemoryAccess(OrcRPCEPCImplT &Parent) : Parent(Parent) {} void writeUInt8s(ArrayRef Ws, WriteResultFn OnWriteComplete) override { @@ -269,20 +269,20 @@ private: } } - OrcRPCTPCImplT &Parent; + OrcRPCEPCImplT &Parent; }; -// TargetProcessControl for a process connected via an ORC RPC Endpoint. +// ExecutorProcessControl for a process connected via an ORC RPC Endpoint. template -class OrcRPCTargetProcessControlBase : public TargetProcessControl { +class OrcRPCExecutorProcessControlBase : public ExecutorProcessControl { public: using ErrorReporter = unique_function; using OnCloseConnectionFunction = unique_function; - OrcRPCTargetProcessControlBase(std::shared_ptr SSP, - RPCEndpointT &EP, ErrorReporter ReportError) - : TargetProcessControl(std::move(SSP)), + OrcRPCExecutorProcessControlBase(std::shared_ptr SSP, + RPCEndpointT &EP, ErrorReporter ReportError) + : ExecutorProcessControl(std::move(SSP)), ReportError(std::move(ReportError)), EP(EP) {} void reportError(Error Err) { ReportError(std::move(Err)); } @@ -391,7 +391,7 @@ public: protected: /// Subclasses must call this during construction to initialize the /// TargetTriple and PageSize members. - Error initializeORCRPCTPCBase() { + Error initializeORCRPCEPCBase() { if (auto TripleOrErr = EP.template callB()) TargetTriple = Triple(*TripleOrErr); else @@ -413,4 +413,4 @@ private: } // end namespace orc } // end namespace llvm -#endif // LLVM_EXECUTIONENGINE_ORC_ORCRPCTARGETPROCESSCONTROL_H +#endif // LLVM_EXECUTIONENGINE_ORC_ORCRPCEXECUTORPROCESSCONTROL_H diff --git a/lib/ExecutionEngine/Orc/CMakeLists.txt b/lib/ExecutionEngine/Orc/CMakeLists.txt index edcdfb2b1c4..edf9b3ff9b3 100644 --- a/lib/ExecutionEngine/Orc/CMakeLists.txt +++ b/lib/ExecutionEngine/Orc/CMakeLists.txt @@ -4,6 +4,10 @@ add_llvm_component_library(LLVMOrcJIT Core.cpp DebugObjectManagerPlugin.cpp DebugUtils.cpp + EPCDynamicLibrarySearchGenerator.cpp + EPCDebugObjectRegistrar.cpp + EPCEHFrameRegistrar.cpp + EPCIndirectionUtils.cpp ExecutionUtils.cpp IndirectionUtils.cpp IRCompileLayer.cpp @@ -21,12 +25,8 @@ add_llvm_component_library(LLVMOrcJIT RTDyldObjectLinkingLayer.cpp Speculation.cpp SpeculateAnalyses.cpp - TargetProcessControl.cpp + ExecutorProcessControl.cpp ThreadSafeModule.cpp - TPCDebugObjectRegistrar.cpp - TPCDynamicLibrarySearchGenerator.cpp - TPCEHFrameRegistrar.cpp - TPCIndirectionUtils.cpp ADDITIONAL_HEADER_DIRS ${LLVM_MAIN_INCLUDE_DIR}/llvm/ExecutionEngine/Orc diff --git a/lib/ExecutionEngine/Orc/TPCDebugObjectRegistrar.cpp b/lib/ExecutionEngine/Orc/EPCDebugObjectRegistrar.cpp similarity index 61% rename from lib/ExecutionEngine/Orc/TPCDebugObjectRegistrar.cpp rename to lib/ExecutionEngine/Orc/EPCDebugObjectRegistrar.cpp index 29dc26292d4..803cf96f5bd 100644 --- a/lib/ExecutionEngine/Orc/TPCDebugObjectRegistrar.cpp +++ b/lib/ExecutionEngine/Orc/EPCDebugObjectRegistrar.cpp @@ -1,4 +1,4 @@ -//===----- TPCDebugObjectRegistrar.cpp - TPC-based debug registration -----===// +//===----- EPCDebugObjectRegistrar.cpp - EPC-based debug registration -----===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "llvm/ExecutionEngine/Orc/TPCDebugObjectRegistrar.h" +#include "llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h" #include "llvm/ExecutionEngine/Orc/Core.h" #include "llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h" @@ -15,21 +15,21 @@ namespace llvm { namespace orc { -Expected> -createJITLoaderGDBRegistrar(TargetProcessControl &TPC) { - auto ProcessHandle = TPC.loadDylib(nullptr); +Expected> +createJITLoaderGDBRegistrar(ExecutorProcessControl &EPC) { + auto ProcessHandle = EPC.loadDylib(nullptr); if (!ProcessHandle) return ProcessHandle.takeError(); SymbolStringPtr RegisterFn = - TPC.getTargetTriple().isOSBinFormatMachO() - ? TPC.intern("_llvm_orc_registerJITLoaderGDBWrapper") - : TPC.intern("llvm_orc_registerJITLoaderGDBWrapper"); + EPC.getTargetTriple().isOSBinFormatMachO() + ? EPC.intern("_llvm_orc_registerJITLoaderGDBWrapper") + : EPC.intern("llvm_orc_registerJITLoaderGDBWrapper"); SymbolLookupSet RegistrationSymbols; RegistrationSymbols.add(RegisterFn); - auto Result = TPC.lookupSymbols({{*ProcessHandle, RegistrationSymbols}}); + auto Result = EPC.lookupSymbols({{*ProcessHandle, RegistrationSymbols}}); if (!Result) return Result.takeError(); @@ -37,7 +37,7 @@ createJITLoaderGDBRegistrar(TargetProcessControl &TPC) { assert((*Result)[0].size() == 1 && "Unexpected number of addresses in result"); - return std::make_unique(TPC, (*Result)[0][0]); + return std::make_unique(EPC, (*Result)[0][0]); } } // namespace orc diff --git a/lib/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.cpp b/lib/ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.cpp similarity index 76% rename from lib/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.cpp rename to lib/ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.cpp index bbf3ada1d4b..9958a52f0e4 100644 --- a/lib/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.cpp +++ b/lib/ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.cpp @@ -1,4 +1,4 @@ -//===---------------- TPCDynamicLibrarySearchGenerator.cpp ----------------===// +//===---------------- EPCDynamicLibrarySearchGenerator.cpp ----------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,24 +6,24 @@ // //===----------------------------------------------------------------------===// -#include "llvm/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.h" +#include "llvm/ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.h" namespace llvm { namespace orc { -Expected> -TPCDynamicLibrarySearchGenerator::Load(TargetProcessControl &TPC, +Expected> +EPCDynamicLibrarySearchGenerator::Load(ExecutorProcessControl &EPC, const char *LibraryPath, SymbolPredicate Allow) { - auto Handle = TPC.loadDylib(LibraryPath); + auto Handle = EPC.loadDylib(LibraryPath); if (!Handle) return Handle.takeError(); - return std::make_unique(TPC, *Handle, + return std::make_unique(EPC, *Handle, std::move(Allow)); } -Error TPCDynamicLibrarySearchGenerator::tryToGenerate( +Error EPCDynamicLibrarySearchGenerator::tryToGenerate( LookupState &LS, LookupKind K, JITDylib &JD, JITDylibLookupFlags JDLookupFlags, const SymbolLookupSet &Symbols) { @@ -41,8 +41,8 @@ Error TPCDynamicLibrarySearchGenerator::tryToGenerate( SymbolMap NewSymbols; - TargetProcessControl::LookupRequest Request(H, LookupSymbols); - auto Result = TPC.lookupSymbols(Request); + ExecutorProcessControl::LookupRequest Request(H, LookupSymbols); + auto Result = EPC.lookupSymbols(Request); if (!Result) return Result.takeError(); diff --git a/lib/ExecutionEngine/Orc/TPCEHFrameRegistrar.cpp b/lib/ExecutionEngine/Orc/EPCEHFrameRegistrar.cpp similarity index 66% rename from lib/ExecutionEngine/Orc/TPCEHFrameRegistrar.cpp rename to lib/ExecutionEngine/Orc/EPCEHFrameRegistrar.cpp index 332fba7b6a6..c51a68c1bfe 100644 --- a/lib/ExecutionEngine/Orc/TPCEHFrameRegistrar.cpp +++ b/lib/ExecutionEngine/Orc/EPCEHFrameRegistrar.cpp @@ -1,4 +1,4 @@ -//===------ TPCEHFrameRegistrar.cpp - TPC-based eh-frame registration -----===// +//===------ EPCEHFrameRegistrar.cpp - EPC-based eh-frame registration -----===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "llvm/ExecutionEngine/Orc/TPCEHFrameRegistrar.h" +#include "llvm/ExecutionEngine/Orc/EPCEHFrameRegistrar.h" #include "llvm/Support/BinaryStreamWriter.h" using namespace llvm::orc::shared; @@ -14,19 +14,19 @@ using namespace llvm::orc::shared; namespace llvm { namespace orc { -Expected> -TPCEHFrameRegistrar::Create(TargetProcessControl &TPC) { +Expected> +EPCEHFrameRegistrar::Create(ExecutorProcessControl &EPC) { // FIXME: Proper mangling here -- we really need to decouple linker mangling // from DataLayout. // Find the addresses of the registration/deregistration functions in the - // target process. - auto ProcessHandle = TPC.loadDylib(nullptr); + // executor process. + auto ProcessHandle = EPC.loadDylib(nullptr); if (!ProcessHandle) return ProcessHandle.takeError(); std::string RegisterWrapperName, DeregisterWrapperName; - if (TPC.getTargetTriple().isOSBinFormatMachO()) { + if (EPC.getTargetTriple().isOSBinFormatMachO()) { RegisterWrapperName += '_'; DeregisterWrapperName += '_'; } @@ -34,10 +34,10 @@ TPCEHFrameRegistrar::Create(TargetProcessControl &TPC) { DeregisterWrapperName += "llvm_orc_deregisterEHFrameSectionWrapper"; SymbolLookupSet RegistrationSymbols; - RegistrationSymbols.add(TPC.intern(RegisterWrapperName)); - RegistrationSymbols.add(TPC.intern(DeregisterWrapperName)); + RegistrationSymbols.add(EPC.intern(RegisterWrapperName)); + RegistrationSymbols.add(EPC.intern(DeregisterWrapperName)); - auto Result = TPC.lookupSymbols({{*ProcessHandle, RegistrationSymbols}}); + auto Result = EPC.lookupSymbols({{*ProcessHandle, RegistrationSymbols}}); if (!Result) return Result.takeError(); @@ -48,22 +48,22 @@ TPCEHFrameRegistrar::Create(TargetProcessControl &TPC) { auto RegisterEHFrameWrapperFnAddr = (*Result)[0][0]; auto DeregisterEHFrameWrapperFnAddr = (*Result)[0][1]; - return std::make_unique( - TPC, RegisterEHFrameWrapperFnAddr, DeregisterEHFrameWrapperFnAddr); + return std::make_unique( + EPC, RegisterEHFrameWrapperFnAddr, DeregisterEHFrameWrapperFnAddr); } -Error TPCEHFrameRegistrar::registerEHFrames(JITTargetAddress EHFrameSectionAddr, +Error EPCEHFrameRegistrar::registerEHFrames(JITTargetAddress EHFrameSectionAddr, size_t EHFrameSectionSize) { return WrapperFunction::call( - TPCCaller(TPC, RegisterEHFrameWrapperFnAddr), EHFrameSectionAddr, + EPCCaller(EPC, RegisterEHFrameWrapperFnAddr), EHFrameSectionAddr, static_cast(EHFrameSectionSize)); } -Error TPCEHFrameRegistrar::deregisterEHFrames( +Error EPCEHFrameRegistrar::deregisterEHFrames( JITTargetAddress EHFrameSectionAddr, size_t EHFrameSectionSize) { return WrapperFunction::call( - TPCCaller(TPC, DeregisterEHFrameWrapperFnAddr), EHFrameSectionAddr, + EPCCaller(EPC, DeregisterEHFrameWrapperFnAddr), EHFrameSectionAddr, static_cast(EHFrameSectionSize)); } diff --git a/lib/ExecutionEngine/Orc/TPCIndirectionUtils.cpp b/lib/ExecutionEngine/Orc/EPCIndirectionUtils.cpp similarity index 73% rename from lib/ExecutionEngine/Orc/TPCIndirectionUtils.cpp rename to lib/ExecutionEngine/Orc/EPCIndirectionUtils.cpp index 7989ec41952..b9c70b0aeb3 100644 --- a/lib/ExecutionEngine/Orc/TPCIndirectionUtils.cpp +++ b/lib/ExecutionEngine/Orc/EPCIndirectionUtils.cpp @@ -1,4 +1,4 @@ -//===------ TargetProcessControl.cpp -- Target process control APIs -------===// +//===------- EPCIndirectionUtils.cpp -- EPC based indirection APIs --------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,9 +6,9 @@ // //===----------------------------------------------------------------------===// -#include "llvm/ExecutionEngine/Orc/TPCIndirectionUtils.h" +#include "llvm/ExecutionEngine/Orc/EPCIndirectionUtils.h" -#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h" +#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h" #include "llvm/Support/MathExtras.h" #include @@ -19,14 +19,14 @@ using namespace llvm::orc; namespace llvm { namespace orc { -class TPCIndirectionUtilsAccess { +class EPCIndirectionUtilsAccess { public: - using IndirectStubInfo = TPCIndirectionUtils::IndirectStubInfo; - using IndirectStubInfoVector = TPCIndirectionUtils::IndirectStubInfoVector; + using IndirectStubInfo = EPCIndirectionUtils::IndirectStubInfo; + using IndirectStubInfoVector = EPCIndirectionUtils::IndirectStubInfoVector; static Expected - getIndirectStubs(TPCIndirectionUtils &TPCIU, unsigned NumStubs) { - return TPCIU.getIndirectStubs(NumStubs); + getIndirectStubs(EPCIndirectionUtils &EPCIU, unsigned NumStubs) { + return EPCIU.getIndirectStubs(NumStubs); }; }; @@ -35,9 +35,9 @@ public: namespace { -class TPCTrampolinePool : public TrampolinePool { +class EPCTrampolinePool : public TrampolinePool { public: - TPCTrampolinePool(TPCIndirectionUtils &TPCIU); + EPCTrampolinePool(EPCIndirectionUtils &EPCIU); Error deallocatePool(); protected: @@ -45,16 +45,16 @@ protected: using Allocation = jitlink::JITLinkMemoryManager::Allocation; - TPCIndirectionUtils &TPCIU; + EPCIndirectionUtils &EPCIU; unsigned TrampolineSize = 0; unsigned TrampolinesPerPage = 0; std::vector> TrampolineBlocks; }; -class TPCIndirectStubsManager : public IndirectStubsManager, - private TPCIndirectionUtilsAccess { +class EPCIndirectStubsManager : public IndirectStubsManager, + private EPCIndirectionUtilsAccess { public: - TPCIndirectStubsManager(TPCIndirectionUtils &TPCIU) : TPCIU(TPCIU) {} + EPCIndirectStubsManager(EPCIndirectionUtils &EPCIU) : EPCIU(EPCIU) {} Error deallocateStubs(); @@ -73,43 +73,43 @@ private: using StubInfo = std::pair; std::mutex ISMMutex; - TPCIndirectionUtils &TPCIU; + EPCIndirectionUtils &EPCIU; StringMap StubInfos; }; -TPCTrampolinePool::TPCTrampolinePool(TPCIndirectionUtils &TPCIU) - : TPCIU(TPCIU) { - auto &TPC = TPCIU.getTargetProcessControl(); - auto &ABI = TPCIU.getABISupport(); +EPCTrampolinePool::EPCTrampolinePool(EPCIndirectionUtils &EPCIU) + : EPCIU(EPCIU) { + auto &EPC = EPCIU.getExecutorProcessControl(); + auto &ABI = EPCIU.getABISupport(); TrampolineSize = ABI.getTrampolineSize(); TrampolinesPerPage = - (TPC.getPageSize() - ABI.getPointerSize()) / TrampolineSize; + (EPC.getPageSize() - ABI.getPointerSize()) / TrampolineSize; } -Error TPCTrampolinePool::deallocatePool() { +Error EPCTrampolinePool::deallocatePool() { Error Err = Error::success(); for (auto &Alloc : TrampolineBlocks) Err = joinErrors(std::move(Err), Alloc->deallocate()); return Err; } -Error TPCTrampolinePool::grow() { +Error EPCTrampolinePool::grow() { assert(AvailableTrampolines.empty() && "Grow called with trampolines still available"); - auto ResolverAddress = TPCIU.getResolverBlockAddress(); + auto ResolverAddress = EPCIU.getResolverBlockAddress(); assert(ResolverAddress && "Resolver address can not be null"); - auto &TPC = TPCIU.getTargetProcessControl(); + auto &EPC = EPCIU.getExecutorProcessControl(); constexpr auto TrampolinePagePermissions = static_cast(sys::Memory::MF_READ | sys::Memory::MF_EXEC); - auto PageSize = TPC.getPageSize(); + auto PageSize = EPC.getPageSize(); jitlink::JITLinkMemoryManager::SegmentsRequestMap Request; Request[TrampolinePagePermissions] = {PageSize, static_cast(PageSize), 0}; - auto Alloc = TPC.getMemMgr().allocate(nullptr, Request); + auto Alloc = EPC.getMemMgr().allocate(nullptr, Request); if (!Alloc) return Alloc.takeError(); @@ -119,7 +119,7 @@ Error TPCTrampolinePool::grow() { auto WorkingMemory = (*Alloc)->getWorkingMemory(TrampolinePagePermissions); auto TargetAddress = (*Alloc)->getTargetMemory(TrampolinePagePermissions); - TPCIU.getABISupport().writeTrampolines(WorkingMemory.data(), TargetAddress, + EPCIU.getABISupport().writeTrampolines(WorkingMemory.data(), TargetAddress, ResolverAddress, NumTrampolines); auto TargetAddr = (*Alloc)->getTargetMemory(TrampolinePagePermissions); @@ -134,7 +134,7 @@ Error TPCTrampolinePool::grow() { return Error::success(); } -Error TPCIndirectStubsManager::createStub(StringRef StubName, +Error EPCIndirectStubsManager::createStub(StringRef StubName, JITTargetAddress StubAddr, JITSymbolFlags StubFlags) { StubInitsMap SIM; @@ -142,8 +142,8 @@ Error TPCIndirectStubsManager::createStub(StringRef StubName, return createStubs(SIM); } -Error TPCIndirectStubsManager::createStubs(const StubInitsMap &StubInits) { - auto AvailableStubInfos = getIndirectStubs(TPCIU, StubInits.size()); +Error EPCIndirectStubsManager::createStubs(const StubInitsMap &StubInits) { + auto AvailableStubInfos = getIndirectStubs(EPCIU, StubInits.size()); if (!AvailableStubInfos) return AvailableStubInfos.takeError(); @@ -156,8 +156,8 @@ Error TPCIndirectStubsManager::createStubs(const StubInitsMap &StubInits) { } } - auto &MemAccess = TPCIU.getTargetProcessControl().getMemoryAccess(); - switch (TPCIU.getABISupport().getPointerSize()) { + auto &MemAccess = EPCIU.getExecutorProcessControl().getMemoryAccess(); + switch (EPCIU.getABISupport().getPointerSize()) { case 4: { unsigned ASIdx = 0; std::vector PtrUpdates; @@ -180,7 +180,7 @@ Error TPCIndirectStubsManager::createStubs(const StubInitsMap &StubInits) { } } -JITEvaluatedSymbol TPCIndirectStubsManager::findStub(StringRef Name, +JITEvaluatedSymbol EPCIndirectStubsManager::findStub(StringRef Name, bool ExportedStubsOnly) { std::lock_guard Lock(ISMMutex); auto I = StubInfos.find(Name); @@ -189,7 +189,7 @@ JITEvaluatedSymbol TPCIndirectStubsManager::findStub(StringRef Name, return {I->second.first.StubAddress, I->second.second}; } -JITEvaluatedSymbol TPCIndirectStubsManager::findPointer(StringRef Name) { +JITEvaluatedSymbol EPCIndirectStubsManager::findPointer(StringRef Name) { std::lock_guard Lock(ISMMutex); auto I = StubInfos.find(Name); if (I == StubInfos.end()) @@ -197,7 +197,7 @@ JITEvaluatedSymbol TPCIndirectStubsManager::findPointer(StringRef Name) { return {I->second.first.PointerAddress, I->second.second}; } -Error TPCIndirectStubsManager::updatePointer(StringRef Name, +Error EPCIndirectStubsManager::updatePointer(StringRef Name, JITTargetAddress NewAddr) { JITTargetAddress PtrAddr = 0; @@ -210,8 +210,8 @@ Error TPCIndirectStubsManager::updatePointer(StringRef Name, PtrAddr = I->second.first.PointerAddress; } - auto &MemAccess = TPCIU.getTargetProcessControl().getMemoryAccess(); - switch (TPCIU.getABISupport().getPointerSize()) { + auto &MemAccess = EPCIU.getExecutorProcessControl().getMemoryAccess(); + switch (EPCIU.getABISupport().getPointerSize()) { case 4: { tpctypes::UInt32Write PUpdate(PtrAddr, NewAddr); return MemAccess.writeUInt32s(PUpdate); @@ -231,42 +231,42 @@ Error TPCIndirectStubsManager::updatePointer(StringRef Name, namespace llvm { namespace orc { -TPCIndirectionUtils::ABISupport::~ABISupport() {} +EPCIndirectionUtils::ABISupport::~ABISupport() {} -Expected> -TPCIndirectionUtils::Create(TargetProcessControl &TPC) { - const auto &TT = TPC.getTargetTriple(); +Expected> +EPCIndirectionUtils::Create(ExecutorProcessControl &EPC) { + const auto &TT = EPC.getTargetTriple(); switch (TT.getArch()) { default: return make_error( - std::string("No TPCIndirectionUtils available for ") + TT.str(), + std::string("No EPCIndirectionUtils available for ") + TT.str(), inconvertibleErrorCode()); case Triple::aarch64: case Triple::aarch64_32: - return CreateWithABI(TPC); + return CreateWithABI(EPC); case Triple::x86: - return CreateWithABI(TPC); + return CreateWithABI(EPC); case Triple::mips: - return CreateWithABI(TPC); + return CreateWithABI(EPC); case Triple::mipsel: - return CreateWithABI(TPC); + return CreateWithABI(EPC); case Triple::mips64: case Triple::mips64el: - return CreateWithABI(TPC); + return CreateWithABI(EPC); case Triple::x86_64: if (TT.getOS() == Triple::OSType::Win32) - return CreateWithABI(TPC); + return CreateWithABI(EPC); else - return CreateWithABI(TPC); + return CreateWithABI(EPC); } } -Error TPCIndirectionUtils::cleanup() { +Error EPCIndirectionUtils::cleanup() { Error Err = Error::success(); for (auto &A : IndirectStubAllocs) @@ -274,7 +274,7 @@ Error TPCIndirectionUtils::cleanup() { if (TP) Err = joinErrors(std::move(Err), - static_cast(*TP).deallocatePool()); + static_cast(*TP).deallocatePool()); if (ResolverBlock) Err = joinErrors(std::move(Err), ResolverBlock->deallocate()); @@ -283,7 +283,7 @@ Error TPCIndirectionUtils::cleanup() { } Expected -TPCIndirectionUtils::writeResolverBlock(JITTargetAddress ReentryFnAddr, +EPCIndirectionUtils::writeResolverBlock(JITTargetAddress ReentryFnAddr, JITTargetAddress ReentryCtxAddr) { assert(ABI && "ABI can not be null"); constexpr auto ResolverBlockPermissions = @@ -292,9 +292,9 @@ TPCIndirectionUtils::writeResolverBlock(JITTargetAddress ReentryFnAddr, auto ResolverSize = ABI->getResolverCodeSize(); jitlink::JITLinkMemoryManager::SegmentsRequestMap Request; - Request[ResolverBlockPermissions] = {TPC.getPageSize(), + Request[ResolverBlockPermissions] = {EPC.getPageSize(), static_cast(ResolverSize), 0}; - auto Alloc = TPC.getMemMgr().allocate(nullptr, Request); + auto Alloc = EPC.getMemMgr().allocate(nullptr, Request); if (!Alloc) return Alloc.takeError(); @@ -311,17 +311,17 @@ TPCIndirectionUtils::writeResolverBlock(JITTargetAddress ReentryFnAddr, } std::unique_ptr -TPCIndirectionUtils::createIndirectStubsManager() { - return std::make_unique(*this); +EPCIndirectionUtils::createIndirectStubsManager() { + return std::make_unique(*this); } -TrampolinePool &TPCIndirectionUtils::getTrampolinePool() { +TrampolinePool &EPCIndirectionUtils::getTrampolinePool() { if (!TP) - TP = std::make_unique(*this); + TP = std::make_unique(*this); return *TP; } -LazyCallThroughManager &TPCIndirectionUtils::createLazyCallThroughManager( +LazyCallThroughManager &EPCIndirectionUtils::createLazyCallThroughManager( ExecutionSession &ES, JITTargetAddress ErrorHandlerAddr) { assert(!LCTM && "createLazyCallThroughManager can not have been called before"); @@ -330,24 +330,24 @@ LazyCallThroughManager &TPCIndirectionUtils::createLazyCallThroughManager( return *LCTM; } -TPCIndirectionUtils::TPCIndirectionUtils(TargetProcessControl &TPC, +EPCIndirectionUtils::EPCIndirectionUtils(ExecutorProcessControl &EPC, std::unique_ptr ABI) - : TPC(TPC), ABI(std::move(ABI)) { + : EPC(EPC), ABI(std::move(ABI)) { assert(this->ABI && "ABI can not be null"); - assert(TPC.getPageSize() > getABISupport().getStubSize() && + assert(EPC.getPageSize() > getABISupport().getStubSize() && "Stubs larger than one page are not supported"); } -Expected -TPCIndirectionUtils::getIndirectStubs(unsigned NumStubs) { +Expected +EPCIndirectionUtils::getIndirectStubs(unsigned NumStubs) { - std::lock_guard Lock(TPCUIMutex); + std::lock_guard Lock(EPCUIMutex); // If there aren't enough stubs available then allocate some more. if (NumStubs > AvailableIndirectStubs.size()) { auto NumStubsToAllocate = NumStubs; - auto PageSize = TPC.getPageSize(); + auto PageSize = EPC.getPageSize(); auto StubBytes = alignTo(NumStubsToAllocate * ABI->getStubSize(), PageSize); NumStubsToAllocate = StubBytes / ABI->getStubSize(); auto PointerBytes = @@ -364,7 +364,7 @@ TPCIndirectionUtils::getIndirectStubs(unsigned NumStubs) { Request[StubPagePermissions] = {PageSize, static_cast(StubBytes), 0}; Request[PointerPagePermissions] = {PageSize, 0, PointerBytes}; - auto Alloc = TPC.getMemMgr().allocate(nullptr, Request); + auto Alloc = EPC.getMemMgr().allocate(nullptr, Request); if (!Alloc) return Alloc.takeError(); @@ -411,9 +411,9 @@ static JITTargetAddress reentry(JITTargetAddress LCTMAddr, return LandingAddrF.get(); } -Error setUpInProcessLCTMReentryViaTPCIU(TPCIndirectionUtils &TPCIU) { - auto &LCTM = TPCIU.getLazyCallThroughManager(); - return TPCIU +Error setUpInProcessLCTMReentryViaEPCIU(EPCIndirectionUtils &EPCIU) { + auto &LCTM = EPCIU.getLazyCallThroughManager(); + return EPCIU .writeResolverBlock(pointerToJITTargetAddress(&reentry), pointerToJITTargetAddress(&LCTM)) .takeError(); diff --git a/lib/ExecutionEngine/Orc/TargetProcessControl.cpp b/lib/ExecutionEngine/Orc/ExecutorProcessControl.cpp similarity index 69% rename from lib/ExecutionEngine/Orc/TargetProcessControl.cpp rename to lib/ExecutionEngine/Orc/ExecutorProcessControl.cpp index bc5cff43bd9..f8bd74eabc9 100644 --- a/lib/ExecutionEngine/Orc/TargetProcessControl.cpp +++ b/lib/ExecutionEngine/Orc/ExecutorProcessControl.cpp @@ -1,4 +1,4 @@ -//===------ TargetProcessControl.cpp -- Target process control APIs -------===// +//===---- ExecutorProcessControl.cpp -- Executor process control APIs -----===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h" +#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h" #include "llvm/ExecutionEngine/Orc/Core.h" #include "llvm/ExecutionEngine/Orc/TargetProcess/TargetExecutionUtils.h" @@ -18,14 +18,14 @@ namespace llvm { namespace orc { -TargetProcessControl::MemoryAccess::~MemoryAccess() {} +ExecutorProcessControl::MemoryAccess::~MemoryAccess() {} -TargetProcessControl::~TargetProcessControl() {} +ExecutorProcessControl::~ExecutorProcessControl() {} -SelfTargetProcessControl::SelfTargetProcessControl( +SelfExecutorProcessControl::SelfExecutorProcessControl( std::shared_ptr SSP, Triple TargetTriple, unsigned PageSize, std::unique_ptr MemMgr) - : TargetProcessControl(std::move(SSP)) { + : ExecutorProcessControl(std::move(SSP)) { OwnedMemMgr = std::move(MemMgr); if (!OwnedMemMgr) @@ -39,8 +39,8 @@ SelfTargetProcessControl::SelfTargetProcessControl( GlobalManglingPrefix = '_'; } -Expected> -SelfTargetProcessControl::Create( +Expected> +SelfExecutorProcessControl::Create( std::shared_ptr SSP, std::unique_ptr MemMgr) { auto PageSize = sys::Process::getPageSize(); @@ -49,12 +49,12 @@ SelfTargetProcessControl::Create( Triple TT(sys::getProcessTriple()); - return std::make_unique( + return std::make_unique( std::move(SSP), std::move(TT), *PageSize, std::move(MemMgr)); } Expected -SelfTargetProcessControl::loadDylib(const char *DylibPath) { +SelfExecutorProcessControl::loadDylib(const char *DylibPath) { std::string ErrMsg; auto Dylib = std::make_unique( sys::DynamicLibrary::getPermanentLibrary(DylibPath, &ErrMsg)); @@ -65,7 +65,7 @@ SelfTargetProcessControl::loadDylib(const char *DylibPath) { } Expected> -SelfTargetProcessControl::lookupSymbols(ArrayRef Request) { +SelfExecutorProcessControl::lookupSymbols(ArrayRef Request) { std::vector R; for (auto &Elem : Request) { @@ -96,53 +96,53 @@ SelfTargetProcessControl::lookupSymbols(ArrayRef Request) { } Expected -SelfTargetProcessControl::runAsMain(JITTargetAddress MainFnAddr, - ArrayRef Args) { +SelfExecutorProcessControl::runAsMain(JITTargetAddress MainFnAddr, + ArrayRef Args) { using MainTy = int (*)(int, char *[]); return orc::runAsMain(jitTargetAddressToFunction(MainFnAddr), Args); } Expected -SelfTargetProcessControl::runWrapper(JITTargetAddress WrapperFnAddr, - ArrayRef ArgBuffer) { +SelfExecutorProcessControl::runWrapper(JITTargetAddress WrapperFnAddr, + ArrayRef ArgBuffer) { using WrapperFnTy = shared::detail::CWrapperFunctionResult (*)( const char *Data, uint64_t Size); auto *WrapperFn = jitTargetAddressToFunction(WrapperFnAddr); return WrapperFn(ArgBuffer.data(), ArgBuffer.size()); } -Error SelfTargetProcessControl::disconnect() { return Error::success(); } +Error SelfExecutorProcessControl::disconnect() { return Error::success(); } -void SelfTargetProcessControl::writeUInt8s(ArrayRef Ws, - WriteResultFn OnWriteComplete) { +void SelfExecutorProcessControl::writeUInt8s(ArrayRef Ws, + WriteResultFn OnWriteComplete) { for (auto &W : Ws) *jitTargetAddressToPointer(W.Address) = W.Value; OnWriteComplete(Error::success()); } -void SelfTargetProcessControl::writeUInt16s(ArrayRef Ws, - WriteResultFn OnWriteComplete) { +void SelfExecutorProcessControl::writeUInt16s( + ArrayRef Ws, WriteResultFn OnWriteComplete) { for (auto &W : Ws) *jitTargetAddressToPointer(W.Address) = W.Value; OnWriteComplete(Error::success()); } -void SelfTargetProcessControl::writeUInt32s(ArrayRef Ws, - WriteResultFn OnWriteComplete) { +void SelfExecutorProcessControl::writeUInt32s( + ArrayRef Ws, WriteResultFn OnWriteComplete) { for (auto &W : Ws) *jitTargetAddressToPointer(W.Address) = W.Value; OnWriteComplete(Error::success()); } -void SelfTargetProcessControl::writeUInt64s(ArrayRef Ws, - WriteResultFn OnWriteComplete) { +void SelfExecutorProcessControl::writeUInt64s( + ArrayRef Ws, WriteResultFn OnWriteComplete) { for (auto &W : Ws) *jitTargetAddressToPointer(W.Address) = W.Value; OnWriteComplete(Error::success()); } -void SelfTargetProcessControl::writeBuffers(ArrayRef Ws, - WriteResultFn OnWriteComplete) { +void SelfExecutorProcessControl::writeBuffers( + ArrayRef Ws, WriteResultFn OnWriteComplete) { for (auto &W : Ws) memcpy(jitTargetAddressToPointer(W.Address), W.Buffer.data(), W.Buffer.size()); diff --git a/lib/ExecutionEngine/Orc/LLJIT.cpp b/lib/ExecutionEngine/Orc/LLJIT.cpp index a79882a04e7..08fd86b7979 100644 --- a/lib/ExecutionEngine/Orc/LLJIT.cpp +++ b/lib/ExecutionEngine/Orc/LLJIT.cpp @@ -9,12 +9,12 @@ #include "llvm/ExecutionEngine/Orc/LLJIT.h" #include "llvm/ExecutionEngine/JITLink/EHFrameSupport.h" #include "llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h" +#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h" #include "llvm/ExecutionEngine/Orc/MachOPlatform.h" #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h" #include "llvm/ExecutionEngine/Orc/ObjectTransformLayer.h" #include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h" #include "llvm/ExecutionEngine/Orc/Shared/OrcError.h" -#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h" #include "llvm/ExecutionEngine/SectionMemoryManager.h" #include "llvm/IR/GlobalVariable.h" #include "llvm/IR/IRBuilder.h" @@ -976,13 +976,13 @@ Error LLJITBuilderState::prepareForConstruction() { JTMB->setRelocationModel(Reloc::PIC_); JTMB->setCodeModel(CodeModel::Small); CreateObjectLinkingLayer = - [TPC = this->TPC]( + [EPC = this->EPC]( ExecutionSession &ES, const Triple &) -> Expected> { std::unique_ptr ObjLinkingLayer; - if (TPC) + if (EPC) ObjLinkingLayer = - std::make_unique(ES, TPC->getMemMgr()); + std::make_unique(ES, EPC->getMemMgr()); else ObjLinkingLayer = std::make_unique( ES, std::make_unique()); diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp index 8908b43d71e..47fb3642128 100644 --- a/tools/lli/lli.cpp +++ b/tools/lli/lli.cpp @@ -22,12 +22,14 @@ #include "llvm/Config/llvm-config.h" #include "llvm/ExecutionEngine/GenericValue.h" #include "llvm/ExecutionEngine/Interpreter.h" -#include "llvm/ExecutionEngine/JITSymbol.h" #include "llvm/ExecutionEngine/JITEventListener.h" +#include "llvm/ExecutionEngine/JITSymbol.h" #include "llvm/ExecutionEngine/MCJIT.h" #include "llvm/ExecutionEngine/ObjectCache.h" #include "llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h" #include "llvm/ExecutionEngine/Orc/DebugUtils.h" +#include "llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h" +#include "llvm/ExecutionEngine/Orc/EPCEHFrameRegistrar.h" #include "llvm/ExecutionEngine/Orc/ExecutionUtils.h" #include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h" #include "llvm/ExecutionEngine/Orc/LLJIT.h" @@ -35,8 +37,6 @@ #include "llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h" #include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h" #include "llvm/ExecutionEngine/Orc/SymbolStringPool.h" -#include "llvm/ExecutionEngine/Orc/TPCDebugObjectRegistrar.h" -#include "llvm/ExecutionEngine/Orc/TPCEHFrameRegistrar.h" #include "llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h" #include "llvm/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.h" #include "llvm/ExecutionEngine/Orc/TargetProcess/TargetExecutionUtils.h" @@ -936,18 +936,18 @@ int runOrcJIT(const char *ProgName) { } } - std::unique_ptr TPC = nullptr; + std::unique_ptr EPC = nullptr; if (JITLinker == JITLinkerKind::JITLink) { - TPC = ExitOnErr(orc::SelfTargetProcessControl::Create( + EPC = ExitOnErr(orc::SelfExecutorProcessControl::Create( std::make_shared())); - Builder.setObjectLinkingLayerCreator([&TPC](orc::ExecutionSession &ES, + Builder.setObjectLinkingLayerCreator([&EPC](orc::ExecutionSession &ES, const Triple &) { - auto L = std::make_unique(ES, TPC->getMemMgr()); + auto L = std::make_unique(ES, EPC->getMemMgr()); L->addPlugin(std::make_unique( - ES, ExitOnErr(orc::TPCEHFrameRegistrar::Create(*TPC)))); + ES, ExitOnErr(orc::EPCEHFrameRegistrar::Create(*EPC)))); L->addPlugin(std::make_unique( - ES, ExitOnErr(orc::createJITLoaderGDBRegistrar(*TPC)))); + ES, ExitOnErr(orc::createJITLoaderGDBRegistrar(*EPC)))); return L; }); } @@ -1069,9 +1069,9 @@ int runOrcJIT(const char *ProgName) { JITEvaluatedSymbol MainSym = ExitOnErr(J->lookup(EntryFunc)); int Result; - if (TPC) { - // TargetProcessControl-based execution with JITLink. - Result = ExitOnErr(TPC->runAsMain(MainSym.getAddress(), InputArgv)); + if (EPC) { + // ExecutorProcessControl-based execution with JITLink. + Result = ExitOnErr(EPC->runAsMain(MainSym.getAddress(), InputArgv)); } else { // Manual in-process execution with RuntimeDyld. using MainFnTy = int(int, char *[]); diff --git a/tools/llvm-jitlink/llvm-jitlink.cpp b/tools/llvm-jitlink/llvm-jitlink.cpp index 99af0a48b35..f8298317fee 100644 --- a/tools/llvm-jitlink/llvm-jitlink.cpp +++ b/tools/llvm-jitlink/llvm-jitlink.cpp @@ -16,10 +16,10 @@ #include "llvm/BinaryFormat/Magic.h" #include "llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h" +#include "llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h" +#include "llvm/ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.h" +#include "llvm/ExecutionEngine/Orc/EPCEHFrameRegistrar.h" #include "llvm/ExecutionEngine/Orc/ExecutionUtils.h" -#include "llvm/ExecutionEngine/Orc/TPCDebugObjectRegistrar.h" -#include "llvm/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.h" -#include "llvm/ExecutionEngine/Orc/TPCEHFrameRegistrar.h" #include "llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h" #include "llvm/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.h" #include "llvm/MC/MCAsmInfo.h" @@ -588,8 +588,8 @@ Error LLVMJITLinkObjectLinkingLayer::add(ResourceTrackerSP RT, return JD.define(std::move(MU), std::move(RT)); } -Expected> -LLVMJITLinkRemoteTargetProcessControl::LaunchExecutor() { +Expected> +LLVMJITLinkRemoteExecutorProcessControl::LaunchExecutor() { #ifndef LLVM_ON_UNIX // FIXME: Add support for Windows. return make_error("-" + OutOfProcessExecutor.ArgStr + @@ -661,13 +661,13 @@ LLVMJITLinkRemoteTargetProcessControl::LaunchExecutor() { }; Error Err = Error::success(); - std::unique_ptr RTPC( - new LLVMJITLinkRemoteTargetProcessControl( + std::unique_ptr REPC( + new LLVMJITLinkRemoteExecutorProcessControl( std::move(SSP), std::move(Channel), std::move(Endpoint), std::move(ReportError), Err)); if (Err) return std::move(Err); - return std::move(RTPC); + return std::move(REPC); #endif } @@ -717,8 +717,8 @@ static Expected connectTCPSocket(std::string Host, std::string PortStr) { } #endif -Expected> -LLVMJITLinkRemoteTargetProcessControl::ConnectToExecutor() { +Expected> +LLVMJITLinkRemoteExecutorProcessControl::ConnectToExecutor() { #ifndef LLVM_ON_UNIX // FIXME: Add TCP support for Windows. return make_error("-" + OutOfProcessExecutorConnect.ArgStr + @@ -756,17 +756,17 @@ LLVMJITLinkRemoteTargetProcessControl::ConnectToExecutor() { }; Error Err = Error::success(); - std::unique_ptr RTPC( - new LLVMJITLinkRemoteTargetProcessControl( + std::unique_ptr REPC( + new LLVMJITLinkRemoteExecutorProcessControl( std::move(SSP), std::move(Channel), std::move(Endpoint), std::move(ReportError), Err)); if (Err) return std::move(Err); - return std::move(RTPC); + return std::move(REPC); #endif } -Error LLVMJITLinkRemoteTargetProcessControl::disconnect() { +Error LLVMJITLinkRemoteExecutorProcessControl::disconnect() { std::promise P; auto F = P.get_future(); auto Err = closeConnection([&](Error Err) -> Error { @@ -797,24 +797,25 @@ Expected> Session::Create(Triple TT) { return PageSize.takeError(); /// If -oop-executor is passed then launch the executor. - std::unique_ptr TPC; + std::unique_ptr EPC; if (OutOfProcessExecutor.getNumOccurrences()) { - if (auto RTPC = LLVMJITLinkRemoteTargetProcessControl::LaunchExecutor()) - TPC = std::move(*RTPC); + if (auto REPC = LLVMJITLinkRemoteExecutorProcessControl::LaunchExecutor()) + EPC = std::move(*REPC); else - return RTPC.takeError(); + return REPC.takeError(); } else if (OutOfProcessExecutorConnect.getNumOccurrences()) { - if (auto RTPC = LLVMJITLinkRemoteTargetProcessControl::ConnectToExecutor()) - TPC = std::move(*RTPC); + if (auto REPC = + LLVMJITLinkRemoteExecutorProcessControl::ConnectToExecutor()) + EPC = std::move(*REPC); else - return RTPC.takeError(); + return REPC.takeError(); } else - TPC = std::make_unique( + EPC = std::make_unique( std::make_shared(), std::move(TT), *PageSize, createMemoryManager()); Error Err = Error::success(); - std::unique_ptr S(new Session(std::move(TPC), Err)); + std::unique_ptr S(new Session(std::move(EPC), Err)); if (Err) return std::move(Err); return std::move(S); @@ -827,8 +828,8 @@ Session::~Session() { // FIXME: Move to createJITDylib if/when we start using Platform support in // llvm-jitlink. -Session::Session(std::unique_ptr TPC, Error &Err) - : TPC(std::move(TPC)), ObjLayer(*this, this->TPC->getMemMgr()) { +Session::Session(std::unique_ptr EPC, Error &Err) + : EPC(std::move(EPC)), ObjLayer(*this, this->EPC->getMemMgr()) { /// Local ObjectLinkingLayer::Plugin class to forward modifyPassConfig to the /// Session. @@ -862,11 +863,11 @@ Session::Session(std::unique_ptr TPC, Error &Err) return; } - if (!NoExec && !this->TPC->getTargetTriple().isOSWindows()) { + if (!NoExec && !this->EPC->getTargetTriple().isOSWindows()) { ObjLayer.addPlugin(std::make_unique( - ES, ExitOnErr(TPCEHFrameRegistrar::Create(*this->TPC)))); + ES, ExitOnErr(EPCEHFrameRegistrar::Create(*this->EPC)))); ObjLayer.addPlugin(std::make_unique( - ES, ExitOnErr(createJITLoaderGDBRegistrar(*this->TPC)))); + ES, ExitOnErr(createJITLoaderGDBRegistrar(*this->EPC)))); } ObjLayer.addPlugin(std::make_unique(*this)); @@ -913,10 +914,10 @@ void Session::modifyPassConfig(const Triple &TT, PassConfiguration &PassConfig) { if (!CheckFiles.empty()) PassConfig.PostFixupPasses.push_back([this](LinkGraph &G) { - if (TPC->getTargetTriple().getObjectFormat() == Triple::ELF) + if (EPC->getTargetTriple().getObjectFormat() == Triple::ELF) return registerELFGraphInfo(*this, G); - if (TPC->getTargetTriple().getObjectFormat() == Triple::MachO) + if (EPC->getTargetTriple().getObjectFormat() == Triple::MachO) return registerMachOGraphInfo(*this, G); return make_error("Unsupported object format for GOT/stub " @@ -1094,15 +1095,15 @@ static Error loadProcessSymbols(Session &S) { return Name != EPName; }; S.MainJD->addGenerator( - ExitOnErr(orc::TPCDynamicLibrarySearchGenerator::GetForTargetProcess( - *S.TPC, std::move(FilterMainEntryPoint)))); + ExitOnErr(orc::EPCDynamicLibrarySearchGenerator::GetForTargetProcess( + *S.EPC, std::move(FilterMainEntryPoint)))); return Error::success(); } static Error loadDylibs(Session &S) { for (const auto &Dylib : Dylibs) { - auto G = orc::TPCDynamicLibrarySearchGenerator::Load(*S.TPC, Dylib.c_str()); + auto G = orc::EPCDynamicLibrarySearchGenerator::Load(*S.EPC, Dylib.c_str()); if (!G) return G.takeError(); S.MainJD->addGenerator(std::move(*G)); @@ -1178,7 +1179,7 @@ static Error loadObjects(Session &S) { if (Magic == file_magic::archive || Magic == file_magic::macho_universal_binary) JD.addGenerator(ExitOnErr(StaticLibraryDefinitionGenerator::Load( - S.ObjLayer, InputFile.c_str(), S.TPC->getTargetTriple()))); + S.ObjLayer, InputFile.c_str(), S.EPC->getTargetTriple()))); else ExitOnErr(S.ObjLayer.add(JD, std::move(ObjBuffer))); } @@ -1226,7 +1227,7 @@ static Error loadObjects(Session &S) { static Error runChecks(Session &S) { - auto TripleName = S.TPC->getTargetTriple().str(); + auto TripleName = S.EPC->getTargetTriple().str(); std::string ErrorStr; const Target *TheTarget = TargetRegistry::lookupTarget(TripleName, ErrorStr); if (!TheTarget) @@ -1292,7 +1293,7 @@ static Error runChecks(Session &S) { RuntimeDyldChecker Checker( IsSymbolValid, GetSymbolInfo, GetSectionInfo, GetStubInfo, GetGOTInfo, - S.TPC->getTargetTriple().isLittleEndian() ? support::little + S.EPC->getTargetTriple().isLittleEndian() ? support::little : support::big, Disassembler.get(), InstPrinter.get(), dbgs()); @@ -1381,11 +1382,11 @@ int main(int argc, char *argv[]) { int Result = 0; { TimeRegion TR(Timers ? &Timers->RunTimer : nullptr); - Result = ExitOnErr(S->TPC->runAsMain(EntryPoint.getAddress(), InputArgv)); + Result = ExitOnErr(S->EPC->runAsMain(EntryPoint.getAddress(), InputArgv)); } ExitOnErr(S->ES.endSession()); - ExitOnErr(S->TPC->disconnect()); + ExitOnErr(S->EPC->disconnect()); return Result; } diff --git a/tools/llvm-jitlink/llvm-jitlink.h b/tools/llvm-jitlink/llvm-jitlink.h index 041c04d8631..750e543fba1 100644 --- a/tools/llvm-jitlink/llvm-jitlink.h +++ b/tools/llvm-jitlink/llvm-jitlink.h @@ -17,11 +17,11 @@ #include "llvm/ADT/StringSet.h" #include "llvm/ADT/Triple.h" #include "llvm/ExecutionEngine/Orc/Core.h" +#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h" #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h" -#include "llvm/ExecutionEngine/Orc/OrcRPCTargetProcessControl.h" +#include "llvm/ExecutionEngine/Orc/OrcRPCExecutorProcessControl.h" #include "llvm/ExecutionEngine/Orc/Shared/FDRawByteChannel.h" #include "llvm/ExecutionEngine/Orc/Shared/RPCUtils.h" -#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h" #include "llvm/ExecutionEngine/RuntimeDyldChecker.h" #include "llvm/Support/Error.h" #include "llvm/Support/Regex.h" @@ -52,26 +52,26 @@ using LLVMJITLinkChannel = orc::shared::FDRawByteChannel; using LLVMJITLinkRPCEndpoint = orc::shared::MultiThreadedRPCEndpoint; using LLVMJITLinkRemoteMemoryAccess = - orc::OrcRPCTPCMemoryAccess; + orc::OrcRPCEPCMemoryAccess; -class LLVMJITLinkRemoteTargetProcessControl - : public orc::OrcRPCTargetProcessControlBase { +class LLVMJITLinkRemoteExecutorProcessControl + : public orc::OrcRPCExecutorProcessControlBase { public: - using BaseT = orc::OrcRPCTargetProcessControlBase; - static Expected> LaunchExecutor(); + using BaseT = orc::OrcRPCExecutorProcessControlBase; + static Expected> LaunchExecutor(); - static Expected> ConnectToExecutor(); + static Expected> ConnectToExecutor(); Error disconnect() override; private: using LLVMJITLinkRemoteMemoryAccess = - orc::OrcRPCTPCMemoryAccess; + orc::OrcRPCEPCMemoryAccess; - using LLVMJITLinkRemoteMemoryManager = - orc::OrcRPCTPCJITLinkMemoryManager; + using LLVMJITLinkRemoteMemoryManager = orc::OrcRPCEPCJITLinkMemoryManager< + LLVMJITLinkRemoteExecutorProcessControl>; - LLVMJITLinkRemoteTargetProcessControl( + LLVMJITLinkRemoteExecutorProcessControl( std::shared_ptr SSP, std::unique_ptr Channel, std::unique_ptr Endpoint, @@ -89,7 +89,7 @@ private: } }); - if (auto Err2 = initializeORCRPCTPCBase()) { + if (auto Err2 = initializeORCRPCEPCBase()) { Err = joinErrors(std::move(Err2), disconnect()); return; } @@ -102,14 +102,14 @@ private: std::unique_ptr Channel; std::unique_ptr Endpoint; - std::unique_ptr OwnedMemAccess; + std::unique_ptr OwnedMemAccess; std::unique_ptr OwnedMemMgr; std::atomic Finished{false}; std::thread ListenerThread; }; struct Session { - std::unique_ptr TPC; + std::unique_ptr EPC; orc::ExecutionSession ES; orc::JITDylib *MainJD; LLVMJITLinkObjectLinkingLayer ObjLayer; @@ -156,7 +156,7 @@ struct Session { DenseMap CanonicalWeakDefs; private: - Session(std::unique_ptr TPC, Error &Err); + Session(std::unique_ptr EPC, Error &Err); }; /// Record symbols, GOT entries, stubs, and sections for ELF file.