[llvm] r181168 - Port ExceptionDemo to MCJIT.

Rafael Espindola rafael.espindola at gmail.com
Sun May 5 13:57:58 PDT 2013


Author: rafael
Date: Sun May  5 15:57:58 2013
New Revision: 181168

URL: http://llvm.org/viewvc/llvm-project?rev=181168&view=rev
Log:
Port ExceptionDemo to MCJIT.

Modified:
    llvm/trunk/examples/ExceptionDemo/CMakeLists.txt
    llvm/trunk/examples/ExceptionDemo/ExceptionDemo.cpp

Modified: llvm/trunk/examples/ExceptionDemo/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/ExceptionDemo/CMakeLists.txt?rev=181168&r1=181167&r2=181168&view=diff
==============================================================================
--- llvm/trunk/examples/ExceptionDemo/CMakeLists.txt (original)
+++ llvm/trunk/examples/ExceptionDemo/CMakeLists.txt Sun May  5 15:57:58 2013
@@ -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

Modified: llvm/trunk/examples/ExceptionDemo/ExceptionDemo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/ExceptionDemo/ExceptionDemo.cpp?rev=181168&r1=181167&r2=181168&view=diff
==============================================================================
--- llvm/trunk/examples/ExceptionDemo/ExceptionDemo.cpp (original)
+++ llvm/trunk/examples/ExceptionDemo/ExceptionDemo.cpp Sun May  5 15:57:58 2013
@@ -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();





More information about the llvm-commits mailing list