Skip to content

Commit 0eeb59d

Browse files
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
1 parent 3ed425b commit 0eeb59d

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

examples/BrainF/BrainFDriver.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "llvm/Bitcode/BitcodeWriter.h"
3030
#include "llvm/ExecutionEngine/ExecutionEngine.h"
3131
#include "llvm/ExecutionEngine/GenericValue.h"
32+
#include "llvm/ExecutionEngine/MCJIT.h"
3233
#include "llvm/IR/BasicBlock.h"
3334
#include "llvm/IR/Constants.h"
3435
#include "llvm/IR/DerivedTypes.h"
@@ -153,10 +154,15 @@ int main(int argc, char **argv) {
153154
//Write it out
154155
if (JIT) {
155156
InitializeNativeTarget();
157+
InitializeNativeTargetAsmPrinter();
156158

157159
outs() << "------- Running JIT -------\n";
158160
Module &M = *Mod;
159161
ExecutionEngine *ee = EngineBuilder(std::move(Mod)).create();
162+
if (!ee) {
163+
errs() << "Error: execution engine creation failed.\n";
164+
abort();
165+
}
160166
std::vector<GenericValue> args;
161167
Function *brainf_func = M.getFunction("brainf");
162168
GenericValue gv = ee->runFunction(brainf_func, args);

examples/BrainF/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS
33
Core
44
ExecutionEngine
55
MC
6+
MCJIT
67
Support
78
nativecodegen
89
)

0 commit comments

Comments
 (0)