diff --git a/src/llvm/parser.c b/src/llvm/parser.c index 57c989e..ae86e32 100644 --- a/src/llvm/parser.c +++ b/src/llvm/parser.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -203,6 +204,15 @@ static BackendError build_module(LLVMBackendCompileUnit* unit, // TODO: implement functions err = impl_functions(unit, global_scope, module->functions); + char* error = NULL; + LLVMVerifyModule(unit->module, LLVMAbortProcessAction, &error); + + if (error) { + print_message(Error, "Unable to compile due to: %s", error); + LLVMDisposeMessage(error); + err = new_backend_impl_error(Implementation, NULL, "LLVM backend verification error, see stdout"); + } + return err; }