From cd9d49b605cc0c3283bc6f2ad4c38f8e1a525e7d Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Fri, 23 Jun 2017 23:25:28 +0000 Subject: [ORC] Re-apply r306166 and r306168 with fix for regression test. llvm-svn: 306182 --- .../ExecutionEngine/Orc/LazyEmittingLayerTest.cpp | 8 ++-- .../Orc/ObjectTransformLayerTest.cpp | 2 +- llvm/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp | 13 ++++-- llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h | 48 +++++++++++----------- 4 files changed, 38 insertions(+), 33 deletions(-) (limited to 'llvm/unittests/ExecutionEngine/Orc') diff --git a/llvm/unittests/ExecutionEngine/Orc/LazyEmittingLayerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/LazyEmittingLayerTest.cpp index 213c460aa67..f65dc0cd609 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>, + typedef int ModuleHandleT; + ModuleHandleT addModule( + std::shared_ptr, std::unique_ptr MemMgr, std::unique_ptr Resolver) { EXPECT_FALSE(MemMgr); @@ -27,7 +27,7 @@ struct MockBaseLayer { TEST(LazyEmittingLayerTest, Empty) { MockBaseLayer M; llvm::orc::LazyEmittingLayer L(M); - L.addModuleSet(std::list>(), nullptr, nullptr); + L.addModule(std::unique_ptr(), nullptr, nullptr); } } diff --git a/llvm/unittests/ExecutionEngine/Orc/ObjectTransformLayerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/ObjectTransformLayerTest.cpp index 6da2894ae0e..2fdf9e8b737 100644 --- a/llvm/unittests/ExecutionEngine/Orc/ObjectTransformLayerTest.cpp +++ b/llvm/unittests/ExecutionEngine/Orc/ObjectTransformLayerTest.cpp @@ -314,7 +314,7 @@ TEST(ObjectTransformLayerTest, Main) { // compile. NullResolver Resolver; NullManager Manager; - CompileLayer.addModuleSet(std::vector(), &Manager, &Resolver); + CompileLayer.addModule(std::shared_ptr(), &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 e8ba16a472b..2900a9c9276 100644 --- a/llvm/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp +++ b/llvm/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp @@ -65,8 +65,9 @@ protected: CompileContext *CCtx = static_cast(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 @@ TEST_F(OrcCAPIExecutionTest, TestEagerIRCompilation) { 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 @@ TEST_F(OrcCAPIExecutionTest, TestLazyIRCompilation) { 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 24320034a17..d7049ef00e6 100644 --- a/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h +++ b/llvm/unittests/ExecutionEngine/Orc/OrcTestCommon.h @@ -106,65 +106,65 @@ public: }; template 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 - 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 -MockBaseLayer -createMockBaseLayer(AddModuleSetFtor &&AddModuleSet, - RemoveModuleSetFtor &&RemoveModuleSet, +createMockBaseLayer(AddModuleFtor &&AddModule, + RemoveModuleFtor &&RemoveModule, FindSymbolFtor &&FindSymbol, FindSymbolInFtor &&FindSymbolIn) { - return MockBaseLayer( - std::forward(AddModuleSet), - std::forward(RemoveModuleSet), + std::forward(AddModule), + std::forward(RemoveModule), std::forward(FindSymbol), std::forward(FindSymbolIn)); } -- cgit v1.2.3