Make Kaleidoscope not link against the interpreter, since that didn't

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
This commit is contained in:
Jeffrey Yasskin 2010-02-11 19:15:20 +00:00
parent bbe99362e5
commit 42fc558624
12 changed files with 53 additions and 21 deletions

View File

@ -485,7 +485,7 @@ LLVM JIT and optimizer. To build this example, use:
<div class="doc_code"> <div class="doc_code">
<pre> <pre>
# Compile # 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 # Run
./toy ./toy
</pre> </pre>
@ -502,7 +502,6 @@ at runtime.</p>
<pre> <pre>
#include "llvm/DerivedTypes.h" #include "llvm/DerivedTypes.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/Interpreter.h"
#include "llvm/ExecutionEngine/JIT.h" #include "llvm/ExecutionEngine/JIT.h"
#include "llvm/LLVMContext.h" #include "llvm/LLVMContext.h"
#include "llvm/Module.h" #include "llvm/Module.h"
@ -1075,7 +1074,12 @@ int main() {
TheModule = new Module("my cool jit", Context); TheModule = new Module("my cool jit", Context);
// Create the JIT. This takes ownership of the module. // 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); FunctionPassManager OurFPM(TheModule);

View File

@ -902,7 +902,6 @@ if/then/else and for expressions.. To build this example, use:
<pre> <pre>
#include "llvm/DerivedTypes.h" #include "llvm/DerivedTypes.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/Interpreter.h"
#include "llvm/ExecutionEngine/JIT.h" #include "llvm/ExecutionEngine/JIT.h"
#include "llvm/LLVMContext.h" #include "llvm/LLVMContext.h"
#include "llvm/Module.h" #include "llvm/Module.h"
@ -1720,7 +1719,12 @@ int main() {
TheModule = new Module("my cool jit", Context); TheModule = new Module("my cool jit", Context);
// Create the JIT. This takes ownership of the module. // 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); FunctionPassManager OurFPM(TheModule);

View File

@ -821,7 +821,6 @@ if/then/else and for expressions.. To build this example, use:
<pre> <pre>
#include "llvm/DerivedTypes.h" #include "llvm/DerivedTypes.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/Interpreter.h"
#include "llvm/ExecutionEngine/JIT.h" #include "llvm/ExecutionEngine/JIT.h"
#include "llvm/LLVMContext.h" #include "llvm/LLVMContext.h"
#include "llvm/Module.h" #include "llvm/Module.h"
@ -1757,7 +1756,12 @@ int main() {
TheModule = new Module("my cool jit", Context); TheModule = new Module("my cool jit", Context);
// Create the JIT. This takes ownership of the module. // 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); FunctionPassManager OurFPM(TheModule);

View File

@ -1004,7 +1004,6 @@ variables and var/in support. To build this example, use:
<pre> <pre>
#include "llvm/DerivedTypes.h" #include "llvm/DerivedTypes.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/Interpreter.h"
#include "llvm/ExecutionEngine/JIT.h" #include "llvm/ExecutionEngine/JIT.h"
#include "llvm/LLVMContext.h" #include "llvm/LLVMContext.h"
#include "llvm/Module.h" #include "llvm/Module.h"
@ -2105,7 +2104,12 @@ int main() {
TheModule = new Module("my cool jit", Context); TheModule = new Module("my cool jit", Context);
// Create the JIT. This takes ownership of the module. // 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); FunctionPassManager OurFPM(TheModule);

View File

@ -10,6 +10,6 @@ LEVEL = ../../..
TOOLNAME = Kaleidoscope-Ch4 TOOLNAME = Kaleidoscope-Ch4
EXAMPLE_TOOL = 1 EXAMPLE_TOOL = 1
LINK_COMPONENTS := core jit interpreter native LINK_COMPONENTS := core jit native
include $(LEVEL)/Makefile.common include $(LEVEL)/Makefile.common

View File

@ -1,6 +1,5 @@
#include "llvm/DerivedTypes.h" #include "llvm/DerivedTypes.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/Interpreter.h"
#include "llvm/ExecutionEngine/JIT.h" #include "llvm/ExecutionEngine/JIT.h"
#include "llvm/LLVMContext.h" #include "llvm/LLVMContext.h"
#include "llvm/Module.h" #include "llvm/Module.h"
@ -573,7 +572,12 @@ int main() {
TheModule = new Module("my cool jit", Context); TheModule = new Module("my cool jit", Context);
// Create the JIT. This takes ownership of the module. // 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); FunctionPassManager OurFPM(TheModule);

View File

@ -10,6 +10,6 @@ LEVEL = ../../..
TOOLNAME = Kaleidoscope-Ch5 TOOLNAME = Kaleidoscope-Ch5
EXAMPLE_TOOL = 1 EXAMPLE_TOOL = 1
LINK_COMPONENTS := core jit interpreter native LINK_COMPONENTS := core jit native
include $(LEVEL)/Makefile.common include $(LEVEL)/Makefile.common

View File

@ -1,6 +1,5 @@
#include "llvm/DerivedTypes.h" #include "llvm/DerivedTypes.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/Interpreter.h"
#include "llvm/ExecutionEngine/JIT.h" #include "llvm/ExecutionEngine/JIT.h"
#include "llvm/LLVMContext.h" #include "llvm/LLVMContext.h"
#include "llvm/Module.h" #include "llvm/Module.h"
@ -818,7 +817,12 @@ int main() {
TheModule = new Module("my cool jit", Context); TheModule = new Module("my cool jit", Context);
// Create the JIT. This takes ownership of the module. // 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); FunctionPassManager OurFPM(TheModule);

View File

@ -10,6 +10,6 @@ LEVEL = ../../..
TOOLNAME = Kaleidoscope-Ch6 TOOLNAME = Kaleidoscope-Ch6
EXAMPLE_TOOL = 1 EXAMPLE_TOOL = 1
LINK_COMPONENTS := core jit interpreter native LINK_COMPONENTS := core jit native
include $(LEVEL)/Makefile.common include $(LEVEL)/Makefile.common

View File

@ -1,6 +1,5 @@
#include "llvm/DerivedTypes.h" #include "llvm/DerivedTypes.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/Interpreter.h"
#include "llvm/ExecutionEngine/JIT.h" #include "llvm/ExecutionEngine/JIT.h"
#include "llvm/LLVMContext.h" #include "llvm/LLVMContext.h"
#include "llvm/Module.h" #include "llvm/Module.h"
@ -936,7 +935,12 @@ int main() {
TheModule = new Module("my cool jit", Context); TheModule = new Module("my cool jit", Context);
// Create the JIT. This takes ownership of the module. // 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); FunctionPassManager OurFPM(TheModule);

View File

@ -11,6 +11,6 @@ TOOLNAME = Kaleidoscope-Ch7
EXAMPLE_TOOL = 1 EXAMPLE_TOOL = 1
REQUIRES_RTTI := 1 REQUIRES_RTTI := 1
LINK_COMPONENTS := core jit interpreter native LINK_COMPONENTS := core jit native
include $(LEVEL)/Makefile.common include $(LEVEL)/Makefile.common

View File

@ -1,6 +1,5 @@
#include "llvm/DerivedTypes.h" #include "llvm/DerivedTypes.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/Interpreter.h"
#include "llvm/ExecutionEngine/JIT.h" #include "llvm/ExecutionEngine/JIT.h"
#include "llvm/LLVMContext.h" #include "llvm/LLVMContext.h"
#include "llvm/Module.h" #include "llvm/Module.h"
@ -1100,7 +1099,12 @@ int main() {
TheModule = new Module("my cool jit", Context); TheModule = new Module("my cool jit", Context);
// Create the JIT. This takes ownership of the module. // 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); FunctionPassManager OurFPM(TheModule);