llvm.org GIT mirror llvm / c8b9551
Port ExceptionDemo to MCJIT. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181168 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 6 years ago
2 changed file(s) with 10 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
None set(LLVM_LINK_COMPONENTS jit nativecodegen)
0 set(LLVM_LINK_COMPONENTS jit mcjit nativecodegen)
11 set(LLVM_REQUIRES_EH 1)
22
33 add_llvm_example(ExceptionDemo
4848 //===----------------------------------------------------------------------===//
4949
5050 #include "llvm/Analysis/Verifier.h"
51 #include "llvm/ExecutionEngine/ExecutionEngine.h"
52 #include "llvm/ExecutionEngine/JIT.h"
51 #include "llvm/ExecutionEngine/MCJIT.h"
52 #include "llvm/ExecutionEngine/SectionMemoryManager.h"
5353 #include "llvm/IR/DataLayout.h"
5454 #include "llvm/IR/DerivedTypes.h"
5555 #include "llvm/IR/IRBuilder.h"
19521952 Opts.JITExceptionHandling = true;
19531953
19541954 llvm::InitializeNativeTarget();
1955 llvm::InitializeNativeTargetAsmPrinter();
19551956 llvm::LLVMContext &context = llvm::getGlobalContext();
19561957 llvm::IRBuilder<> theBuilder(context);
19571958
19581959 // Make the module, which holds all the code.
19591960 llvm::Module *module = new llvm::Module("my cool jit", context);
1961
1962 llvm::JITMemoryManager *MemMgr = new llvm::SectionMemoryManager();
19601963
19611964 // Build engine with JIT
19621965 llvm::EngineBuilder factory(module);
19631966 factory.setEngineKind(llvm::EngineKind::JIT);
19641967 factory.setAllocateGVsWithCode(false);
19651968 factory.setTargetOptions(Opts);
1969 factory.setJITMemoryManager(MemMgr);
1970 factory.setUseMCJIT(true);
19661971 llvm::ExecutionEngine *executionEngine = factory.create();
19671972
19681973 {
20062011 fpm,
20072012 "throwCppException");
20082013
2014 executionEngine->finalizeObject();
2015
20092016 fprintf(stderr, "\nBegin module dump:\n\n");
20102017
20112018 module->dump();