From 51e4b46c2c6a2046bd98312d8e6f9bd976fdc8dd Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 23 Jun 2017 22:50:24 +0000 Subject: This reverts commit r306166 and r306168. Revert "[ORC] Remove redundant semicolons from DEFINE_SIMPLE_CONVERSION_FUNCTIONS uses." Revert "[ORC] Move ORC IR layer interface from addModuleSet to addModule and fix the module type as std::shared_ptr." They broke ExecutionEngine/OrcMCJIT/test-global-ctors.ll on linux. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306176 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../BuildingAJIT/Chapter1/KaleidoscopeJIT.h | 14 +++++++++----- .../BuildingAJIT/Chapter2/KaleidoscopeJIT.h | 20 ++++++++++++-------- .../BuildingAJIT/Chapter3/KaleidoscopeJIT.h | 20 ++++++++++++-------- .../BuildingAJIT/Chapter4/KaleidoscopeJIT.h | 20 ++++++++++++-------- .../BuildingAJIT/Chapter5/KaleidoscopeJIT.h | 20 ++++++++++++-------- examples/Kaleidoscope/include/KaleidoscopeJIT.h | 16 +++++++++++----- 6 files changed, 68 insertions(+), 42 deletions(-) (limited to 'examples') diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h b/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h index f99722f60e9..3274433178b 100644 --- a/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h +++ b/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h @@ -44,7 +44,7 @@ private: IRCompileLayer CompileLayer; public: - using ModuleHandle = decltype(CompileLayer)::ModuleHandleT; + using ModuleHandle = decltype(CompileLayer)::ModuleSetHandleT; KaleidoscopeJIT() : TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()), @@ -72,11 +72,15 @@ public: return JITSymbol(nullptr); }); + // Build a singleton module set to hold our module. + std::vector> Ms; + Ms.push_back(std::move(M)); + // Add the set to the JIT with the resolver we created above and a newly // created SectionMemoryManager. - return CompileLayer.addModule(std::move(M), - make_unique(), - std::move(Resolver)); + return CompileLayer.addModuleSet(std::move(Ms), + make_unique(), + std::move(Resolver)); } JITSymbol findSymbol(const std::string Name) { @@ -87,7 +91,7 @@ public: } void removeModule(ModuleHandle H) { - CompileLayer.removeModule(H); + CompileLayer.removeModuleSet(H); } }; diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h b/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h index 2cd4ed79aaf..f71b322bff7 100644 --- a/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h +++ b/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h @@ -48,18 +48,18 @@ private: IRCompileLayer CompileLayer; using OptimizeFunction = - std::function(std::shared_ptr)>; + std::function(std::unique_ptr)>; IRTransformLayer OptimizeLayer; public: - using ModuleHandle = decltype(OptimizeLayer)::ModuleHandleT; + using ModuleHandle = decltype(OptimizeLayer)::ModuleSetHandleT; KaleidoscopeJIT() : TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()), CompileLayer(ObjectLayer, SimpleCompiler(*TM)), OptimizeLayer(CompileLayer, - [this](std::shared_ptr M) { + [this](std::unique_ptr M) { return optimizeModule(std::move(M)); }) { llvm::sys::DynamicLibrary::LoadLibraryPermanently(nullptr); @@ -85,11 +85,15 @@ public: return JITSymbol(nullptr); }); + // Build a singleton module set to hold our module. + std::vector> Ms; + Ms.push_back(std::move(M)); + // Add the set to the JIT with the resolver we created above and a newly // created SectionMemoryManager. - return OptimizeLayer.addModule(std::move(M), - make_unique(), - std::move(Resolver)); + return OptimizeLayer.addModuleSet(std::move(Ms), + make_unique(), + std::move(Resolver)); } JITSymbol findSymbol(const std::string Name) { @@ -100,11 +104,11 @@ public: } void removeModule(ModuleHandle H) { - OptimizeLayer.removeModule(H); + OptimizeLayer.removeModuleSet(H); } private: - std::shared_ptr optimizeModule(std::shared_ptr M) { + std::unique_ptr optimizeModule(std::unique_ptr M) { // Create a function pass manager. auto FPM = llvm::make_unique(M.get()); diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h b/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h index f6fb3071d52..c851b609779 100644 --- a/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h +++ b/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h @@ -51,7 +51,7 @@ private: IRCompileLayer CompileLayer; using OptimizeFunction = - std::function(std::shared_ptr)>; + std::function(std::unique_ptr)>; IRTransformLayer OptimizeLayer; @@ -59,13 +59,13 @@ private: CompileOnDemandLayer CODLayer; public: - using ModuleHandle = decltype(CODLayer)::ModuleHandleT; + using ModuleHandle = decltype(CODLayer)::ModuleSetHandleT; KaleidoscopeJIT() : TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()), CompileLayer(ObjectLayer, SimpleCompiler(*TM)), OptimizeLayer(CompileLayer, - [this](std::shared_ptr M) { + [this](std::unique_ptr M) { return optimizeModule(std::move(M)); }), CompileCallbackManager( @@ -98,11 +98,15 @@ public: return JITSymbol(nullptr); }); + // Build a singleton module set to hold our module. + std::vector> Ms; + Ms.push_back(std::move(M)); + // Add the set to the JIT with the resolver we created above and a newly // created SectionMemoryManager. - return CODLayer.addModule(std::move(M), - make_unique(), - std::move(Resolver)); + return CODLayer.addModuleSet(std::move(Ms), + make_unique(), + std::move(Resolver)); } JITSymbol findSymbol(const std::string Name) { @@ -113,11 +117,11 @@ public: } void removeModule(ModuleHandle H) { - CODLayer.removeModule(H); + CODLayer.removeModuleSet(H); } private: - std::shared_ptr optimizeModule(std::shared_ptr M) { + std::unique_ptr optimizeModule(std::unique_ptr M) { // Create a function pass manager. auto FPM = llvm::make_unique(M.get()); diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h b/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h index d45874e9a69..58642237d4f 100644 --- a/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h +++ b/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h @@ -77,7 +77,7 @@ private: IRCompileLayer CompileLayer; using OptimizeFunction = - std::function(std::shared_ptr)>; + std::function(std::unique_ptr)>; IRTransformLayer OptimizeLayer; @@ -85,14 +85,14 @@ private: std::unique_ptr IndirectStubsMgr; public: - using ModuleHandle = decltype(OptimizeLayer)::ModuleHandleT; + using ModuleHandle = decltype(OptimizeLayer)::ModuleSetHandleT; KaleidoscopeJIT() : TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()), CompileLayer(ObjectLayer, SimpleCompiler(*TM)), OptimizeLayer(CompileLayer, - [this](std::shared_ptr M) { + [this](std::unique_ptr M) { return optimizeModule(std::move(M)); }), CompileCallbackMgr( @@ -125,11 +125,15 @@ public: return JITSymbol(nullptr); }); + // Build a singleton module set to hold our module. + std::vector> Ms; + Ms.push_back(std::move(M)); + // Add the set to the JIT with the resolver we created above and a newly // created SectionMemoryManager. - return OptimizeLayer.addModule(std::move(M), - make_unique(), - std::move(Resolver)); + return OptimizeLayer.addModuleSet(std::move(Ms), + make_unique(), + std::move(Resolver)); } Error addFunctionAST(std::unique_ptr FnAST) { @@ -195,7 +199,7 @@ public: } void removeModule(ModuleHandle H) { - OptimizeLayer.removeModule(H); + OptimizeLayer.removeModuleSet(H); } private: @@ -206,7 +210,7 @@ private: return MangledNameStream.str(); } - std::shared_ptr optimizeModule(std::shared_ptr M) { + std::unique_ptr optimizeModule(std::unique_ptr M) { // Create a function pass manager. auto FPM = llvm::make_unique(M.get()); diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h b/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h index e889c6d3432..84916b8f2b8 100644 --- a/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h +++ b/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h @@ -82,7 +82,7 @@ private: IRCompileLayer CompileLayer; using OptimizeFunction = - std::function(std::shared_ptr)>; + std::function(std::unique_ptr)>; IRTransformLayer OptimizeLayer; @@ -91,7 +91,7 @@ private: MyRemote &Remote; public: - using ModuleHandle = decltype(OptimizeLayer)::ModuleHandleT; + using ModuleHandle = decltype(OptimizeLayer)::ModuleSetHandleT; KaleidoscopeJIT(MyRemote &Remote) : TM(EngineBuilder().selectTarget(Triple(Remote.getTargetTriple()), "", @@ -99,7 +99,7 @@ public: DL(TM->createDataLayout()), CompileLayer(ObjectLayer, SimpleCompiler(*TM)), OptimizeLayer(CompileLayer, - [this](std::shared_ptr M) { + [this](std::unique_ptr M) { return optimizeModule(std::move(M)); }), Remote(Remote) { @@ -153,11 +153,15 @@ public: exit(1); } + // Build a singleton module set to hold our module. + std::vector> Ms; + Ms.push_back(std::move(M)); + // Add the set to the JIT with the resolver we created above and a newly // created SectionMemoryManager. - return OptimizeLayer.addModule(std::move(M), - std::move(MemMgr), - std::move(Resolver)); + return OptimizeLayer.addModuleSet(std::move(Ms), + std::move(MemMgr), + std::move(Resolver)); } Error addFunctionAST(std::unique_ptr FnAST) { @@ -227,7 +231,7 @@ public: } void removeModule(ModuleHandle H) { - OptimizeLayer.removeModule(H); + OptimizeLayer.removeModuleSet(H); } private: @@ -238,7 +242,7 @@ private: return MangledNameStream.str(); } - std::shared_ptr optimizeModule(std::shared_ptr M) { + std::unique_ptr optimizeModule(std::unique_ptr M) { // Create a function pass manager. auto FPM = llvm::make_unique(M.get()); diff --git a/examples/Kaleidoscope/include/KaleidoscopeJIT.h b/examples/Kaleidoscope/include/KaleidoscopeJIT.h index fe73d717976..1e2d567c057 100644 --- a/examples/Kaleidoscope/include/KaleidoscopeJIT.h +++ b/examples/Kaleidoscope/include/KaleidoscopeJIT.h @@ -41,7 +41,7 @@ class KaleidoscopeJIT { public: using ObjLayerT = RTDyldObjectLinkingLayer; using CompileLayerT = IRCompileLayer; - using ModuleHandleT = CompileLayerT::ModuleHandleT; + using ModuleHandleT = CompileLayerT::ModuleSetHandleT; KaleidoscopeJIT() : TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()), @@ -62,9 +62,9 @@ public: return JITSymbol(nullptr); }, [](const std::string &S) { return nullptr; }); - auto H = CompileLayer.addModule(std::move(M), - make_unique(), - std::move(Resolver)); + auto H = CompileLayer.addModuleSet(singletonSet(std::move(M)), + make_unique(), + std::move(Resolver)); ModuleHandles.push_back(H); return H; @@ -72,7 +72,7 @@ public: void removeModule(ModuleHandleT H) { ModuleHandles.erase(find(ModuleHandles, H)); - CompileLayer.removeModule(H); + CompileLayer.removeModuleSet(H); } JITSymbol findSymbol(const std::string Name) { @@ -89,6 +89,12 @@ private: return MangledName; } + template static std::vector singletonSet(T t) { + std::vector Vec; + Vec.push_back(std::move(t)); + return Vec; + } + JITSymbol findMangledSymbol(const std::string &Name) { #ifdef LLVM_ON_WIN32 // The symbol lookup of ObjectLinkingLayer uses the SymbolRef::SF_Exported -- cgit v1.2.3