From 30230249ae12c1b70ea7039596f7cb5d0a8f692a Mon Sep 17 00:00:00 2001 From: servostar Date: Wed, 5 Jun 2024 21:38:46 +0200 Subject: [PATCH] added: verification of llvm module after compilation --- src/llvm/parser.c | 10 ++++++++++ 1 file changed, 10 insertions(+) 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; }