diff --git a/include/ravi_llvmcodegen.h b/include/ravi_llvmcodegen.h index 21062da6..9bab3aea 100644 --- a/include/ravi_llvmcodegen.h +++ b/include/ravi_llvmcodegen.h @@ -374,7 +374,7 @@ class RAVI_API RaviJITStateImpl : public RaviJITState { // map of names to functions std::map functions_; - llvm::LLVMContext &context_; + llvm::LLVMContext *context_; // The triple represents the host target std::string triple_; @@ -420,7 +420,7 @@ class RAVI_API RaviJITStateImpl : public RaviJITState { void addGlobalSymbol(const std::string &name, void *address); virtual void dump(); - virtual llvm::LLVMContext &context() { return context_; } + virtual llvm::LLVMContext &context() { return *context_; } LuaLLVMTypes *types() const { return types_; } const std::string &triple() const { return triple_; } bool is_auto() const { return auto_; } diff --git a/src/ravi_llvmjit.cpp b/src/ravi_llvmjit.cpp index 1abc1843..af945c65 100644 --- a/src/ravi_llvmjit.cpp +++ b/src/ravi_llvmjit.cpp @@ -42,7 +42,7 @@ RaviJITState *RaviJITFunctionImpl::owner() const { return owner_; } // lua_State - all compilation activity happens // in the context of the JIT State RaviJITStateImpl::RaviJITStateImpl() - : context_(llvm::getGlobalContext()), auto_(false), enabled_(true), + : auto_(false), enabled_(true), opt_level_(2), size_level_(0), min_code_size_(150), min_exec_count_(50), gc_step_(200) { // LLVM needs to be initialized else @@ -64,7 +64,8 @@ RaviJITStateImpl::RaviJITStateImpl() // format; LLVM 3.7 onwards COEFF is supported triple_ += "-elf"; #endif - types_ = new LuaLLVMTypes(context_); + context_ = new llvm::LLVMContext(); + types_ = new LuaLLVMTypes(*context_); } // Destroy the JIT state freeing up any @@ -79,6 +80,7 @@ RaviJITStateImpl::~RaviJITStateImpl() { delete todelete[i]; } delete types_; + delete context_; } void RaviJITStateImpl::addGlobalSymbol(const std::string &name, void *address) {