Skip to content

Commit

Permalink
fix PR5649 by making fib use the JIT instead of the interpreter, patc…
Browse files Browse the repository at this point in the history
…h by Perry Lorier!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90186 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
lattner committed Dec 1, 2009
1 parent 0488ecd commit 18f0c67
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion examples/Fibonacci/fibonacci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "llvm/ExecutionEngine/Interpreter.h"
#include "llvm/ExecutionEngine/GenericValue.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetSelect.h"
using namespace llvm;

static Function *CreateFibFunction(Module *M, LLVMContext &Context) {
Expand Down Expand Up @@ -92,6 +93,7 @@ static Function *CreateFibFunction(Module *M, LLVMContext &Context) {
int main(int argc, char **argv) {
int n = argc > 1 ? atol(argv[1]) : 24;

InitializeNativeTarget();
LLVMContext Context;

// Create some module to put our function into it.
Expand All @@ -101,7 +103,13 @@ int main(int argc, char **argv) {
Function *FibF = CreateFibFunction(M, Context);

// Now we going to create JIT
ExecutionEngine *EE = EngineBuilder(M).create();
std::string errStr;
ExecutionEngine *EE = EngineBuilder(M).setErrorStr(&errStr).setEngineKind(EngineKind::JIT).create();

if (!EE) {
errs() << argv[0] << ": Failed to construct ExecutionEngine: " << errStr << "\n";
return 1;
}

errs() << "verifying... ";
if (verifyModule(*M)) {
Expand Down

0 comments on commit 18f0c67

Please sign in to comment.