diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h --- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h +++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h @@ -32,7 +32,6 @@ class KaleidoscopeJIT { private: - std::unique_ptr TPC; std::unique_ptr ES; DataLayout DL; @@ -44,11 +43,9 @@ JITDylib &MainJD; public: - KaleidoscopeJIT(std::unique_ptr TPC, - std::unique_ptr ES, + KaleidoscopeJIT(std::unique_ptr ES, JITTargetMachineBuilder JTMB, DataLayout DL) - : TPC(std::move(TPC)), ES(std::move(ES)), DL(std::move(DL)), - Mangle(*this->ES, this->DL), + : ES(std::move(ES)), DL(std::move(DL)), Mangle(*this->ES, this->DL), ObjectLayer(*this->ES, []() { return std::make_unique(); }), CompileLayer(*this->ES, ObjectLayer, @@ -65,21 +62,21 @@ } static Expected> Create() { - auto SSP = std::make_shared(); - auto TPC = SelfTargetProcessControl::Create(SSP); + auto TPC = SelfTargetProcessControl::Create(); if (!TPC) return TPC.takeError(); - auto ES = std::make_unique(std::move(SSP)); + auto ES = std::make_unique(std::move(*TPC)); - JITTargetMachineBuilder JTMB((*TPC)->getTargetTriple()); + JITTargetMachineBuilder JTMB( + ES->getTargetProcessControl().getTargetTriple()); auto DL = JTMB.getDefaultDataLayoutForTarget(); if (!DL) return DL.takeError(); - return std::make_unique(std::move(*TPC), std::move(ES), - std::move(JTMB), std::move(*DL)); + return std::make_unique(std::move(ES), std::move(JTMB), + std::move(*DL)); } const DataLayout &getDataLayout() const { return DL; } diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h --- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h +++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h @@ -37,7 +37,6 @@ class KaleidoscopeJIT { private: - std::unique_ptr TPC; std::unique_ptr ES; DataLayout DL; @@ -50,11 +49,9 @@ JITDylib &MainJD; public: - KaleidoscopeJIT(std::unique_ptr TPC, - std::unique_ptr ES, + KaleidoscopeJIT(std::unique_ptr ES, JITTargetMachineBuilder JTMB, DataLayout DL) - : TPC(std::move(TPC)), ES(std::move(ES)), DL(std::move(DL)), - Mangle(*this->ES, this->DL), + : ES(std::move(ES)), DL(std::move(DL)), Mangle(*this->ES, this->DL), ObjectLayer(*this->ES, []() { return std::make_unique(); }), CompileLayer(*this->ES, ObjectLayer, @@ -72,21 +69,21 @@ } static Expected> Create() { - auto SSP = std::make_shared(); - auto TPC = SelfTargetProcessControl::Create(SSP); + auto TPC = SelfTargetProcessControl::Create(); if (!TPC) return TPC.takeError(); - auto ES = std::make_unique(std::move(SSP)); + auto ES = std::make_unique(std::move(*TPC)); - JITTargetMachineBuilder JTMB((*TPC)->getTargetTriple()); + JITTargetMachineBuilder JTMB( + ES->getTargetProcessControl().getTargetTriple()); auto DL = JTMB.getDefaultDataLayoutForTarget(); if (!DL) return DL.takeError(); - return std::make_unique(std::move(*TPC), std::move(ES), - std::move(JTMB), std::move(*DL)); + return std::make_unique(std::move(ES), std::move(JTMB), + std::move(*DL)); } const DataLayout &getDataLayout() const { return DL; } diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h --- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h +++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h @@ -39,7 +39,6 @@ class KaleidoscopeJIT { private: - std::unique_ptr TPC; std::unique_ptr ES; std::unique_ptr TPCIU; @@ -59,12 +58,11 @@ } public: - KaleidoscopeJIT(std::unique_ptr TPC, - std::unique_ptr ES, + KaleidoscopeJIT(std::unique_ptr ES, std::unique_ptr TPCIU, JITTargetMachineBuilder JTMB, DataLayout DL) - : TPC(std::move(TPC)), ES(std::move(ES)), TPCIU(std::move(TPCIU)), - DL(std::move(DL)), Mangle(*this->ES, this->DL), + : ES(std::move(ES)), TPCIU(std::move(TPCIU)), DL(std::move(DL)), + Mangle(*this->ES, this->DL), ObjectLayer(*this->ES, []() { return std::make_unique(); }), CompileLayer(*this->ES, ObjectLayer, @@ -87,14 +85,13 @@ } static Expected> Create() { - auto SSP = std::make_shared(); - auto TPC = SelfTargetProcessControl::Create(SSP); + auto TPC = SelfTargetProcessControl::Create(); if (!TPC) return TPC.takeError(); - auto ES = std::make_unique(std::move(SSP)); + auto ES = std::make_unique(std::move(*TPC)); - auto TPCIU = TPCIndirectionUtils::Create(**TPC); + auto TPCIU = TPCIndirectionUtils::Create(ES->getTargetProcessControl()); if (!TPCIU) return TPCIU.takeError(); @@ -104,15 +101,15 @@ if (auto Err = setUpInProcessLCTMReentryViaTPCIU(**TPCIU)) return std::move(Err); - JITTargetMachineBuilder JTMB((*TPC)->getTargetTriple()); + JITTargetMachineBuilder JTMB( + ES->getTargetProcessControl().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), - std::move(*DL)); + return std::make_unique(std::move(ES), std::move(*TPCIU), + std::move(JTMB), std::move(*DL)); } const DataLayout &getDataLayout() const { return DL; } diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h --- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h +++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h @@ -126,7 +126,6 @@ class KaleidoscopeJIT { private: - std::unique_ptr TPC; std::unique_ptr ES; std::unique_ptr TPCIU; @@ -146,12 +145,11 @@ } public: - KaleidoscopeJIT(std::unique_ptr TPC, - std::unique_ptr ES, + KaleidoscopeJIT(std::unique_ptr ES, std::unique_ptr TPCIU, JITTargetMachineBuilder JTMB, DataLayout DL) - : TPC(std::move(TPC)), ES(std::move(ES)), TPCIU(std::move(TPCIU)), - DL(std::move(DL)), Mangle(*this->ES, this->DL), + : ES(std::move(ES)), TPCIU(std::move(TPCIU)), DL(std::move(DL)), + Mangle(*this->ES, this->DL), ObjectLayer(*this->ES, []() { return std::make_unique(); }), CompileLayer(*this->ES, ObjectLayer, @@ -172,14 +170,13 @@ } static Expected> Create() { - auto SSP = std::make_shared(); - auto TPC = SelfTargetProcessControl::Create(SSP); + auto TPC = SelfTargetProcessControl::Create(); if (!TPC) return TPC.takeError(); - auto ES = std::make_unique(std::move(SSP)); + auto ES = std::make_unique(std::move(*TPC)); - auto TPCIU = TPCIndirectionUtils::Create(**TPC); + auto TPCIU = TPCIndirectionUtils::Create(ES->getTargetProcessControl()); if (!TPCIU) return TPCIU.takeError(); @@ -195,9 +192,8 @@ if (!DL) return DL.takeError(); - return std::make_unique(std::move(*TPC), std::move(ES), - std::move(*TPCIU), std::move(JTMB), - std::move(*DL)); + return std::make_unique(std::move(ES), std::move(*TPCIU), + std::move(JTMB), std::move(*DL)); } const DataLayout &getDataLayout() const { return DL; } diff --git a/llvm/examples/Kaleidoscope/include/KaleidoscopeJIT.h b/llvm/examples/Kaleidoscope/include/KaleidoscopeJIT.h --- a/llvm/examples/Kaleidoscope/include/KaleidoscopeJIT.h +++ b/llvm/examples/Kaleidoscope/include/KaleidoscopeJIT.h @@ -32,7 +32,6 @@ class KaleidoscopeJIT { private: - std::unique_ptr TPC; std::unique_ptr ES; DataLayout DL; @@ -44,11 +43,9 @@ JITDylib &MainJD; public: - KaleidoscopeJIT(std::unique_ptr TPC, - std::unique_ptr ES, + KaleidoscopeJIT(std::unique_ptr ES, JITTargetMachineBuilder JTMB, DataLayout DL) - : TPC(std::move(TPC)), ES(std::move(ES)), DL(std::move(DL)), - Mangle(*this->ES, this->DL), + : ES(std::move(ES)), DL(std::move(DL)), Mangle(*this->ES, this->DL), ObjectLayer(*this->ES, []() { return std::make_unique(); }), CompileLayer(*this->ES, ObjectLayer, @@ -65,21 +62,21 @@ } static Expected> Create() { - auto SSP = std::make_shared(); - auto TPC = SelfTargetProcessControl::Create(SSP); + auto TPC = SelfTargetProcessControl::Create(); if (!TPC) return TPC.takeError(); - auto ES = std::make_unique(std::move(SSP)); + auto ES = std::make_unique(std::move(*TPC)); - JITTargetMachineBuilder JTMB((*TPC)->getTargetTriple()); + JITTargetMachineBuilder JTMB( + ES->getTargetProcessControl().getTargetTriple()); auto DL = JTMB.getDefaultDataLayoutForTarget(); if (!DL) return DL.takeError(); - return std::make_unique(std::move(*TPC), std::move(ES), - std::move(JTMB), std::move(*DL)); + return std::make_unique(std::move(ES), std::move(JTMB), + std::move(*DL)); } const DataLayout &getDataLayout() const { return DL; } diff --git a/llvm/include/llvm/ExecutionEngine/Orc/Core.h b/llvm/include/llvm/ExecutionEngine/Orc/Core.h --- a/llvm/include/llvm/ExecutionEngine/Orc/Core.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/Core.h @@ -19,7 +19,7 @@ #include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ExecutionEngine/JITLink/JITLinkDylib.h" #include "llvm/ExecutionEngine/JITSymbol.h" -#include "llvm/ExecutionEngine/Orc/SymbolStringPool.h" +#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h" #include "llvm/ExecutionEngine/OrcV1Deprecation.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ExtensibleRTTI.h" @@ -1264,19 +1264,17 @@ /// For dispatching ORC tasks (typically materialization tasks). using DispatchTaskFunction = unique_function T)>; - /// Construct an ExecutionSession. - /// - /// SymbolStringPools may be shared between ExecutionSessions. - ExecutionSession(std::shared_ptr SSP = nullptr); + /// Construct an ExecutionSession with the given TargetProcessControl object. + ExecutionSession(std::unique_ptr TPC); /// End the session. Closes all JITDylibs. Error endSession(); - /// Add a symbol name to the SymbolStringPool and return a pointer to it. - SymbolStringPtr intern(StringRef SymName) { return SSP->intern(SymName); } + /// Get the TargetProcessControl object associated with this ExecutionSession. + TargetProcessControl &getTargetProcessControl() { return *TPC; } - /// Returns a shared_ptr to the SymbolStringPool for this ExecutionSession. - std::shared_ptr getSymbolStringPool() const { return SSP; } + /// Add a symbol name to the SymbolStringPool and return a pointer to it. + SymbolStringPtr intern(StringRef SymName) { return TPC->intern(SymName); } /// Set the Platform for this ExecutionSession. void setPlatform(std::unique_ptr P) { this->P = std::move(P); } @@ -1501,7 +1499,7 @@ mutable std::recursive_mutex SessionMutex; bool SessionOpen = true; - std::shared_ptr SSP; + std::unique_ptr TPC; std::unique_ptr P; ErrorReporter ReportError = logErrorsToStdErr; DispatchTaskFunction DispatchTask = runOnCurrentThread; diff --git a/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h b/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h --- a/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h @@ -260,6 +260,7 @@ using PlatformSetupFunction = std::function; + std::unique_ptr TPC; std::unique_ptr ES; Optional JTMB; Optional DL; @@ -267,7 +268,6 @@ CompileFunctionCreator CreateCompileFunction; PlatformSetupFunction SetUpPlatform; unsigned NumCompileThreads = 0; - TargetProcessControl *TPC = nullptr; /// Called prior to JIT class construcion to fix up defaults. Error prepareForConstruction(); @@ -276,7 +276,17 @@ template class LLJITBuilderSetters { public: - + /// Set a TargetProcessControl for this instance. + /// This should not be called if ExecutionSession has already been set. + SetterImpl & + setTargetProcessControl(std::unique_ptr TPC) { + assert( + !impl().ES && + "setTargetProcessControl should not be called if an ExecutionSession " + "has already been set"); + impl().TPC = std::move(TPC); + return impl(); + } /// Set an ExecutionSession for this instance. SetterImpl &setExecutionSession(std::unique_ptr ES) { impl().ES = std::move(ES); @@ -350,17 +360,6 @@ return impl(); } - /// Set a TargetProcessControl object. - /// - /// If the platform uses ObjectLinkingLayer by default and no - /// ObjectLinkingLayerCreator has been set then the TargetProcessControl - /// object will be used to supply the memory manager for the - /// ObjectLinkingLayer. - SetterImpl &setTargetProcessControl(TargetProcessControl &TPC) { - impl().TPC = &TPC; - return impl(); - } - /// Create an instance of the JIT. Expected> create() { if (auto Err = impl().prepareForConstruction()) diff --git a/llvm/include/llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h b/llvm/include/llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h --- a/llvm/include/llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h @@ -101,7 +101,11 @@ using ReturnObjectBufferFunction = std::function)>; - /// Construct an ObjectLinkingLayer. + /// Construct an ObjectLinkingLayer using the TargetProcessControl + /// instance's memory manager. + ObjectLinkingLayer(ExecutionSession &ES); + + /// Construct an ObjectLinkingLayer using a custom memory manager. ObjectLinkingLayer(ExecutionSession &ES, jitlink::JITLinkMemoryManager &MemMgr); diff --git a/llvm/include/llvm/ExecutionEngine/Orc/TPCDebugObjectRegistrar.h b/llvm/include/llvm/ExecutionEngine/Orc/TPCDebugObjectRegistrar.h --- a/llvm/include/llvm/ExecutionEngine/Orc/TPCDebugObjectRegistrar.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/TPCDebugObjectRegistrar.h @@ -14,7 +14,7 @@ #define LLVM_EXECUTIONENGINE_ORC_TPCDEBUGOBJECTREGISTRAR_H #include "llvm/ExecutionEngine/JITSymbol.h" -#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h" +#include "llvm/ExecutionEngine/Orc/Shared/WrapperFunctionUtils.h" #include "llvm/Support/Error.h" #include "llvm/Support/Memory.h" @@ -27,6 +27,9 @@ namespace llvm { namespace orc { +class ExecutionSession; +class TargetProcessControl; + /// Abstract interface for registering debug objects in the target process. class DebugObjectRegistrar { public: @@ -38,25 +41,20 @@ /// target process. class TPCDebugObjectRegistrar : public DebugObjectRegistrar { public: - TPCDebugObjectRegistrar(TargetProcessControl &TPC, - JITTargetAddress RegisterFn) - : TPC(TPC), RegisterFn(RegisterFn) {} + TPCDebugObjectRegistrar(ExecutionSession &ES, JITTargetAddress RegisterFn) + : ES(ES), RegisterFn(RegisterFn) {} - Error registerDebugObject(sys::MemoryBlock TargetMem) override { - return WrapperFunction::call( - TPCCaller(TPC, RegisterFn), pointerToJITTargetAddress(TargetMem.base()), - static_cast(TargetMem.allocatedSize())); - } + Error registerDebugObject(sys::MemoryBlock TargetMem) override; private: - TargetProcessControl &TPC; + ExecutionSession &ES; JITTargetAddress RegisterFn; }; /// Create a TargetProcessControl-based DebugObjectRegistrar that emits debug /// objects to the GDB JIT interface. Expected> -createJITLoaderGDBRegistrar(TargetProcessControl &TPC); +createJITLoaderGDBRegistrar(ExecutionSession &ES); } // end namespace orc } // end namespace llvm diff --git a/llvm/include/llvm/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.h b/llvm/include/llvm/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.h --- a/llvm/include/llvm/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.h @@ -15,11 +15,13 @@ #define LLVM_EXECUTIONENGINE_ORC_TPCDYNAMICLIBRARYSEARCHGENERATOR_H #include "llvm/ADT/FunctionExtras.h" -#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h" +#include "llvm/ExecutionEngine/Orc/Core.h" namespace llvm { namespace orc { +class TargetProcessControl; + class TPCDynamicLibrarySearchGenerator : public DefinitionGenerator { public: using SymbolPredicate = unique_function; @@ -30,24 +32,24 @@ /// 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, + TPCDynamicLibrarySearchGenerator(ExecutionSession &ES, tpctypes::DylibHandle H, SymbolPredicate Allow = SymbolPredicate()) - : TPC(TPC), H(H), Allow(std::move(Allow)) {} + : TPC(ES.getTargetProcessControl()), 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, + Load(ExecutionSession &ES, const char *LibraryPath, SymbolPredicate Allow = SymbolPredicate()); /// Creates a TPCDynamicLibrarySearchGenerator that searches for symbols in /// the target process. static Expected> - GetForTargetProcess(TargetProcessControl &TPC, + GetForTargetProcess(ExecutionSession &ES, SymbolPredicate Allow = SymbolPredicate()) { - return Load(TPC, nullptr, std::move(Allow)); + return Load(ES, nullptr, std::move(Allow)); } Error tryToGenerate(LookupState &LS, LookupKind K, JITDylib &JD, diff --git a/llvm/include/llvm/ExecutionEngine/Orc/TPCEHFrameRegistrar.h b/llvm/include/llvm/ExecutionEngine/Orc/TPCEHFrameRegistrar.h --- a/llvm/include/llvm/ExecutionEngine/Orc/TPCEHFrameRegistrar.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/TPCEHFrameRegistrar.h @@ -14,11 +14,12 @@ #define LLVM_EXECUTIONENGINE_ORC_TPCEHFRAMEREGISTRAR_H #include "llvm/ExecutionEngine/JITLink/EHFrameSupport.h" -#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h" namespace llvm { namespace orc { +class ExecutionSession; + /// Register/Deregisters EH frames in a remote process via a /// TargetProcessControl instance. class TPCEHFrameRegistrar : public jitlink::EHFrameRegistrar { @@ -27,14 +28,14 @@ /// the TPC's lookupSymbols method to find the registration/deregistration /// funciton addresses by name. static Expected> - Create(TargetProcessControl &TPC); + Create(ExecutionSession &ES); /// Create a TPCEHFrameRegistrar with the given TargetProcessControl /// object and registration/deregistration function addresses. - TPCEHFrameRegistrar(TargetProcessControl &TPC, + TPCEHFrameRegistrar(ExecutionSession &ES, JITTargetAddress RegisterEHFrameWrapperFnAddr, JITTargetAddress DeregisterEHFRameWrapperFnAddr) - : TPC(TPC), RegisterEHFrameWrapperFnAddr(RegisterEHFrameWrapperFnAddr), + : ES(ES), RegisterEHFrameWrapperFnAddr(RegisterEHFrameWrapperFnAddr), DeregisterEHFrameWrapperFnAddr(DeregisterEHFRameWrapperFnAddr) {} Error registerEHFrames(JITTargetAddress EHFrameSectionAddr, @@ -43,7 +44,7 @@ size_t EHFrameSectionSize) override; private: - TargetProcessControl &TPC; + ExecutionSession &ES; JITTargetAddress RegisterEHFrameWrapperFnAddr; JITTargetAddress DeregisterEHFrameWrapperFnAddr; }; diff --git a/llvm/include/llvm/ExecutionEngine/Orc/TargetProcessControl.h b/llvm/include/llvm/ExecutionEngine/Orc/TargetProcessControl.h --- a/llvm/include/llvm/ExecutionEngine/Orc/TargetProcessControl.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/TargetProcessControl.h @@ -17,9 +17,9 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Triple.h" #include "llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h" -#include "llvm/ExecutionEngine/Orc/Core.h" #include "llvm/ExecutionEngine/Orc/Shared/TargetProcessControlTypes.h" #include "llvm/ExecutionEngine/Orc/Shared/WrapperFunctionUtils.h" +#include "llvm/ExecutionEngine/Orc/SymbolStringPool.h" #include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/MSVCErrorWorkarounds.h" @@ -29,6 +29,8 @@ namespace llvm { namespace orc { +class SymbolLookupSet; + /// TargetProcessControl supports interaction with a JIT target process. class TargetProcessControl { public: @@ -114,10 +116,16 @@ unsigned getPageSize() const { return PageSize; } /// Return a MemoryAccess object for the target process. - MemoryAccess &getMemoryAccess() const { return *MemAccess; } + MemoryAccess &getMemoryAccess() const { + assert(MemAccess && "No MemAccess object set."); + return *MemAccess; + } /// Return a JITLinkMemoryManager for the target process. - jitlink::JITLinkMemoryManager &getMemMgr() const { return *MemMgr; } + jitlink::JITLinkMemoryManager &getMemMgr() const { + assert(MemMgr && "No MemMgr object set"); + return *MemMgr; + } /// Load the dynamic library at the given path and return a handle to it. /// If LibraryPath is null this function will return the global handle for @@ -178,6 +186,43 @@ JITTargetAddress WrapperFnAddr; }; +/// A TargetProcessControl instance that asserts if any of its methods are used. +/// Suitable for use is unit tests, and by ORC clients who haven't moved to +/// TargetProcessControl-based APIs yet. +class UnsupportedTargetProcessControl : public TargetProcessControl { +public: + UnsupportedTargetProcessControl( + std::shared_ptr SSP = nullptr, + const std::string &TT = "", unsigned PageSize = 0) + : TargetProcessControl(SSP ? std::move(SSP) + : std::make_shared()) { + this->TargetTriple = Triple(TT); + this->PageSize = PageSize; + } + + Expected loadDylib(const char *DylibPath) override { + llvm_unreachable("Unsupported"); + } + + Expected> + lookupSymbols(ArrayRef Request) override { + llvm_unreachable("Unsupported"); + } + + Expected runAsMain(JITTargetAddress MainFnAddr, + ArrayRef Args) override { + llvm_unreachable("Unsupported"); + } + + Expected + runWrapper(JITTargetAddress WrapperFnAddr, + ArrayRef ArgBuffer) override { + llvm_unreachable("Unsupported"); + } + + Error disconnect() override { llvm_unreachable("Unsupported"); } +}; + /// A TargetProcessControl implementation targeting the current process. class SelfTargetProcessControl : public TargetProcessControl, private TargetProcessControl::MemoryAccess { @@ -186,11 +231,13 @@ std::shared_ptr SSP, Triple TargetTriple, unsigned PageSize, std::unique_ptr MemMgr); - /// Create a SelfTargetProcessControl with the given memory manager. + /// Create a SelfTargetProcessControl with the given symbol string pool and + /// memory manager. + /// If no symbol string pool is given then one will be created. /// If no memory manager is given a jitlink::InProcessMemoryManager will - /// be used by default. + /// be created and used by default. static Expected> - Create(std::shared_ptr SSP, + Create(std::shared_ptr SSP = nullptr, std::unique_ptr MemMgr = nullptr); Expected loadDylib(const char *DylibPath) override; diff --git a/llvm/lib/ExecutionEngine/Orc/Core.cpp b/llvm/lib/ExecutionEngine/Orc/Core.cpp --- a/llvm/lib/ExecutionEngine/Orc/Core.cpp +++ b/llvm/lib/ExecutionEngine/Orc/Core.cpp @@ -1759,8 +1759,8 @@ void MaterializationTask::run() { MU->materialize(std::move(MR)); } -ExecutionSession::ExecutionSession(std::shared_ptr SSP) - : SSP(SSP ? std::move(SSP) : std::make_shared()) {} +ExecutionSession::ExecutionSession(std::unique_ptr TPC) + : TPC(std::move(TPC)) {} Error ExecutionSession::endSession() { LLVM_DEBUG(dbgs() << "Ending ExecutionSession " << this << "\n"); diff --git a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp --- a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp +++ b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp @@ -976,16 +976,9 @@ JTMB->setRelocationModel(Reloc::PIC_); JTMB->setCodeModel(CodeModel::Small); CreateObjectLinkingLayer = - [TPC = this->TPC]( - ExecutionSession &ES, - const Triple &) -> Expected> { - std::unique_ptr ObjLinkingLayer; - if (TPC) - ObjLinkingLayer = - std::make_unique(ES, TPC->getMemMgr()); - else - ObjLinkingLayer = std::make_unique( - ES, std::make_unique()); + [](ExecutionSession &ES, + const Triple &) -> Expected> { + auto ObjLinkingLayer = std::make_unique(ES); ObjLinkingLayer->addPlugin(std::make_unique( ES, std::make_unique())); return std::move(ObjLinkingLayer); @@ -1079,11 +1072,25 @@ } LLJIT::LLJIT(LLJITBuilderState &S, Error &Err) - : ES(S.ES ? std::move(S.ES) : std::make_unique()), Main(), - DL(""), TT(S.JTMB->getTargetTriple()) { + : DL(""), TT(S.JTMB->getTargetTriple()) { ErrorAsOutParameter _(&Err); + assert(!(S.TPC && S.ES) && "TPC and ES should not both be set"); + + if (S.TPC) { + ES = std::make_unique(std::move(S.TPC)); + } else if (S.ES) + ES = std::move(S.ES); + else { + if (auto TPC = SelfTargetProcessControl::Create()) { + ES = std::make_unique(std::move(*TPC)); + } else { + Err = TPC.takeError(); + return; + } + } + if (auto MainOrErr = this->ES->createJITDylib("main")) Main = &*MainOrErr; else { diff --git a/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp b/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp --- a/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp +++ b/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp @@ -567,6 +567,11 @@ using BaseT = RTTIExtends; +ObjectLinkingLayer::ObjectLinkingLayer(ExecutionSession &ES) + : BaseT(ES), MemMgr(ES.getTargetProcessControl().getMemMgr()) { + ES.registerResourceManager(*this); +} + ObjectLinkingLayer::ObjectLinkingLayer(ExecutionSession &ES, JITLinkMemoryManager &MemMgr) : BaseT(ES), MemMgr(MemMgr) { diff --git a/llvm/lib/ExecutionEngine/Orc/OrcV2CBindings.cpp b/llvm/lib/ExecutionEngine/Orc/OrcV2CBindings.cpp --- a/llvm/lib/ExecutionEngine/Orc/OrcV2CBindings.cpp +++ b/llvm/lib/ExecutionEngine/Orc/OrcV2CBindings.cpp @@ -248,7 +248,8 @@ LLVMOrcSymbolStringPoolRef LLVMOrcExecutionSessionGetSymbolStringPool(LLVMOrcExecutionSessionRef ES) { - return wrap(unwrap(ES)->getSymbolStringPool().get()); + return wrap( + unwrap(ES)->getTargetProcessControl().getSymbolStringPool().get()); } void LLVMOrcSymbolStringPoolClearDeadEntries(LLVMOrcSymbolStringPoolRef SSP) { diff --git a/llvm/lib/ExecutionEngine/Orc/TPCDebugObjectRegistrar.cpp b/llvm/lib/ExecutionEngine/Orc/TPCDebugObjectRegistrar.cpp --- a/llvm/lib/ExecutionEngine/Orc/TPCDebugObjectRegistrar.cpp +++ b/llvm/lib/ExecutionEngine/Orc/TPCDebugObjectRegistrar.cpp @@ -16,7 +16,8 @@ namespace orc { Expected> -createJITLoaderGDBRegistrar(TargetProcessControl &TPC) { +createJITLoaderGDBRegistrar(ExecutionSession &ES) { + auto &TPC = ES.getTargetProcessControl(); auto ProcessHandle = TPC.loadDylib(nullptr); if (!ProcessHandle) return ProcessHandle.takeError(); @@ -37,7 +38,14 @@ assert((*Result)[0].size() == 1 && "Unexpected number of addresses in result"); - return std::make_unique(TPC, (*Result)[0][0]); + return std::make_unique(ES, (*Result)[0][0]); +} + +Error TPCDebugObjectRegistrar::registerDebugObject(sys::MemoryBlock TargetMem) { + return WrapperFunction::call( + TPCCaller(ES.getTargetProcessControl(), RegisterFn), + pointerToJITTargetAddress(TargetMem.base()), + static_cast(TargetMem.allocatedSize())); } } // namespace orc diff --git a/llvm/lib/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.cpp b/llvm/lib/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.cpp --- a/llvm/lib/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.cpp +++ b/llvm/lib/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.cpp @@ -12,14 +12,14 @@ namespace orc { Expected> -TPCDynamicLibrarySearchGenerator::Load(TargetProcessControl &TPC, +TPCDynamicLibrarySearchGenerator::Load(ExecutionSession &ES, const char *LibraryPath, SymbolPredicate Allow) { - auto Handle = TPC.loadDylib(LibraryPath); + auto Handle = ES.getTargetProcessControl().loadDylib(LibraryPath); if (!Handle) return Handle.takeError(); - return std::make_unique(TPC, *Handle, + return std::make_unique(ES, *Handle, std::move(Allow)); } diff --git a/llvm/lib/ExecutionEngine/Orc/TPCEHFrameRegistrar.cpp b/llvm/lib/ExecutionEngine/Orc/TPCEHFrameRegistrar.cpp --- a/llvm/lib/ExecutionEngine/Orc/TPCEHFrameRegistrar.cpp +++ b/llvm/lib/ExecutionEngine/Orc/TPCEHFrameRegistrar.cpp @@ -7,6 +7,8 @@ //===----------------------------------------------------------------------===// #include "llvm/ExecutionEngine/Orc/TPCEHFrameRegistrar.h" + +#include "llvm/ExecutionEngine/Orc/Core.h" #include "llvm/Support/BinaryStreamWriter.h" using namespace llvm::orc::shared; @@ -15,12 +17,14 @@ namespace orc { Expected> -TPCEHFrameRegistrar::Create(TargetProcessControl &TPC) { +TPCEHFrameRegistrar::Create(ExecutionSession &ES) { // 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 &TPC = ES.getTargetProcessControl(); + auto ProcessHandle = TPC.loadDylib(nullptr); if (!ProcessHandle) return ProcessHandle.takeError(); @@ -48,23 +52,23 @@ auto RegisterEHFrameWrapperFnAddr = (*Result)[0][0]; auto DeregisterEHFrameWrapperFnAddr = (*Result)[0][1]; - return std::make_unique( - TPC, RegisterEHFrameWrapperFnAddr, DeregisterEHFrameWrapperFnAddr); + return std::make_unique(ES, RegisterEHFrameWrapperFnAddr, + DeregisterEHFrameWrapperFnAddr); } Error TPCEHFrameRegistrar::registerEHFrames(JITTargetAddress EHFrameSectionAddr, size_t EHFrameSectionSize) { return WrapperFunction::call( - TPCCaller(TPC, RegisterEHFrameWrapperFnAddr), EHFrameSectionAddr, - static_cast(EHFrameSectionSize)); + TPCCaller(ES.getTargetProcessControl(), RegisterEHFrameWrapperFnAddr), + EHFrameSectionAddr, static_cast(EHFrameSectionSize)); } Error TPCEHFrameRegistrar::deregisterEHFrames( JITTargetAddress EHFrameSectionAddr, size_t EHFrameSectionSize) { return WrapperFunction::call( - TPCCaller(TPC, DeregisterEHFrameWrapperFnAddr), EHFrameSectionAddr, - static_cast(EHFrameSectionSize)); + TPCCaller(ES.getTargetProcessControl(), DeregisterEHFrameWrapperFnAddr), + EHFrameSectionAddr, static_cast(EHFrameSectionSize)); } } // end namespace orc diff --git a/llvm/lib/ExecutionEngine/Orc/TargetProcessControl.cpp b/llvm/lib/ExecutionEngine/Orc/TargetProcessControl.cpp --- a/llvm/lib/ExecutionEngine/Orc/TargetProcessControl.cpp +++ b/llvm/lib/ExecutionEngine/Orc/TargetProcessControl.cpp @@ -43,6 +43,10 @@ SelfTargetProcessControl::Create( std::shared_ptr SSP, std::unique_ptr MemMgr) { + + if (!SSP) + SSP = std::make_shared(); + auto PageSize = sys::Process::getPageSize(); if (!PageSize) return PageSize.takeError(); diff --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp --- a/llvm/tools/lli/lli.cpp +++ b/llvm/tools/lli/lli.cpp @@ -22,8 +22,8 @@ #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" @@ -40,6 +40,7 @@ #include "llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h" #include "llvm/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.h" #include "llvm/ExecutionEngine/Orc/TargetProcess/TargetExecutionUtils.h" +#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h" #include "llvm/ExecutionEngine/SectionMemoryManager.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/LLVMContext.h" @@ -720,7 +721,8 @@ } // Create a remote target client running over the channel. - llvm::orc::ExecutionSession ES; + llvm::orc::ExecutionSession ES( + std::make_unique()); ES.setErrorReporter([&](Error Err) { ExitOnErr(std::move(Err)); }); typedef orc::remote::OrcRemoteTargetClient MyRemote; auto R = ExitOnErr(MyRemote::Create(*C, ES)); @@ -877,7 +879,8 @@ // JIT builder to instantiate a default (which would fail with an error for // unsupported architectures). if (UseJITKind != JITKind::OrcLazy) { - auto ES = std::make_unique(); + auto TPC = ExitOnErr(orc::SelfTargetProcessControl::Create()); + auto ES = std::make_unique(std::move(TPC)); Builder.setLazyCallthroughManager( std::make_unique(*ES, 0, nullptr)); Builder.setExecutionSession(std::move(ES)); @@ -936,20 +939,16 @@ } } - std::unique_ptr TPC = nullptr; if (JITLinker == JITLinkerKind::JITLink) { - TPC = ExitOnErr(orc::SelfTargetProcessControl::Create( - std::make_shared())); - - Builder.setObjectLinkingLayerCreator([&TPC](orc::ExecutionSession &ES, - const Triple &) { - auto L = std::make_unique(ES, TPC->getMemMgr()); - L->addPlugin(std::make_unique( - ES, ExitOnErr(orc::TPCEHFrameRegistrar::Create(*TPC)))); - L->addPlugin(std::make_unique( - ES, ExitOnErr(orc::createJITLoaderGDBRegistrar(*TPC)))); - return L; - }); + Builder.setObjectLinkingLayerCreator( + [](orc::ExecutionSession &ES, const Triple &) { + auto L = std::make_unique(ES); + L->addPlugin(std::make_unique( + ES, ExitOnErr(orc::TPCEHFrameRegistrar::Create(ES)))); + L->addPlugin(std::make_unique( + ES, ExitOnErr(orc::createJITLoaderGDBRegistrar(ES)))); + return L; + }); } auto J = ExitOnErr(Builder.create()); @@ -1069,9 +1068,11 @@ JITEvaluatedSymbol MainSym = ExitOnErr(J->lookup(EntryFunc)); int Result; - if (TPC) { + if (JITLinker == JITLinkerKind::JITLink) { // TargetProcessControl-based execution with JITLink. - Result = ExitOnErr(TPC->runAsMain(MainSym.getAddress(), InputArgv)); + Result = + ExitOnErr(J->getExecutionSession().getTargetProcessControl().runAsMain( + MainSym.getAddress(), InputArgv)); } else { // Manual in-process execution with RuntimeDyld. using MainFnTy = int(int, char *[]); diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.h b/llvm/tools/llvm-jitlink/llvm-jitlink.h --- a/llvm/tools/llvm-jitlink/llvm-jitlink.h +++ b/llvm/tools/llvm-jitlink/llvm-jitlink.h @@ -109,7 +109,6 @@ }; struct Session { - std::unique_ptr TPC; orc::ExecutionSession ES; orc::JITDylib *MainJD; LLVMJITLinkObjectLinkingLayer ObjLayer; diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp --- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp +++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp @@ -828,7 +828,8 @@ // 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()) { + : ES(std::move(TPC)), + ObjLayer(*this, ES.getTargetProcessControl().getMemMgr()) { /// Local ObjectLinkingLayer::Plugin class to forward modifyPassConfig to the /// Session. @@ -862,11 +863,12 @@ return; } - if (!NoExec && !this->TPC->getTargetTriple().isOSWindows()) { + if (!NoExec && + !ES.getTargetProcessControl().getTargetTriple().isOSWindows()) { ObjLayer.addPlugin(std::make_unique( - ES, ExitOnErr(TPCEHFrameRegistrar::Create(*this->TPC)))); + ES, ExitOnErr(TPCEHFrameRegistrar::Create(this->ES)))); ObjLayer.addPlugin(std::make_unique( - ES, ExitOnErr(createJITLoaderGDBRegistrar(*this->TPC)))); + ES, ExitOnErr(createJITLoaderGDBRegistrar(this->ES)))); } ObjLayer.addPlugin(std::make_unique(*this)); @@ -913,10 +915,11 @@ PassConfiguration &PassConfig) { if (!CheckFiles.empty()) PassConfig.PostFixupPasses.push_back([this](LinkGraph &G) { - if (TPC->getTargetTriple().getObjectFormat() == Triple::ELF) + auto &TPC = ES.getTargetProcessControl(); + if (TPC.getTargetTriple().getObjectFormat() == Triple::ELF) return registerELFGraphInfo(*this, G); - if (TPC->getTargetTriple().getObjectFormat() == Triple::MachO) + if (TPC.getTargetTriple().getObjectFormat() == Triple::MachO) return registerMachOGraphInfo(*this, G); return make_error("Unsupported object format for GOT/stub " @@ -1095,14 +1098,14 @@ }; S.MainJD->addGenerator( ExitOnErr(orc::TPCDynamicLibrarySearchGenerator::GetForTargetProcess( - *S.TPC, std::move(FilterMainEntryPoint)))); + S.ES, 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::TPCDynamicLibrarySearchGenerator::Load(S.ES, Dylib.c_str()); if (!G) return G.takeError(); S.MainJD->addGenerator(std::move(*G)); @@ -1178,7 +1181,8 @@ 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.ES.getTargetProcessControl().getTargetTriple()))); else ExitOnErr(S.ObjLayer.add(JD, std::move(ObjBuffer))); } @@ -1225,8 +1229,9 @@ } static Error runChecks(Session &S) { + auto &TPC = S.ES.getTargetProcessControl(); - auto TripleName = S.TPC->getTargetTriple().str(); + auto TripleName = TPC.getTargetTriple().str(); std::string ErrorStr; const Target *TheTarget = TargetRegistry::lookupTarget(TripleName, ErrorStr); if (!TheTarget) @@ -1292,8 +1297,7 @@ RuntimeDyldChecker Checker( IsSymbolValid, GetSymbolInfo, GetSectionInfo, GetStubInfo, GetGOTInfo, - S.TPC->getTargetTriple().isLittleEndian() ? support::little - : support::big, + TPC.getTargetTriple().isLittleEndian() ? support::little : support::big, Disassembler.get(), InstPrinter.get(), dbgs()); std::string CheckLineStart = "# " + CheckName + ":"; @@ -1381,11 +1385,12 @@ int Result = 0; { TimeRegion TR(Timers ? &Timers->RunTimer : nullptr); - Result = ExitOnErr(S->TPC->runAsMain(EntryPoint.getAddress(), InputArgv)); + auto &TPC = S->ES.getTargetProcessControl(); + Result = ExitOnErr(TPC.runAsMain(EntryPoint.getAddress(), InputArgv)); } ExitOnErr(S->ES.endSession()); - ExitOnErr(S->TPC->disconnect()); + ExitOnErr(S->ES.getTargetProcessControl().disconnect()); return Result; } diff --git a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp b/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp --- a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp +++ b/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp @@ -1409,7 +1409,7 @@ // Test that DFS ordering behaves as expected when the linkage relationships // form a tree. - ExecutionSession ES; + ExecutionSession ES{std::make_unique()}; auto &LibA = ES.createBareJITDylib("A"); auto &LibB = ES.createBareJITDylib("B"); @@ -1450,7 +1450,7 @@ // Test that DFS ordering behaves as expected when the linkage relationships // contain a diamond. - ExecutionSession ES; + ExecutionSession ES{std::make_unique()}; auto &LibA = ES.createBareJITDylib("A"); auto &LibB = ES.createBareJITDylib("B"); auto &LibC = ES.createBareJITDylib("C"); @@ -1472,7 +1472,7 @@ // Test that DFS ordering behaves as expected when the linkage relationships // contain a cycle. - ExecutionSession ES; + ExecutionSession ES{std::make_unique()}; auto &LibA = ES.createBareJITDylib("A"); auto &LibB = ES.createBareJITDylib("B"); auto &LibC = ES.createBareJITDylib("C"); diff --git a/llvm/unittests/ExecutionEngine/Orc/ObjectLinkingLayerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/ObjectLinkingLayerTest.cpp --- a/llvm/unittests/ExecutionEngine/Orc/ObjectLinkingLayerTest.cpp +++ b/llvm/unittests/ExecutionEngine/Orc/ObjectLinkingLayerTest.cpp @@ -35,7 +35,7 @@ } protected: - ExecutionSession ES; + ExecutionSession ES{std::make_unique()}; JITDylib &JD = ES.createBareJITDylib("main"); ObjectLinkingLayer ObjLinkingLayer{ ES, std::make_unique()}; diff --git a/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h b/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h --- a/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h +++ b/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h @@ -14,9 +14,10 @@ #ifndef LLVM_UNITTESTS_EXECUTIONENGINE_ORC_ORCTESTCOMMON_H #define LLVM_UNITTESTS_EXECUTIONENGINE_ORC_ORCTESTCOMMON_H -#include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/JITSymbol.h" +#include "llvm/ExecutionEngine/Orc/Core.h" #include "llvm/ExecutionEngine/Orc/IndirectionUtils.h" +#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h" #include "llvm/IR/Function.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/LLVMContext.h" @@ -52,7 +53,7 @@ protected: std::shared_ptr SSP = std::make_shared(); - ExecutionSession ES{SSP}; + ExecutionSession ES{std::make_unique(SSP)}; JITDylib &JD = ES.createBareJITDylib("JD"); SymbolStringPtr Foo = ES.intern("foo"); SymbolStringPtr Bar = ES.intern("bar"); diff --git a/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp --- a/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp +++ b/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp @@ -45,7 +45,7 @@ bool NonAllocSectionSeen = false; - ExecutionSession ES; + ExecutionSession ES(std::make_unique()); auto &JD = ES.createBareJITDylib("main"); auto Foo = ES.intern("foo"); @@ -152,7 +152,7 @@ } // Create a simple stack and set the override flags option. - ExecutionSession ES; + ExecutionSession ES{std::make_unique()}; auto &JD = ES.createBareJITDylib("main"); auto Foo = ES.intern("foo"); RTDyldObjectLinkingLayer ObjLayer( @@ -222,7 +222,7 @@ } // Create a simple stack and set the override flags option. - ExecutionSession ES; + ExecutionSession ES{std::make_unique()}; auto &JD = ES.createBareJITDylib("main"); auto Foo = ES.intern("foo"); RTDyldObjectLinkingLayer ObjLayer(