summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2014-12-01 14:51:49 -0800
committerStephen Hines <srhines@google.com>2014-12-02 16:08:10 -0800
commit37ed9c199ca639565f6ce88105f9e39e898d82d0 (patch)
tree8fb36d3910e3ee4c4e1b7422f4f017108efc52f5 /examples
parentd2327b22152ced7bc46dc629fc908959e8a52d03 (diff)
downloadexternal_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.zip
external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.tar.gz
external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.tar.bz2
Update aosp/master LLVM for rebase to r222494.
Change-Id: Ic787f5e0124df789bd26f3f24680f45e678eef2d
Diffstat (limited to 'examples')
-rw-r--r--examples/BrainF/BrainFDriver.cpp21
-rw-r--r--examples/BrainF/CMakeLists.txt2
-rw-r--r--examples/BrainF/Makefile2
-rw-r--r--examples/ExceptionDemo/CMakeLists.txt3
-rw-r--r--examples/ExceptionDemo/ExceptionDemo.cpp10
-rw-r--r--examples/ExceptionDemo/Makefile2
-rw-r--r--examples/Fibonacci/CMakeLists.txt2
-rw-r--r--examples/Fibonacci/Makefile2
-rw-r--r--examples/Fibonacci/fibonacci.cpp8
-rw-r--r--examples/HowToUseJIT/CMakeLists.txt2
-rw-r--r--examples/HowToUseJIT/HowToUseJIT.cpp7
-rw-r--r--examples/HowToUseJIT/Makefile2
-rw-r--r--examples/Kaleidoscope/Chapter4/CMakeLists.txt2
-rw-r--r--examples/Kaleidoscope/Chapter4/Makefile2
-rw-r--r--examples/Kaleidoscope/Chapter4/toy.cpp9
-rw-r--r--examples/Kaleidoscope/Chapter5/CMakeLists.txt2
-rw-r--r--examples/Kaleidoscope/Chapter5/Makefile2
-rw-r--r--examples/Kaleidoscope/Chapter5/toy.cpp9
-rw-r--r--examples/Kaleidoscope/Chapter6/CMakeLists.txt2
-rw-r--r--examples/Kaleidoscope/Chapter6/Makefile2
-rw-r--r--examples/Kaleidoscope/Chapter6/toy.cpp9
-rw-r--r--examples/Kaleidoscope/Chapter7/CMakeLists.txt2
-rw-r--r--examples/Kaleidoscope/Chapter7/Makefile2
-rw-r--r--examples/Kaleidoscope/Chapter7/toy.cpp9
-rw-r--r--examples/Kaleidoscope/MCJIT/cached/toy-jit.cpp1
-rw-r--r--examples/Kaleidoscope/MCJIT/cached/toy.cpp1
-rw-r--r--examples/Kaleidoscope/MCJIT/complete/toy.cpp129
-rw-r--r--examples/Kaleidoscope/MCJIT/initial/toy.cpp1
-rw-r--r--examples/Kaleidoscope/MCJIT/lazy/toy-jit.cpp1
-rw-r--r--examples/Kaleidoscope/MCJIT/lazy/toy.cpp1
-rw-r--r--examples/ParallelJIT/CMakeLists.txt2
-rw-r--r--examples/ParallelJIT/Makefile2
-rw-r--r--examples/ParallelJIT/ParallelJIT.cpp6
33 files changed, 73 insertions, 186 deletions
diff --git a/examples/BrainF/BrainFDriver.cpp b/examples/BrainF/BrainFDriver.cpp
index e2de6bc..99c8ff3 100644
--- a/examples/BrainF/BrainFDriver.cpp
+++ b/examples/BrainF/BrainFDriver.cpp
@@ -26,8 +26,8 @@
#include "BrainF.h"
#include "llvm/Bitcode/ReaderWriter.h"
+#include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/GenericValue.h"
-#include "llvm/ExecutionEngine/JIT.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Verifier.h"
#include "llvm/Support/CommandLine.h"
@@ -107,9 +107,8 @@ int main(int argc, char **argv) {
OutputFilename = base+".bc";
}
if (OutputFilename != "-") {
- std::string ErrInfo;
- out = new raw_fd_ostream(OutputFilename.c_str(), ErrInfo,
- sys::fs::F_None);
+ std::error_code EC;
+ out = new raw_fd_ostream(OutputFilename, EC, sys::fs::F_None);
}
}
@@ -125,13 +124,13 @@ int main(int argc, char **argv) {
//Read the BrainF program
BrainF bf;
- Module *mod = bf.parse(in, 65536, cf, Context); //64 KiB
+ std::unique_ptr<Module> Mod(bf.parse(in, 65536, cf, Context)); // 64 KiB
if (in != &std::cin)
delete in;
- addMainFunction(mod);
+ addMainFunction(Mod.get());
//Verify generated code
- if (verifyModule(*mod)) {
+ if (verifyModule(*Mod)) {
errs() << "Error: module failed verification. This shouldn't happen.\n";
abort();
}
@@ -141,18 +140,18 @@ int main(int argc, char **argv) {
InitializeNativeTarget();
outs() << "------- Running JIT -------\n";
- ExecutionEngine *ee = EngineBuilder(mod).create();
+ Module &M = *Mod;
+ ExecutionEngine *ee = EngineBuilder(std::move(Mod)).create();
std::vector<GenericValue> args;
- Function *brainf_func = mod->getFunction("brainf");
+ Function *brainf_func = M.getFunction("brainf");
GenericValue gv = ee->runFunction(brainf_func, args);
} else {
- WriteBitcodeToFile(mod, *out);
+ WriteBitcodeToFile(Mod.get(), *out);
}
//Clean up
if (out != &outs())
delete out;
- delete mod;
llvm_shutdown();
diff --git a/examples/BrainF/CMakeLists.txt b/examples/BrainF/CMakeLists.txt
index 025d093..cf1cf1b 100644
--- a/examples/BrainF/CMakeLists.txt
+++ b/examples/BrainF/CMakeLists.txt
@@ -2,7 +2,7 @@ set(LLVM_LINK_COMPONENTS
BitWriter
Core
ExecutionEngine
- JIT
+ MC
Support
nativecodegen
)
diff --git a/examples/BrainF/Makefile b/examples/BrainF/Makefile
index 2c3e066..3e36e07 100644
--- a/examples/BrainF/Makefile
+++ b/examples/BrainF/Makefile
@@ -10,6 +10,6 @@ LEVEL = ../..
TOOLNAME = BrainF
EXAMPLE_TOOL = 1
-LINK_COMPONENTS := jit bitwriter nativecodegen interpreter
+LINK_COMPONENTS := mcjit bitwriter nativecodegen interpreter
include $(LEVEL)/Makefile.common
diff --git a/examples/ExceptionDemo/CMakeLists.txt b/examples/ExceptionDemo/CMakeLists.txt
index 5324acd..9cadd94 100644
--- a/examples/ExceptionDemo/CMakeLists.txt
+++ b/examples/ExceptionDemo/CMakeLists.txt
@@ -1,12 +1,15 @@
set(LLVM_LINK_COMPONENTS
Core
ExecutionEngine
+ MC
MCJIT
Support
nativecodegen
)
+# Enable EH and RTTI for this demo
set(LLVM_REQUIRES_EH 1)
+set(LLVM_REQUIRES_RTTI 1)
add_llvm_example(ExceptionDemo
ExceptionDemo.cpp
diff --git a/examples/ExceptionDemo/ExceptionDemo.cpp b/examples/ExceptionDemo/ExceptionDemo.cpp
index 24e538c..17076fa 100644
--- a/examples/ExceptionDemo/ExceptionDemo.cpp
+++ b/examples/ExceptionDemo/ExceptionDemo.cpp
@@ -1957,17 +1957,17 @@ int main(int argc, char *argv[]) {
llvm::IRBuilder<> theBuilder(context);
// Make the module, which holds all the code.
- llvm::Module *module = new llvm::Module("my cool jit", context);
+ std::unique_ptr<llvm::Module> Owner =
+ llvm::make_unique<llvm::Module>("my cool jit", context);
+ llvm::Module *module = Owner.get();
llvm::RTDyldMemoryManager *MemMgr = new llvm::SectionMemoryManager();
// Build engine with JIT
- llvm::EngineBuilder factory(module);
+ llvm::EngineBuilder factory(std::move(Owner));
factory.setEngineKind(llvm::EngineKind::JIT);
- factory.setAllocateGVsWithCode(false);
factory.setTargetOptions(Opts);
factory.setMCJITMemoryManager(MemMgr);
- factory.setUseMCJIT(true);
llvm::ExecutionEngine *executionEngine = factory.create();
{
@@ -1977,7 +1977,7 @@ int main(int argc, char *argv[]) {
// Start with registering info about how the
// target lays out data structures.
module->setDataLayout(executionEngine->getDataLayout());
- fpm.add(new llvm::DataLayoutPass(module));
+ fpm.add(new llvm::DataLayoutPass());
// Optimizations turned on
#ifdef ADD_OPT_PASSES
diff --git a/examples/ExceptionDemo/Makefile b/examples/ExceptionDemo/Makefile
index 58d9def..895b61d 100644
--- a/examples/ExceptionDemo/Makefile
+++ b/examples/ExceptionDemo/Makefile
@@ -11,6 +11,6 @@ TOOLNAME = ExceptionDemo
EXAMPLE_TOOL = 1
REQUIRES_EH = 1
-LINK_COMPONENTS := jit mcjit nativecodegen
+LINK_COMPONENTS := mcjit nativecodegen
include $(LEVEL)/Makefile.common
diff --git a/examples/Fibonacci/CMakeLists.txt b/examples/Fibonacci/CMakeLists.txt
index 724a0f6..087ccdd 100644
--- a/examples/Fibonacci/CMakeLists.txt
+++ b/examples/Fibonacci/CMakeLists.txt
@@ -2,7 +2,7 @@ set(LLVM_LINK_COMPONENTS
Core
ExecutionEngine
Interpreter
- JIT
+ MC
Support
nativecodegen
)
diff --git a/examples/Fibonacci/Makefile b/examples/Fibonacci/Makefile
index 71f6ba0..c99110a 100644
--- a/examples/Fibonacci/Makefile
+++ b/examples/Fibonacci/Makefile
@@ -12,6 +12,6 @@ TOOLNAME = Fibonacci
EXAMPLE_TOOL = 1
# Link in JIT support
-LINK_COMPONENTS := jit interpreter nativecodegen
+LINK_COMPONENTS := interpreter mcjit nativecodegen
include $(LEVEL)/Makefile.common
diff --git a/examples/Fibonacci/fibonacci.cpp b/examples/Fibonacci/fibonacci.cpp
index ba8e953..8092e19 100644
--- a/examples/Fibonacci/fibonacci.cpp
+++ b/examples/Fibonacci/fibonacci.cpp
@@ -26,7 +26,6 @@
#include "llvm/IR/Verifier.h"
#include "llvm/ExecutionEngine/GenericValue.h"
#include "llvm/ExecutionEngine/Interpreter.h"
-#include "llvm/ExecutionEngine/JIT.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Instructions.h"
@@ -96,15 +95,16 @@ int main(int argc, char **argv) {
LLVMContext Context;
// Create some module to put our function into it.
- std::unique_ptr<Module> M(new Module("test", Context));
+ std::unique_ptr<Module> Owner(new Module("test", Context));
+ Module *M = Owner.get();
// We are about to create the "fib" function:
- Function *FibF = CreateFibFunction(M.get(), Context);
+ Function *FibF = CreateFibFunction(M, Context);
// Now we going to create JIT
std::string errStr;
ExecutionEngine *EE =
- EngineBuilder(M.get())
+ EngineBuilder(std::move(Owner))
.setErrorStr(&errStr)
.setEngineKind(EngineKind::JIT)
.create();
diff --git a/examples/HowToUseJIT/CMakeLists.txt b/examples/HowToUseJIT/CMakeLists.txt
index 88aed02..a344ad0 100644
--- a/examples/HowToUseJIT/CMakeLists.txt
+++ b/examples/HowToUseJIT/CMakeLists.txt
@@ -2,7 +2,7 @@ set(LLVM_LINK_COMPONENTS
Core
ExecutionEngine
Interpreter
- JIT
+ MC
Support
nativecodegen
)
diff --git a/examples/HowToUseJIT/HowToUseJIT.cpp b/examples/HowToUseJIT/HowToUseJIT.cpp
index 7125a15..9552240 100644
--- a/examples/HowToUseJIT/HowToUseJIT.cpp
+++ b/examples/HowToUseJIT/HowToUseJIT.cpp
@@ -36,7 +36,6 @@
#include "llvm/ExecutionEngine/GenericValue.h"
#include "llvm/ExecutionEngine/Interpreter.h"
-#include "llvm/ExecutionEngine/JIT.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/IRBuilder.h"
@@ -56,7 +55,8 @@ int main() {
LLVMContext Context;
// Create some module to put our function into it.
- Module *M = new Module("test", Context);
+ std::unique_ptr<Module> Owner = make_unique<Module>("test", Context);
+ Module *M = Owner.get();
// Create the add1 function entry and insert this entry into module M. The
// function will have a return type of "int" and take an argument of "int".
@@ -114,7 +114,7 @@ int main() {
builder.CreateRet(Add1CallRes);
// Now we create the JIT.
- ExecutionEngine* EE = EngineBuilder(M).create();
+ ExecutionEngine* EE = EngineBuilder(std::move(Owner)).create();
outs() << "We just constructed this LLVM module:\n\n" << *M;
outs() << "\n\nRunning foo: ";
@@ -126,7 +126,6 @@ int main() {
// Import result of execution:
outs() << "Result: " << gv.IntVal << "\n";
- EE->freeMachineCodeForFunction(FooF);
delete EE;
llvm_shutdown();
return 0;
diff --git a/examples/HowToUseJIT/Makefile b/examples/HowToUseJIT/Makefile
index c8919db..26a25a1 100644
--- a/examples/HowToUseJIT/Makefile
+++ b/examples/HowToUseJIT/Makefile
@@ -10,6 +10,6 @@ LEVEL = ../..
TOOLNAME = HowToUseJIT
EXAMPLE_TOOL = 1
-LINK_COMPONENTS := jit interpreter nativecodegen
+LINK_COMPONENTS := mcjit interpreter nativecodegen
include $(LEVEL)/Makefile.common
diff --git a/examples/Kaleidoscope/Chapter4/CMakeLists.txt b/examples/Kaleidoscope/Chapter4/CMakeLists.txt
index 72a9f05..2f828dc 100644
--- a/examples/Kaleidoscope/Chapter4/CMakeLists.txt
+++ b/examples/Kaleidoscope/Chapter4/CMakeLists.txt
@@ -3,7 +3,7 @@ set(LLVM_LINK_COMPONENTS
Core
ExecutionEngine
InstCombine
- JIT
+ MC
ScalarOpts
Support
nativecodegen
diff --git a/examples/Kaleidoscope/Chapter4/Makefile b/examples/Kaleidoscope/Chapter4/Makefile
index 30162d9..6d6a670 100644
--- a/examples/Kaleidoscope/Chapter4/Makefile
+++ b/examples/Kaleidoscope/Chapter4/Makefile
@@ -10,6 +10,6 @@ LEVEL = ../../..
TOOLNAME = Kaleidoscope-Ch4
EXAMPLE_TOOL = 1
-LINK_COMPONENTS := core jit native
+LINK_COMPONENTS := core mcjit native
include $(LEVEL)/Makefile.common
diff --git a/examples/Kaleidoscope/Chapter4/toy.cpp b/examples/Kaleidoscope/Chapter4/toy.cpp
index a8f5942..3564d75 100644
--- a/examples/Kaleidoscope/Chapter4/toy.cpp
+++ b/examples/Kaleidoscope/Chapter4/toy.cpp
@@ -1,6 +1,5 @@
#include "llvm/Analysis/Passes.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
-#include "llvm/ExecutionEngine/JIT.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/IRBuilder.h"
@@ -572,11 +571,13 @@ int main() {
getNextToken();
// Make the module, which holds all the code.
- TheModule = new Module("my cool jit", Context);
+ std::unique_ptr<Module> Owner = make_unique<Module>("my cool jit", Context);
+ TheModule = Owner.get();
// Create the JIT. This takes ownership of the module.
std::string ErrStr;
- TheExecutionEngine = EngineBuilder(TheModule).setErrorStr(&ErrStr).create();
+ TheExecutionEngine =
+ EngineBuilder(std::move(Owner)).setErrorStr(&ErrStr).create();
if (!TheExecutionEngine) {
fprintf(stderr, "Could not create ExecutionEngine: %s\n", ErrStr.c_str());
exit(1);
@@ -587,7 +588,7 @@ int main() {
// Set up the optimizer pipeline. Start with registering info about how the
// target lays out data structures.
TheModule->setDataLayout(TheExecutionEngine->getDataLayout());
- OurFPM.add(new DataLayoutPass(TheModule));
+ OurFPM.add(new DataLayoutPass());
// Provide basic AliasAnalysis support for GVN.
OurFPM.add(createBasicAliasAnalysisPass());
// Do simple "peephole" optimizations and bit-twiddling optzns.
diff --git a/examples/Kaleidoscope/Chapter5/CMakeLists.txt b/examples/Kaleidoscope/Chapter5/CMakeLists.txt
index c7d0276..1912ddc 100644
--- a/examples/Kaleidoscope/Chapter5/CMakeLists.txt
+++ b/examples/Kaleidoscope/Chapter5/CMakeLists.txt
@@ -3,7 +3,7 @@ set(LLVM_LINK_COMPONENTS
Core
ExecutionEngine
InstCombine
- JIT
+ MC
ScalarOpts
Support
nativecodegen
diff --git a/examples/Kaleidoscope/Chapter5/Makefile b/examples/Kaleidoscope/Chapter5/Makefile
index d1f5e20..d780967 100644
--- a/examples/Kaleidoscope/Chapter5/Makefile
+++ b/examples/Kaleidoscope/Chapter5/Makefile
@@ -10,6 +10,6 @@ LEVEL = ../../..
TOOLNAME = Kaleidoscope-Ch5
EXAMPLE_TOOL = 1
-LINK_COMPONENTS := core jit native
+LINK_COMPONENTS := core mcjit native
include $(LEVEL)/Makefile.common
diff --git a/examples/Kaleidoscope/Chapter5/toy.cpp b/examples/Kaleidoscope/Chapter5/toy.cpp
index a31b5b4..4929a20 100644
--- a/examples/Kaleidoscope/Chapter5/toy.cpp
+++ b/examples/Kaleidoscope/Chapter5/toy.cpp
@@ -1,6 +1,5 @@
#include "llvm/Analysis/Passes.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
-#include "llvm/ExecutionEngine/JIT.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/IRBuilder.h"
@@ -817,11 +816,13 @@ int main() {
getNextToken();
// Make the module, which holds all the code.
- TheModule = new Module("my cool jit", Context);
+ std::unique_ptr<Module> Owner = make_unique<Module>("my cool jit", Context);
+ TheModule = Owner.get();
// Create the JIT. This takes ownership of the module.
std::string ErrStr;
- TheExecutionEngine = EngineBuilder(TheModule).setErrorStr(&ErrStr).create();
+ TheExecutionEngine =
+ EngineBuilder(std::move(Owner)).setErrorStr(&ErrStr).create();
if (!TheExecutionEngine) {
fprintf(stderr, "Could not create ExecutionEngine: %s\n", ErrStr.c_str());
exit(1);
@@ -832,7 +833,7 @@ int main() {
// Set up the optimizer pipeline. Start with registering info about how the
// target lays out data structures.
TheModule->setDataLayout(TheExecutionEngine->getDataLayout());
- OurFPM.add(new DataLayoutPass(TheModule));
+ OurFPM.add(new DataLayoutPass());
// Provide basic AliasAnalysis support for GVN.
OurFPM.add(createBasicAliasAnalysisPass());
// Do simple "peephole" optimizations and bit-twiddling optzns.
diff --git a/examples/Kaleidoscope/Chapter6/CMakeLists.txt b/examples/Kaleidoscope/Chapter6/CMakeLists.txt
index 669c7eb..d36f030 100644
--- a/examples/Kaleidoscope/Chapter6/CMakeLists.txt
+++ b/examples/Kaleidoscope/Chapter6/CMakeLists.txt
@@ -3,7 +3,7 @@ set(LLVM_LINK_COMPONENTS
Core
ExecutionEngine
InstCombine
- JIT
+ MC
ScalarOpts
Support
nativecodegen
diff --git a/examples/Kaleidoscope/Chapter6/Makefile b/examples/Kaleidoscope/Chapter6/Makefile
index a5fbcbd..8f47ea0 100644
--- a/examples/Kaleidoscope/Chapter6/Makefile
+++ b/examples/Kaleidoscope/Chapter6/Makefile
@@ -10,6 +10,6 @@ LEVEL = ../../..
TOOLNAME = Kaleidoscope-Ch6
EXAMPLE_TOOL = 1
-LINK_COMPONENTS := core jit native
+LINK_COMPONENTS := core mcjit native
include $(LEVEL)/Makefile.common
diff --git a/examples/Kaleidoscope/Chapter6/toy.cpp b/examples/Kaleidoscope/Chapter6/toy.cpp
index 5a3bd2e..06da9ac 100644
--- a/examples/Kaleidoscope/Chapter6/toy.cpp
+++ b/examples/Kaleidoscope/Chapter6/toy.cpp
@@ -1,6 +1,5 @@
#include "llvm/Analysis/Passes.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
-#include "llvm/ExecutionEngine/JIT.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/IRBuilder.h"
@@ -935,11 +934,13 @@ int main() {
getNextToken();
// Make the module, which holds all the code.
- TheModule = new Module("my cool jit", Context);
+ std::unique_ptr<Module> Owner = make_unique<Module>("my cool jit", Context);
+ TheModule = Owner.get();
// Create the JIT. This takes ownership of the module.
std::string ErrStr;
- TheExecutionEngine = EngineBuilder(TheModule).setErrorStr(&ErrStr).create();
+ TheExecutionEngine =
+ EngineBuilder(std::move(Owner)).setErrorStr(&ErrStr).create();
if (!TheExecutionEngine) {
fprintf(stderr, "Could not create ExecutionEngine: %s\n", ErrStr.c_str());
exit(1);
@@ -950,7 +951,7 @@ int main() {
// Set up the optimizer pipeline. Start with registering info about how the
// target lays out data structures.
TheModule->setDataLayout(TheExecutionEngine->getDataLayout());
- OurFPM.add(new DataLayoutPass(TheModule));
+ OurFPM.add(new DataLayoutPass());
// Provide basic AliasAnalysis support for GVN.
OurFPM.add(createBasicAliasAnalysisPass());
// Do simple "peephole" optimizations and bit-twiddling optzns.
diff --git a/examples/Kaleidoscope/Chapter7/CMakeLists.txt b/examples/Kaleidoscope/Chapter7/CMakeLists.txt
index 0a0c8e7..bdc0e55 100644
--- a/examples/Kaleidoscope/Chapter7/CMakeLists.txt
+++ b/examples/Kaleidoscope/Chapter7/CMakeLists.txt
@@ -3,7 +3,7 @@ set(LLVM_LINK_COMPONENTS
Core
ExecutionEngine
InstCombine
- JIT
+ MC
ScalarOpts
Support
TransformUtils
diff --git a/examples/Kaleidoscope/Chapter7/Makefile b/examples/Kaleidoscope/Chapter7/Makefile
index 6cec323..7abeb3e 100644
--- a/examples/Kaleidoscope/Chapter7/Makefile
+++ b/examples/Kaleidoscope/Chapter7/Makefile
@@ -11,6 +11,6 @@ TOOLNAME = Kaleidoscope-Ch7
EXAMPLE_TOOL = 1
REQUIRES_RTTI := 1
-LINK_COMPONENTS := core jit native
+LINK_COMPONENTS := core mcjit native
include $(LEVEL)/Makefile.common
diff --git a/examples/Kaleidoscope/Chapter7/toy.cpp b/examples/Kaleidoscope/Chapter7/toy.cpp
index c2c337c..56a6fa9 100644
--- a/examples/Kaleidoscope/Chapter7/toy.cpp
+++ b/examples/Kaleidoscope/Chapter7/toy.cpp
@@ -1,6 +1,5 @@
#include "llvm/Analysis/Passes.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
-#include "llvm/ExecutionEngine/JIT.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/IRBuilder.h"
@@ -1099,11 +1098,13 @@ int main() {
getNextToken();
// Make the module, which holds all the code.
- TheModule = new Module("my cool jit", Context);
+ std::unique_ptr<Module> Owner = make_unique<Module>("my cool jit", Context);
+ TheModule = Owner.get();
// Create the JIT. This takes ownership of the module.
std::string ErrStr;
- TheExecutionEngine = EngineBuilder(TheModule).setErrorStr(&ErrStr).create();
+ TheExecutionEngine =
+ EngineBuilder(std::move(Owner)).setErrorStr(&ErrStr).create();
if (!TheExecutionEngine) {
fprintf(stderr, "Could not create ExecutionEngine: %s\n", ErrStr.c_str());
exit(1);
@@ -1114,7 +1115,7 @@ int main() {
// Set up the optimizer pipeline. Start with registering info about how the
// target lays out data structures.
TheModule->setDataLayout(TheExecutionEngine->getDataLayout());
- OurFPM.add(new DataLayoutPass(TheModule));
+ OurFPM.add(new DataLayoutPass());
// Provide basic AliasAnalysis support for GVN.
OurFPM.add(createBasicAliasAnalysisPass());
// Promote allocas to registers.
diff --git a/examples/Kaleidoscope/MCJIT/cached/toy-jit.cpp b/examples/Kaleidoscope/MCJIT/cached/toy-jit.cpp
index 9466360..00f5b83 100644
--- a/examples/Kaleidoscope/MCJIT/cached/toy-jit.cpp
+++ b/examples/Kaleidoscope/MCJIT/cached/toy-jit.cpp
@@ -2,7 +2,6 @@
#include "llvm/Analysis/Passes.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
-#include "llvm/ExecutionEngine/JIT.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/IRBuilder.h"
diff --git a/examples/Kaleidoscope/MCJIT/cached/toy.cpp b/examples/Kaleidoscope/MCJIT/cached/toy.cpp
index 16c548c..af51b4a 100644
--- a/examples/Kaleidoscope/MCJIT/cached/toy.cpp
+++ b/examples/Kaleidoscope/MCJIT/cached/toy.cpp
@@ -897,7 +897,6 @@ ExecutionEngine *MCJITHelper::compileModule(Module *M) {
std::string ErrStr;
ExecutionEngine *NewEngine = EngineBuilder(M)
.setErrorStr(&ErrStr)
- .setUseMCJIT(true)
.setMCJITMemoryManager(new HelpingMemoryManager(this))
.create();
if (!NewEngine) {
diff --git a/examples/Kaleidoscope/MCJIT/complete/toy.cpp b/examples/Kaleidoscope/MCJIT/complete/toy.cpp
index 10e7ada..3beb0d8 100644
--- a/examples/Kaleidoscope/MCJIT/complete/toy.cpp
+++ b/examples/Kaleidoscope/MCJIT/complete/toy.cpp
@@ -1,6 +1,5 @@
#include "llvm/Analysis/Passes.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
-#include "llvm/ExecutionEngine/JIT.h"
#include "llvm/ExecutionEngine/MCJIT.h"
#include "llvm/ExecutionEngine/ObjectCache.h"
#include "llvm/ExecutionEngine/SectionMemoryManager.h"
@@ -52,10 +51,6 @@ namespace {
cl::desc("Dump IR from modules to stderr on shutdown"),
cl::init(false));
- cl::opt<bool> UseMCJIT(
- "use-mcjit", cl::desc("Use the MCJIT execution engine"),
- cl::init(true));
-
cl::opt<bool> EnableLazyCompilation(
"enable-lazy-compilation", cl::desc("Enable lazy compilation when using the MCJIT engine"),
cl::init(true));
@@ -793,96 +788,6 @@ public:
};
//===----------------------------------------------------------------------===//
-// Helper class for JIT execution engine
-//===----------------------------------------------------------------------===//
-
-class JITHelper : public BaseHelper {
-public:
- JITHelper(LLVMContext &Context) {
- // Make the module, which holds all the code.
- if (!InputIR.empty()) {
- TheModule = parseInputIR(InputIR, Context);
- } else {
- TheModule = new Module("my cool jit", Context);
- }
-
- // Create the JIT. This takes ownership of the module.
- std::string ErrStr;
- TheExecutionEngine = EngineBuilder(TheModule).setErrorStr(&ErrStr).create();
- if (!TheExecutionEngine) {
- fprintf(stderr, "Could not create ExecutionEngine: %s\n", ErrStr.c_str());
- exit(1);
- }
-
- TheFPM = new FunctionPassManager(TheModule);
-
- // Set up the optimizer pipeline. Start with registering info about how the
- // target lays out data structures.
- TheFPM->add(new DataLayout(*TheExecutionEngine->getDataLayout()));
- // Provide basic AliasAnalysis support for GVN.
- TheFPM->add(createBasicAliasAnalysisPass());
- // Promote allocas to registers.
- TheFPM->add(createPromoteMemoryToRegisterPass());
- // Do simple "peephole" optimizations and bit-twiddling optzns.
- TheFPM->add(createInstructionCombiningPass());
- // Reassociate expressions.
- TheFPM->add(createReassociatePass());
- // Eliminate Common SubExpressions.
- TheFPM->add(createGVNPass());
- // Simplify the control flow graph (deleting unreachable blocks, etc).
- TheFPM->add(createCFGSimplificationPass());
-
- TheFPM->doInitialization();
- }
-
- virtual ~JITHelper() {
- if (TheFPM)
- delete TheFPM;
- if (TheExecutionEngine)
- delete TheExecutionEngine;
- }
-
- virtual Function *getFunction(const std::string FnName) {
- assert(TheModule);
- return TheModule->getFunction(FnName);
- }
-
- virtual Module *getModuleForNewFunction() {
- assert(TheModule);
- return TheModule;
- }
-
- virtual void *getPointerToFunction(Function* F) {
- assert(TheExecutionEngine);
- return TheExecutionEngine->getPointerToFunction(F);
- }
-
- virtual void *getPointerToNamedFunction(const std::string &Name) {
- return TheExecutionEngine->getPointerToNamedFunction(Name);
- }
-
- virtual void runFPM(Function &F) {
- assert(TheFPM);
- TheFPM->run(F);
- }
-
- virtual void closeCurrentModule() {
- // This should never be called for JIT
- assert(false);
- }
-
- virtual void dump() {
- assert(TheModule);
- TheModule->dump();
- }
-
-private:
- Module *TheModule;
- ExecutionEngine *TheExecutionEngine;
- FunctionPassManager *TheFPM;
-};
-
-//===----------------------------------------------------------------------===//
// MCJIT helper class
//===----------------------------------------------------------------------===//
@@ -1034,7 +939,6 @@ ExecutionEngine *MCJITHelper::compileModule(Module *M) {
std::string ErrStr;
ExecutionEngine *EE = EngineBuilder(M)
.setErrorStr(&ErrStr)
- .setUseMCJIT(true)
.setMCJITMemoryManager(new HelpingMemoryManager(this))
.create();
if (!EE) {
@@ -1194,10 +1098,8 @@ Value *UnaryExprAST::Codegen() {
Value *OperandV = Operand->Codegen();
if (OperandV == 0) return 0;
Function *F;
- if (UseMCJIT)
- F = TheHelper->getFunction(MakeLegalFunctionName(std::string("unary")+Opcode));
- else
- F = TheHelper->getFunction(std::string("unary")+Opcode);
+ F = TheHelper->getFunction(
+ MakeLegalFunctionName(std::string("unary") + Opcode));
if (F == 0)
return ErrorV("Unknown unary operator");
@@ -1246,10 +1148,7 @@ Value *BinaryExprAST::Codegen() {
// If it wasn't a builtin binary operator, it must be a user defined one. Emit
// a call to it.
Function *F;
- if (UseMCJIT)
- F = TheHelper->getFunction(MakeLegalFunctionName(std::string("binary")+Op));
- else
- F = TheHelper->getFunction(std::string("binary")+Op);
+ F = TheHelper->getFunction(MakeLegalFunctionName(std::string("binary")+Op));
assert(F && "binary operator not found!");
Value *Ops[] = { L, R };
@@ -1482,10 +1381,7 @@ Function *PrototypeAST::Codegen() {
Doubles, false);
std::string FnName;
- if (UseMCJIT)
- FnName = MakeLegalFunctionName(Name);
- else
- FnName = Name;
+ FnName = MakeLegalFunctionName(Name);
Module* M = TheHelper->getModuleForNewFunction();
Function *F = Function::Create(FT, Function::ExternalLinkage, FnName, M);
@@ -1560,10 +1456,6 @@ Function *FunctionAST::Codegen() {
// Validate the generated code, checking for consistency.
verifyFunction(*TheFunction);
- // Optimize the function.
- if (!UseMCJIT)
- TheHelper->runFPM(*TheFunction);
-
return TheFunction;
}
@@ -1581,7 +1473,7 @@ Function *FunctionAST::Codegen() {
static void HandleDefinition() {
if (FunctionAST *F = ParseDefinition()) {
- if (UseMCJIT && EnableLazyCompilation)
+ if (EnableLazyCompilation)
TheHelper->closeCurrentModule();
Function *LF = F->Codegen();
if (LF && VerboseOutput) {
@@ -1671,10 +1563,8 @@ double printlf() {
int main(int argc, char **argv) {
InitializeNativeTarget();
- if (UseMCJIT) {
- InitializeNativeTargetAsmPrinter();
- InitializeNativeTargetAsmParser();
- }
+ InitializeNativeTargetAsmPrinter();
+ InitializeNativeTargetAsmParser();
LLVMContext &Context = getGlobalContext();
cl::ParseCommandLineOptions(argc, argv,
@@ -1690,10 +1580,7 @@ int main(int argc, char **argv) {
BinopPrecedence['*'] = 40; // highest.
// Make the Helper, which holds all the code.
- if (UseMCJIT)
- TheHelper = new MCJITHelper(Context);
- else
- TheHelper = new JITHelper(Context);
+ TheHelper = new MCJITHelper(Context);
// Prime the first token.
if (!SuppressPrompts)
diff --git a/examples/Kaleidoscope/MCJIT/initial/toy.cpp b/examples/Kaleidoscope/MCJIT/initial/toy.cpp
index 4c47113..2c1b297 100644
--- a/examples/Kaleidoscope/MCJIT/initial/toy.cpp
+++ b/examples/Kaleidoscope/MCJIT/initial/toy.cpp
@@ -778,7 +778,6 @@ void *MCJITHelper::getPointerToFunction(Function* F) {
std::string ErrStr;
ExecutionEngine *NewEngine = EngineBuilder(OpenModule)
.setErrorStr(&ErrStr)
- .setUseMCJIT(true)
.setMCJITMemoryManager(new HelpingMemoryManager(this))
.create();
if (!NewEngine) {
diff --git a/examples/Kaleidoscope/MCJIT/lazy/toy-jit.cpp b/examples/Kaleidoscope/MCJIT/lazy/toy-jit.cpp
index 2d540dd..98c1001 100644
--- a/examples/Kaleidoscope/MCJIT/lazy/toy-jit.cpp
+++ b/examples/Kaleidoscope/MCJIT/lazy/toy-jit.cpp
@@ -2,7 +2,6 @@
#include "llvm/Analysis/Passes.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
-#include "llvm/ExecutionEngine/JIT.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/IRBuilder.h"
diff --git a/examples/Kaleidoscope/MCJIT/lazy/toy.cpp b/examples/Kaleidoscope/MCJIT/lazy/toy.cpp
index ff88e23..9c2a0d4 100644
--- a/examples/Kaleidoscope/MCJIT/lazy/toy.cpp
+++ b/examples/Kaleidoscope/MCJIT/lazy/toy.cpp
@@ -808,7 +808,6 @@ ExecutionEngine *MCJITHelper::compileModule(Module *M) {
std::string ErrStr;
ExecutionEngine *NewEngine = EngineBuilder(M)
.setErrorStr(&ErrStr)
- .setUseMCJIT(true)
.setMCJITMemoryManager(new HelpingMemoryManager(this))
.create();
if (!NewEngine) {
diff --git a/examples/ParallelJIT/CMakeLists.txt b/examples/ParallelJIT/CMakeLists.txt
index 8673917..07c0a08 100644
--- a/examples/ParallelJIT/CMakeLists.txt
+++ b/examples/ParallelJIT/CMakeLists.txt
@@ -2,7 +2,7 @@ set(LLVM_LINK_COMPONENTS
Core
ExecutionEngine
Interpreter
- JIT
+ MC
Support
nativecodegen
)
diff --git a/examples/ParallelJIT/Makefile b/examples/ParallelJIT/Makefile
index 8a49d42..0f2a357 100644
--- a/examples/ParallelJIT/Makefile
+++ b/examples/ParallelJIT/Makefile
@@ -10,7 +10,7 @@ LEVEL = ../..
TOOLNAME = ParallelJIT
EXAMPLE_TOOL = 1
-LINK_COMPONENTS := jit interpreter nativecodegen
+LINK_COMPONENTS := mcjit interpreter nativecodegen
include $(LEVEL)/Makefile.common
diff --git a/examples/ParallelJIT/ParallelJIT.cpp b/examples/ParallelJIT/ParallelJIT.cpp
index 2aa63d9..4ebf3d0 100644
--- a/examples/ParallelJIT/ParallelJIT.cpp
+++ b/examples/ParallelJIT/ParallelJIT.cpp
@@ -19,7 +19,6 @@
#include "llvm/ExecutionEngine/GenericValue.h"
#include "llvm/ExecutionEngine/Interpreter.h"
-#include "llvm/ExecutionEngine/JIT.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Instructions.h"
@@ -243,13 +242,14 @@ int main() {
LLVMContext Context;
// Create some module to put our function into it.
- Module *M = new Module("test", Context);
+ std::unique_ptr<Module> Owner = make_unique<Module>("test", Context);
+ Module *M = Owner.get();
Function* add1F = createAdd1( M );
Function* fibF = CreateFibFunction( M );
// Now we create the JIT.
- ExecutionEngine* EE = EngineBuilder(M).create();
+ ExecutionEngine* EE = EngineBuilder(std::move(Owner)).create();
//~ std::cout << "We just constructed this LLVM module:\n\n" << *M;
//~ std::cout << "\n\nRunning foo: " << std::flush;