[ORC] Move ORC IR layer interface from addModuleSet to addModule and fix the
module type as std::shared_ptr<Module>.

llvm-svn: 306166
diff --git a/llvm/unittests/ExecutionEngine/Orc/LazyEmittingLayerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/LazyEmittingLayerTest.cpp
index 213c460..f65dc0c 100644
--- a/llvm/unittests/ExecutionEngine/Orc/LazyEmittingLayerTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/LazyEmittingLayerTest.cpp
@@ -14,9 +14,9 @@
 namespace {
 
 struct MockBaseLayer {
-  typedef int ModuleSetHandleT;
-  ModuleSetHandleT addModuleSet(
-                  std::list<std::unique_ptr<llvm::Module>>,
+  typedef int ModuleHandleT;
+  ModuleHandleT addModule(
+                  std::shared_ptr<llvm::Module>,
                   std::unique_ptr<llvm::RuntimeDyld::MemoryManager> MemMgr,
                   std::unique_ptr<llvm::JITSymbolResolver> Resolver) {
     EXPECT_FALSE(MemMgr);
@@ -27,7 +27,7 @@
 TEST(LazyEmittingLayerTest, Empty) {
   MockBaseLayer M;
   llvm::orc::LazyEmittingLayer<MockBaseLayer> L(M);
-  L.addModuleSet(std::list<std::unique_ptr<llvm::Module>>(), nullptr, nullptr);
+  L.addModule(std::unique_ptr<llvm::Module>(), nullptr, nullptr);
 }
 
 }
diff --git a/llvm/unittests/ExecutionEngine/Orc/ObjectTransformLayerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/ObjectTransformLayerTest.cpp
index 6da2894..2fdf9e8 100644
--- a/llvm/unittests/ExecutionEngine/Orc/ObjectTransformLayerTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/ObjectTransformLayerTest.cpp
@@ -314,7 +314,7 @@
   // compile.
   NullResolver Resolver;
   NullManager Manager;
-  CompileLayer.addModuleSet(std::vector<llvm::Module *>(), &Manager, &Resolver);
+  CompileLayer.addModule(std::shared_ptr<llvm::Module>(), &Manager, &Resolver);
 
   // Make sure that the calls from ObjectTransformLayer to ObjectLinkingLayer
   // compile.
diff --git a/llvm/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp b/llvm/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp
index e8ba16a..2900a9c 100644
--- a/llvm/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp
@@ -65,8 +65,9 @@
     CompileContext *CCtx = static_cast<CompileContext*>(Ctx);
     auto *ET = CCtx->APIExecTest;
     CCtx->M = ET->createTestModule(ET->TM->getTargetTriple());
-    CCtx->H = LLVMOrcAddEagerlyCompiledIR(JITStack, wrap(CCtx->M.get()),
-                                          myResolver, nullptr);
+    LLVMSharedModuleRef SM = LLVMOrcMakeSharedModule(wrap(CCtx->M.release()));
+    CCtx->H = LLVMOrcAddEagerlyCompiledIR(JITStack, SM, myResolver, nullptr);
+    LLVMOrcDisposeSharedModuleRef(SM);
     CCtx->Compiled = true;
     LLVMOrcTargetAddress MainAddr = LLVMOrcGetSymbolAddress(JITStack, "main");
     LLVMOrcSetIndirectStubPointer(JITStack, "foo", MainAddr);
@@ -87,8 +88,10 @@
 
   LLVMOrcGetMangledSymbol(JIT, &testFuncName, "testFunc");
 
+  LLVMSharedModuleRef SM = LLVMOrcMakeSharedModule(wrap(M.release()));
   LLVMOrcModuleHandle H =
-    LLVMOrcAddEagerlyCompiledIR(JIT, wrap(M.get()), myResolver, nullptr);
+    LLVMOrcAddEagerlyCompiledIR(JIT, SM, myResolver, nullptr);
+  LLVMOrcDisposeSharedModuleRef(SM);
   MainFnTy MainFn = (MainFnTy)LLVMOrcGetSymbolAddress(JIT, "main");
   int Result = MainFn();
   EXPECT_EQ(Result, 42)
@@ -111,8 +114,10 @@
 
   LLVMOrcGetMangledSymbol(JIT, &testFuncName, "testFunc");
 
+  LLVMSharedModuleRef SM = LLVMOrcMakeSharedModule(wrap(M.release()));
   LLVMOrcModuleHandle H =
-    LLVMOrcAddLazilyCompiledIR(JIT, wrap(M.get()), myResolver, nullptr);
+    LLVMOrcAddLazilyCompiledIR(JIT, SM, myResolver, nullptr);
+  LLVMOrcDisposeSharedModuleRef(SM);
   MainFnTy MainFn = (MainFnTy)LLVMOrcGetSymbolAddress(JIT, "main");
   int Result = MainFn();
   EXPECT_EQ(Result, 42)
diff --git a/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h b/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h
index 2432003..d7049ef 100644
--- a/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h
+++ b/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h
@@ -106,65 +106,65 @@
 };
 
 template <typename HandleT,
-          typename AddModuleSetFtor,
-          typename RemoveModuleSetFtor,
+          typename AddModuleFtor,
+          typename RemoveModuleFtor,
           typename FindSymbolFtor,
           typename FindSymbolInFtor>
 class MockBaseLayer {
 public:
 
-  typedef HandleT ModuleSetHandleT;
+  typedef HandleT ModuleHandleT;
 
-  MockBaseLayer(AddModuleSetFtor &&AddModuleSet,
-                RemoveModuleSetFtor &&RemoveModuleSet,
+  MockBaseLayer(AddModuleFtor &&AddModule,
+                RemoveModuleFtor &&RemoveModule,
                 FindSymbolFtor &&FindSymbol,
                 FindSymbolInFtor &&FindSymbolIn)
-      : AddModuleSet(AddModuleSet), RemoveModuleSet(RemoveModuleSet),
+      : AddModule(AddModule), RemoveModule(RemoveModule),
         FindSymbol(FindSymbol), FindSymbolIn(FindSymbolIn)
   {}
 
-  template <typename ModuleSetT, typename MemoryManagerPtrT,
+  template <typename ModuleT, typename MemoryManagerPtrT,
             typename SymbolResolverPtrT>
-  ModuleSetHandleT addModuleSet(ModuleSetT Ms, MemoryManagerPtrT MemMgr,
-                                SymbolResolverPtrT Resolver) {
-    return AddModuleSet(std::move(Ms), std::move(MemMgr), std::move(Resolver));
+  ModuleHandleT addModule(ModuleT Ms, MemoryManagerPtrT MemMgr,
+                          SymbolResolverPtrT Resolver) {
+    return AddModule(std::move(Ms), std::move(MemMgr), std::move(Resolver));
   }
 
-  void removeModuleSet(ModuleSetHandleT H) {
-    RemoveModuleSet(H);
+  void removeModule(ModuleHandleT H) {
+    RemoveModule(H);
   }
 
   JITSymbol findSymbol(const std::string &Name, bool ExportedSymbolsOnly) {
     return FindSymbol(Name, ExportedSymbolsOnly);
   }
 
-  JITSymbol findSymbolIn(ModuleSetHandleT H, const std::string &Name,
+  JITSymbol findSymbolIn(ModuleHandleT H, const std::string &Name,
                          bool ExportedSymbolsOnly) {
     return FindSymbolIn(H, Name, ExportedSymbolsOnly);
   }
 
 private:
-  AddModuleSetFtor AddModuleSet;
-  RemoveModuleSetFtor RemoveModuleSet;
+  AddModuleFtor AddModule;
+  RemoveModuleFtor RemoveModule;
   FindSymbolFtor FindSymbol;
   FindSymbolInFtor FindSymbolIn;
 };
 
-template <typename ModuleSetHandleT,
-          typename AddModuleSetFtor,
-          typename RemoveModuleSetFtor,
+template <typename ModuleHandleT,
+          typename AddModuleFtor,
+          typename RemoveModuleFtor,
           typename FindSymbolFtor,
           typename FindSymbolInFtor>
-MockBaseLayer<ModuleSetHandleT, AddModuleSetFtor, RemoveModuleSetFtor,
+MockBaseLayer<ModuleHandleT, AddModuleFtor, RemoveModuleFtor,
               FindSymbolFtor, FindSymbolInFtor>
-createMockBaseLayer(AddModuleSetFtor &&AddModuleSet,
-                    RemoveModuleSetFtor &&RemoveModuleSet,
+createMockBaseLayer(AddModuleFtor &&AddModule,
+                    RemoveModuleFtor &&RemoveModule,
                     FindSymbolFtor &&FindSymbol,
                     FindSymbolInFtor &&FindSymbolIn) {
-  return MockBaseLayer<ModuleSetHandleT, AddModuleSetFtor, RemoveModuleSetFtor,
+  return MockBaseLayer<ModuleHandleT, AddModuleFtor, RemoveModuleFtor,
                        FindSymbolFtor, FindSymbolInFtor>(
-                         std::forward<AddModuleSetFtor>(AddModuleSet),
-                         std::forward<RemoveModuleSetFtor>(RemoveModuleSet),
+                         std::forward<AddModuleFtor>(AddModule),
+                         std::forward<RemoveModuleFtor>(RemoveModule),
                          std::forward<FindSymbolFtor>(FindSymbol),
                          std::forward<FindSymbolInFtor>(FindSymbolIn));
 }