diff --git a/llvm/include/llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h b/llvm/include/llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h index caf8e707516d..50d25f18891e 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h @@ -79,7 +79,7 @@ public: /// Construct an ObjectLinkingLayer with the given NotifyLoaded, /// and NotifyEmitted functors. ObjectLinkingLayer(ExecutionSession &ES, - jitlink::JITLinkMemoryManager &MemMgr); + std::unique_ptr MemMgr); /// Destruct an ObjectLinkingLayer. ~ObjectLinkingLayer(); @@ -145,7 +145,7 @@ private: Error removeAllModules(); mutable std::mutex LayerMutex; - jitlink::JITLinkMemoryManager &MemMgr; + std::unique_ptr MemMgr; bool OverrideObjectFlags = false; bool AutoClaimObjectSymbols = false; ReturnObjectBufferFunction ReturnObjectBuffer; diff --git a/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp b/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp index be0ce4a1d75a..2572b7f4878d 100644 --- a/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp +++ b/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp @@ -36,7 +36,7 @@ public: Layer.ReturnObjectBuffer(std::move(ObjBuffer)); } - JITLinkMemoryManager &getMemoryManager() override { return Layer.MemMgr; } + JITLinkMemoryManager &getMemoryManager() override { return *Layer.MemMgr; } MemoryBufferRef getObjectBuffer() const override { return ObjBuffer->getMemBufferRef(); @@ -328,9 +328,9 @@ private: ObjectLinkingLayer::Plugin::~Plugin() {} -ObjectLinkingLayer::ObjectLinkingLayer(ExecutionSession &ES, - JITLinkMemoryManager &MemMgr) - : ObjectLayer(ES), MemMgr(MemMgr) {} +ObjectLinkingLayer::ObjectLinkingLayer( + ExecutionSession &ES, std::unique_ptr MemMgr) + : ObjectLayer(ES), MemMgr(std::move(MemMgr)) {} ObjectLinkingLayer::~ObjectLinkingLayer() { if (auto Err = removeAllModules()) diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp index de52bb9ec637..26bcf46d60a6 100644 --- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp +++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp @@ -397,8 +397,8 @@ static std::unique_ptr createMemoryManager() { } Session::Session(Triple TT) - : MainJD(ES.createJITDylib("
")), MemMgr(createMemoryManager()), - ObjLayer(ES, *MemMgr), TT(std::move(TT)) { + : MainJD(ES.createJITDylib("
")), ObjLayer(ES, createMemoryManager()), + TT(std::move(TT)) { /// Local ObjectLinkingLayer::Plugin class to forward modifyPassConfig to the /// Session. diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.h b/llvm/tools/llvm-jitlink/llvm-jitlink.h index 005f7f211e98..0f92d7605012 100644 --- a/llvm/tools/llvm-jitlink/llvm-jitlink.h +++ b/llvm/tools/llvm-jitlink/llvm-jitlink.h @@ -27,7 +27,6 @@ namespace llvm { struct Session { orc::ExecutionSession ES; orc::JITDylib &MainJD; - std::unique_ptr MemMgr; orc::ObjectLinkingLayer ObjLayer; std::vector JDSearchOrder; Triple TT;