diff options
author | Lang Hames <lhames@gmail.com> | 2018-02-21 21:55:49 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2018-02-21 21:55:49 +0000 |
commit | 589eece1323e5ba20e8887bc4314db9af477ba77 (patch) | |
tree | 88ef672592bfa38e0beea4ee2761a9b27e196991 /llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h | |
parent | c1b46381dbfc070ccdba327d36053c154cde2b4f (diff) | |
download | bcm5719-llvm-589eece1323e5ba20e8887bc4314db9af477ba77.tar.gz bcm5719-llvm-589eece1323e5ba20e8887bc4314db9af477ba77.zip |
[ORC] Switch RTDyldObjectLinkingLayer to take a unique_ptr<MemoryBuffer> rather
than a shared ObjectFile/MemoryBuffer pair.
There's no need to pre-parse the buffer into an ObjectFile before passing it
down to the linking layer, and moving the parsing into the linking layer allows
us remove the parsing code at each call site.
llvm-svn: 325725
Diffstat (limited to 'llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h')
-rw-r--r-- | llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h b/llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h index 7e412f677db..0a067501170 100644 --- a/llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h +++ b/llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h @@ -263,16 +263,15 @@ public: } void addObjectFile(std::unique_ptr<object::ObjectFile> O) override { - auto Obj = - std::make_shared<object::OwningBinary<object::ObjectFile>>(std::move(O), - nullptr); - cantFail(ObjectLayer.addObject(ES.allocateVModule(), std::move(Obj))); + cantFail(ObjectLayer.addObject( + ES.allocateVModule(), MemoryBuffer::getMemBufferCopy(O->getData()))); } void addObjectFile(object::OwningBinary<object::ObjectFile> O) override { - auto Obj = - std::make_shared<object::OwningBinary<object::ObjectFile>>(std::move(O)); - cantFail(ObjectLayer.addObject(ES.allocateVModule(), std::move(Obj))); + std::unique_ptr<object::ObjectFile> Obj; + std::unique_ptr<MemoryBuffer> ObjBuffer; + std::tie(Obj, ObjBuffer) = O.takeBinary(); + cantFail(ObjectLayer.addObject(ES.allocateVModule(), std::move(ObjBuffer))); } void addArchive(object::OwningBinary<object::Archive> A) override { @@ -375,12 +374,9 @@ private: } std::unique_ptr<object::Binary> &ChildBin = ChildBinOrErr.get(); if (ChildBin->isObject()) { - std::unique_ptr<object::ObjectFile> ChildObj( - static_cast<object::ObjectFile*>(ChildBinOrErr->release())); - auto Obj = - std::make_shared<object::OwningBinary<object::ObjectFile>>( - std::move(ChildObj), nullptr); - cantFail(ObjectLayer.addObject(ES.allocateVModule(), std::move(Obj))); + cantFail(ObjectLayer.addObject( + ES.allocateVModule(), + MemoryBuffer::getMemBufferCopy(ChildBin->getData()))); if (auto Sym = ObjectLayer.findSymbol(Name, true)) return Sym; } @@ -396,12 +392,11 @@ private: NotifyObjectLoadedT(OrcMCJITReplacement &M) : M(M) {} - void operator()(VModuleKey K, - const RTDyldObjectLinkingLayer::ObjectPtr &Obj, + void operator()(VModuleKey K, const object::ObjectFile &Obj, const RuntimeDyld::LoadedObjectInfo &Info) const { M.UnfinalizedSections[K] = std::move(M.SectionsAllocatedSinceLastLoad); M.SectionsAllocatedSinceLastLoad = SectionAddrSet(); - M.MemMgr->notifyObjectLoaded(&M, *Obj->getBinary()); + M.MemMgr->notifyObjectLoaded(&M, Obj); } private: OrcMCJITReplacement &M; |