Commit 431f245c authored by Robert Kimball's avatar Robert Kimball

fix codegen to not segfault if compile failed

parent 0d26f380
......@@ -193,14 +193,15 @@ std::unique_ptr<llvm::Module> execution_state::compile(const string& source, con
// Create and execute action
CodeGenAction* compilerAction = new EmitCodeGenOnlyAction();
if (Clang->ExecuteAction(*compilerAction) == false)
std::unique_ptr<llvm::Module> rc;
if (Clang->ExecuteAction(*compilerAction) == true)
{
throw runtime_error("codegen compile failed");
rc = compilerAction->takeModule();
}
buffer.release();
return compilerAction->takeModule();
return rc;
}
bool execution_state::add_module(std::unique_ptr<llvm::Module>& module)
......
This diff is collapsed.
......@@ -371,7 +371,10 @@ extern "C" void free_aligned_buffer(void* allocated);
#endif
auto llvm_module = estate.compile(code, "__ngcpu_codegen.cpp");
assert(llvm_module);
if (llvm_module == nullptr)
{
throw runtime_error("function failed to compile");
}
estate.add_module(llvm_module);
estate.finalize();
m_compiled_function = estate.find_function<EntryPoint_t>(function_name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment