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
This commit is contained in:
Boris Ulasevich 2016-12-15 19:29:42 +00:00
parent 3ed425b164
commit 0eeb59d037
2 changed files with 7 additions and 0 deletions

View File

@ -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);

View File

@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS
Core
ExecutionEngine
MC
MCJIT
Support
nativecodegen
)