[Orc] Make the ObjectLinkingLayer take ownership of object files until
[oota-llvm.git] / include / llvm / ExecutionEngine / Orc / IRCompileLayer.h
index 0851b1b..e16ff8d 100644 (file)
@@ -76,7 +76,12 @@ public:
       Buffers.push_back(std::move(Buffer));
     }
 
-    return BaseLayer.addObjectSet(std::move(Objects), std::move(MM));
+    ModuleSetHandleT H =
+      BaseLayer.addObjectSet(Objects, std::move(MM));
+
+    BaseLayer.takeOwnershipOfBuffers(H, std::move(Buffers));
+
+    return H;
   }
 
   /// @brief Remove the module set associated with the handle H.
@@ -101,14 +106,15 @@ private:
   tryToLoadFromObjectCache(const Module &M) {
     std::unique_ptr<MemoryBuffer> ObjBuffer = ObjCache->getObject(&M);
     if (!ObjBuffer)
-      return {nullptr, nullptr};
+      return object::OwningBinary<object::ObjectFile>();
 
     ErrorOr<std::unique_ptr<object::ObjectFile>> Obj =
         object::ObjectFile::createObjectFile(ObjBuffer->getMemBufferRef());
     if (!Obj)
-      return {nullptr, nullptr};
+      return object::OwningBinary<object::ObjectFile>();
 
-    return {std::move(*Obj), std::move(ObjBuffer)};
+    return object::OwningBinary<object::ObjectFile>(std::move(*Obj),
+                                                    std::move(ObjBuffer));
   }
 
   BaseLayerT &BaseLayer;