Make Kaleidoscope not link against the interpreter, since that didn't
authorJeffrey Yasskin <jyasskin@google.com>
Thu, 11 Feb 2010 19:15:20 +0000 (19:15 +0000)
committerJeffrey Yasskin <jyasskin@google.com>
Thu, 11 Feb 2010 19:15:20 +0000 (19:15 +0000)
work anyway (Interpreter::getPointerToFunction doesn't return a
callable pointer), and improve the error message when an
ExecutionEngine can't be created.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95896 91177308-0d34-0410-b5e6-96231b3b80d8

12 files changed:
docs/tutorial/LangImpl4.html
docs/tutorial/LangImpl5.html
docs/tutorial/LangImpl6.html
docs/tutorial/LangImpl7.html
examples/Kaleidoscope/Chapter4/Makefile
examples/Kaleidoscope/Chapter4/toy.cpp
examples/Kaleidoscope/Chapter5/Makefile
examples/Kaleidoscope/Chapter5/toy.cpp
examples/Kaleidoscope/Chapter6/Makefile
examples/Kaleidoscope/Chapter6/toy.cpp
examples/Kaleidoscope/Chapter7/Makefile
examples/Kaleidoscope/Chapter7/toy.cpp

index b1ee25a88d12f25c87c995fc2126e691135ccc74..70fd673d64ba8b412a4e1cb92e71561970d26717 100644 (file)
@@ -485,7 +485,7 @@ LLVM JIT and optimizer.  To build this example, use:
 <div class="doc_code">
 <pre>
    # Compile
-   g++ -g toy.cpp `llvm-config --cppflags --ldflags --libs core jit interpreter native` -O3 -o toy
+   g++ -g toy.cpp `llvm-config --cppflags --ldflags --libs core jit native` -O3 -o toy
    # Run
    ./toy
 </pre>
@@ -502,7 +502,6 @@ at runtime.</p>
 <pre>
 #include "llvm/DerivedTypes.h"
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
-#include "llvm/ExecutionEngine/Interpreter.h"
 #include "llvm/ExecutionEngine/JIT.h"
 #include "llvm/LLVMContext.h"
 #include "llvm/Module.h"
@@ -1075,7 +1074,12 @@ int main() {
   TheModule = new Module("my cool jit", Context);
 
   // Create the JIT.  This takes ownership of the module.
-  TheExecutionEngine = EngineBuilder(TheModule).create();
+  std::string ErrStr;
+  TheExecutionEngine = EngineBuilder(TheModule).setErrorStr(&ErrStr).create();
+  if (!TheExecutionEngine) {
+    fprintf(stderr, "Could not create ExecutionEngine: %s\n", ErrStr.c_str());
+    exit(1);
+  }
 
   FunctionPassManager OurFPM(TheModule);
 
index 9706cf1c2b0d9878dcd65456a67fe09b6c00592a..2b0450fef98131bfaffd5e07fa6dbcf00df40f5e 100644 (file)
@@ -902,7 +902,6 @@ if/then/else and for expressions..  To build this example, use:
 <pre>
 #include "llvm/DerivedTypes.h"
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
-#include "llvm/ExecutionEngine/Interpreter.h"
 #include "llvm/ExecutionEngine/JIT.h"
 #include "llvm/LLVMContext.h"
 #include "llvm/Module.h"
@@ -1720,7 +1719,12 @@ int main() {
   TheModule = new Module("my cool jit", Context);
 
   // Create the JIT.  This takes ownership of the module.
-  TheExecutionEngine = EngineBuilder(TheModule).create();
+  std::string ErrStr;
+  TheExecutionEngine = EngineBuilder(TheModule).setErrorStr(&ErrStr).create();
+  if (!TheExecutionEngine) {
+    fprintf(stderr, "Could not create ExecutionEngine: %s\n", ErrStr.c_str());
+    exit(1);
+  }
 
   FunctionPassManager OurFPM(TheModule);
 
index 4433450159f514ff6af47548d58c36107627f302..5fae906c3b3234c2aeb3701cc117f135cd9a999b 100644 (file)
@@ -821,7 +821,6 @@ if/then/else and for expressions..  To build this example, use:
 <pre>
 #include "llvm/DerivedTypes.h"
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
-#include "llvm/ExecutionEngine/Interpreter.h"
 #include "llvm/ExecutionEngine/JIT.h"
 #include "llvm/LLVMContext.h"
 #include "llvm/Module.h"
@@ -1757,7 +1756,12 @@ int main() {
   TheModule = new Module("my cool jit", Context);
 
   // Create the JIT.  This takes ownership of the module.
-  TheExecutionEngine = EngineBuilder(TheModule).create();
+  std::string ErrStr;
+  TheExecutionEngine = EngineBuilder(TheModule).setErrorStr(&ErrStr).create();
+  if (!TheExecutionEngine) {
+    fprintf(stderr, "Could not create ExecutionEngine: %s\n", ErrStr.c_str());
+    exit(1);
+  }
 
   FunctionPassManager OurFPM(TheModule);
 
index 211d14a3f5577b1a7b300b2954bb26c3c8f263fb..f0a03c3cc89580aa3310bc537b7423db67af7e72 100644 (file)
@@ -1004,7 +1004,6 @@ variables and var/in support.  To build this example, use:
 <pre>
 #include "llvm/DerivedTypes.h"
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
-#include "llvm/ExecutionEngine/Interpreter.h"
 #include "llvm/ExecutionEngine/JIT.h"
 #include "llvm/LLVMContext.h"
 #include "llvm/Module.h"
@@ -2105,7 +2104,12 @@ int main() {
   TheModule = new Module("my cool jit", Context);
 
   // Create the JIT.  This takes ownership of the module.
-  TheExecutionEngine = EngineBuilder(TheModule).create();
+  std::string ErrStr;
+  TheExecutionEngine = EngineBuilder(TheModule).setErrorStr(&amp;ErrStr).create();
+  if (!TheExecutionEngine) {
+    fprintf(stderr, "Could not create ExecutionEngine: %s\n", ErrStr.c_str());
+    exit(1);
+  }
 
   FunctionPassManager OurFPM(TheModule);
 
index 7bc742fb1e44afdaff6dff59ce2d31f4d152718e..30162d94bcee4f63d61af02c3e3558ec4e10e1aa 100644 (file)
@@ -10,6 +10,6 @@ LEVEL = ../../..
 TOOLNAME = Kaleidoscope-Ch4
 EXAMPLE_TOOL = 1
 
-LINK_COMPONENTS := core jit interpreter native
+LINK_COMPONENTS := core jit native
 
 include $(LEVEL)/Makefile.common
index cdc9d74dde3507211ad1604dec7b20e9246c94e4..a2ddda2e9169c7751f28cc94e89028dbaf22be24 100644 (file)
@@ -1,6 +1,5 @@
 #include "llvm/DerivedTypes.h"
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
-#include "llvm/ExecutionEngine/Interpreter.h"
 #include "llvm/ExecutionEngine/JIT.h"
 #include "llvm/LLVMContext.h"
 #include "llvm/Module.h"
@@ -573,7 +572,12 @@ int main() {
   TheModule = new Module("my cool jit", Context);
 
   // Create the JIT.  This takes ownership of the module.
-  TheExecutionEngine = EngineBuilder(TheModule).create();
+  std::string ErrStr;
+  TheExecutionEngine = EngineBuilder(TheModule).setErrorStr(&ErrStr).create();
+  if (!TheExecutionEngine) {
+    fprintf(stderr, "Could not create ExecutionEngine: %s\n", ErrStr.c_str());
+    exit(1);
+  }
 
   FunctionPassManager OurFPM(TheModule);
 
index 5a8355d3153d1aaa928b3cace45cc76675064372..d1f5e2035b46486c95c60395642391d20f2e0583 100644 (file)
@@ -10,6 +10,6 @@ LEVEL = ../../..
 TOOLNAME = Kaleidoscope-Ch5
 EXAMPLE_TOOL = 1
 
-LINK_COMPONENTS := core jit interpreter native
+LINK_COMPONENTS := core jit native
 
 include $(LEVEL)/Makefile.common
index 24f551f3a69831665bfdb71222b6d1609dab2b41..da64b7eb528b749a413e0d440cca3d3418eb5655 100644 (file)
@@ -1,6 +1,5 @@
 #include "llvm/DerivedTypes.h"
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
-#include "llvm/ExecutionEngine/Interpreter.h"
 #include "llvm/ExecutionEngine/JIT.h"
 #include "llvm/LLVMContext.h"
 #include "llvm/Module.h"
@@ -818,7 +817,12 @@ int main() {
   TheModule = new Module("my cool jit", Context);
 
   // Create the JIT.  This takes ownership of the module.
-  TheExecutionEngine = EngineBuilder(TheModule).create();
+  std::string ErrStr;
+  TheExecutionEngine = EngineBuilder(TheModule).setErrorStr(&ErrStr).create();
+  if (!TheExecutionEngine) {
+    fprintf(stderr, "Could not create ExecutionEngine: %s\n", ErrStr.c_str());
+    exit(1);
+  }
 
   FunctionPassManager OurFPM(TheModule);
 
index de2d758728eb271a739b2c1e057a494d060be32c..a5fbcbdf9b2baa2c072e9d615faa59819ae71c4d 100644 (file)
@@ -10,6 +10,6 @@ LEVEL = ../../..
 TOOLNAME = Kaleidoscope-Ch6
 EXAMPLE_TOOL = 1
 
-LINK_COMPONENTS := core jit interpreter native
+LINK_COMPONENTS := core jit native
 
 include $(LEVEL)/Makefile.common
index f4b5b8cd388d11bca675544629259313aca88f6f..4e719e3481a0fd358f002c0d330dbd4c27bffe56 100644 (file)
@@ -1,6 +1,5 @@
 #include "llvm/DerivedTypes.h"
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
-#include "llvm/ExecutionEngine/Interpreter.h"
 #include "llvm/ExecutionEngine/JIT.h"
 #include "llvm/LLVMContext.h"
 #include "llvm/Module.h"
@@ -936,7 +935,12 @@ int main() {
   TheModule = new Module("my cool jit", Context);
 
   // Create the JIT.  This takes ownership of the module.
-  TheExecutionEngine = EngineBuilder(TheModule).create();
+  std::string ErrStr;
+  TheExecutionEngine = EngineBuilder(TheModule).setErrorStr(&ErrStr).create();
+  if (!TheExecutionEngine) {
+    fprintf(stderr, "Could not create ExecutionEngine: %s\n", ErrStr.c_str());
+    exit(1);
+  }
 
   FunctionPassManager OurFPM(TheModule);
 
index 8911d52560b5c32c2f70708468438e6ff09413d2..6cec323efd402f4c8c858df8e42268ce4703831f 100644 (file)
@@ -11,6 +11,6 @@ TOOLNAME = Kaleidoscope-Ch7
 EXAMPLE_TOOL = 1
 REQUIRES_RTTI := 1
 
-LINK_COMPONENTS := core jit interpreter native
+LINK_COMPONENTS := core jit native
 
 include $(LEVEL)/Makefile.common
index 951dfd8e63a0e1b7f34854e746d81c0709cdc992..7dd9eae3e2ec70537b87e9142e5c53a4b51f02ba 100644 (file)
@@ -1,6 +1,5 @@
 #include "llvm/DerivedTypes.h"
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
-#include "llvm/ExecutionEngine/Interpreter.h"
 #include "llvm/ExecutionEngine/JIT.h"
 #include "llvm/LLVMContext.h"
 #include "llvm/Module.h"
@@ -1100,7 +1099,12 @@ int main() {
   TheModule = new Module("my cool jit", Context);
 
   // Create the JIT.  This takes ownership of the module.
-  TheExecutionEngine = EngineBuilder(TheModule).create();
+  std::string ErrStr;
+  TheExecutionEngine = EngineBuilder(TheModule).setErrorStr(&ErrStr).create();
+  if (!TheExecutionEngine) {
+    fprintf(stderr, "Could not create ExecutionEngine: %s\n", ErrStr.c_str());
+    exit(1);
+  }
 
   FunctionPassManager OurFPM(TheModule);