[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
diff --git a/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp
index 740abed..2156ae8 100644
--- a/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp
@@ -95,14 +95,13 @@
   if (!TM)
     return;
 
-  auto Obj =
-    std::make_shared<object::OwningBinary<object::ObjectFile>>(
-      SimpleCompiler(*TM)(*M));
+  auto Obj = SimpleCompiler(*TM)(*M);
 
   {
     // Test with ProcessAllSections = false (the default).
     auto K = ES.allocateVModule();
-    cantFail(ObjLayer.addObject(K, Obj));
+    cantFail(ObjLayer.addObject(
+        K, MemoryBuffer::getMemBufferCopy(Obj->getBuffer())));
     cantFail(ObjLayer.emitAndFinalize(K));
     EXPECT_EQ(DebugSectionSeen, false)
       << "Unexpected debug info section";
@@ -113,7 +112,7 @@
     // Test with ProcessAllSections = true.
     ObjLayer.setProcessAllSections(true);
     auto K = ES.allocateVModule();
-    cantFail(ObjLayer.addObject(K, Obj));
+    cantFail(ObjLayer.addObject(K, std::move(Obj)));
     cantFail(ObjLayer.emitAndFinalize(K));
     EXPECT_EQ(DebugSectionSeen, true)
       << "Expected debug info section not seen";
@@ -164,9 +163,7 @@
     Builder.CreateRet(FourtyTwo);
   }
 
-  auto Obj1 =
-    std::make_shared<object::OwningBinary<object::ObjectFile>>(
-      Compile(*MB1.getModule()));
+  auto Obj1 = Compile(*MB1.getModule());
 
   ModuleBuilder MB2(Context, "", "dummy");
   {
@@ -177,9 +174,7 @@
     IRBuilder<> Builder(FooEntry);
     Builder.CreateRet(Builder.CreateCall(BarDecl));
   }
-  auto Obj2 =
-    std::make_shared<object::OwningBinary<object::ObjectFile>>(
-      Compile(*MB2.getModule()));
+  auto Obj2 = Compile(*MB2.getModule());
 
   auto K1 = ES.allocateVModule();
   Resolvers[K1] = std::make_shared<NullResolver>();
@@ -249,9 +244,7 @@
     Builder.CreateRet(FourtyTwo);
   }
 
-  auto Obj1 =
-    std::make_shared<object::OwningBinary<object::ObjectFile>>(
-      Compile(*MB1.getModule()));
+  auto Obj1 = Compile(*MB1.getModule());
 
   ModuleBuilder MB2(Context, "", "dummy");
   {
@@ -263,9 +256,7 @@
     Value *Seven = ConstantInt::getSigned(Int32Ty, 7);
     Builder.CreateRet(Seven);
   }
-  auto Obj2 =
-    std::make_shared<object::OwningBinary<object::ObjectFile>>(
-      Compile(*MB2.getModule()));
+  auto Obj2 = Compile(*MB2.getModule());
 
   auto K = ES.allocateVModule();
   cantFail(ObjLayer.addObject(K, std::move(Obj1)));
@@ -288,7 +279,7 @@
         return RTDyldObjectLinkingLayer::Resources{
             nullptr, std::make_shared<NullResolver>()};
       },
-      [](VModuleKey, const RTDyldObjectLinkingLayer::ObjectPtr &obj,
+      [](VModuleKey, const object::ObjectFile &obj,
          const RuntimeDyld::LoadedObjectInfo &info) {});
 }