summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2014-12-08 18:00:38 +0000
committerEric Christopher <echristo@gmail.com>2014-12-08 18:00:38 +0000
commit1b74b65e9b52ea039d35b58ea9d9955caf607e75 (patch)
tree792dde4df0d262c6e507f6fa9763156e915fcc9a
parent67be569a31a5808e898d2f8aaaaaa1b460b6efa4 (diff)
downloadbcm5719-llvm-1b74b65e9b52ea039d35b58ea9d9955caf607e75.tar.gz
bcm5719-llvm-1b74b65e9b52ea039d35b58ea9d9955caf607e75.zip
Fix the JIT code for the Kaleidoscope tutorial.
llvm-svn: 223670
-rw-r--r--llvm/examples/Kaleidoscope/Chapter4/toy.cpp11
-rw-r--r--llvm/examples/Kaleidoscope/Chapter5/toy.cpp11
-rw-r--r--llvm/examples/Kaleidoscope/Chapter6/toy.cpp11
-rw-r--r--llvm/examples/Kaleidoscope/Chapter7/toy.cpp11
4 files changed, 36 insertions, 8 deletions
diff --git a/llvm/examples/Kaleidoscope/Chapter4/toy.cpp b/llvm/examples/Kaleidoscope/Chapter4/toy.cpp
index 3564d751e65..a7585f5ff7d 100644
--- a/llvm/examples/Kaleidoscope/Chapter4/toy.cpp
+++ b/llvm/examples/Kaleidoscope/Chapter4/toy.cpp
@@ -1,5 +1,7 @@
#include "llvm/Analysis/Passes.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
+#include "llvm/ExecutionEngine/MCJIT.h"
+#include "llvm/ExecutionEngine/SectionMemoryManager.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/IRBuilder.h"
@@ -512,6 +514,7 @@ static void HandleTopLevelExpression() {
// Evaluate a top-level expression into an anonymous function.
if (FunctionAST *F = ParseTopLevelExpr()) {
if (Function *LF = F->Codegen()) {
+ TheExecutionEngine->finalizeObject();
// JIT the function, returning a function pointer.
void *FPtr = TheExecutionEngine->getPointerToFunction(LF);
@@ -557,6 +560,8 @@ double putchard(double X) {
int main() {
InitializeNativeTarget();
+ InitializeNativeTargetAsmPrinter();
+ InitializeNativeTargetAsmParser();
LLVMContext &Context = getGlobalContext();
// Install standard binary operators.
@@ -576,8 +581,10 @@ int main() {
// Create the JIT. This takes ownership of the module.
std::string ErrStr;
- TheExecutionEngine =
- EngineBuilder(std::move(Owner)).setErrorStr(&ErrStr).create();
+ TheExecutionEngine = EngineBuilder(std::move(Owner))
+ .setErrorStr(&ErrStr)
+ .setMCJITMemoryManager(new SectionMemoryManager())
+ .create();
if (!TheExecutionEngine) {
fprintf(stderr, "Could not create ExecutionEngine: %s\n", ErrStr.c_str());
exit(1);
diff --git a/llvm/examples/Kaleidoscope/Chapter5/toy.cpp b/llvm/examples/Kaleidoscope/Chapter5/toy.cpp
index 4929a20cd7e..8d84421fec0 100644
--- a/llvm/examples/Kaleidoscope/Chapter5/toy.cpp
+++ b/llvm/examples/Kaleidoscope/Chapter5/toy.cpp
@@ -1,5 +1,7 @@
#include "llvm/Analysis/Passes.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
+#include "llvm/ExecutionEngine/MCJIT.h"
+#include "llvm/ExecutionEngine/SectionMemoryManager.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/IRBuilder.h"
@@ -757,6 +759,7 @@ static void HandleTopLevelExpression() {
// Evaluate a top-level expression into an anonymous function.
if (FunctionAST *F = ParseTopLevelExpr()) {
if (Function *LF = F->Codegen()) {
+ TheExecutionEngine->finalizeObject();
// JIT the function, returning a function pointer.
void *FPtr = TheExecutionEngine->getPointerToFunction(LF);
@@ -802,6 +805,8 @@ double putchard(double X) {
int main() {
InitializeNativeTarget();
+ InitializeNativeTargetAsmPrinter();
+ InitializeNativeTargetAsmParser();
LLVMContext &Context = getGlobalContext();
// Install standard binary operators.
@@ -821,8 +826,10 @@ int main() {
// Create the JIT. This takes ownership of the module.
std::string ErrStr;
- TheExecutionEngine =
- EngineBuilder(std::move(Owner)).setErrorStr(&ErrStr).create();
+ TheExecutionEngine = EngineBuilder(std::move(Owner))
+ .setErrorStr(&ErrStr)
+ .setMCJITMemoryManager(new SectionMemoryManager())
+ .create();
if (!TheExecutionEngine) {
fprintf(stderr, "Could not create ExecutionEngine: %s\n", ErrStr.c_str());
exit(1);
diff --git a/llvm/examples/Kaleidoscope/Chapter6/toy.cpp b/llvm/examples/Kaleidoscope/Chapter6/toy.cpp
index 06da9ac682d..14b8e55348f 100644
--- a/llvm/examples/Kaleidoscope/Chapter6/toy.cpp
+++ b/llvm/examples/Kaleidoscope/Chapter6/toy.cpp
@@ -1,5 +1,7 @@
#include "llvm/Analysis/Passes.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
+#include "llvm/ExecutionEngine/MCJIT.h"
+#include "llvm/ExecutionEngine/SectionMemoryManager.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/IRBuilder.h"
@@ -868,6 +870,7 @@ static void HandleTopLevelExpression() {
// Evaluate a top-level expression into an anonymous function.
if (FunctionAST *F = ParseTopLevelExpr()) {
if (Function *LF = F->Codegen()) {
+ TheExecutionEngine->finalizeObject();
// JIT the function, returning a function pointer.
void *FPtr = TheExecutionEngine->getPointerToFunction(LF);
@@ -920,6 +923,8 @@ double printd(double X) {
int main() {
InitializeNativeTarget();
+ InitializeNativeTargetAsmPrinter();
+ InitializeNativeTargetAsmParser();
LLVMContext &Context = getGlobalContext();
// Install standard binary operators.
@@ -939,8 +944,10 @@ int main() {
// Create the JIT. This takes ownership of the module.
std::string ErrStr;
- TheExecutionEngine =
- EngineBuilder(std::move(Owner)).setErrorStr(&ErrStr).create();
+ TheExecutionEngine = EngineBuilder(std::move(Owner))
+ .setErrorStr(&ErrStr)
+ .setMCJITMemoryManager(new SectionMemoryManager())
+ .create();
if (!TheExecutionEngine) {
fprintf(stderr, "Could not create ExecutionEngine: %s\n", ErrStr.c_str());
exit(1);
diff --git a/llvm/examples/Kaleidoscope/Chapter7/toy.cpp b/llvm/examples/Kaleidoscope/Chapter7/toy.cpp
index 56a6fa96e25..12eaae1f067 100644
--- a/llvm/examples/Kaleidoscope/Chapter7/toy.cpp
+++ b/llvm/examples/Kaleidoscope/Chapter7/toy.cpp
@@ -1,5 +1,7 @@
#include "llvm/Analysis/Passes.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
+#include "llvm/ExecutionEngine/MCJIT.h"
+#include "llvm/ExecutionEngine/SectionMemoryManager.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/IRBuilder.h"
@@ -1031,6 +1033,7 @@ static void HandleTopLevelExpression() {
// Evaluate a top-level expression into an anonymous function.
if (FunctionAST *F = ParseTopLevelExpr()) {
if (Function *LF = F->Codegen()) {
+ TheExecutionEngine->finalizeObject();
// JIT the function, returning a function pointer.
void *FPtr = TheExecutionEngine->getPointerToFunction(LF);
@@ -1083,6 +1086,8 @@ double printd(double X) {
int main() {
InitializeNativeTarget();
+ InitializeNativeTargetAsmPrinter();
+ InitializeNativeTargetAsmParser();
LLVMContext &Context = getGlobalContext();
// Install standard binary operators.
@@ -1103,8 +1108,10 @@ int main() {
// Create the JIT. This takes ownership of the module.
std::string ErrStr;
- TheExecutionEngine =
- EngineBuilder(std::move(Owner)).setErrorStr(&ErrStr).create();
+ TheExecutionEngine = EngineBuilder(std::move(Owner))
+ .setErrorStr(&ErrStr)
+ .setMCJITMemoryManager(new SectionMemoryManager())
+ .create();
if (!TheExecutionEngine) {
fprintf(stderr, "Could not create ExecutionEngine: %s\n", ErrStr.c_str());
exit(1);
OpenPOWER on IntegriCloud