[llvm] r289857 - BrainF example: fixing segfault caused by outdated code with missing MCJIT dependency
Boris Ulasevich via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 15 11:29:42 PST 2016
Author: bulasevich
Date: Thu Dec 15 13:29:42 2016
New Revision: 289857
URL: http://llvm.org/viewvc/llvm-project?rev=289857&view=rev
Log:
BrainF example: fixing segfault caused by outdated code with missing MCJIT dependency
Differential Revision: https://reviews.llvm.org/D26280
Modified:
llvm/trunk/examples/BrainF/BrainFDriver.cpp
llvm/trunk/examples/BrainF/CMakeLists.txt
Modified: llvm/trunk/examples/BrainF/BrainFDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/BrainF/BrainFDriver.cpp?rev=289857&r1=289856&r2=289857&view=diff
==============================================================================
--- llvm/trunk/examples/BrainF/BrainFDriver.cpp (original)
+++ llvm/trunk/examples/BrainF/BrainFDriver.cpp Thu Dec 15 13:29:42 2016
@@ -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);
Modified: llvm/trunk/examples/BrainF/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/BrainF/CMakeLists.txt?rev=289857&r1=289856&r2=289857&view=diff
==============================================================================
--- llvm/trunk/examples/BrainF/CMakeLists.txt (original)
+++ llvm/trunk/examples/BrainF/CMakeLists.txt Thu Dec 15 13:29:42 2016
@@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS
Core
ExecutionEngine
MC
+ MCJIT
Support
nativecodegen
)
More information about the llvm-commits
mailing list