summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-05-05 20:57:58 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-05-05 20:57:58 +0000
commitc8b9551a8fe52cefbefeac820c81996281fff4e5 (patch)
tree69bc75e16c2012f723f35ab90b7097b59e8eda8a /examples
parenta2e40fbd624916c187a95ed76939ca7f02ed3e53 (diff)
downloadexternal_llvm-c8b9551a8fe52cefbefeac820c81996281fff4e5.zip
external_llvm-c8b9551a8fe52cefbefeac820c81996281fff4e5.tar.gz
external_llvm-c8b9551a8fe52cefbefeac820c81996281fff4e5.tar.bz2
Port ExceptionDemo to MCJIT.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181168 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'examples')
-rw-r--r--examples/ExceptionDemo/CMakeLists.txt2
-rw-r--r--examples/ExceptionDemo/ExceptionDemo.cpp11
2 files changed, 10 insertions, 3 deletions
diff --git a/examples/ExceptionDemo/CMakeLists.txt b/examples/ExceptionDemo/CMakeLists.txt
index 432e683..ea818fa 100644
--- a/examples/ExceptionDemo/CMakeLists.txt
+++ b/examples/ExceptionDemo/CMakeLists.txt
@@ -1,4 +1,4 @@
-set(LLVM_LINK_COMPONENTS jit nativecodegen)
+set(LLVM_LINK_COMPONENTS jit mcjit nativecodegen)
set(LLVM_REQUIRES_EH 1)
add_llvm_example(ExceptionDemo
diff --git a/examples/ExceptionDemo/ExceptionDemo.cpp b/examples/ExceptionDemo/ExceptionDemo.cpp
index 0bd49a3..f9498a5 100644
--- a/examples/ExceptionDemo/ExceptionDemo.cpp
+++ b/examples/ExceptionDemo/ExceptionDemo.cpp
@@ -49,8 +49,8 @@
//===----------------------------------------------------------------------===//
#include "llvm/Analysis/Verifier.h"
-#include "llvm/ExecutionEngine/ExecutionEngine.h"
-#include "llvm/ExecutionEngine/JIT.h"
+#include "llvm/ExecutionEngine/MCJIT.h"
+#include "llvm/ExecutionEngine/SectionMemoryManager.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/IRBuilder.h"
@@ -1953,17 +1953,22 @@ int main(int argc, char *argv[]) {
Opts.JITExceptionHandling = true;
llvm::InitializeNativeTarget();
+ llvm::InitializeNativeTargetAsmPrinter();
llvm::LLVMContext &context = llvm::getGlobalContext();
llvm::IRBuilder<> theBuilder(context);
// Make the module, which holds all the code.
llvm::Module *module = new llvm::Module("my cool jit", context);
+ llvm::JITMemoryManager *MemMgr = new llvm::SectionMemoryManager();
+
// Build engine with JIT
llvm::EngineBuilder factory(module);
factory.setEngineKind(llvm::EngineKind::JIT);
factory.setAllocateGVsWithCode(false);
factory.setTargetOptions(Opts);
+ factory.setJITMemoryManager(MemMgr);
+ factory.setUseMCJIT(true);
llvm::ExecutionEngine *executionEngine = factory.create();
{
@@ -2007,6 +2012,8 @@ int main(int argc, char *argv[]) {
fpm,
"throwCppException");
+ executionEngine->finalizeObject();
+
fprintf(stderr, "\nBegin module dump:\n\n");
module->dump();