<div dir="ltr">I've got in a fix in the works. Should be in shortly.<div><br></div><div>- Lang.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 23, 2017 at 3:50 PM, Rafael Avila de Espindola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This is causing test failures on linux. Reverting.<br>
<br>
Cheers,<br>
Rafael<br>
<div class="HOEnZb"><div class="h5"><br>
Lang Hames via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> writes:<br>
<br>
> Author: lhames<br>
> Date: Fri Jun 23 16:45:29 2017<br>
> New Revision: 306166<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=306166&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=306166&view=rev</a><br>
> Log:<br>
> [ORC] Move ORC IR layer interface from addModuleSet to addModule and fix the<br>
> module type as std::shared_ptr<Module>.<br>
><br>
><br>
> Modified:<br>
> llvm/trunk/examples/<wbr>Kaleidoscope/BuildingAJIT/<wbr>Chapter1/KaleidoscopeJIT.h<br>
> llvm/trunk/examples/<wbr>Kaleidoscope/BuildingAJIT/<wbr>Chapter2/KaleidoscopeJIT.h<br>
> llvm/trunk/examples/<wbr>Kaleidoscope/BuildingAJIT/<wbr>Chapter3/KaleidoscopeJIT.h<br>
> llvm/trunk/examples/<wbr>Kaleidoscope/BuildingAJIT/<wbr>Chapter4/KaleidoscopeJIT.h<br>
> llvm/trunk/examples/<wbr>Kaleidoscope/BuildingAJIT/<wbr>Chapter5/KaleidoscopeJIT.h<br>
> llvm/trunk/examples/<wbr>Kaleidoscope/include/<wbr>KaleidoscopeJIT.h<br>
> llvm/trunk/include/llvm-c/<wbr>OrcBindings.h<br>
> llvm/trunk/include/llvm/<wbr>ExecutionEngine/Orc/<wbr>CompileOnDemandLayer.h<br>
> llvm/trunk/include/llvm/<wbr>ExecutionEngine/Orc/<wbr>ExecutionUtils.h<br>
> llvm/trunk/include/llvm/<wbr>ExecutionEngine/Orc/<wbr>IRCompileLayer.h<br>
> llvm/trunk/include/llvm/<wbr>ExecutionEngine/Orc/<wbr>IRTransformLayer.h<br>
> llvm/trunk/include/llvm/<wbr>ExecutionEngine/Orc/<wbr>LazyEmittingLayer.h<br>
> llvm/trunk/lib/<wbr>ExecutionEngine/Orc/<wbr>OrcCBindings.cpp<br>
> llvm/trunk/lib/<wbr>ExecutionEngine/Orc/<wbr>OrcCBindingsStack.h<br>
> llvm/trunk/lib/<wbr>ExecutionEngine/Orc/<wbr>OrcMCJITReplacement.h<br>
> llvm/trunk/tools/lli/<wbr>OrcLazyJIT.cpp<br>
> llvm/trunk/tools/lli/<wbr>OrcLazyJIT.h<br>
> llvm/trunk/unittests/<wbr>ExecutionEngine/Orc/<wbr>LazyEmittingLayerTest.cpp<br>
> llvm/trunk/unittests/<wbr>ExecutionEngine/Orc/<wbr>ObjectTransformLayerTest.cpp<br>
> llvm/trunk/unittests/<wbr>ExecutionEngine/Orc/<wbr>OrcCAPITest.cpp<br>
> llvm/trunk/unittests/<wbr>ExecutionEngine/Orc/<wbr>OrcTestCommon.h<br>
><br>
> Modified: llvm/trunk/examples/<wbr>Kaleidoscope/BuildingAJIT/<wbr>Chapter1/KaleidoscopeJIT.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h?rev=306166&r1=306165&r2=306166&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/examples/<wbr>Kaleidoscope/BuildingAJIT/<wbr>Chapter1/KaleidoscopeJIT.h?<wbr>rev=306166&r1=306165&r2=<wbr>306166&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/examples/<wbr>Kaleidoscope/BuildingAJIT/<wbr>Chapter1/KaleidoscopeJIT.h (original)<br>
> +++ llvm/trunk/examples/<wbr>Kaleidoscope/BuildingAJIT/<wbr>Chapter1/KaleidoscopeJIT.h Fri Jun 23 16:45:29 2017<br>
> @@ -44,7 +44,7 @@ private:<br>
> IRCompileLayer<decltype(<wbr>ObjectLayer), SimpleCompiler> CompileLayer;<br>
><br>
> public:<br>
> - using ModuleHandle = decltype(CompileLayer)::<wbr>ModuleSetHandleT;<br>
> + using ModuleHandle = decltype(CompileLayer)::<wbr>ModuleHandleT;<br>
><br>
> KaleidoscopeJIT()<br>
> : TM(EngineBuilder().<wbr>selectTarget()), DL(TM->createDataLayout()),<br>
> @@ -72,15 +72,11 @@ public:<br>
> return JITSymbol(nullptr);<br>
> });<br>
><br>
> - // Build a singleton module set to hold our module.<br>
> - std::vector<std::unique_ptr<<wbr>Module>> Ms;<br>
> - Ms.push_back(std::move(M));<br>
> -<br>
> // Add the set to the JIT with the resolver we created above and a newly<br>
> // created SectionMemoryManager.<br>
> - return CompileLayer.addModuleSet(std:<wbr>:move(Ms),<br>
> - make_unique<<wbr>SectionMemoryManager>(),<br>
> - std::move(Resolver));<br>
> + return CompileLayer.addModule(std::<wbr>move(M),<br>
> + make_unique<<wbr>SectionMemoryManager>(),<br>
> + std::move(Resolver));<br>
> }<br>
><br>
> JITSymbol findSymbol(const std::string Name) {<br>
> @@ -91,7 +87,7 @@ public:<br>
> }<br>
><br>
> void removeModule(ModuleHandle H) {<br>
> - CompileLayer.removeModuleSet(<wbr>H);<br>
> + CompileLayer.removeModule(H);<br>
> }<br>
> };<br>
><br>
><br>
> Modified: llvm/trunk/examples/<wbr>Kaleidoscope/BuildingAJIT/<wbr>Chapter2/KaleidoscopeJIT.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h?rev=306166&r1=306165&r2=306166&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/examples/<wbr>Kaleidoscope/BuildingAJIT/<wbr>Chapter2/KaleidoscopeJIT.h?<wbr>rev=306166&r1=306165&r2=<wbr>306166&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/examples/<wbr>Kaleidoscope/BuildingAJIT/<wbr>Chapter2/KaleidoscopeJIT.h (original)<br>
> +++ llvm/trunk/examples/<wbr>Kaleidoscope/BuildingAJIT/<wbr>Chapter2/KaleidoscopeJIT.h Fri Jun 23 16:45:29 2017<br>
> @@ -48,18 +48,18 @@ private:<br>
> IRCompileLayer<decltype(<wbr>ObjectLayer), SimpleCompiler> CompileLayer;<br>
><br>
> using OptimizeFunction =<br>
> - std::function<std::unique_ptr<<wbr>Module>(std::unique_ptr<<wbr>Module>)>;<br>
> + std::function<std::shared_ptr<<wbr>Module>(std::shared_ptr<<wbr>Module>)>;<br>
><br>
> IRTransformLayer<decltype(<wbr>CompileLayer), OptimizeFunction> OptimizeLayer;<br>
><br>
> public:<br>
> - using ModuleHandle = decltype(OptimizeLayer)::<wbr>ModuleSetHandleT;<br>
> + using ModuleHandle = decltype(OptimizeLayer)::<wbr>ModuleHandleT;<br>
><br>
> KaleidoscopeJIT()<br>
> : TM(EngineBuilder().<wbr>selectTarget()), DL(TM->createDataLayout()),<br>
> CompileLayer(ObjectLayer, SimpleCompiler(*TM)),<br>
> OptimizeLayer(CompileLayer,<br>
> - [this](std::unique_ptr<Module> M) {<br>
> + [this](std::shared_ptr<Module> M) {<br>
> return optimizeModule(std::move(M));<br>
> }) {<br>
> llvm::sys::DynamicLibrary::<wbr>LoadLibraryPermanently(<wbr>nullptr);<br>
> @@ -85,15 +85,11 @@ public:<br>
> return JITSymbol(nullptr);<br>
> });<br>
><br>
> - // Build a singleton module set to hold our module.<br>
> - std::vector<std::unique_ptr<<wbr>Module>> Ms;<br>
> - Ms.push_back(std::move(M));<br>
> -<br>
> // Add the set to the JIT with the resolver we created above and a newly<br>
> // created SectionMemoryManager.<br>
> - return OptimizeLayer.addModuleSet(<wbr>std::move(Ms),<br>
> - make_unique<<wbr>SectionMemoryManager>(),<br>
> - std::move(Resolver));<br>
> + return OptimizeLayer.addModule(std::<wbr>move(M),<br>
> + make_unique<<wbr>SectionMemoryManager>(),<br>
> + std::move(Resolver));<br>
> }<br>
><br>
> JITSymbol findSymbol(const std::string Name) {<br>
> @@ -104,11 +100,11 @@ public:<br>
> }<br>
><br>
> void removeModule(ModuleHandle H) {<br>
> - OptimizeLayer.removeModuleSet(<wbr>H);<br>
> + OptimizeLayer.removeModule(H);<br>
> }<br>
><br>
> private:<br>
> - std::unique_ptr<Module> optimizeModule(std::unique_<wbr>ptr<Module> M) {<br>
> + std::shared_ptr<Module> optimizeModule(std::shared_<wbr>ptr<Module> M) {<br>
> // Create a function pass manager.<br>
> auto FPM = llvm::make_unique<legacy::<wbr>FunctionPassManager>(M.get());<br>
><br>
><br>
> Modified: llvm/trunk/examples/<wbr>Kaleidoscope/BuildingAJIT/<wbr>Chapter3/KaleidoscopeJIT.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h?rev=306166&r1=306165&r2=306166&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/examples/<wbr>Kaleidoscope/BuildingAJIT/<wbr>Chapter3/KaleidoscopeJIT.h?<wbr>rev=306166&r1=306165&r2=<wbr>306166&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/examples/<wbr>Kaleidoscope/BuildingAJIT/<wbr>Chapter3/KaleidoscopeJIT.h (original)<br>
> +++ llvm/trunk/examples/<wbr>Kaleidoscope/BuildingAJIT/<wbr>Chapter3/KaleidoscopeJIT.h Fri Jun 23 16:45:29 2017<br>
> @@ -51,7 +51,7 @@ private:<br>
> IRCompileLayer<decltype(<wbr>ObjectLayer), SimpleCompiler> CompileLayer;<br>
><br>
> using OptimizeFunction =<br>
> - std::function<std::unique_ptr<<wbr>Module>(std::unique_ptr<<wbr>Module>)>;<br>
> + std::function<std::shared_ptr<<wbr>Module>(std::shared_ptr<<wbr>Module>)>;<br>
><br>
> IRTransformLayer<decltype(<wbr>CompileLayer), OptimizeFunction> OptimizeLayer;<br>
><br>
> @@ -59,13 +59,13 @@ private:<br>
> CompileOnDemandLayer<decltype(<wbr>OptimizeLayer)> CODLayer;<br>
><br>
> public:<br>
> - using ModuleHandle = decltype(CODLayer)::<wbr>ModuleSetHandleT;<br>
> + using ModuleHandle = decltype(CODLayer)::<wbr>ModuleHandleT;<br>
><br>
> KaleidoscopeJIT()<br>
> : TM(EngineBuilder().<wbr>selectTarget()), DL(TM->createDataLayout()),<br>
> CompileLayer(ObjectLayer, SimpleCompiler(*TM)),<br>
> OptimizeLayer(CompileLayer,<br>
> - [this](std::unique_ptr<Module> M) {<br>
> + [this](std::shared_ptr<Module> M) {<br>
> return optimizeModule(std::move(M));<br>
> }),<br>
> CompileCallbackManager(<br>
> @@ -98,15 +98,11 @@ public:<br>
> return JITSymbol(nullptr);<br>
> });<br>
><br>
> - // Build a singleton module set to hold our module.<br>
> - std::vector<std::unique_ptr<<wbr>Module>> Ms;<br>
> - Ms.push_back(std::move(M));<br>
> -<br>
> // Add the set to the JIT with the resolver we created above and a newly<br>
> // created SectionMemoryManager.<br>
> - return CODLayer.addModuleSet(std::<wbr>move(Ms),<br>
> - make_unique<<wbr>SectionMemoryManager>(),<br>
> - std::move(Resolver));<br>
> + return CODLayer.addModule(std::move(<wbr>M),<br>
> + make_unique<<wbr>SectionMemoryManager>(),<br>
> + std::move(Resolver));<br>
> }<br>
><br>
> JITSymbol findSymbol(const std::string Name) {<br>
> @@ -117,11 +113,11 @@ public:<br>
> }<br>
><br>
> void removeModule(ModuleHandle H) {<br>
> - CODLayer.removeModuleSet(H);<br>
> + CODLayer.removeModule(H);<br>
> }<br>
><br>
> private:<br>
> - std::unique_ptr<Module> optimizeModule(std::unique_<wbr>ptr<Module> M) {<br>
> + std::shared_ptr<Module> optimizeModule(std::shared_<wbr>ptr<Module> M) {<br>
> // Create a function pass manager.<br>
> auto FPM = llvm::make_unique<legacy::<wbr>FunctionPassManager>(M.get());<br>
><br>
><br>
> Modified: llvm/trunk/examples/<wbr>Kaleidoscope/BuildingAJIT/<wbr>Chapter4/KaleidoscopeJIT.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h?rev=306166&r1=306165&r2=306166&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/examples/<wbr>Kaleidoscope/BuildingAJIT/<wbr>Chapter4/KaleidoscopeJIT.h?<wbr>rev=306166&r1=306165&r2=<wbr>306166&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/examples/<wbr>Kaleidoscope/BuildingAJIT/<wbr>Chapter4/KaleidoscopeJIT.h (original)<br>
> +++ llvm/trunk/examples/<wbr>Kaleidoscope/BuildingAJIT/<wbr>Chapter4/KaleidoscopeJIT.h Fri Jun 23 16:45:29 2017<br>
> @@ -77,7 +77,7 @@ private:<br>
> IRCompileLayer<decltype(<wbr>ObjectLayer), SimpleCompiler> CompileLayer;<br>
><br>
> using OptimizeFunction =<br>
> - std::function<std::unique_ptr<<wbr>Module>(std::unique_ptr<<wbr>Module>)>;<br>
> + std::function<std::shared_ptr<<wbr>Module>(std::shared_ptr<<wbr>Module>)>;<br>
><br>
> IRTransformLayer<decltype(<wbr>CompileLayer), OptimizeFunction> OptimizeLayer;<br>
><br>
> @@ -85,14 +85,14 @@ private:<br>
> std::unique_ptr<<wbr>IndirectStubsManager> IndirectStubsMgr;<br>
><br>
> public:<br>
> - using ModuleHandle = decltype(OptimizeLayer)::<wbr>ModuleSetHandleT;<br>
> + using ModuleHandle = decltype(OptimizeLayer)::<wbr>ModuleHandleT;<br>
><br>
> KaleidoscopeJIT()<br>
> : TM(EngineBuilder().<wbr>selectTarget()),<br>
> DL(TM->createDataLayout()),<br>
> CompileLayer(ObjectLayer, SimpleCompiler(*TM)),<br>
> OptimizeLayer(CompileLayer,<br>
> - [this](std::unique_ptr<Module> M) {<br>
> + [this](std::shared_ptr<Module> M) {<br>
> return optimizeModule(std::move(M));<br>
> }),<br>
> CompileCallbackMgr(<br>
> @@ -125,15 +125,11 @@ public:<br>
> return JITSymbol(nullptr);<br>
> });<br>
><br>
> - // Build a singleton module set to hold our module.<br>
> - std::vector<std::unique_ptr<<wbr>Module>> Ms;<br>
> - Ms.push_back(std::move(M));<br>
> -<br>
> // Add the set to the JIT with the resolver we created above and a newly<br>
> // created SectionMemoryManager.<br>
> - return OptimizeLayer.addModuleSet(<wbr>std::move(Ms),<br>
> - make_unique<<wbr>SectionMemoryManager>(),<br>
> - std::move(Resolver));<br>
> + return OptimizeLayer.addModule(std::<wbr>move(M),<br>
> + make_unique<<wbr>SectionMemoryManager>(),<br>
> + std::move(Resolver));<br>
> }<br>
><br>
> Error addFunctionAST(std::unique_<wbr>ptr<FunctionAST> FnAST) {<br>
> @@ -199,7 +195,7 @@ public:<br>
> }<br>
><br>
> void removeModule(ModuleHandle H) {<br>
> - OptimizeLayer.removeModuleSet(<wbr>H);<br>
> + OptimizeLayer.removeModule(H);<br>
> }<br>
><br>
> private:<br>
> @@ -210,7 +206,7 @@ private:<br>
> return MangledNameStream.str();<br>
> }<br>
><br>
> - std::unique_ptr<Module> optimizeModule(std::unique_<wbr>ptr<Module> M) {<br>
> + std::shared_ptr<Module> optimizeModule(std::shared_<wbr>ptr<Module> M) {<br>
> // Create a function pass manager.<br>
> auto FPM = llvm::make_unique<legacy::<wbr>FunctionPassManager>(M.get());<br>
><br>
><br>
> Modified: llvm/trunk/examples/<wbr>Kaleidoscope/BuildingAJIT/<wbr>Chapter5/KaleidoscopeJIT.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h?rev=306166&r1=306165&r2=306166&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/examples/<wbr>Kaleidoscope/BuildingAJIT/<wbr>Chapter5/KaleidoscopeJIT.h?<wbr>rev=306166&r1=306165&r2=<wbr>306166&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/examples/<wbr>Kaleidoscope/BuildingAJIT/<wbr>Chapter5/KaleidoscopeJIT.h (original)<br>
> +++ llvm/trunk/examples/<wbr>Kaleidoscope/BuildingAJIT/<wbr>Chapter5/KaleidoscopeJIT.h Fri Jun 23 16:45:29 2017<br>
> @@ -82,7 +82,7 @@ private:<br>
> IRCompileLayer<decltype(<wbr>ObjectLayer), SimpleCompiler> CompileLayer;<br>
><br>
> using OptimizeFunction =<br>
> - std::function<std::unique_ptr<<wbr>Module>(std::unique_ptr<<wbr>Module>)>;<br>
> + std::function<std::shared_ptr<<wbr>Module>(std::shared_ptr<<wbr>Module>)>;<br>
><br>
> IRTransformLayer<decltype(<wbr>CompileLayer), OptimizeFunction> OptimizeLayer;<br>
><br>
> @@ -91,7 +91,7 @@ private:<br>
> MyRemote &Remote;<br>
><br>
> public:<br>
> - using ModuleHandle = decltype(OptimizeLayer)::<wbr>ModuleSetHandleT;<br>
> + using ModuleHandle = decltype(OptimizeLayer)::<wbr>ModuleHandleT;<br>
><br>
> KaleidoscopeJIT(MyRemote &Remote)<br>
> : TM(EngineBuilder().<wbr>selectTarget(Triple(Remote.<wbr>getTargetTriple()), "",<br>
> @@ -99,7 +99,7 @@ public:<br>
> DL(TM->createDataLayout()),<br>
> CompileLayer(ObjectLayer, SimpleCompiler(*TM)),<br>
> OptimizeLayer(CompileLayer,<br>
> - [this](std::unique_ptr<Module> M) {<br>
> + [this](std::shared_ptr<Module> M) {<br>
> return optimizeModule(std::move(M));<br>
> }),<br>
> Remote(Remote) {<br>
> @@ -153,15 +153,11 @@ public:<br>
> exit(1);<br>
> }<br>
><br>
> - // Build a singleton module set to hold our module.<br>
> - std::vector<std::unique_ptr<<wbr>Module>> Ms;<br>
> - Ms.push_back(std::move(M));<br>
> -<br>
> // Add the set to the JIT with the resolver we created above and a newly<br>
> // created SectionMemoryManager.<br>
> - return OptimizeLayer.addModuleSet(<wbr>std::move(Ms),<br>
> - std::move(MemMgr),<br>
> - std::move(Resolver));<br>
> + return OptimizeLayer.addModule(std::<wbr>move(M),<br>
> + std::move(MemMgr),<br>
> + std::move(Resolver));<br>
> }<br>
><br>
> Error addFunctionAST(std::unique_<wbr>ptr<FunctionAST> FnAST) {<br>
> @@ -231,7 +227,7 @@ public:<br>
> }<br>
><br>
> void removeModule(ModuleHandle H) {<br>
> - OptimizeLayer.removeModuleSet(<wbr>H);<br>
> + OptimizeLayer.removeModule(H);<br>
> }<br>
><br>
> private:<br>
> @@ -242,7 +238,7 @@ private:<br>
> return MangledNameStream.str();<br>
> }<br>
><br>
> - std::unique_ptr<Module> optimizeModule(std::unique_<wbr>ptr<Module> M) {<br>
> + std::shared_ptr<Module> optimizeModule(std::shared_<wbr>ptr<Module> M) {<br>
> // Create a function pass manager.<br>
> auto FPM = llvm::make_unique<legacy::<wbr>FunctionPassManager>(M.get());<br>
><br>
><br>
> Modified: llvm/trunk/examples/<wbr>Kaleidoscope/include/<wbr>KaleidoscopeJIT.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/include/KaleidoscopeJIT.h?rev=306166&r1=306165&r2=306166&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/examples/<wbr>Kaleidoscope/include/<wbr>KaleidoscopeJIT.h?rev=306166&<wbr>r1=306165&r2=306166&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/examples/<wbr>Kaleidoscope/include/<wbr>KaleidoscopeJIT.h (original)<br>
> +++ llvm/trunk/examples/<wbr>Kaleidoscope/include/<wbr>KaleidoscopeJIT.h Fri Jun 23 16:45:29 2017<br>
> @@ -41,7 +41,7 @@ class KaleidoscopeJIT {<br>
> public:<br>
> using ObjLayerT = RTDyldObjectLinkingLayer;<br>
> using CompileLayerT = IRCompileLayer<ObjLayerT, SimpleCompiler>;<br>
> - using ModuleHandleT = CompileLayerT::<wbr>ModuleSetHandleT;<br>
> + using ModuleHandleT = CompileLayerT::ModuleHandleT;<br>
><br>
> KaleidoscopeJIT()<br>
> : TM(EngineBuilder().<wbr>selectTarget()), DL(TM->createDataLayout()),<br>
> @@ -62,9 +62,9 @@ public:<br>
> return JITSymbol(nullptr);<br>
> },<br>
> [](const std::string &S) { return nullptr; });<br>
> - auto H = CompileLayer.addModuleSet(<wbr>singletonSet(std::move(M)),<br>
> - make_unique<<wbr>SectionMemoryManager>(),<br>
> - std::move(Resolver));<br>
> + auto H = CompileLayer.addModule(std::<wbr>move(M),<br>
> + make_unique<<wbr>SectionMemoryManager>(),<br>
> + std::move(Resolver));<br>
><br>
> ModuleHandles.push_back(H);<br>
> return H;<br>
> @@ -72,7 +72,7 @@ public:<br>
><br>
> void removeModule(ModuleHandleT H) {<br>
> ModuleHandles.erase(find(<wbr>ModuleHandles, H));<br>
> - CompileLayer.removeModuleSet(<wbr>H);<br>
> + CompileLayer.removeModule(H);<br>
> }<br>
><br>
> JITSymbol findSymbol(const std::string Name) {<br>
> @@ -89,12 +89,6 @@ private:<br>
> return MangledName;<br>
> }<br>
><br>
> - template <typename T> static std::vector<T> singletonSet(T t) {<br>
> - std::vector<T> Vec;<br>
> - Vec.push_back(std::move(t));<br>
> - return Vec;<br>
> - }<br>
> -<br>
> JITSymbol findMangledSymbol(const std::string &Name) {<br>
> #ifdef LLVM_ON_WIN32<br>
> // The symbol lookup of ObjectLinkingLayer uses the SymbolRef::SF_Exported<br>
><br>
> Modified: llvm/trunk/include/llvm-c/<wbr>OrcBindings.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/OrcBindings.h?rev=306166&r1=306165&r2=306166&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm-c/OrcBindings.h?rev=<wbr>306166&r1=306165&r2=306166&<wbr>view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/include/llvm-c/<wbr>OrcBindings.h (original)<br>
> +++ llvm/trunk/include/llvm-c/<wbr>OrcBindings.h Fri Jun 23 16:45:29 2017<br>
> @@ -29,6 +29,8 @@<br>
> extern "C" {<br>
> #endif<br>
><br>
> +typedef struct LLVMOpaqueSharedModule *LLVMSharedModuleRef;<br>
> +typedef struct LLVMOpaqueSharedObjectBuffer *LLVMSharedObjectBufferRef;<br>
> typedef struct LLVMOrcOpaqueJITStack *LLVMOrcJITStackRef;<br>
> typedef uint32_t LLVMOrcModuleHandle;<br>
> typedef uint64_t LLVMOrcTargetAddress;<br>
> @@ -39,6 +41,45 @@ typedef uint64_t (*LLVMOrcLazyCompileCal<br>
> typedef enum { LLVMOrcErrSuccess = 0, LLVMOrcErrGeneric } LLVMOrcErrorCode;<br>
><br>
> /**<br>
> + * Turn an LLVMModuleRef into an LLVMSharedModuleRef.<br>
> + *<br>
> + * The JIT uses shared ownership for LLVM modules, since it is generally<br>
> + * difficult to know when the JIT will be finished with a module (and the JIT<br>
> + * has no way of knowing when a user may be finished with one).<br>
> + *<br>
> + * Calling this method with an LLVMModuleRef creates a shared-pointer to the<br>
> + * module, and returns a reference to this shared pointer.<br>
> + *<br>
> + * The shared module should be disposed when finished with by calling<br>
> + * LLVMOrcDisposeSharedModule (not LLVMDisposeModule). The Module will be<br>
> + * deleted when the last shared pointer owner relinquishes it.<br>
> + */<br>
> +<br>
> +LLVMSharedModuleRef LLVMOrcMakeSharedModule(<wbr>LLVMModuleRef Mod);<br>
> +<br>
> +/**<br>
> + * Dispose of a shared module.<br>
> + *<br>
> + * The module should not be accessed after this call. The module will be<br>
> + * deleted once all clients (including the JIT itself) have released their<br>
> + * shared pointers.<br>
> + */<br>
> +<br>
> +void LLVMOrcDisposeSharedModuleRef(<wbr>LLVMSharedModuleRef SharedMod);<br>
> +<br>
> +/**<br>
> + * Get an LLVMSharedObjectBufferRef from an LLVMMemoryBufferRef.<br>
> + */<br>
> +LLVMSharedObjectBufferRef<br>
> +<wbr>LLVMOrcMakeSharedObjectBuffer(<wbr>LLVMMemoryBufferRef ObjBuffer);<br>
> +<br>
> +/**<br>
> + * Dispose of a shared object buffer.<br>
> + */<br>
> +void<br>
> +<wbr>LLVMOrcDisposeSharedObjectBuff<wbr>erRef(<wbr>LLVMSharedObjectBufferRef SharedObjBuffer);<br>
> +<br>
> +/**<br>
> * Create an ORC JIT stack.<br>
> *<br>
> * The client owns the resulting stack, and must call OrcDisposeInstance(...)<br>
> @@ -95,7 +136,8 @@ LLVMOrcErrorCode LLVMOrcSetIndirectStubP<br>
> * Add module to be eagerly compiled.<br>
> */<br>
> LLVMOrcModuleHandle<br>
> -LLVMOrcAddEagerlyCompiledIR(<wbr>LLVMOrcJITStackRef JITStack, LLVMModuleRef Mod,<br>
> +LLVMOrcAddEagerlyCompiledIR(<wbr>LLVMOrcJITStackRef JITStack,<br>
> + LLVMSharedModuleRef Mod,<br>
> LLVMOrcSymbolResolverFn SymbolResolver,<br>
> void *SymbolResolverCtx);<br>
><br>
> @@ -103,7 +145,8 @@ LLVMOrcAddEagerlyCompiledIR(<wbr>LLVMOrcJITSt<br>
> * Add module to be lazily compiled one function at a time.<br>
> */<br>
> LLVMOrcModuleHandle<br>
> -LLVMOrcAddLazilyCompiledIR(<wbr>LLVMOrcJITStackRef JITStack, LLVMModuleRef Mod,<br>
> +LLVMOrcAddLazilyCompiledIR(<wbr>LLVMOrcJITStackRef JITStack,<br>
> + LLVMSharedModuleRef Mod,<br>
> LLVMOrcSymbolResolverFn SymbolResolver,<br>
> void *SymbolResolverCtx);<br>
><br>
> @@ -111,7 +154,7 @@ LLVMOrcAddLazilyCompiledIR(<wbr>LLVMOrcJITSta<br>
> * Add an object file.<br>
> */<br>
> LLVMOrcModuleHandle LLVMOrcAddObjectFile(<wbr>LLVMOrcJITStackRef JITStack,<br>
> - LLVMObjectFileRef Obj,<br>
> + LLVMSharedObjectBufferRef Obj,<br>
> LLVMOrcSymbolResolverFn SymbolResolver,<br>
> void *SymbolResolverCtx);<br>
><br>
><br>
> Modified: llvm/trunk/include/llvm/<wbr>ExecutionEngine/Orc/<wbr>CompileOnDemandLayer.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h?rev=306166&r1=306165&r2=306166&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/ExecutionEngine/Orc/<wbr>CompileOnDemandLayer.h?rev=<wbr>306166&r1=306165&r2=306166&<wbr>view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/include/llvm/<wbr>ExecutionEngine/Orc/<wbr>CompileOnDemandLayer.h (original)<br>
> +++ llvm/trunk/include/llvm/<wbr>ExecutionEngine/Orc/<wbr>CompileOnDemandLayer.h Fri Jun 23 16:45:29 2017<br>
> @@ -84,7 +84,7 @@ private:<br>
> return LambdaMaterializer<<wbr>MaterializerFtor>(std::move(M)<wbr>);<br>
> }<br>
><br>
> - using BaseLayerModuleSetHandleT = typename BaseLayerT::ModuleSetHandleT;<br>
> + using BaseLayerModuleHandleT = typename BaseLayerT::ModuleHandleT;<br>
><br>
> // Provide type-erasure for the Modules and MemoryManagers.<br>
> template <typename ResourceT><br>
> @@ -139,9 +139,11 @@ private:<br>
> struct LogicalDylib {<br>
> using SymbolResolverFtor = std::function<JITSymbol(const std::string&)>;<br>
><br>
> - using ModuleAdderFtor = std::function<typename BaseLayerT::ModuleSetHandleT(<br>
> - BaseLayerT &, std::unique_ptr<Module>,<br>
> - std::unique_ptr<<wbr>JITSymbolResolver>)>;<br>
> + using ModuleAdderFtor =<br>
> + std::function<typename BaseLayerT::ModuleHandleT(<br>
> + BaseLayerT&,<br>
> + std::unique_ptr<Module>,<br>
> + std::unique_ptr<<wbr>JITSymbolResolver>)>;<br>
><br>
> struct SourceModuleEntry {<br>
> std::unique_ptr<ResourceOwner<<wbr>Module>> SourceMod;<br>
> @@ -179,7 +181,7 @@ private:<br>
><br>
> void removeModulesFromBaseLayer(<wbr>BaseLayerT &BaseLayer) {<br>
> for (auto &BLH : BaseLayerHandles)<br>
> - BaseLayer.removeModuleSet(BLH)<wbr>;<br>
> + BaseLayer.removeModule(BLH);<br>
> }<br>
><br>
> std::unique_ptr<<wbr>JITSymbolResolver> ExternalSymbolResolver;<br>
> @@ -188,14 +190,14 @@ private:<br>
> StaticGlobalRenamer StaticRenamer;<br>
> ModuleAdderFtor ModuleAdder;<br>
> SourceModulesList SourceModules;<br>
> - std::vector<<wbr>BaseLayerModuleSetHandleT> BaseLayerHandles;<br>
> + std::vector<<wbr>BaseLayerModuleHandleT> BaseLayerHandles;<br>
> };<br>
><br>
> using LogicalDylibList = std::list<LogicalDylib>;<br>
><br>
> public:<br>
> - /// @brief Handle to a set of loaded modules.<br>
> - using ModuleSetHandleT = typename LogicalDylibList::iterator;<br>
> + /// @brief Handle to loaded module.<br>
> + using ModuleHandleT = typename LogicalDylibList::iterator;<br>
><br>
> /// @brief Module partitioning functor.<br>
> using PartitioningFtor = std::function<std::set<<wbr>Function*>(Function&)>;<br>
> @@ -216,15 +218,15 @@ public:<br>
><br>
> ~CompileOnDemandLayer() {<br>
> while (!LogicalDylibs.empty())<br>
> - removeModuleSet(LogicalDylibs.<wbr>begin());<br>
> + removeModule(LogicalDylibs.<wbr>begin());<br>
> }<br>
> -<br>
> +<br>
> /// @brief Add a module to the compile-on-demand layer.<br>
> - template <typename ModuleSetT, typename MemoryManagerPtrT,<br>
> - typename SymbolResolverPtrT><br>
> - ModuleSetHandleT addModuleSet(ModuleSetT Ms,<br>
> - MemoryManagerPtrT MemMgr,<br>
> - SymbolResolverPtrT Resolver) {<br>
> + template <typename MemoryManagerPtrT, typename SymbolResolverPtrT><br>
> + ModuleHandleT addModule(std::shared_ptr<<wbr>Module> M,<br>
> + MemoryManagerPtrT MemMgr,<br>
> + SymbolResolverPtrT Resolver) {<br>
> +<br>
> LogicalDylibs.push_back(<wbr>LogicalDylib());<br>
> auto &LD = LogicalDylibs.back();<br>
> LD.ExternalSymbolResolver = std::move(Resolver);<br>
> @@ -236,23 +238,25 @@ public:<br>
> LD.ModuleAdder =<br>
> [&MemMgrRef](BaseLayerT &B, std::unique_ptr<Module> M,<br>
> std::unique_ptr<<wbr>JITSymbolResolver> R) {<br>
> - std::vector<std::unique_ptr<<wbr>Module>> Ms;<br>
> - Ms.push_back(std::move(M));<br>
> - return B.addModuleSet(std::move(Ms), &MemMgrRef, std::move(R));<br>
> + return B.addModule(std::move(M), &MemMgrRef, std::move(R));<br>
> };<br>
><br>
> // Process each of the modules in this module set.<br>
> - for (auto &M : Ms)<br>
> - addLogicalModule(<wbr>LogicalDylibs.back(), std::move(M));<br>
> + addLogicalModule(<wbr>LogicalDylibs.back(), std::move(M));<br>
><br>
> return std::prev(LogicalDylibs.end())<wbr>;<br>
> }<br>
><br>
> + /// @brief Add extra modules to an existing logical module.<br>
> + void addExtraModule(ModuleHandleT H, std::shared_ptr<Module> M) {<br>
> + addLogicalModule(*H, std::move(M));<br>
> + }<br>
> +<br>
> /// @brief Remove the module represented by the given handle.<br>
> ///<br>
> /// This will remove all modules in the layers below that were derived from<br>
> /// the module represented by H.<br>
> - void removeModuleSet(<wbr>ModuleSetHandleT H) {<br>
> + void removeModule(ModuleHandleT H) {<br>
> H->removeModulesFromBaseLayer(<wbr>BaseLayer);<br>
> LogicalDylibs.erase(H);<br>
> }<br>
> @@ -274,7 +278,7 @@ public:<br>
><br>
> /// @brief Get the address of a symbol provided by this layer, or some layer<br>
> /// below this one.<br>
> - JITSymbol findSymbolIn(ModuleSetHandleT H, const std::string &Name,<br>
> + JITSymbol findSymbolIn(ModuleHandleT H, const std::string &Name,<br>
> bool ExportedSymbolsOnly) {<br>
> return H->findSymbol(BaseLayer, Name, ExportedSymbolsOnly);<br>
> }<br>
> @@ -498,7 +502,7 @@ private:<br>
> }<br>
><br>
> template <typename PartitionT><br>
> - BaseLayerModuleSetHandleT<br>
> + BaseLayerModuleHandleT<br>
> emitPartition(LogicalDylib &LD,<br>
> typename LogicalDylib::<wbr>SourceModuleHandle LMId,<br>
> const PartitionT &Part) {<br>
><br>
> Modified: llvm/trunk/include/llvm/<wbr>ExecutionEngine/Orc/<wbr>ExecutionUtils.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/ExecutionUtils.h?rev=306166&r1=306165&r2=306166&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/ExecutionEngine/Orc/<wbr>ExecutionUtils.h?rev=306166&<wbr>r1=306165&r2=306166&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/include/llvm/<wbr>ExecutionEngine/Orc/<wbr>ExecutionUtils.h (original)<br>
> +++ llvm/trunk/include/llvm/<wbr>ExecutionEngine/Orc/<wbr>ExecutionUtils.h Fri Jun 23 16:45:29 2017<br>
> @@ -94,7 +94,7 @@ public:<br>
> /// @brief Construct a CtorDtorRunner for the given range using the given<br>
> /// name mangling function.<br>
> CtorDtorRunner(std::vector<<wbr>std::string> CtorDtorNames,<br>
> - typename JITLayerT::ModuleSetHandleT H)<br>
> + typename JITLayerT::ModuleHandleT H)<br>
> : CtorDtorNames(std::move(<wbr>CtorDtorNames)), H(H) {}<br>
><br>
> /// @brief Run the recorded constructors/destructors through the given JIT<br>
> @@ -116,7 +116,7 @@ public:<br>
><br>
> private:<br>
> std::vector<std::string> CtorDtorNames;<br>
> - typename JITLayerT::ModuleSetHandleT H;<br>
> + typename JITLayerT::ModuleHandleT H;<br>
> };<br>
><br>
> /// @brief Support class for static dtor execution. For hosted (in-process) JITs<br>
><br>
> Modified: llvm/trunk/include/llvm/<wbr>ExecutionEngine/Orc/<wbr>IRCompileLayer.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/IRCompileLayer.h?rev=306166&r1=306165&r2=306166&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/ExecutionEngine/Orc/<wbr>IRCompileLayer.h?rev=306166&<wbr>r1=306165&r2=306166&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/include/llvm/<wbr>ExecutionEngine/Orc/<wbr>IRCompileLayer.h (original)<br>
> +++ llvm/trunk/include/llvm/<wbr>ExecutionEngine/Orc/<wbr>IRCompileLayer.h Fri Jun 23 16:45:29 2017<br>
> @@ -28,15 +28,15 @@ namespace orc {<br>
><br>
> /// @brief Eager IR compiling layer.<br>
> ///<br>
> -/// This layer accepts sets of LLVM IR Modules (via addModuleSet). It<br>
> -/// immediately compiles each IR module to an object file (each IR Module is<br>
> -/// compiled separately). The resulting set of object files is then added to<br>
> -/// the layer below, which must implement the object layer concept.<br>
> +/// This layer immediately compiles each IR module added via addModule to an<br>
> +/// object file and adds this module file to the layer below, which must<br>
> +/// implement the object layer concept.<br>
> template <typename BaseLayerT, typename CompileFtor><br>
> class IRCompileLayer {<br>
> public:<br>
> - /// @brief Handle to a set of compiled modules.<br>
> - using ModuleSetHandleT = typename BaseLayerT::ObjHandleT;<br>
> +<br>
> + /// @brief Handle to a compiled module.<br>
> + using ModuleHandleT = typename BaseLayerT::ObjHandleT;<br>
><br>
> /// @brief Construct an IRCompileLayer with the given BaseLayer, which must<br>
> /// implement the ObjectLayer concept.<br>
> @@ -46,25 +46,22 @@ public:<br>
> /// @brief Get a reference to the compiler functor.<br>
> CompileFtor& getCompiler() { return Compile; }<br>
><br>
> - /// @brief Compile each module in the given module set, then add the resulting<br>
> - /// set of objects to the base layer along with the memory manager and<br>
> - /// symbol resolver.<br>
> + /// @brief Compile the module, and add the resulting object to the base layer<br>
> + /// along with the given memory manager and symbol resolver.<br>
> ///<br>
> - /// @return A handle for the added modules.<br>
> - template <typename ModuleSetT, typename MemoryManagerPtrT,<br>
> - typename SymbolResolverPtrT><br>
> - ModuleSetHandleT addModuleSet(ModuleSetT Ms,<br>
> - MemoryManagerPtrT MemMgr,<br>
> - SymbolResolverPtrT Resolver) {<br>
> - assert(Ms.size() == 1);<br>
> - using CompileResult = decltype(Compile(*Ms.front()))<wbr>;<br>
> - auto Obj = std::make_shared<<wbr>CompileResult>(Compile(*Ms.<wbr>front()));<br>
> + /// @return A handle for the added module.<br>
> + template <typename MemoryManagerPtrT, typename SymbolResolverPtrT><br>
> + ModuleHandleT addModule(std::shared_ptr<<wbr>Module> M,<br>
> + MemoryManagerPtrT MemMgr,<br>
> + SymbolResolverPtrT Resolver) {<br>
> + using CompileResult = decltype(Compile(*M));<br>
> + auto Obj = std::make_shared<<wbr>CompileResult>(Compile(*M));<br>
> return BaseLayer.addObject(std::move(<wbr>Obj), std::move(MemMgr),<br>
> std::move(Resolver));<br>
> }<br>
><br>
> - /// @brief Remove the module set associated with the handle H.<br>
> - void removeModuleSet(<wbr>ModuleSetHandleT H) { BaseLayer.removeObject(H); }<br>
> + /// @brief Remove the module associated with the handle H.<br>
> + void removeModule(ModuleHandleT H) { BaseLayer.removeObject(H); }<br>
><br>
> /// @brief Search for the given named symbol.<br>
> /// @param Name The name of the symbol to search for.<br>
> @@ -74,23 +71,23 @@ public:<br>
> return BaseLayer.findSymbol(Name, ExportedSymbolsOnly);<br>
> }<br>
><br>
> - /// @brief Get the address of the given symbol in the context of the set of<br>
> - /// compiled modules represented by the handle H. This call is<br>
> - /// forwarded to the base layer's implementation.<br>
> - /// @param H The handle for the module set to search in.<br>
> + /// @brief Get the address of the given symbol in compiled module represented<br>
> + /// by the handle H. This call is forwarded to the base layer's<br>
> + /// implementation.<br>
> + /// @param H The handle for the module to search in.<br>
> /// @param Name The name of the symbol to search for.<br>
> /// @param ExportedSymbolsOnly If true, search only for exported symbols.<br>
> /// @return A handle for the given named symbol, if it is found in the<br>
> - /// given module set.<br>
> - JITSymbol findSymbolIn(ModuleSetHandleT H, const std::string &Name,<br>
> + /// given module.<br>
> + JITSymbol findSymbolIn(ModuleHandleT H, const std::string &Name,<br>
> bool ExportedSymbolsOnly) {<br>
> return BaseLayer.findSymbolIn(H, Name, ExportedSymbolsOnly);<br>
> }<br>
><br>
> - /// @brief Immediately emit and finalize the moduleOB set represented by the<br>
> - /// given handle.<br>
> - /// @param H Handle for module set to emit/finalize.<br>
> - void emitAndFinalize(<wbr>ModuleSetHandleT H) {<br>
> + /// @brief Immediately emit and finalize the module represented by the given<br>
> + /// handle.<br>
> + /// @param H Handle for module to emit/finalize.<br>
> + void emitAndFinalize(ModuleHandleT H) {<br>
> BaseLayer.emitAndFinalize(H);<br>
> }<br>
><br>
><br>
> Modified: llvm/trunk/include/llvm/<wbr>ExecutionEngine/Orc/<wbr>IRTransformLayer.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/IRTransformLayer.h?rev=306166&r1=306165&r2=306166&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/ExecutionEngine/Orc/<wbr>IRTransformLayer.h?rev=306166&<wbr>r1=306165&r2=306166&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/include/llvm/<wbr>ExecutionEngine/Orc/<wbr>IRTransformLayer.h (original)<br>
> +++ llvm/trunk/include/llvm/<wbr>ExecutionEngine/Orc/<wbr>IRTransformLayer.h Fri Jun 23 16:45:29 2017<br>
> @@ -22,39 +22,34 @@ namespace orc {<br>
><br>
> /// @brief IR mutating layer.<br>
> ///<br>
> -/// This layer accepts sets of LLVM IR Modules (via addModuleSet). It<br>
> -/// immediately applies the user supplied functor to each module, then adds<br>
> -/// the set of transformed modules to the layer below.<br>
> +/// This layer applies a user supplied transform to each module that is added,<br>
> +/// then adds the transformed module to the layer below.<br>
> template <typename BaseLayerT, typename TransformFtor><br>
> class IRTransformLayer {<br>
> public:<br>
> +<br>
> /// @brief Handle to a set of added modules.<br>
> - using ModuleSetHandleT = typename BaseLayerT::ModuleSetHandleT;<br>
> + using ModuleHandleT = typename BaseLayerT::ModuleHandleT;<br>
><br>
> /// @brief Construct an IRTransformLayer with the given BaseLayer<br>
> IRTransformLayer(BaseLayerT &BaseLayer,<br>
> TransformFtor Transform = TransformFtor())<br>
> : BaseLayer(BaseLayer), Transform(std::move(Transform)<wbr>) {}<br>
><br>
> - /// @brief Apply the transform functor to each module in the module set, then<br>
> - /// add the resulting set of modules to the base layer, along with the<br>
> - /// memory manager and symbol resolver.<br>
> + /// @brief Apply the transform functor to the module, then add the module to<br>
> + /// the layer below, along with the memory manager and symbol resolver.<br>
> ///<br>
> /// @return A handle for the added modules.<br>
> - template <typename ModuleSetT, typename MemoryManagerPtrT,<br>
> - typename SymbolResolverPtrT><br>
> - ModuleSetHandleT addModuleSet(ModuleSetT Ms,<br>
> - MemoryManagerPtrT MemMgr,<br>
> - SymbolResolverPtrT Resolver) {<br>
> - for (auto I = Ms.begin(), E = Ms.end(); I != E; ++I)<br>
> - *I = Transform(std::move(*I));<br>
> -<br>
> - return BaseLayer.addModuleSet(std::<wbr>move(Ms), std::move(MemMgr),<br>
> - std::move(Resolver));<br>
> + template <typename MemoryManagerPtrT, typename SymbolResolverPtrT><br>
> + ModuleHandleT addModule(std::shared_ptr<<wbr>Module> M,<br>
> + MemoryManagerPtrT MemMgr,<br>
> + SymbolResolverPtrT Resolver) {<br>
> + return BaseLayer.addModule(Transform(<wbr>std::move(M)), std::move(MemMgr),<br>
> + std::move(Resolver));<br>
> }<br>
><br>
> - /// @brief Remove the module set associated with the handle H.<br>
> - void removeModuleSet(<wbr>ModuleSetHandleT H) { BaseLayer.removeModuleSet(H); }<br>
> + /// @brief Remove the module associated with the handle H.<br>
> + void removeModule(ModuleHandleT H) { BaseLayer.removeModule(H); }<br>
><br>
> /// @brief Search for the given named symbol.<br>
> /// @param Name The name of the symbol to search for.<br>
> @@ -64,23 +59,23 @@ public:<br>
> return BaseLayer.findSymbol(Name, ExportedSymbolsOnly);<br>
> }<br>
><br>
> - /// @brief Get the address of the given symbol in the context of the set of<br>
> - /// modules represented by the handle H. This call is forwarded to the<br>
> - /// base layer's implementation.<br>
> - /// @param H The handle for the module set to search in.<br>
> + /// @brief Get the address of the given symbol in the context of the module<br>
> + /// represented by the handle H. This call is forwarded to the base<br>
> + /// layer's implementation.<br>
> + /// @param H The handle for the module to search in.<br>
> /// @param Name The name of the symbol to search for.<br>
> /// @param ExportedSymbolsOnly If true, search only for exported symbols.<br>
> /// @return A handle for the given named symbol, if it is found in the<br>
> - /// given module set.<br>
> - JITSymbol findSymbolIn(ModuleSetHandleT H, const std::string &Name,<br>
> + /// given module.<br>
> + JITSymbol findSymbolIn(ModuleHandleT H, const std::string &Name,<br>
> bool ExportedSymbolsOnly) {<br>
> return BaseLayer.findSymbolIn(H, Name, ExportedSymbolsOnly);<br>
> }<br>
><br>
> - /// @brief Immediately emit and finalize the module set represented by the<br>
> - /// given handle.<br>
> - /// @param H Handle for module set to emit/finalize.<br>
> - void emitAndFinalize(<wbr>ModuleSetHandleT H) {<br>
> + /// @brief Immediately emit and finalize the module represented by the given<br>
> + /// handle.<br>
> + /// @param H Handle for module to emit/finalize.<br>
> + void emitAndFinalize(ModuleHandleT H) {<br>
> BaseLayer.emitAndFinalize(H);<br>
> }<br>
><br>
><br>
> Modified: llvm/trunk/include/llvm/<wbr>ExecutionEngine/Orc/<wbr>LazyEmittingLayer.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h?rev=306166&r1=306165&r2=306166&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/ExecutionEngine/Orc/<wbr>LazyEmittingLayer.h?rev=<wbr>306166&r1=306165&r2=306166&<wbr>view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/include/llvm/<wbr>ExecutionEngine/Orc/<wbr>LazyEmittingLayer.h (original)<br>
> +++ llvm/trunk/include/llvm/<wbr>ExecutionEngine/Orc/<wbr>LazyEmittingLayer.h Fri Jun 23 16:45:29 2017<br>
> @@ -34,19 +34,20 @@ namespace orc {<br>
><br>
> /// @brief Lazy-emitting IR layer.<br>
> ///<br>
> -/// This layer accepts sets of LLVM IR Modules (via addModuleSet), but does<br>
> -/// not immediately emit them the layer below. Instead, emissing to the base<br>
> -/// layer is deferred until the first time the client requests the address<br>
> -/// (via JITSymbol::getAddress) for a symbol contained in this layer.<br>
> +/// This layer accepts LLVM IR Modules (via addModule), but does not<br>
> +/// immediately emit them the layer below. Instead, emissing to the base layer<br>
> +/// is deferred until the first time the client requests the address (via<br>
> +/// JITSymbol::getAddress) for a symbol contained in this layer.<br>
> template <typename BaseLayerT> class LazyEmittingLayer {<br>
> public:<br>
> - using BaseLayerHandleT = typename BaseLayerT::ModuleSetHandleT;<br>
> +<br>
> + using BaseLayerHandleT = typename BaseLayerT::ModuleHandleT;<br>
><br>
> private:<br>
> - class EmissionDeferredSet {<br>
> + class EmissionDeferredModule {<br>
> public:<br>
> - EmissionDeferredSet() = default;<br>
> - virtual ~EmissionDeferredSet() = default;<br>
> + EmissionDeferredModule() = default;<br>
> + virtual ~EmissionDeferredModule() = default;<br>
><br>
> JITSymbol find(StringRef Name, bool ExportedSymbolsOnly, BaseLayerT &B) {<br>
> switch (EmitState) {<br>
> @@ -84,9 +85,9 @@ private:<br>
> llvm_unreachable("Invalid emit-state.");<br>
> }<br>
><br>
> - void removeModulesFromBaseLayer(<wbr>BaseLayerT &BaseLayer) {<br>
> + void removeModuleFromBaseLayer(<wbr>BaseLayerT &BaseLayer) {<br>
> if (EmitState != NotEmitted)<br>
> - BaseLayer.removeModuleSet(<wbr>Handle);<br>
> + BaseLayer.removeModule(Handle)<wbr>;<br>
> }<br>
><br>
> void emitAndFinalize(BaseLayerT &BaseLayer) {<br>
> @@ -100,10 +101,9 @@ private:<br>
> BaseLayer.emitAndFinalize(<wbr>Handle);<br>
> }<br>
><br>
> - template <typename ModuleSetT, typename MemoryManagerPtrT,<br>
> - typename SymbolResolverPtrT><br>
> - static std::unique_ptr<<wbr>EmissionDeferredSet><br>
> - create(BaseLayerT &B, ModuleSetT Ms, MemoryManagerPtrT MemMgr,<br>
> + template <typename MemoryManagerPtrT, typename SymbolResolverPtrT><br>
> + static std::unique_ptr<<wbr>EmissionDeferredModule><br>
> + create(BaseLayerT &B, std::shared_ptr<Module> M, MemoryManagerPtrT MemMgr,<br>
> SymbolResolverPtrT Resolver);<br>
><br>
> protected:<br>
> @@ -116,14 +116,13 @@ private:<br>
> BaseLayerHandleT Handle;<br>
> };<br>
><br>
> - template <typename ModuleSetT, typename MemoryManagerPtrT,<br>
> - typename SymbolResolverPtrT><br>
> - class EmissionDeferredSetImpl : public EmissionDeferredSet {<br>
> + template <typename MemoryManagerPtrT, typename SymbolResolverPtrT><br>
> + class EmissionDeferredModuleImpl : public EmissionDeferredModule {<br>
> public:<br>
> - EmissionDeferredSetImpl(<wbr>ModuleSetT Ms,<br>
> - MemoryManagerPtrT MemMgr,<br>
> - SymbolResolverPtrT Resolver)<br>
> - : Ms(std::move(Ms)), MemMgr(std::move(MemMgr)),<br>
> + EmissionDeferredModuleImpl(<wbr>std::shared_ptr<Module> M,<br>
> + MemoryManagerPtrT MemMgr,<br>
> + SymbolResolverPtrT Resolver)<br>
> + : M(std::move(M)), MemMgr(std::move(MemMgr)),<br>
> Resolver(std::move(Resolver)) {}<br>
><br>
> protected:<br>
> @@ -154,8 +153,8 @@ private:<br>
> // We don't need the mangled names set any more: Once we've emitted this<br>
> // to the base layer we'll just look for symbols there.<br>
> MangledSymbols.reset();<br>
> - return BaseLayer.addModuleSet(std::<wbr>move(Ms), std::move(MemMgr),<br>
> - std::move(Resolver));<br>
> + return BaseLayer.addModule(std::move(<wbr>M), std::move(MemMgr),<br>
> + std::move(Resolver));<br>
> }<br>
><br>
> private:<br>
> @@ -197,56 +196,54 @@ private:<br>
><br>
> auto Symbols = llvm::make_unique<StringMap<<wbr>const GlobalValue*>>();<br>
><br>
> - for (const auto &M : Ms) {<br>
> - Mangler Mang;<br>
> + Mangler Mang;<br>
><br>
> - for (const auto &GO : M->global_objects())<br>
> + for (const auto &GO : M->global_objects())<br>
> if (auto GV = addGlobalValue(*Symbols, GO, Mang, SearchName,<br>
> ExportedSymbolsOnly))<br>
> return GV;<br>
> - }<br>
><br>
> MangledSymbols = std::move(Symbols);<br>
> return nullptr;<br>
> }<br>
><br>
> - ModuleSetT Ms;<br>
> + std::shared_ptr<Module> M;<br>
> MemoryManagerPtrT MemMgr;<br>
> SymbolResolverPtrT Resolver;<br>
> mutable std::unique_ptr<StringMap<<wbr>const GlobalValue*>> MangledSymbols;<br>
> };<br>
><br>
> - using ModuleSetListT = std::list<std::unique_ptr<<wbr>EmissionDeferredSet>>;<br>
> + using ModuleListT = std::list<std::unique_ptr<<wbr>EmissionDeferredModule>>;<br>
><br>
> BaseLayerT &BaseLayer;<br>
> - ModuleSetListT ModuleSetList;<br>
> + ModuleListT ModuleList;<br>
><br>
> public:<br>
> - /// @brief Handle to a set of loaded modules.<br>
> - using ModuleSetHandleT = typename ModuleSetListT::iterator;<br>
> + /// @brief Handle to a loaded module.<br>
> + using ModuleHandleT = typename ModuleListT::iterator;<br>
><br>
> /// @brief Construct a lazy emitting layer.<br>
> LazyEmittingLayer(BaseLayerT &BaseLayer) : BaseLayer(BaseLayer) {}<br>
><br>
> - /// @brief Add the given set of modules to the lazy emitting layer.<br>
> - template <typename ModuleSetT, typename MemoryManagerPtrT,<br>
> - typename SymbolResolverPtrT><br>
> - ModuleSetHandleT addModuleSet(ModuleSetT Ms,<br>
> - MemoryManagerPtrT MemMgr,<br>
> - SymbolResolverPtrT Resolver) {<br>
> - return ModuleSetList.insert(<br>
> - ModuleSetList.end(),<br>
> - EmissionDeferredSet::create(<wbr>BaseLayer, std::move(Ms), std::move(MemMgr),<br>
> - std::move(Resolver)));<br>
> + /// @brief Add the given module to the lazy emitting layer.<br>
> + template <typename MemoryManagerPtrT, typename SymbolResolverPtrT><br>
> + ModuleHandleT addModule(std::shared_ptr<<wbr>Module> M,<br>
> + MemoryManagerPtrT MemMgr,<br>
> + SymbolResolverPtrT Resolver) {<br>
> + return ModuleList.insert(<br>
> + ModuleList.end(),<br>
> + EmissionDeferredModule::<wbr>create(BaseLayer, std::move(M),<br>
> + std::move(MemMgr),<br>
> + std::move(Resolver)));<br>
> }<br>
><br>
> - /// @brief Remove the module set represented by the given handle.<br>
> + /// @brief Remove the module represented by the given handle.<br>
> ///<br>
> - /// This method will free the memory associated with the given module set,<br>
> - /// both in this layer, and the base layer.<br>
> - void removeModuleSet(<wbr>ModuleSetHandleT H) {<br>
> - (*H)-><wbr>removeModulesFromBaseLayer(<wbr>BaseLayer);<br>
> - ModuleSetList.erase(H);<br>
> + /// This method will free the memory associated with the given module, both<br>
> + /// in this layer, and the base layer.<br>
> + void removeModule(ModuleHandleT H) {<br>
> + (*H)-><wbr>removeModuleFromBaseLayer(<wbr>BaseLayer);<br>
> + ModuleList.erase(H);<br>
> }<br>
><br>
> /// @brief Search for the given named symbol.<br>
> @@ -258,42 +255,40 @@ public:<br>
> if (auto Symbol = BaseLayer.findSymbol(Name, ExportedSymbolsOnly))<br>
> return Symbol;<br>
><br>
> - // If not found then search the deferred sets. If any of these contain a<br>
> + // If not found then search the deferred modules. If any of these contain a<br>
> // definition of 'Name' then they will return a JITSymbol that will emit<br>
> // the corresponding module when the symbol address is requested.<br>
> - for (auto &DeferredSet : ModuleSetList)<br>
> - if (auto Symbol = DeferredSet->find(Name, ExportedSymbolsOnly, BaseLayer))<br>
> + for (auto &DeferredMod : ModuleList)<br>
> + if (auto Symbol = DeferredMod->find(Name, ExportedSymbolsOnly, BaseLayer))<br>
> return Symbol;<br>
><br>
> // If no definition found anywhere return a null symbol.<br>
> return nullptr;<br>
> }<br>
><br>
> - /// @brief Get the address of the given symbol in the context of the set of<br>
> + /// @brief Get the address of the given symbol in the context of the of<br>
> /// compiled modules represented by the handle H.<br>
> - JITSymbol findSymbolIn(ModuleSetHandleT H, const std::string &Name,<br>
> + JITSymbol findSymbolIn(ModuleHandleT H, const std::string &Name,<br>
> bool ExportedSymbolsOnly) {<br>
> return (*H)->find(Name, ExportedSymbolsOnly, BaseLayer);<br>
> }<br>
><br>
> - /// @brief Immediately emit and finalize the moduleOB set represented by the<br>
> - /// given handle.<br>
> - /// @param H Handle for module set to emit/finalize.<br>
> - void emitAndFinalize(<wbr>ModuleSetHandleT H) {<br>
> + /// @brief Immediately emit and finalize the module represented by the given<br>
> + /// handle.<br>
> + /// @param H Handle for module to emit/finalize.<br>
> + void emitAndFinalize(ModuleHandleT H) {<br>
> (*H)->emitAndFinalize(<wbr>BaseLayer);<br>
> }<br>
> };<br>
><br>
> template <typename BaseLayerT><br>
> -template <typename ModuleSetT, typename MemoryManagerPtrT,<br>
> - typename SymbolResolverPtrT><br>
> -std::unique_ptr<typename LazyEmittingLayer<BaseLayerT>:<wbr>:EmissionDeferredSet><br>
> -LazyEmittingLayer<BaseLayerT><wbr>::EmissionDeferredSet::create(<br>
> - BaseLayerT &B, ModuleSetT Ms, MemoryManagerPtrT MemMgr,<br>
> +template <typename MemoryManagerPtrT, typename SymbolResolverPtrT><br>
> +std::unique_ptr<typename LazyEmittingLayer<BaseLayerT>:<wbr>:EmissionDeferredModule><br>
> +LazyEmittingLayer<BaseLayerT><wbr>::EmissionDeferredModule::<wbr>create(<br>
> + BaseLayerT &B, std::shared_ptr<Module> M, MemoryManagerPtrT MemMgr,<br>
> SymbolResolverPtrT Resolver) {<br>
> - using EDS = EmissionDeferredSetImpl<<wbr>ModuleSetT, MemoryManagerPtrT,<br>
> - SymbolResolverPtrT>;<br>
> - return llvm::make_unique<EDS>(std::<wbr>move(Ms), std::move(MemMgr),<br>
> + using EDS = EmissionDeferredModuleImpl<<wbr>MemoryManagerPtrT, SymbolResolverPtrT>;<br>
> + return llvm::make_unique<EDS>(std::<wbr>move(M), std::move(MemMgr),<br>
> std::move(Resolver));<br>
> }<br>
><br>
><br>
> Modified: llvm/trunk/lib/<wbr>ExecutionEngine/Orc/<wbr>OrcCBindings.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindings.cpp?rev=306166&r1=306165&r2=306166&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>ExecutionEngine/Orc/<wbr>OrcCBindings.cpp?rev=306166&<wbr>r1=306165&r2=306166&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/lib/<wbr>ExecutionEngine/Orc/<wbr>OrcCBindings.cpp (original)<br>
> +++ llvm/trunk/lib/<wbr>ExecutionEngine/Orc/<wbr>OrcCBindings.cpp Fri Jun 23 16:45:29 2017<br>
> @@ -12,6 +12,24 @@<br>
><br>
> using namespace llvm;<br>
><br>
> +LLVMSharedModuleRef LLVMOrcMakeSharedModule(<wbr>LLVMModuleRef Mod) {<br>
> + return wrap(new std::shared_ptr<Module>(<wbr>unwrap(Mod)));<br>
> +}<br>
> +<br>
> +void LLVMOrcDisposeSharedModuleRef(<wbr>LLVMSharedModuleRef SharedMod) {<br>
> + delete unwrap(SharedMod);<br>
> +}<br>
> +<br>
> +LLVMSharedObjectBufferRef<br>
> +<wbr>LLVMOrcMakeSharedObjectBuffer(<wbr>LLVMMemoryBufferRef ObjBuffer) {<br>
> + return wrap(new std::shared_ptr<MemoryBuffer>(<wbr>unwrap(ObjBuffer)));<br>
> +}<br>
> +<br>
> +void<br>
> +<wbr>LLVMOrcDisposeSharedObjectBuff<wbr>erRef(<wbr>LLVMSharedObjectBufferRef SharedObjBuffer) {<br>
> + delete unwrap(SharedObjBuffer);<br>
> +}<br>
> +<br>
> LLVMOrcJITStackRef LLVMOrcCreateInstance(<wbr>LLVMTargetMachineRef TM) {<br>
> TargetMachine *TM2(unwrap(TM));<br>
><br>
> @@ -65,21 +83,23 @@ LLVMOrcErrorCode LLVMOrcSetIndirectStubP<br>
> }<br>
><br>
> LLVMOrcModuleHandle<br>
> -LLVMOrcAddEagerlyCompiledIR(<wbr>LLVMOrcJITStackRef JITStack, LLVMModuleRef Mod,<br>
> +LLVMOrcAddEagerlyCompiledIR(<wbr>LLVMOrcJITStackRef JITStack,<br>
> + LLVMSharedModuleRef Mod,<br>
> LLVMOrcSymbolResolverFn SymbolResolver,<br>
> void *SymbolResolverCtx) {<br>
> OrcCBindingsStack &J = *unwrap(JITStack);<br>
> - Module *M(unwrap(Mod));<br>
> - return J.addIRModuleEager(M, SymbolResolver, SymbolResolverCtx);<br>
> + std::shared_ptr<Module> *M(unwrap(Mod));<br>
> + return J.addIRModuleEager(*M, SymbolResolver, SymbolResolverCtx);<br>
> }<br>
><br>
> LLVMOrcModuleHandle<br>
> -LLVMOrcAddLazilyCompiledIR(<wbr>LLVMOrcJITStackRef JITStack, LLVMModuleRef Mod,<br>
> +LLVMOrcAddLazilyCompiledIR(<wbr>LLVMOrcJITStackRef JITStack,<br>
> + LLVMSharedModuleRef Mod,<br>
> LLVMOrcSymbolResolverFn SymbolResolver,<br>
> void *SymbolResolverCtx) {<br>
> OrcCBindingsStack &J = *unwrap(JITStack);<br>
> - Module *M(unwrap(Mod));<br>
> - return J.addIRModuleLazy(M, SymbolResolver, SymbolResolverCtx);<br>
> + std::shared_ptr<Module> *M(unwrap(Mod));<br>
> + return J.addIRModuleLazy(*M, SymbolResolver, SymbolResolverCtx);<br>
> }<br>
><br>
> void LLVMOrcRemoveModule(<wbr>LLVMOrcJITStackRef JITStack, LLVMOrcModuleHandle H) {<br>
><br>
> Modified: llvm/trunk/lib/<wbr>ExecutionEngine/Orc/<wbr>OrcCBindingsStack.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindingsStack.h?rev=306166&r1=306165&r2=306166&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>ExecutionEngine/Orc/<wbr>OrcCBindingsStack.h?rev=<wbr>306166&r1=306165&r2=306166&<wbr>view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/lib/<wbr>ExecutionEngine/Orc/<wbr>OrcCBindingsStack.h (original)<br>
> +++ llvm/trunk/lib/<wbr>ExecutionEngine/Orc/<wbr>OrcCBindingsStack.h Fri Jun 23 16:45:29 2017<br>
> @@ -42,6 +42,10 @@ namespace llvm {<br>
><br>
> class OrcCBindingsStack;<br>
><br>
> +DEFINE_SIMPLE_CONVERSION_<wbr>FUNCTIONS(std::shared_ptr<<wbr>Module>,<br>
> + LLVMSharedModuleRef);<br>
> +DEFINE_SIMPLE_CONVERSION_<wbr>FUNCTIONS(std::shared_ptr<<wbr>MemoryBuffer>,<br>
> + LLVMSharedObjectBufferRef);<br>
> DEFINE_SIMPLE_CONVERSION_<wbr>FUNCTIONS(OrcCBindingsStack, LLVMOrcJITStackRef)<br>
> DEFINE_SIMPLE_CONVERSION_<wbr>FUNCTIONS(TargetMachine, LLVMTargetMachineRef)<br>
><br>
> @@ -71,7 +75,7 @@ private:<br>
><br>
> template <typename LayerT> class GenericHandleImpl : public GenericHandle {<br>
> public:<br>
> - GenericHandleImpl(LayerT &Layer, typename LayerT::ModuleSetHandleT Handle)<br>
> + GenericHandleImpl(LayerT &Layer, typename LayerT::ModuleHandleT Handle)<br>
> : Layer(Layer), Handle(std::move(Handle)) {}<br>
><br>
> JITSymbol findSymbolIn(const std::string &Name,<br>
> @@ -79,24 +83,21 @@ private:<br>
> return Layer.findSymbolIn(Handle, Name, ExportedSymbolsOnly);<br>
> }<br>
><br>
> - void removeModule() override { return Layer.removeModuleSet(Handle); }<br>
> + void removeModule() override { return Layer.removeModule(Handle); }<br>
><br>
> private:<br>
> LayerT &Layer;<br>
> - typename LayerT::ModuleSetHandleT Handle;<br>
> + typename LayerT::ModuleHandleT Handle;<br>
> };<br>
><br>
> template <typename LayerT><br>
> std::unique_ptr<<wbr>GenericHandleImpl<LayerT>><br>
> - createGenericHandle(LayerT &Layer, typename LayerT::ModuleSetHandleT Handle) {<br>
> + createGenericHandle(LayerT &Layer, typename LayerT::ModuleHandleT Handle) {<br>
> return llvm::make_unique<<wbr>GenericHandleImpl<LayerT>>(<wbr>Layer,<br>
> std::move(Handle));<br>
> }<br>
><br>
> public:<br>
> - // We need a 'ModuleSetHandleT' to conform to the layer concept.<br>
> - using ModuleSetHandleT = unsigned;<br>
> -<br>
> using ModuleHandleT = unsigned;<br>
><br>
> OrcCBindingsStack(<wbr>TargetMachine &TM,<br>
> @@ -183,7 +184,7 @@ public:<br>
> }<br>
><br>
> template <typename LayerT><br>
> - ModuleHandleT addIRModule(LayerT &Layer, Module *M,<br>
> + ModuleHandleT addIRModule(LayerT &Layer, std::shared_ptr<Module> M,<br>
> std::unique_ptr<RuntimeDyld::<wbr>MemoryManager> MemMgr,<br>
> LLVMOrcSymbolResolverFn ExternalResolver,<br>
> void *ExternalResolverCtx) {<br>
> @@ -203,11 +204,8 @@ public:<br>
> auto Resolver = createResolver(<wbr>ExternalResolver, ExternalResolverCtx);<br>
><br>
> // Add the module to the JIT.<br>
> - std::vector<Module *> S;<br>
> - S.push_back(std::move(M));<br>
> -<br>
> - auto LH = Layer.addModuleSet(std::move(<wbr>S), std::move(MemMgr),<br>
> - std::move(Resolver));<br>
> + auto LH = Layer.addModule(std::move(M), std::move(MemMgr),<br>
> + std::move(Resolver));<br>
> ModuleHandleT H = createHandle(Layer, LH);<br>
><br>
> // Run the static constructors, and save the static destructor runner for<br>
> @@ -220,7 +218,7 @@ public:<br>
> return H;<br>
> }<br>
><br>
> - ModuleHandleT addIRModuleEager(Module *M,<br>
> + ModuleHandleT addIRModuleEager(std::shared_<wbr>ptr<Module> M,<br>
> LLVMOrcSymbolResolverFn ExternalResolver,<br>
> void *ExternalResolverCtx) {<br>
> return addIRModule(CompileLayer, std::move(M),<br>
> @@ -228,7 +226,7 @@ public:<br>
> std::move(ExternalResolver), ExternalResolverCtx);<br>
> }<br>
><br>
> - ModuleHandleT addIRModuleLazy(Module *M,<br>
> + ModuleHandleT addIRModuleLazy(std::shared_<wbr>ptr<Module> M,<br>
> LLVMOrcSymbolResolverFn ExternalResolver,<br>
> void *ExternalResolverCtx) {<br>
> return addIRModule(CODLayer, std::move(M),<br>
> @@ -257,8 +255,7 @@ public:<br>
><br>
> private:<br>
> template <typename LayerT><br>
> - unsigned createHandle(LayerT &Layer,<br>
> - typename LayerT::ModuleSetHandleT Handle) {<br>
> + unsigned createHandle(LayerT &Layer, typename LayerT::ModuleHandleT Handle) {<br>
> unsigned NewHandle;<br>
> if (!FreeHandleIndexes.empty()) {<br>
> NewHandle = FreeHandleIndexes.back();<br>
><br>
> Modified: llvm/trunk/lib/<wbr>ExecutionEngine/Orc/<wbr>OrcMCJITReplacement.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h?rev=306166&r1=306165&r2=306166&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>ExecutionEngine/Orc/<wbr>OrcMCJITReplacement.h?rev=<wbr>306166&r1=306165&r2=306166&<wbr>view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/lib/<wbr>ExecutionEngine/Orc/<wbr>OrcMCJITReplacement.h (original)<br>
> +++ llvm/trunk/lib/<wbr>ExecutionEngine/Orc/<wbr>OrcMCJITReplacement.h Fri Jun 23 16:45:29 2017<br>
> @@ -191,10 +191,15 @@ public:<br>
> } else {<br>
> assert(M->getDataLayout() == getDataLayout() && "DataLayout Mismatch");<br>
> }<br>
> - Modules.push_back(std::move(M)<wbr>);<br>
> - std::vector<Module *> Ms;<br>
> - Ms.push_back(&*Modules.back())<wbr>;<br>
> - LazyEmitLayer.addModuleSet(<wbr>std::move(Ms), &MemMgr, &Resolver);<br>
> + auto *MPtr = M.release();<br>
> + Retain[MPtr] = false;<br>
> + auto Deleter =<br>
> + [this](Module *Mod) {<br>
> + if (!Retain[Mod])<br>
> + delete Mod;<br>
> + };<br>
> + LocalModules.push_back(std::<wbr>shared_ptr<Module>(MPtr, std::move(Deleter)));<br>
> + LazyEmitLayer.addModule(<wbr>LocalModules.back(), &MemMgr, &Resolver);<br>
> }<br>
><br>
> void addObjectFile(std::unique_ptr<<wbr>object::ObjectFile> O) override {<br>
> @@ -381,6 +386,8 @@ private:<br>
> std::map<ObjectLayerT::<wbr>ObjHandleT, SectionAddrSet, ObjHandleCompare><br>
> UnfinalizedSections;<br>
><br>
> + std::map<Module*, bool> Retain;<br>
> + std::vector<std::shared_ptr<<wbr>Module>> LocalModules;<br>
> std::vector<object::<wbr>OwningBinary<object::Archive>> Archives;<br>
> };<br>
><br>
><br>
> Modified: llvm/trunk/tools/lli/<wbr>OrcLazyJIT.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/OrcLazyJIT.cpp?rev=306166&r1=306165&r2=306166&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/tools/lli/<wbr>OrcLazyJIT.cpp?rev=306166&r1=<wbr>306165&r2=306166&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/tools/lli/<wbr>OrcLazyJIT.cpp (original)<br>
> +++ llvm/trunk/tools/lli/<wbr>OrcLazyJIT.cpp Fri Jun 23 16:45:29 2017<br>
> @@ -54,10 +54,10 @@ static cl::opt<bool> OrcInlineStubs("orc<br>
> OrcLazyJIT::TransformFtor OrcLazyJIT::createDebugDumper(<wbr>) {<br>
> switch (OrcDumpKind) {<br>
> case DumpKind::NoDump:<br>
> - return [](std::unique_ptr<Module> M) { return M; };<br>
> + return [](std::shared_ptr<Module> M) { return M; };<br>
><br>
> case DumpKind::DumpFuncsToStdOut:<br>
> - return [](std::unique_ptr<Module> M) {<br>
> + return [](std::shared_ptr<Module> M) {<br>
> printf("[ ");<br>
><br>
> for (const auto &F : *M) {<br>
> @@ -76,7 +76,7 @@ OrcLazyJIT::TransformFtor OrcLazyJIT::cr<br>
> };<br>
><br>
> case DumpKind::DumpModsToStdOut:<br>
> - return [](std::unique_ptr<Module> M) {<br>
> + return [](std::shared_ptr<Module> M) {<br>
> outs() << "----- Module Start -----\n" << *M<br>
> << "----- Module End -----\n";<br>
><br>
> @@ -84,7 +84,7 @@ OrcLazyJIT::TransformFtor OrcLazyJIT::cr<br>
> };<br>
><br>
> case DumpKind::DumpModsToDisk:<br>
> - return [](std::unique_ptr<Module> M) {<br>
> + return [](std::shared_ptr<Module> M) {<br>
> std::error_code EC;<br>
> raw_fd_ostream Out(M->getModuleIdentifier() + ".ll", EC,<br>
> sys::fs::F_Text);<br>
> @@ -147,7 +147,8 @@ int llvm::runOrcLazyJIT(std::<wbr>vector<std:<br>
> OrcInlineStubs);<br>
><br>
> // Add the module, look up main and run it.<br>
> - J.addModuleSet(std::move(Ms));<br>
> + for (auto &M : Ms)<br>
> + J.addModule(std::shared_ptr<<wbr>Module>(std::move(M)));<br>
> auto MainSym = J.findSymbol("main");<br>
><br>
> if (!MainSym) {<br>
><br>
> Modified: llvm/trunk/tools/lli/<wbr>OrcLazyJIT.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/OrcLazyJIT.h?rev=306166&r1=306165&r2=306166&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/tools/lli/<wbr>OrcLazyJIT.h?rev=306166&r1=<wbr>306165&r2=306166&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/tools/lli/<wbr>OrcLazyJIT.h (original)<br>
> +++ llvm/trunk/tools/lli/<wbr>OrcLazyJIT.h Fri Jun 23 16:45:29 2017<br>
> @@ -50,11 +50,11 @@ public:<br>
> using ObjLayerT = orc::RTDyldObjectLinkingLayer;<br>
> using CompileLayerT = orc::IRCompileLayer<ObjLayerT, orc::SimpleCompiler>;<br>
> using TransformFtor =<br>
> - std::function<std::unique_ptr<<wbr>Module>(std::unique_ptr<<wbr>Module>)>;<br>
> + std::function<std::shared_ptr<<wbr>Module>(std::shared_ptr<<wbr>Module>)>;<br>
> using IRDumpLayerT = orc::IRTransformLayer<<wbr>CompileLayerT, TransformFtor>;<br>
> using CODLayerT = orc::CompileOnDemandLayer<<wbr>IRDumpLayerT, CompileCallbackMgr>;<br>
> using IndirectStubsManagerBuilder = CODLayerT::<wbr>IndirectStubsManagerBuilderT;<br>
> - using ModuleSetHandleT = CODLayerT::ModuleSetHandleT;<br>
> + using ModuleHandleT = CODLayerT::ModuleHandleT;<br>
><br>
> OrcLazyJIT(std::unique_ptr<<wbr>TargetMachine> TM,<br>
> std::unique_ptr<<wbr>CompileCallbackMgr> CCMgr,<br>
> @@ -77,11 +77,9 @@ public:<br>
> DtorRunner.runViaLayer(<wbr>CODLayer);<br>
> }<br>
><br>
> - ModuleSetHandleT addModuleSet(std::vector<std::<wbr>unique_ptr<Module>> Ms) {<br>
> - // Attach a data-layouts if they aren't already present.<br>
> - for (auto &M : Ms)<br>
> - if (M->getDataLayout().isDefault(<wbr>))<br>
> - M->setDataLayout(DL);<br>
> + void addModule(std::shared_ptr<<wbr>Module> M) {<br>
> + if (M->getDataLayout().isDefault(<wbr>))<br>
> + M->setDataLayout(DL);<br>
><br>
> // Rename, bump linkage and record static constructors and destructors.<br>
> // We have to do this before we hand over ownership of the module to the<br>
> @@ -89,21 +87,19 @@ public:<br>
> std::vector<std::string> CtorNames, DtorNames;<br>
> {<br>
> unsigned CtorId = 0, DtorId = 0;<br>
> - for (auto &M : Ms) {<br>
> - for (auto Ctor : orc::getConstructors(*M)) {<br>
> - std::string NewCtorName = ("$static_ctor." + Twine(CtorId++)).str();<br>
> - Ctor.Func->setName(<wbr>NewCtorName);<br>
> - Ctor.Func->setLinkage(<wbr>GlobalValue::ExternalLinkage);<br>
> - Ctor.Func->setVisibility(<wbr>GlobalValue::HiddenVisibility)<wbr>;<br>
> - CtorNames.push_back(mangle(<wbr>NewCtorName));<br>
> - }<br>
> - for (auto Dtor : orc::getDestructors(*M)) {<br>
> - std::string NewDtorName = ("$static_dtor." + Twine(DtorId++)).str();<br>
> - Dtor.Func->setLinkage(<wbr>GlobalValue::ExternalLinkage);<br>
> - Dtor.Func->setVisibility(<wbr>GlobalValue::HiddenVisibility)<wbr>;<br>
> - DtorNames.push_back(mangle(<wbr>Dtor.Func->getName()));<br>
> - Dtor.Func->setName(<wbr>NewDtorName);<br>
> - }<br>
> + for (auto Ctor : orc::getConstructors(*M)) {<br>
> + std::string NewCtorName = ("$static_ctor." + Twine(CtorId++)).str();<br>
> + Ctor.Func->setName(<wbr>NewCtorName);<br>
> + Ctor.Func->setLinkage(<wbr>GlobalValue::ExternalLinkage);<br>
> + Ctor.Func->setVisibility(<wbr>GlobalValue::HiddenVisibility)<wbr>;<br>
> + CtorNames.push_back(mangle(<wbr>NewCtorName));<br>
> + }<br>
> + for (auto Dtor : orc::getDestructors(*M)) {<br>
> + std::string NewDtorName = ("$static_dtor." + Twine(DtorId++)).str();<br>
> + Dtor.Func->setLinkage(<wbr>GlobalValue::ExternalLinkage);<br>
> + Dtor.Func->setVisibility(<wbr>GlobalValue::HiddenVisibility)<wbr>;<br>
> + DtorNames.push_back(mangle(<wbr>Dtor.Func->getName()));<br>
> + Dtor.Func->setName(<wbr>NewDtorName);<br>
> }<br>
> }<br>
><br>
> @@ -111,41 +107,45 @@ public:<br>
> // 1) Search the JIT symbols.<br>
> // 2) Check for C++ runtime overrides.<br>
> // 3) Search the host process (LLI)'s symbol table.<br>
> - auto Resolver =<br>
> - orc::createLambdaResolver(<br>
> - [this](const std::string &Name) -> JITSymbol {<br>
> - if (auto Sym = CODLayer.findSymbol(Name, true))<br>
> - return Sym;<br>
> - return CXXRuntimeOverrides.<wbr>searchOverrides(Name);<br>
> - },<br>
> - [](const std::string &Name) {<br>
> - if (auto Addr =<br>
> - RTDyldMemoryManager::<wbr>getSymbolAddressInProcess(<wbr>Name))<br>
> - return JITSymbol(Addr, JITSymbolFlags::Exported);<br>
> - return JITSymbol(nullptr);<br>
> - }<br>
> - );<br>
> -<br>
> - // Add the module to the JIT.<br>
> - auto H = CODLayer.addModuleSet(std::<wbr>move(Ms),<br>
> - llvm::make_unique<<wbr>SectionMemoryManager>(),<br>
> - std::move(Resolver));<br>
> + if (ModulesHandle == CODLayerT::ModuleHandleT()) {<br>
> + auto Resolver =<br>
> + orc::createLambdaResolver(<br>
> + [this](const std::string &Name) -> JITSymbol {<br>
> + if (auto Sym = CODLayer.findSymbol(Name, true))<br>
> + return Sym;<br>
> + return CXXRuntimeOverrides.<wbr>searchOverrides(Name);<br>
> + },<br>
> + [](const std::string &Name) {<br>
> + if (auto Addr =<br>
> + RTDyldMemoryManager::<wbr>getSymbolAddressInProcess(<wbr>Name))<br>
> + return JITSymbol(Addr, JITSymbolFlags::Exported);<br>
> + return JITSymbol(nullptr);<br>
> + }<br>
> + );<br>
> +<br>
> + // Add the module to the JIT.<br>
> + ModulesHandle =<br>
> + CODLayer.addModule(std::move(<wbr>M),<br>
> + llvm::make_unique<<wbr>SectionMemoryManager>(),<br>
> + std::move(Resolver));<br>
> + } else<br>
> + CODLayer.addExtraModule(<wbr>ModulesHandle, std::move(M));<br>
><br>
> // Run the static constructors, and save the static destructor runner for<br>
> // execution when the JIT is torn down.<br>
> - orc::CtorDtorRunner<CODLayerT> CtorRunner(std::move(<wbr>CtorNames), H);<br>
> + orc::CtorDtorRunner<CODLayerT> CtorRunner(std::move(<wbr>CtorNames),<br>
> + ModulesHandle);<br>
> CtorRunner.runViaLayer(<wbr>CODLayer);<br>
><br>
> - IRStaticDestructorRunners.<wbr>emplace_back(std::move(<wbr>DtorNames), H);<br>
> -<br>
> - return H;<br>
> + IRStaticDestructorRunners.<wbr>emplace_back(std::move(<wbr>DtorNames),<br>
> + ModulesHandle);<br>
> }<br>
><br>
> JITSymbol findSymbol(const std::string &Name) {<br>
> return CODLayer.findSymbol(mangle(<wbr>Name), true);<br>
> }<br>
><br>
> - JITSymbol findSymbolIn(ModuleSetHandleT H, const std::string &Name) {<br>
> + JITSymbol findSymbolIn(ModuleHandleT H, const std::string &Name) {<br>
> return CODLayer.findSymbolIn(H, mangle(Name), true);<br>
> }<br>
><br>
> @@ -179,6 +179,7 @@ private:<br>
><br>
> orc::LocalCXXRuntimeOverrides CXXRuntimeOverrides;<br>
> std::vector<orc::<wbr>CtorDtorRunner<CODLayerT>> IRStaticDestructorRunners;<br>
> + CODLayerT::ModuleHandleT ModulesHandle;<br>
> };<br>
><br>
> int runOrcLazyJIT(std::vector<std:<wbr>:unique_ptr<Module>> Ms,<br>
><br>
> Modified: llvm/trunk/unittests/<wbr>ExecutionEngine/Orc/<wbr>LazyEmittingLayerTest.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/Orc/LazyEmittingLayerTest.cpp?rev=306166&r1=306165&r2=306166&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/unittests/<wbr>ExecutionEngine/Orc/<wbr>LazyEmittingLayerTest.cpp?rev=<wbr>306166&r1=306165&r2=306166&<wbr>view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/unittests/<wbr>ExecutionEngine/Orc/<wbr>LazyEmittingLayerTest.cpp (original)<br>
> +++ llvm/trunk/unittests/<wbr>ExecutionEngine/Orc/<wbr>LazyEmittingLayerTest.cpp Fri Jun 23 16:45:29 2017<br>
> @@ -14,9 +14,9 @@<br>
> namespace {<br>
><br>
> struct MockBaseLayer {<br>
> - typedef int ModuleSetHandleT;<br>
> - ModuleSetHandleT addModuleSet(<br>
> - std::list<std::unique_ptr<<wbr>llvm::Module>>,<br>
> + typedef int ModuleHandleT;<br>
> + ModuleHandleT addModule(<br>
> + std::shared_ptr<llvm::Module>,<br>
> std::unique_ptr<llvm::<wbr>RuntimeDyld::MemoryManager> MemMgr,<br>
> std::unique_ptr<llvm::<wbr>JITSymbolResolver> Resolver) {<br>
> EXPECT_FALSE(MemMgr);<br>
> @@ -27,7 +27,7 @@ struct MockBaseLayer {<br>
> TEST(LazyEmittingLayerTest, Empty) {<br>
> MockBaseLayer M;<br>
> llvm::orc::LazyEmittingLayer<<wbr>MockBaseLayer> L(M);<br>
> - L.addModuleSet(std::list<std::<wbr>unique_ptr<llvm::Module>>(), nullptr, nullptr);<br>
> + L.addModule(std::unique_ptr<<wbr>llvm::Module>(), nullptr, nullptr);<br>
> }<br>
><br>
> }<br>
><br>
> Modified: llvm/trunk/unittests/<wbr>ExecutionEngine/Orc/<wbr>ObjectTransformLayerTest.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/Orc/ObjectTransformLayerTest.cpp?rev=306166&r1=306165&r2=306166&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/unittests/<wbr>ExecutionEngine/Orc/<wbr>ObjectTransformLayerTest.cpp?<wbr>rev=306166&r1=306165&r2=<wbr>306166&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/unittests/<wbr>ExecutionEngine/Orc/<wbr>ObjectTransformLayerTest.cpp (original)<br>
> +++ llvm/trunk/unittests/<wbr>ExecutionEngine/Orc/<wbr>ObjectTransformLayerTest.cpp Fri Jun 23 16:45:29 2017<br>
> @@ -314,7 +314,7 @@ TEST(ObjectTransformLayerTest, Main) {<br>
> // compile.<br>
> NullResolver Resolver;<br>
> NullManager Manager;<br>
> - CompileLayer.addModuleSet(std:<wbr>:vector<llvm::Module *>(), &Manager, &Resolver);<br>
> + CompileLayer.addModule(std::<wbr>shared_ptr<llvm::Module>(), &Manager, &Resolver);<br>
><br>
> // Make sure that the calls from ObjectTransformLayer to ObjectLinkingLayer<br>
> // compile.<br>
><br>
> Modified: llvm/trunk/unittests/<wbr>ExecutionEngine/Orc/<wbr>OrcCAPITest.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp?rev=306166&r1=306165&r2=306166&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/unittests/<wbr>ExecutionEngine/Orc/<wbr>OrcCAPITest.cpp?rev=306166&r1=<wbr>306165&r2=306166&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/unittests/<wbr>ExecutionEngine/Orc/<wbr>OrcCAPITest.cpp (original)<br>
> +++ llvm/trunk/unittests/<wbr>ExecutionEngine/Orc/<wbr>OrcCAPITest.cpp Fri Jun 23 16:45:29 2017<br>
> @@ -65,8 +65,9 @@ protected:<br>
> CompileContext *CCtx = static_cast<CompileContext*>(<wbr>Ctx);<br>
> auto *ET = CCtx->APIExecTest;<br>
> CCtx->M = ET->createTestModule(ET->TM-><wbr>getTargetTriple());<br>
> - CCtx->H = LLVMOrcAddEagerlyCompiledIR(<wbr>JITStack, wrap(CCtx->M.get()),<br>
> - myResolver, nullptr);<br>
> + LLVMSharedModuleRef SM = LLVMOrcMakeSharedModule(wrap(<wbr>CCtx->M.release()));<br>
> + CCtx->H = LLVMOrcAddEagerlyCompiledIR(<wbr>JITStack, SM, myResolver, nullptr);<br>
> + LLVMOrcDisposeSharedModuleRef(<wbr>SM);<br>
> CCtx->Compiled = true;<br>
> LLVMOrcTargetAddress MainAddr = LLVMOrcGetSymbolAddress(<wbr>JITStack, "main");<br>
> LLVMOrcSetIndirectStubPointer(<wbr>JITStack, "foo", MainAddr);<br>
> @@ -87,8 +88,10 @@ TEST_F(OrcCAPIExecutionTest, TestEagerIR<br>
><br>
> LLVMOrcGetMangledSymbol(JIT, &testFuncName, "testFunc");<br>
><br>
> + LLVMSharedModuleRef SM = LLVMOrcMakeSharedModule(wrap(<wbr>M.release()));<br>
> LLVMOrcModuleHandle H =<br>
> - LLVMOrcAddEagerlyCompiledIR(<wbr>JIT, wrap(M.get()), myResolver, nullptr);<br>
> + LLVMOrcAddEagerlyCompiledIR(<wbr>JIT, SM, myResolver, nullptr);<br>
> + LLVMOrcDisposeSharedModuleRef(<wbr>SM);<br>
> MainFnTy MainFn = (MainFnTy)<wbr>LLVMOrcGetSymbolAddress(JIT, "main");<br>
> int Result = MainFn();<br>
> EXPECT_EQ(Result, 42)<br>
> @@ -111,8 +114,10 @@ TEST_F(OrcCAPIExecutionTest, TestLazyIRC<br>
><br>
> LLVMOrcGetMangledSymbol(JIT, &testFuncName, "testFunc");<br>
><br>
> + LLVMSharedModuleRef SM = LLVMOrcMakeSharedModule(wrap(<wbr>M.release()));<br>
> LLVMOrcModuleHandle H =<br>
> - LLVMOrcAddLazilyCompiledIR(<wbr>JIT, wrap(M.get()), myResolver, nullptr);<br>
> + LLVMOrcAddLazilyCompiledIR(<wbr>JIT, SM, myResolver, nullptr);<br>
> + LLVMOrcDisposeSharedModuleRef(<wbr>SM);<br>
> MainFnTy MainFn = (MainFnTy)<wbr>LLVMOrcGetSymbolAddress(JIT, "main");<br>
> int Result = MainFn();<br>
> EXPECT_EQ(Result, 42)<br>
><br>
> Modified: llvm/trunk/unittests/<wbr>ExecutionEngine/Orc/<wbr>OrcTestCommon.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/Orc/OrcTestCommon.h?rev=306166&r1=306165&r2=306166&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/unittests/<wbr>ExecutionEngine/Orc/<wbr>OrcTestCommon.h?rev=306166&r1=<wbr>306165&r2=306166&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/unittests/<wbr>ExecutionEngine/Orc/<wbr>OrcTestCommon.h (original)<br>
> +++ llvm/trunk/unittests/<wbr>ExecutionEngine/Orc/<wbr>OrcTestCommon.h Fri Jun 23 16:45:29 2017<br>
> @@ -106,65 +106,65 @@ public:<br>
> };<br>
><br>
> template <typename HandleT,<br>
> - typename AddModuleSetFtor,<br>
> - typename RemoveModuleSetFtor,<br>
> + typename AddModuleFtor,<br>
> + typename RemoveModuleFtor,<br>
> typename FindSymbolFtor,<br>
> typename FindSymbolInFtor><br>
> class MockBaseLayer {<br>
> public:<br>
><br>
> - typedef HandleT ModuleSetHandleT;<br>
> + typedef HandleT ModuleHandleT;<br>
><br>
> - MockBaseLayer(AddModuleSetFtor &&AddModuleSet,<br>
> - RemoveModuleSetFtor &&RemoveModuleSet,<br>
> + MockBaseLayer(AddModuleFtor &&AddModule,<br>
> + RemoveModuleFtor &&RemoveModule,<br>
> FindSymbolFtor &&FindSymbol,<br>
> FindSymbolInFtor &&FindSymbolIn)<br>
> - : AddModuleSet(AddModuleSet), RemoveModuleSet(<wbr>RemoveModuleSet),<br>
> + : AddModule(AddModule), RemoveModule(RemoveModule),<br>
> FindSymbol(FindSymbol), FindSymbolIn(FindSymbolIn)<br>
> {}<br>
><br>
> - template <typename ModuleSetT, typename MemoryManagerPtrT,<br>
> + template <typename ModuleT, typename MemoryManagerPtrT,<br>
> typename SymbolResolverPtrT><br>
> - ModuleSetHandleT addModuleSet(ModuleSetT Ms, MemoryManagerPtrT MemMgr,<br>
> - SymbolResolverPtrT Resolver) {<br>
> - return AddModuleSet(std::move(Ms), std::move(MemMgr), std::move(Resolver));<br>
> + ModuleHandleT addModule(ModuleT Ms, MemoryManagerPtrT MemMgr,<br>
> + SymbolResolverPtrT Resolver) {<br>
> + return AddModule(std::move(Ms), std::move(MemMgr), std::move(Resolver));<br>
> }<br>
><br>
> - void removeModuleSet(<wbr>ModuleSetHandleT H) {<br>
> - RemoveModuleSet(H);<br>
> + void removeModule(ModuleHandleT H) {<br>
> + RemoveModule(H);<br>
> }<br>
><br>
> JITSymbol findSymbol(const std::string &Name, bool ExportedSymbolsOnly) {<br>
> return FindSymbol(Name, ExportedSymbolsOnly);<br>
> }<br>
><br>
> - JITSymbol findSymbolIn(ModuleSetHandleT H, const std::string &Name,<br>
> + JITSymbol findSymbolIn(ModuleHandleT H, const std::string &Name,<br>
> bool ExportedSymbolsOnly) {<br>
> return FindSymbolIn(H, Name, ExportedSymbolsOnly);<br>
> }<br>
><br>
> private:<br>
> - AddModuleSetFtor AddModuleSet;<br>
> - RemoveModuleSetFtor RemoveModuleSet;<br>
> + AddModuleFtor AddModule;<br>
> + RemoveModuleFtor RemoveModule;<br>
> FindSymbolFtor FindSymbol;<br>
> FindSymbolInFtor FindSymbolIn;<br>
> };<br>
><br>
> -template <typename ModuleSetHandleT,<br>
> - typename AddModuleSetFtor,<br>
> - typename RemoveModuleSetFtor,<br>
> +template <typename ModuleHandleT,<br>
> + typename AddModuleFtor,<br>
> + typename RemoveModuleFtor,<br>
> typename FindSymbolFtor,<br>
> typename FindSymbolInFtor><br>
> -MockBaseLayer<<wbr>ModuleSetHandleT, AddModuleSetFtor, RemoveModuleSetFtor,<br>
> +MockBaseLayer<ModuleHandleT, AddModuleFtor, RemoveModuleFtor,<br>
> FindSymbolFtor, FindSymbolInFtor><br>
> -createMockBaseLayer(<wbr>AddModuleSetFtor &&AddModuleSet,<br>
> - RemoveModuleSetFtor &&RemoveModuleSet,<br>
> +createMockBaseLayer(<wbr>AddModuleFtor &&AddModule,<br>
> + RemoveModuleFtor &&RemoveModule,<br>
> FindSymbolFtor &&FindSymbol,<br>
> FindSymbolInFtor &&FindSymbolIn) {<br>
> - return MockBaseLayer<<wbr>ModuleSetHandleT, AddModuleSetFtor, RemoveModuleSetFtor,<br>
> + return MockBaseLayer<ModuleHandleT, AddModuleFtor, RemoveModuleFtor,<br>
> FindSymbolFtor, FindSymbolInFtor>(<br>
> - std::forward<AddModuleSetFtor><wbr>(AddModuleSet),<br>
> - std::forward<<wbr>RemoveModuleSetFtor>(<wbr>RemoveModuleSet),<br>
> + std::forward<AddModuleFtor>(<wbr>AddModule),<br>
> + std::forward<RemoveModuleFtor><wbr>(RemoveModule),<br>
> std::forward<FindSymbolFtor>(<wbr>FindSymbol),<br>
> std::forward<FindSymbolInFtor><wbr>(FindSymbolIn));<br>
> }<br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div>