forked from OSchip/llvm-project
parent
fa5942bc2c
commit
e93dc3be1b
|
@ -1,4 +1,4 @@
|
||||||
set(LLVM_LINK_COMPONENTS jit nativecodegen)
|
set(LLVM_LINK_COMPONENTS jit mcjit nativecodegen)
|
||||||
set(LLVM_REQUIRES_EH 1)
|
set(LLVM_REQUIRES_EH 1)
|
||||||
|
|
||||||
add_llvm_example(ExceptionDemo
|
add_llvm_example(ExceptionDemo
|
||||||
|
|
|
@ -49,8 +49,8 @@
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "llvm/Analysis/Verifier.h"
|
#include "llvm/Analysis/Verifier.h"
|
||||||
#include "llvm/ExecutionEngine/ExecutionEngine.h"
|
#include "llvm/ExecutionEngine/MCJIT.h"
|
||||||
#include "llvm/ExecutionEngine/JIT.h"
|
#include "llvm/ExecutionEngine/SectionMemoryManager.h"
|
||||||
#include "llvm/IR/DataLayout.h"
|
#include "llvm/IR/DataLayout.h"
|
||||||
#include "llvm/IR/DerivedTypes.h"
|
#include "llvm/IR/DerivedTypes.h"
|
||||||
#include "llvm/IR/IRBuilder.h"
|
#include "llvm/IR/IRBuilder.h"
|
||||||
|
@ -1953,17 +1953,22 @@ int main(int argc, char *argv[]) {
|
||||||
Opts.JITExceptionHandling = true;
|
Opts.JITExceptionHandling = true;
|
||||||
|
|
||||||
llvm::InitializeNativeTarget();
|
llvm::InitializeNativeTarget();
|
||||||
|
llvm::InitializeNativeTargetAsmPrinter();
|
||||||
llvm::LLVMContext &context = llvm::getGlobalContext();
|
llvm::LLVMContext &context = llvm::getGlobalContext();
|
||||||
llvm::IRBuilder<> theBuilder(context);
|
llvm::IRBuilder<> theBuilder(context);
|
||||||
|
|
||||||
// Make the module, which holds all the code.
|
// Make the module, which holds all the code.
|
||||||
llvm::Module *module = new llvm::Module("my cool jit", context);
|
llvm::Module *module = new llvm::Module("my cool jit", context);
|
||||||
|
|
||||||
|
llvm::JITMemoryManager *MemMgr = new llvm::SectionMemoryManager();
|
||||||
|
|
||||||
// Build engine with JIT
|
// Build engine with JIT
|
||||||
llvm::EngineBuilder factory(module);
|
llvm::EngineBuilder factory(module);
|
||||||
factory.setEngineKind(llvm::EngineKind::JIT);
|
factory.setEngineKind(llvm::EngineKind::JIT);
|
||||||
factory.setAllocateGVsWithCode(false);
|
factory.setAllocateGVsWithCode(false);
|
||||||
factory.setTargetOptions(Opts);
|
factory.setTargetOptions(Opts);
|
||||||
|
factory.setJITMemoryManager(MemMgr);
|
||||||
|
factory.setUseMCJIT(true);
|
||||||
llvm::ExecutionEngine *executionEngine = factory.create();
|
llvm::ExecutionEngine *executionEngine = factory.create();
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -2007,6 +2012,8 @@ int main(int argc, char *argv[]) {
|
||||||
fpm,
|
fpm,
|
||||||
"throwCppException");
|
"throwCppException");
|
||||||
|
|
||||||
|
executionEngine->finalizeObject();
|
||||||
|
|
||||||
fprintf(stderr, "\nBegin module dump:\n\n");
|
fprintf(stderr, "\nBegin module dump:\n\n");
|
||||||
|
|
||||||
module->dump();
|
module->dump();
|
||||||
|
|
Loading…
Reference in New Issue