summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2017-06-23 22:50:24 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2017-06-23 22:50:24 +0000
commit51e4b46c2c6a2046bd98312d8e6f9bd976fdc8dd (patch)
tree30db151395f9ca8a15340cf30c04884473869517 /examples
parentb1a9f25ebf0bf71548f35c4bb25c161a84d00ed1 (diff)
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<Module>." 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
Diffstat (limited to 'examples')
-rw-r--r--examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h14
-rw-r--r--examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h20
-rw-r--r--examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h20
-rw-r--r--examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h20
-rw-r--r--examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h20
-rw-r--r--examples/Kaleidoscope/include/KaleidoscopeJIT.h16
6 files changed, 68 insertions, 42 deletions
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<decltype(ObjectLayer), SimpleCompiler> 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<std::unique_ptr<Module>> 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<SectionMemoryManager>(),
- std::move(Resolver));
+ return CompileLayer.addModuleSet(std::move(Ms),
+ make_unique<SectionMemoryManager>(),
+ 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<decltype(ObjectLayer), SimpleCompiler> CompileLayer;
using OptimizeFunction =
- std::function<std::shared_ptr<Module>(std::shared_ptr<Module>)>;
+ std::function<std::unique_ptr<Module>(std::unique_ptr<Module>)>;
IRTransformLayer<decltype(CompileLayer), OptimizeFunction> 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<Module> M) {
+ [this](std::unique_ptr<Module> 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<std::unique_ptr<Module>> 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<SectionMemoryManager>(),
- std::move(Resolver));
+ return OptimizeLayer.addModuleSet(std::move(Ms),
+ make_unique<SectionMemoryManager>(),
+ 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<Module> optimizeModule(std::shared_ptr<Module> M) {
+ std::unique_ptr<Module> optimizeModule(std::unique_ptr<Module> M) {
// Create a function pass manager.
auto FPM = llvm::make_unique<legacy::FunctionPassManager>(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<decltype(ObjectLayer), SimpleCompiler> CompileLayer;
using OptimizeFunction =
- std::function<std::shared_ptr<Module>(std::shared_ptr<Module>)>;
+ std::function<std::unique_ptr<Module>(std::unique_ptr<Module>)>;
IRTransformLayer<decltype(CompileLayer), OptimizeFunction> OptimizeLayer;
@@ -59,13 +59,13 @@ private:
CompileOnDemandLayer<decltype(OptimizeLayer)> 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<Module> M) {
+ [this](std::unique_ptr<Module> 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<std::unique_ptr<Module>> 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<SectionMemoryManager>(),
- std::move(Resolver));
+ return CODLayer.addModuleSet(std::move(Ms),
+ make_unique<SectionMemoryManager>(),
+ 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<Module> optimizeModule(std::shared_ptr<Module> M) {
+ std::unique_ptr<Module> optimizeModule(std::unique_ptr<Module> M) {
// Create a function pass manager.
auto FPM = llvm::make_unique<legacy::FunctionPassManager>(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<decltype(ObjectLayer), SimpleCompiler> CompileLayer;
using OptimizeFunction =
- std::function<std::shared_ptr<Module>(std::shared_ptr<Module>)>;
+ std::function<std::unique_ptr<Module>(std::unique_ptr<Module>)>;
IRTransformLayer<decltype(CompileLayer), OptimizeFunction> OptimizeLayer;
@@ -85,14 +85,14 @@ private:
std::unique_ptr<IndirectStubsManager> 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<Module> M) {
+ [this](std::unique_ptr<Module> 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<std::unique_ptr<Module>> 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<SectionMemoryManager>(),
- std::move(Resolver));
+ return OptimizeLayer.addModuleSet(std::move(Ms),
+ make_unique<SectionMemoryManager>(),
+ std::move(Resolver));
}
Error addFunctionAST(std::unique_ptr<FunctionAST> 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<Module> optimizeModule(std::shared_ptr<Module> M) {
+ std::unique_ptr<Module> optimizeModule(std::unique_ptr<Module> M) {
// Create a function pass manager.
auto FPM = llvm::make_unique<legacy::FunctionPassManager>(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<decltype(ObjectLayer), SimpleCompiler> CompileLayer;
using OptimizeFunction =
- std::function<std::shared_ptr<Module>(std::shared_ptr<Module>)>;
+ std::function<std::unique_ptr<Module>(std::unique_ptr<Module>)>;
IRTransformLayer<decltype(CompileLayer), OptimizeFunction> 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<Module> M) {
+ [this](std::unique_ptr<Module> 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<std::unique_ptr<Module>> 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<FunctionAST> 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<Module> optimizeModule(std::shared_ptr<Module> M) {
+ std::unique_ptr<Module> optimizeModule(std::unique_ptr<Module> M) {
// Create a function pass manager.
auto FPM = llvm::make_unique<legacy::FunctionPassManager>(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<ObjLayerT, SimpleCompiler>;
- 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<SectionMemoryManager>(),
- std::move(Resolver));
+ auto H = CompileLayer.addModuleSet(singletonSet(std::move(M)),
+ make_unique<SectionMemoryManager>(),
+ 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 <typename T> static std::vector<T> singletonSet(T t) {
+ std::vector<T> 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