fixed: false backend error generation

This commit is contained in:
Sven Vogel 2024-06-06 11:55:21 +02:00
parent b843a9aa79
commit b33e769cf8
2 changed files with 9 additions and 10 deletions

View File

@ -1,10 +1,10 @@
#include <codegen/backend.h> #include <codegen/backend.h>
#include <set/types.h>
#include <sys/log.h>
#include <llvm/parser.h>
#include <llvm/llvm-ir/types.h>
#include <llvm-c/Core.h> #include <llvm-c/Core.h>
#include <llvm-c/Types.h> #include <llvm-c/Types.h>
#include <llvm/llvm-ir/types.h>
#include <llvm/parser.h>
#include <set/types.h>
#include <sys/log.h>
#define BASE_BYTES 4 #define BASE_BYTES 4
#define BITS_PER_BYTE 8 #define BITS_PER_BYTE 8
@ -358,6 +358,7 @@ BackendError get_reference_default_value(LLVMTypeRef llvm_type,
BackendError get_box_default_value(LLVMBackendCompileUnit* unit, BackendError get_box_default_value(LLVMBackendCompileUnit* unit,
LLVMGlobalScope* scope, BoxType* type, LLVMGlobalScope* scope, BoxType* type,
LLVMTypeRef llvm_type,
LLVMValueRef* llvm_value) { LLVMValueRef* llvm_value) {
DEBUG("building box default value..."); DEBUG("building box default value...");
GHashTableIter iterator; GHashTableIter iterator;
@ -383,8 +384,8 @@ BackendError get_box_default_value(LLVMBackendCompileUnit* unit,
DEBUG("build %ld member default values", constants->len); DEBUG("build %ld member default values", constants->len);
*llvm_value = LLVMConstStructInContext( *llvm_value = LLVMConstNamedStruct(
unit->context, (LLVMValueRef*)constants->data, constants->len, 0); llvm_type, (LLVMValueRef*)constants->data, constants->len);
g_array_free(constants, FALSE); g_array_free(constants, FALSE);
@ -417,7 +418,7 @@ BackendError get_type_default_value(LLVMBackendCompileUnit* unit,
break; break;
case TypeKindBox: case TypeKindBox:
err = get_box_default_value(unit, scope, &gemstone_type->impl.box, err = get_box_default_value(unit, scope, &gemstone_type->impl.box,
llvm_value); llvm_type, llvm_value);
break; break;
default: default:
PANIC("invalid type kind: %ld", gemstone_type->kind); PANIC("invalid type kind: %ld", gemstone_type->kind);

View File

@ -207,9 +207,7 @@ static BackendError build_module(LLVMBackendCompileUnit* unit,
err = impl_functions(unit, global_scope, module->functions); err = impl_functions(unit, global_scope, module->functions);
char* error = NULL; char* error = NULL;
LLVMVerifyModule(unit->module, LLVMAbortProcessAction, &error); if (LLVMVerifyModule(unit->module, LLVMAbortProcessAction, &error)) {
if (error) {
print_message(Error, "Unable to compile due to: %s", error); print_message(Error, "Unable to compile due to: %s", error);
LLVMDisposeMessage(error); LLVMDisposeMessage(error);
err = new_backend_impl_error(Implementation, NULL, "LLVM backend verification error, see stdout"); err = new_backend_impl_error(Implementation, NULL, "LLVM backend verification error, see stdout");