diff --git a/src/llvm/llvm-ir/types.c b/src/llvm/llvm-ir/types.c index 76dcce1..3e4892d 100644 --- a/src/llvm/llvm-ir/types.c +++ b/src/llvm/llvm-ir/types.c @@ -1,10 +1,10 @@ #include -#include -#include -#include -#include #include #include +#include +#include +#include +#include #define BASE_BYTES 4 #define BITS_PER_BYTE 8 @@ -358,6 +358,7 @@ BackendError get_reference_default_value(LLVMTypeRef llvm_type, BackendError get_box_default_value(LLVMBackendCompileUnit* unit, LLVMGlobalScope* scope, BoxType* type, + LLVMTypeRef llvm_type, LLVMValueRef* llvm_value) { DEBUG("building box default value..."); GHashTableIter iterator; @@ -383,8 +384,8 @@ BackendError get_box_default_value(LLVMBackendCompileUnit* unit, DEBUG("build %ld member default values", constants->len); - *llvm_value = LLVMConstStructInContext( - unit->context, (LLVMValueRef*)constants->data, constants->len, 0); + *llvm_value = LLVMConstNamedStruct( + llvm_type, (LLVMValueRef*)constants->data, constants->len); g_array_free(constants, FALSE); @@ -417,7 +418,7 @@ BackendError get_type_default_value(LLVMBackendCompileUnit* unit, break; case TypeKindBox: err = get_box_default_value(unit, scope, &gemstone_type->impl.box, - llvm_value); + llvm_type, llvm_value); break; default: PANIC("invalid type kind: %ld", gemstone_type->kind); diff --git a/src/llvm/parser.c b/src/llvm/parser.c index 7ca9545..02cd5a8 100644 --- a/src/llvm/parser.c +++ b/src/llvm/parser.c @@ -207,9 +207,7 @@ static BackendError build_module(LLVMBackendCompileUnit* unit, err = impl_functions(unit, global_scope, module->functions); char* error = NULL; - LLVMVerifyModule(unit->module, LLVMAbortProcessAction, &error); - - if (error) { + if (LLVMVerifyModule(unit->module, LLVMAbortProcessAction, &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");