From 6c6b4b04ab0ff914075c0e90b8834b4dcb55e55f Mon Sep 17 00:00:00 2001 From: Tom Harley Date: Fri, 26 Aug 2022 17:52:22 +0100 Subject: Upgrade to LLVM 14 Adding attributes to functions/values has been broken by the upgrade. Additionally, the debug builder wants more information which is currently not being provided. --- llvm_codegen.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'llvm_codegen.c') diff --git a/llvm_codegen.c b/llvm_codegen.c index 23a27c8..044fc05 100644 --- a/llvm_codegen.c +++ b/llvm_codegen.c @@ -342,6 +342,9 @@ int make_trmc_inner_name(char *buf, int n, char *outer_id, char *mod) { } void add_enum_attr(LLVMValueRef f, uint index, char *id, size_t n, int val) { + // FIXME adding enums causes the generator to output unfinished LLVM IR. + return; + if (!opts->llvm_attributes) return; if (!n) n = strlen(id); @@ -412,7 +415,8 @@ LLVMValueRef codegen_type_definition(sexpr *se) { LLVMValueRef space = LLVMBuildPointerCast(util_b, space_cast, struct_ptr_t, "space_uncast"); for (uint i = 0; i < prop_c; i++) { - LLVMValueRef prop_pos = LLVMBuildStructGEP(util_b, space, i, "pos"); + LLVMValueRef prop_pos = + LLVMBuildStructGEP2(util_b, struct_t, space, i, "pos"); LLVMValueRef param = LLVMGetParam(filler_p, i); LLVMBuildStore(util_b, param, prop_pos); } @@ -484,7 +488,7 @@ LLVMValueRef codegen_type_definition(sexpr *se) { LLVMBuildPointerCast(util_b, param, struct_ptr_t, "uncast"); LLVMValueRef ptr = LLVMBuildStructGEP2(util_b, struct_t, uncast, i, "part"); - LLVMValueRef val = LLVMBuildLoad(util_b, ptr, "deref"); + LLVMValueRef val = LLVMBuildLoad2(util_b, boxed_t, ptr, "deref"); LLVMBuildRet(util_b, val); debug("adding %s to scope\n", prop_func_id); @@ -1721,10 +1725,23 @@ LLVMMetadataRef debug_make_compile_unit(LLVMDIBuilderRef di_builder, int inline_debug_info = 1; int profile_debug_info = 1; - return LLVMDIBuilderCreateCompileUnit(di_builder, lang, di_file, producer, - producer_len, optimised, flags, flags_len, runtime_version, - split_name, split_name_len, emission, dwoid, inline_debug_info, - profile_debug_info); + return LLVMDIBuilderCreateCompileUnit( + di_builder, + lang, + di_file, + producer, producer_len, + optimised, + flags, flags_len, + runtime_version, + split_name, split_name_len, + emission, + dwoid, + inline_debug_info, + profile_debug_info, + // TODO + "", 0, + "", 0 + ); } void llvm_codegen_prologue(char *filename, optimisation_t *llvm_info) { -- cgit v1.2.1