r212083 - clang-interpreter: interpret instead of JITing
Alp Toker
alp at nuanti.com
Mon Jun 30 19:41:55 PDT 2014
Author: alp
Date: Mon Jun 30 21:41:55 2014
New Revision: 212083
URL: http://llvm.org/viewvc/llvm-project?rev=212083&view=rev
Log:
clang-interpreter: interpret instead of JITing
Fixes the build when no targets are selected, or no native target is built.
This also better matches up with the description/title of the example and
demonstrates how clang can be used to run C++ on constrained environments
without file IO or executable memory permissions (e.g. iOS apps).
A comment is added explaining how to extend the demo with JIT support as
needed.
Modified:
cfe/trunk/examples/clang-interpreter/CMakeLists.txt
cfe/trunk/examples/clang-interpreter/README.txt
cfe/trunk/examples/clang-interpreter/main.cpp
Modified: cfe/trunk/examples/clang-interpreter/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/clang-interpreter/CMakeLists.txt?rev=212083&r1=212082&r2=212083&view=diff
==============================================================================
--- cfe/trunk/examples/clang-interpreter/CMakeLists.txt (original)
+++ cfe/trunk/examples/clang-interpreter/CMakeLists.txt Mon Jun 30 21:41:55 2014
@@ -1,9 +1,8 @@
set(LLVM_LINK_COMPONENTS
Core
ExecutionEngine
- JIT
+ Interpreter
Support
- nativecodegen
)
add_clang_executable(clang-interpreter
Modified: cfe/trunk/examples/clang-interpreter/README.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/clang-interpreter/README.txt?rev=212083&r1=212082&r2=212083&view=diff
==============================================================================
--- cfe/trunk/examples/clang-interpreter/README.txt (original)
+++ cfe/trunk/examples/clang-interpreter/README.txt Mon Jun 30 21:41:55 2014
@@ -10,7 +10,8 @@ It demonstrates the following features:
3. Invoking the Clang compiler to lex, parse, syntax check, and then generate
LLVM code.
- 4. Use the LLVM JIT functionality to execute the final module.
+ 4. Use the LLVM interpreter functionality to execute the final module, with
+ guidance on how to extend the demo with JIT execution.
The implementation has many limitations and is not designed to be a full fledged
C interpreter. It is designed to demonstrate a simple but functional use of the
Modified: cfe/trunk/examples/clang-interpreter/main.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/clang-interpreter/main.cpp?rev=212083&r1=212082&r2=212083&view=diff
==============================================================================
--- cfe/trunk/examples/clang-interpreter/main.cpp (original)
+++ cfe/trunk/examples/clang-interpreter/main.cpp Mon Jun 30 21:41:55 2014
@@ -18,7 +18,6 @@
#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"
@@ -43,11 +42,12 @@ std::string GetExecutablePath(const char
}
static int Execute(llvm::Module *Mod, char * const *envp) {
- llvm::InitializeNativeTarget();
+ // To JIT instead of interpreting, call llvm::InitializeNativeTarget() here
+ // and pass ForceInterpreter=false to ExecutionEngine::create().
std::string Error;
std::unique_ptr<llvm::ExecutionEngine> EE(
- llvm::ExecutionEngine::createJIT(Mod, &Error));
+ llvm::ExecutionEngine::create(Mod, /*ForceInterpreter*/ true, &Error));
if (!EE) {
llvm::errs() << "unable to make execution engine: " << Error << "\n";
return 255;
More information about the cfe-commits
mailing list