From 60c88cbf7fb90ed98caa2c920c01b38f31a3734e Mon Sep 17 00:00:00 2001 From: Alp Toker Date: Tue, 1 Jul 2014 03:19:50 +0000 Subject: clang-interpreter: use LLVM interpreter if JIT is unavailable Update the strategy in r212083 to try JIT first and otherwise fall back to the interpreter. This gives the best of both worlds and still builds fine with no targets enabled. Requires supporting changes from LLVM r212086. llvm-svn: 212087 --- clang/examples/clang-interpreter/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'clang/examples/clang-interpreter/main.cpp') diff --git a/clang/examples/clang-interpreter/main.cpp b/clang/examples/clang-interpreter/main.cpp index c255f51cee8..fb9d298f0ac 100644 --- a/clang/examples/clang-interpreter/main.cpp +++ b/clang/examples/clang-interpreter/main.cpp @@ -18,6 +18,7 @@ #include "clang/Frontend/TextDiagnosticPrinter.h" #include "llvm/ADT/SmallString.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" +#include "llvm/ExecutionEngine/JIT.h" #include "llvm/IR/Module.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Host.h" @@ -42,12 +43,11 @@ std::string GetExecutablePath(const char *Argv0) { } static int Execute(llvm::Module *Mod, char * const *envp) { - // To JIT instead of interpreting, call llvm::InitializeNativeTarget() here - // and pass ForceInterpreter=false to ExecutionEngine::create(). + llvm::InitializeNativeTarget(); std::string Error; std::unique_ptr EE( - llvm::ExecutionEngine::create(Mod, /*ForceInterpreter*/ true, &Error)); + llvm::ExecutionEngine::create(Mod, /*ForceInterpreter*/ false, &Error)); if (!EE) { llvm::errs() << "unable to make execution engine: " << Error << "\n"; return 255; -- cgit v1.2.3