summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Ulasevich <boris.ulasevich@gmail.com>2016-12-15 19:29:42 +0000
committerBoris Ulasevich <boris.ulasevich@gmail.com>2016-12-15 19:29:42 +0000
commit0eeb59d037f9d7a83aaab709969f8a499ebef9dc (patch)
tree66b8b4770179014f70d866b3d9207a513f6881ee
parent3ed425b164c21adef93626364fafe69980554f42 (diff)
downloadllvm-0eeb59d037f9d7a83aaab709969f8a499ebef9dc.tar.gz
BrainF example: fixing segfault caused by outdated code with missing MCJIT dependency
Differential Revision: https://reviews.llvm.org/D26280 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289857 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--examples/BrainF/BrainFDriver.cpp6
-rw-r--r--examples/BrainF/CMakeLists.txt1
2 files changed, 7 insertions, 0 deletions
diff --git a/examples/BrainF/BrainFDriver.cpp b/examples/BrainF/BrainFDriver.cpp
index 686f476cf463..57a86fbf5212 100644
--- a/examples/BrainF/BrainFDriver.cpp
+++ b/examples/BrainF/BrainFDriver.cpp
@@ -29,6 +29,7 @@
#include "llvm/Bitcode/BitcodeWriter.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/GenericValue.h"
+#include "llvm/ExecutionEngine/MCJIT.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
@@ -153,10 +154,15 @@ int main(int argc, char **argv) {
//Write it out
if (JIT) {
InitializeNativeTarget();
+ InitializeNativeTargetAsmPrinter();
outs() << "------- Running JIT -------\n";
Module &M = *Mod;
ExecutionEngine *ee = EngineBuilder(std::move(Mod)).create();
+ if (!ee) {
+ errs() << "Error: execution engine creation failed.\n";
+ abort();
+ }
std::vector<GenericValue> args;
Function *brainf_func = M.getFunction("brainf");
GenericValue gv = ee->runFunction(brainf_func, args);
diff --git a/examples/BrainF/CMakeLists.txt b/examples/BrainF/CMakeLists.txt
index cf1cf1b61596..7b44b3a62756 100644
--- a/examples/BrainF/CMakeLists.txt
+++ b/examples/BrainF/CMakeLists.txt
@@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS
Core
ExecutionEngine
MC
+ MCJIT
Support
nativecodegen
)