<div dir="ltr"><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Sep 3, 2014 at 12:48 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: dblaikie<br>
Date: Wed Sep 3 14:48:09 2014<br>
New Revision: 217065<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=217065&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=217065&view=rev</a><br>
Log:<br>
unique_ptrify a bunch of stuff through RuntimeDyld::loadObject<br>
<br>
Modified:<br>
llvm/trunk/include/llvm/ExecutionEngine/ObjectBuffer.h<br>
llvm/trunk/include/llvm/ExecutionEngine/ObjectImage.h<br>
llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h<br>
llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp<br>
llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h<br>
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/ObjectImageCommon.h<br>
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp<br>
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp<br>
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.h<br>
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h<br>
llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/ExecutionEngine/ObjectBuffer.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/ObjectBuffer.h?rev=217065&r1=217064&r2=217065&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/ObjectBuffer.h?rev=217065&r1=217064&r2=217065&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/ExecutionEngine/ObjectBuffer.h (original)<br>
+++ llvm/trunk/include/llvm/ExecutionEngine/ObjectBuffer.h Wed Sep 3 14:48:09 2014<br>
@@ -29,7 +29,7 @@ class ObjectBuffer {<br>
virtual void anchor();<br>
public:<br>
ObjectBuffer() {}<br>
- ObjectBuffer(MemoryBuffer* Buf) : Buffer(Buf) {}<br>
+ ObjectBuffer(std::unique_ptr<MemoryBuffer> Buf) : Buffer(std::move(Buf)) {}<br>
virtual ~ObjectBuffer() {}<br>
<br>
MemoryBufferRef getMemBuffer() const { return Buffer->getMemBufferRef(); }<br>
<br>
Modified: llvm/trunk/include/llvm/ExecutionEngine/ObjectImage.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/ObjectImage.h?rev=217065&r1=217064&r2=217065&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/ObjectImage.h?rev=217065&r1=217064&r2=217065&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/ExecutionEngine/ObjectImage.h (original)<br>
+++ llvm/trunk/include/llvm/ExecutionEngine/ObjectImage.h Wed Sep 3 14:48:09 2014<br>
@@ -31,7 +31,7 @@ protected:<br>
std::unique_ptr<ObjectBuffer> Buffer;<br>
<br>
public:<br>
- ObjectImage(ObjectBuffer *Input) : Buffer(Input) {}<br>
+ ObjectImage(std::unique_ptr<ObjectBuffer> Input) : Buffer(std::move(Input)) {}<br>
virtual ~ObjectImage() {}<br>
<br>
virtual object::symbol_iterator begin_symbols() const = 0;<br>
<br>
Modified: llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h?rev=217065&r1=217064&r2=217065&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h?rev=217065&r1=217064&r2=217065&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h (original)<br>
+++ llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h Wed Sep 3 14:48:09 2014<br>
@@ -53,13 +53,15 @@ public:<br>
/// Ownership of the input buffer is transferred to the ObjectImage<br>
/// instance returned from this function if successful. In the case of load<br>
/// failure, the input buffer will be deleted.<br>
- ObjectImage *loadObject(ObjectBuffer *InputBuffer);<br>
+ std::unique_ptr<ObjectImage><br>
+ loadObject(std::unique_ptr<ObjectBuffer> InputBuffer);<br>
<br>
/// Prepare the referenced object file for execution.<br>
/// Ownership of the input object is transferred to the ObjectImage<br>
/// instance returned from this function if successful. In the case of load<br>
/// failure, the input object will be deleted.<br>
- ObjectImage *loadObject(std::unique_ptr<object::ObjectFile> InputObject);<br>
+ std::unique_ptr<ObjectImage><br>
+ loadObject(std::unique_ptr<object::ObjectFile> InputObject);<br>
<br>
/// Get the address of our local copy of the symbol. This may or may not<br>
/// be the address used for relocation (clients can copy the data around<br>
<br>
Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp?rev=217065&r1=217064&r2=217065&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp?rev=217065&r1=217064&r2=217065&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp (original)<br>
+++ llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp Wed Sep 3 14:48:09 2014<br>
@@ -82,15 +82,9 @@ MCJIT::~MCJIT() {<br>
<br>
Dyld.deregisterEHFrames();<br>
<br>
- LoadedObjectList::iterator it, end;<br>
- for (it = LoadedObjects.begin(), end = LoadedObjects.end(); it != end; ++it) {<br>
- ObjectImage *Obj = *it;<br>
- if (Obj) {<br>
+ for (auto &Obj : LoadedObjects)<br>
+ if (Obj)<br>
NotifyFreeingObject(*Obj);<br>
- delete Obj;<br>
- }<br>
- }<br>
- LoadedObjects.clear();<br>
<br>
Archives.clear();<br>
}<br>
@@ -106,11 +100,11 @@ bool MCJIT::removeModule(Module *M) {<br>
}<br>
<br>
void MCJIT::addObjectFile(std::unique_ptr<object::ObjectFile> Obj) {<br>
- ObjectImage *LoadedObject = Dyld.loadObject(std::move(Obj));<br>
+ std::unique_ptr<ObjectImage> LoadedObject = Dyld.loadObject(std::move(Obj));<br>
if (!LoadedObject || Dyld.hasError())<br>
report_fatal_error(Dyld.getErrorString());<br>
<br>
- LoadedObjects.push_back(LoadedObject);<br>
+ LoadedObjects.push_back(std::move(LoadedObject));<br></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
NotifyObjectEmitted(*LoadedObject);<br></blockquote><div><br></div><div>Hm? You can't really dereference LoadedObject after you std::move'd it, can you?</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
}<br>
@@ -183,9 +177,10 @@ void MCJIT::generateCodeForModule(Module<br>
std::unique_ptr<ObjectBuffer> ObjectToLoad;<br>
// Try to load the pre-compiled object from cache if possible<br>
if (ObjCache) {<br>
- std::unique_ptr<MemoryBuffer> PreCompiledObject(ObjCache->getObject(M));<br>
- if (PreCompiledObject.get())<br>
- ObjectToLoad.reset(new ObjectBuffer(PreCompiledObject.release()));<br>
+ if (std::unique_ptr<MemoryBuffer> PreCompiledObject =<br>
+ ObjCache->getObject(M))<br>
+ ObjectToLoad =<br>
+ llvm::make_unique<ObjectBuffer>(std::move(PreCompiledObject));<br>
}<br>
<br>
// If the cache did not contain a suitable object, compile the object<br>
@@ -196,8 +191,8 @@ void MCJIT::generateCodeForModule(Module<br>
<br>
// Load the object into the dynamic linker.<br>
// MCJIT now owns the ObjectImage pointer (via its LoadedObjects list).<br>
- ObjectImage *LoadedObject = Dyld.loadObject(ObjectToLoad.release());<br>
- LoadedObjects.push_back(LoadedObject);<br>
+ std::unique_ptr<ObjectImage> LoadedObject =<br>
+ Dyld.loadObject(std::move(ObjectToLoad));<br>
if (!LoadedObject)<br>
report_fatal_error(Dyld.getErrorString());<br>
<br>
@@ -206,6 +201,8 @@ void MCJIT::generateCodeForModule(Module<br>
<br>
NotifyObjectEmitted(*LoadedObject);<br>
<br>
+ LoadedObjects.push_back(std::move(LoadedObject));<br>
+<br>
OwnedModules.markModuleAsLoaded(M);<br>
}<br>
<br>
@@ -563,10 +560,8 @@ void MCJIT::NotifyObjectEmitted(const Ob<br>
}<br>
void MCJIT::NotifyFreeingObject(const ObjectImage& Obj) {<br>
MutexGuard locked(lock);<br>
- for (unsigned I = 0, S = EventListeners.size(); I < S; ++I) {<br>
- JITEventListener *L = EventListeners[I];<br>
+ for (JITEventListener *L : EventListeners)<br>
L->NotifyFreeingObject(Obj);<br>
- }<br>
}<br>
<br>
uint64_t LinkingMemoryManager::getSymbolAddress(const std::string &Name) {<br>
<br>
Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h?rev=217065&r1=217064&r2=217065&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h?rev=217065&r1=217064&r2=217065&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h (original)<br>
+++ llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h Wed Sep 3 14:48:09 2014<br>
@@ -219,8 +219,7 @@ class MCJIT : public ExecutionEngine {<br>
SmallVector<object::OwningBinary<object::Archive>, 2> Archives;<br>
SmallVector<std::unique_ptr<MemoryBuffer>, 2> Buffers;<br>
<br>
- typedef SmallVector<ObjectImage *, 2> LoadedObjectList;<br>
- LoadedObjectList LoadedObjects;<br>
+ SmallVector<std::unique_ptr<ObjectImage>, 2> LoadedObjects;<br>
<br>
// An optional ObjectCache to be notified of compiled objects and used to<br>
// perform lookup of pre-compiled code to avoid re-compilation.<br>
<br>
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/ObjectImageCommon.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/ObjectImageCommon.h?rev=217065&r1=217064&r2=217065&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/ObjectImageCommon.h?rev=217065&r1=217064&r2=217065&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/ObjectImageCommon.h (original)<br>
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/ObjectImageCommon.h Wed Sep 3 14:48:09 2014<br>
@@ -36,16 +36,13 @@ protected:<br>
<br>
// This form of the constructor allows subclasses to use<br>
// format-specific subclasses of ObjectFile directly<br>
- ObjectImageCommon(ObjectBuffer *Input, std::unique_ptr<object::ObjectFile> Obj)<br>
- : ObjectImage(Input), // saves Input as Buffer and takes ownership<br>
- ObjFile(std::move(Obj))<br>
- {<br>
- }<br>
+ ObjectImageCommon(std::unique_ptr<ObjectBuffer> Input,<br>
+ std::unique_ptr<object::ObjectFile> Obj)<br>
+ : ObjectImage(std::move(Input)), ObjFile(std::move(Obj)) {}<br>
<br>
public:<br>
- ObjectImageCommon(ObjectBuffer* Input)<br>
- : ObjectImage(Input) // saves Input as Buffer and takes ownership<br>
- {<br>
+ ObjectImageCommon(std::unique_ptr<ObjectBuffer> Input)<br>
+ : ObjectImage(std::move(Input)) {<br>
// FIXME: error checking? createObjectFile returns an ErrorOr<ObjectFile*><br>
// and should probably be checked for failure.<br>
MemoryBufferRef Buf = Buffer->getMemBuffer();<br>
<br>
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=217065&r1=217064&r2=217065&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=217065&r1=217064&r2=217065&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (original)<br>
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Wed Sep 3 14:48:09 2014<br>
@@ -794,7 +794,8 @@ createRuntimeDyldMachO(Triple::ArchType<br>
return Dyld;<br>
}<br>
<br>
-ObjectImage *RuntimeDyld::loadObject(std::unique_ptr<ObjectFile> InputObject) {<br>
+std::unique_ptr<ObjectImage><br>
+RuntimeDyld::loadObject(std::unique_ptr<ObjectFile> InputObject) {<br>
std::unique_ptr<ObjectImage> InputImage;<br>
<br>
ObjectFile &Obj = *InputObject;<br>
@@ -816,19 +817,21 @@ ObjectImage *RuntimeDyld::loadObject(std<br>
report_fatal_error("Incompatible object format!");<br>
<br>
Dyld->loadObject(InputImage.get());<br>
- return InputImage.release();<br>
+ return InputImage;<br>
}<br>
<br>
-ObjectImage *RuntimeDyld::loadObject(ObjectBuffer *InputBuffer) {<br>
+std::unique_ptr<ObjectImage><br>
+RuntimeDyld::loadObject(std::unique_ptr<ObjectBuffer> InputBuffer) {<br>
std::unique_ptr<ObjectImage> InputImage;<br>
sys::fs::file_magic Type = sys::fs::identify_magic(InputBuffer->getBuffer());<br>
+ auto *InputBufferPtr = InputBuffer.get();<br>
<br>
switch (Type) {<br>
case sys::fs::file_magic::elf_relocatable:<br>
case sys::fs::file_magic::elf_executable:<br>
case sys::fs::file_magic::elf_shared_object:<br>
case sys::fs::file_magic::elf_core:<br>
- InputImage.reset(RuntimeDyldELF::createObjectImage(InputBuffer));<br>
+ InputImage = RuntimeDyldELF::createObjectImage(std::move(InputBuffer));<br>
if (!Dyld)<br>
Dyld = createRuntimeDyldELF(MM, ProcessAllSections, Checker).release();<br>
break;<br>
@@ -842,7 +845,7 @@ ObjectImage *RuntimeDyld::loadObject(Obj<br>
case sys::fs::file_magic::macho_bundle:<br>
case sys::fs::file_magic::macho_dynamically_linked_shared_lib_stub:<br>
case sys::fs::file_magic::macho_dsym_companion:<br>
- InputImage.reset(RuntimeDyldMachO::createObjectImage(InputBuffer));<br>
+ InputImage = RuntimeDyldMachO::createObjectImage(std::move(InputBuffer));<br>
if (!Dyld)<br>
Dyld = createRuntimeDyldMachO(<br>
static_cast<Triple::ArchType>(InputImage->getArch()),<br>
@@ -859,11 +862,11 @@ ObjectImage *RuntimeDyld::loadObject(Obj<br>
report_fatal_error("Incompatible object format!");<br>
}<br>
<br>
- if (!Dyld->isCompatibleFormat(InputBuffer))<br>
+ if (!Dyld->isCompatibleFormat(InputBufferPtr))<br>
report_fatal_error("Incompatible object format!");<br>
<br>
Dyld->loadObject(InputImage.get());<br>
- return InputImage.release();<br>
+ return InputImage;<br>
}<br>
<br>
void *RuntimeDyld::getSymbolAddress(StringRef Name) {<br>
<br>
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp?rev=217065&r1=217064&r2=217065&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp?rev=217065&r1=217064&r2=217065&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp (original)<br>
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp Wed Sep 3 14:48:09 2014<br>
@@ -77,8 +77,10 @@ template <class ELFT> class ELFObjectIma<br>
bool Registered;<br>
<br>
public:<br>
- ELFObjectImage(ObjectBuffer *Input, std::unique_ptr<DyldELFObject<ELFT>> Obj)<br>
- : ObjectImageCommon(Input, std::move(Obj)), Registered(false) {}<br>
+ ELFObjectImage(std::unique_ptr<ObjectBuffer> Input,<br>
+ std::unique_ptr<DyldELFObject<ELFT>> Obj)<br>
+ : ObjectImageCommon(std::move(Input), std::move(Obj)), Registered(false) {<br>
+ }<br>
<br>
virtual ~ELFObjectImage() {<br>
if (Registered)<br>
@@ -212,7 +214,8 @@ RuntimeDyldELF::createObjectImageFromFil<br>
llvm_unreachable("Unexpected ELF format");<br>
}<br>
<br>
-ObjectImage *RuntimeDyldELF::createObjectImage(ObjectBuffer *Buffer) {<br>
+std::unique_ptr<ObjectImage><br>
+RuntimeDyldELF::createObjectImage(std::unique_ptr<ObjectBuffer> Buffer) {<br>
if (Buffer->getBufferSize() < ELF::EI_NIDENT)<br>
llvm_unreachable("Unexpected ELF object size");<br>
std::pair<unsigned char, unsigned char> Ident =<br>
@@ -226,28 +229,30 @@ ObjectImage *RuntimeDyldELF::createObjec<br>
auto Obj =<br>
llvm::make_unique<DyldELFObject<ELFType<support::little, 4, false>>>(<br>
Buf, ec);<br>
- return new ELFObjectImage<ELFType<support::little, 4, false>>(<br>
- Buffer, std::move(Obj));<br>
- } else if (Ident.first == ELF::ELFCLASS32 &&<br>
- Ident.second == ELF::ELFDATA2MSB) {<br>
+ return llvm::make_unique<<br>
+ ELFObjectImage<ELFType<support::little, 4, false>>>(std::move(Buffer),<br>
+ std::move(Obj));<br>
+ }<br>
+ if (Ident.first == ELF::ELFCLASS32 && Ident.second == ELF::ELFDATA2MSB) {<br>
auto Obj =<br>
llvm::make_unique<DyldELFObject<ELFType<support::big, 4, false>>>(Buf,<br>
ec);<br>
- return new ELFObjectImage<ELFType<support::big, 4, false>>(Buffer,<br>
- std::move(Obj));<br>
- } else if (Ident.first == ELF::ELFCLASS64 &&<br>
- Ident.second == ELF::ELFDATA2MSB) {<br>
+ return llvm::make_unique<ELFObjectImage<ELFType<support::big, 4, false>>>(<br>
+ std::move(Buffer), std::move(Obj));<br>
+ }<br>
+ if (Ident.first == ELF::ELFCLASS64 && Ident.second == ELF::ELFDATA2MSB) {<br>
auto Obj = llvm::make_unique<DyldELFObject<ELFType<support::big, 8, true>>>(<br>
Buf, ec);<br>
- return new ELFObjectImage<ELFType<support::big, 8, true>>(Buffer, std::move(Obj));<br>
- } else if (Ident.first == ELF::ELFCLASS64 &&<br>
- Ident.second == ELF::ELFDATA2LSB) {<br>
- auto Obj =<br>
- llvm::make_unique<DyldELFObject<ELFType<support::little, 8, true>>>(Buf,<br>
- ec);<br>
- return new ELFObjectImage<ELFType<support::little, 8, true>>(Buffer, std::move(Obj));<br>
- } else<br>
- llvm_unreachable("Unexpected ELF format");<br>
+ return llvm::make_unique<ELFObjectImage<ELFType<support::big, 8, true>>>(<br>
+ std::move(Buffer), std::move(Obj));<br>
+ }<br>
+ assert(Ident.first == ELF::ELFCLASS64 && Ident.second == ELF::ELFDATA2LSB &&<br>
+ "Unexpected ELF format");<br>
+ auto Obj =<br>
+ llvm::make_unique<DyldELFObject<ELFType<support::little, 8, true>>>(Buf,<br>
+ ec);<br>
+ return llvm::make_unique<ELFObjectImage<ELFType<support::little, 8, true>>>(<br>
+ std::move(Buffer), std::move(Obj));<br>
}<br>
<br>
RuntimeDyldELF::~RuntimeDyldELF() {}<br>
<br>
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.h?rev=217065&r1=217064&r2=217065&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.h?rev=217065&r1=217064&r2=217065&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.h (original)<br>
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.h Wed Sep 3 14:48:09 2014<br>
@@ -119,7 +119,8 @@ public:<br>
ObjSectionToIDMap &SectionMap) override;<br>
virtual ~RuntimeDyldELF();<br>
<br>
- static ObjectImage *createObjectImage(ObjectBuffer *InputBuffer);<br>
+ static std::unique_ptr<ObjectImage><br>
+ createObjectImage(std::unique_ptr<ObjectBuffer> InputBuffer);<br>
static ObjectImage *createObjectImageFromFile(std::unique_ptr<object::ObjectFile> Obj);<br>
};<br>
<br>
<br>
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h?rev=217065&r1=217064&r2=217065&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h?rev=217065&r1=217064&r2=217065&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h (original)<br>
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h Wed Sep 3 14:48:09 2014<br>
@@ -103,8 +103,9 @@ protected:<br>
<br>
public:<br>
/// Create an ObjectImage from the given ObjectBuffer.<br>
- static ObjectImage *createObjectImage(ObjectBuffer *InputBuffer) {<br>
- return new ObjectImageCommon(InputBuffer);<br>
+ static std::unique_ptr<ObjectImage><br>
+ createObjectImage(std::unique_ptr<ObjectBuffer> InputBuffer) {<br>
+ return llvm::make_unique<ObjectImageCommon>(std::move(InputBuffer));<br>
}<br>
<br>
/// Create an ObjectImage from the given ObjectFile.<br>
<br>
Modified: llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp?rev=217065&r1=217064&r2=217065&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp?rev=217065&r1=217064&r2=217065&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp (original)<br>
+++ llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp Wed Sep 3 14:48:09 2014<br>
@@ -203,8 +203,8 @@ static int printLineInfoForInput() {<br>
<br>
std::unique_ptr<ObjectImage> LoadedObject;<br>
// Load the object file<br>
- LoadedObject.reset(<br>
- Dyld.loadObject(new ObjectBuffer(InputBuffer.get().release())));<br>
+ LoadedObject = Dyld.loadObject(<br>
+ llvm::make_unique<ObjectBuffer>(std::move(*InputBuffer)));<br>
if (!LoadedObject) {<br>
return Error(Dyld.getErrorString());<br>
}<br>
@@ -264,8 +264,8 @@ static int executeInput() {<br>
return Error("unable to read input: '" + EC.message() + "'");<br>
std::unique_ptr<ObjectImage> LoadedObject;<br>
// Load the object file<br>
- LoadedObject.reset(<br>
- Dyld.loadObject(new ObjectBuffer(InputBuffer.get().release())));<br>
+ LoadedObject = Dyld.loadObject(<br>
+ llvm::make_unique<ObjectBuffer>(std::move(*InputBuffer)));<br>
if (!LoadedObject) {<br>
return Error(Dyld.getErrorString());<br>
}<br>
@@ -427,8 +427,8 @@ static int linkAndVerify() {<br>
<br>
std::unique_ptr<ObjectImage> LoadedObject;<br>
// Load the object file<br>
- LoadedObject.reset(<br>
- Dyld.loadObject(new ObjectBuffer(InputBuffer.get().release())));<br>
+ LoadedObject = Dyld.loadObject(<br>
+ llvm::make_unique<ObjectBuffer>(std::move(*InputBuffer)));<br>
if (!LoadedObject) {<br>
return Error(Dyld.getErrorString());<br>
}<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Alexey Samsonov<br><a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a></div>
</div></div>