From dbdeb0205b61e8f27657f5a379e1e2710d890158 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Tue, 18 Jan 2022 11:13:20 +0800 Subject: [PATCH] Defer all code generation until elaboration --- lib/ieee.08/Makemodule.am | 21 ----- lib/ieee/Makemodule.am | 19 ---- lib/nvc.08/Makemodule.am | 16 ---- lib/nvc/Makemodule.am | 16 ---- lib/std.08/Makemodule.am | 17 ---- lib/std/Makemodule.am | 16 ---- lib/synopsys/Makemodule.am | 24 ----- lib/vital/Makemodule.am | 17 ---- src/cgen.c | 185 +++++++++++++++++++++---------------- src/debug.c | 78 ++++++++++------ src/lower.c | 11 +-- src/nvc.c | 11 --- src/rt/jit.c | 6 +- src/rt/rtkern.c | 11 --- test/regress/testlist.txt | 2 +- 15 files changed, 162 insertions(+), 288 deletions(-) diff --git a/lib/ieee.08/Makemodule.am b/lib/ieee.08/Makemodule.am index 54cdd96e..0e7764ce 100644 --- a/lib/ieee.08/Makemodule.am +++ b/lib/ieee.08/Makemodule.am @@ -18,27 +18,6 @@ ieee_08_DATA = \ lib/ieee.08/IEEE.MATH_COMPLEX \ lib/ieee.08/IEEE.MATH_COMPLEX-body -ieee_08_so = \ - lib/ieee.08/_IEEE.NUMERIC_STD.$(DLL_EXT) \ - lib/ieee.08/_IEEE.NUMERIC_STD_UNSIGNED.$(DLL_EXT) \ - lib/ieee.08/_IEEE.NUMERIC_BIT.$(DLL_EXT) \ - lib/ieee.08/_IEEE.NUMERIC_BIT_UNSIGNED.$(DLL_EXT) \ - lib/ieee.08/_IEEE.STD_LOGIC_1164.$(DLL_EXT) \ - lib/ieee.08/_IEEE.MATH_REAL.$(DLL_EXT) \ - lib/ieee.08/_IEEE.MATH_COMPLEX.$(DLL_EXT) - -if IMPLIB_REQUIRED - -# Using SCRIPTS rather than data ensures execute bit gets set on Cygwin -ieee_08_SCRIPTS = $(ieee_08_so) - -$(ieee_08_SCRIPTS) : $(ieee_08_DATA) -else - -ieee_08_DATA += $(ieee_08_so) - -endif # IMPLIB_REQUIRED - EXTRA_DIST += \ lib/ieee.08/numeric_bit.vhdl \ lib/ieee.08/numeric_bit-body.vhdl \ diff --git a/lib/ieee/Makemodule.am b/lib/ieee/Makemodule.am index a7f9f7d6..b97f3d56 100644 --- a/lib/ieee/Makemodule.am +++ b/lib/ieee/Makemodule.am @@ -13,25 +13,6 @@ ieee_DATA = \ lib/ieee/IEEE.MATH_COMPLEX \ lib/ieee/IEEE.MATH_COMPLEX-body -ieee_so = \ - lib/ieee/_IEEE.NUMERIC_STD.$(DLL_EXT) \ - lib/ieee/_IEEE.NUMERIC_BIT.$(DLL_EXT) \ - lib/ieee/_IEEE.STD_LOGIC_1164.$(DLL_EXT) \ - lib/ieee/_IEEE.MATH_REAL.$(DLL_EXT) \ - lib/ieee/_IEEE.MATH_COMPLEX.$(DLL_EXT) - -if IMPLIB_REQUIRED - -# Using SCRIPTS rather than data ensures execute bit gets set on Cygwin -ieee_SCRIPTS = $(ieee_so) - -$(ieee_SCRIPTS) : $(ieee_DATA) -else - -ieee_DATA += $(ieee_so) - -endif # IMPLIB_REQUIRED - EXTRA_DIST += \ lib/ieee/numeric_bit.vhdl \ lib/ieee/math_complex-body.vhdl \ diff --git a/lib/nvc.08/Makemodule.am b/lib/nvc.08/Makemodule.am index 54666347..8ec5d1bb 100644 --- a/lib/nvc.08/Makemodule.am +++ b/lib/nvc.08/Makemodule.am @@ -5,22 +5,6 @@ nvc_08_DATA = \ lib/nvc.08/NVC.SIM_PKG \ lib/nvc.08/NVC.POLYFILL -nvc_08_so = \ - lib/nvc.08/_NVC.SIM_PKG.$(DLL_EXT) \ - lib/nvc.08/_NVC.POLYFILL.$(DLL_EXT) - -if IMPLIB_REQUIRED - -# Using SCRIPTS rather than data ensures execute bit gets set on Cygwin -nvc_08_SCRIPTS = $(nvc_08_so) - -$(nvc_08_SCRIPTS) : $(nvc_08_DATA) -else - -nvc_08_DATA += $(nvc_08_so) - -endif # IMPLIB_REQUIRED - EXTRA_DIST += \ lib/nvc.08/polyfill.vhd diff --git a/lib/nvc/Makemodule.am b/lib/nvc/Makemodule.am index 74f8d9d4..c8fce24c 100644 --- a/lib/nvc/Makemodule.am +++ b/lib/nvc/Makemodule.am @@ -6,22 +6,6 @@ nvc_DATA = \ lib/nvc/NVC.POLYFILL \ lib/nvc/NVC.POLYFILL-body -nvc_so = \ - lib/nvc/_NVC.SIM_PKG.$(DLL_EXT) \ - lib/nvc/_NVC.POLYFILL.$(DLL_EXT) - -if IMPLIB_REQUIRED - -# Using SCRIPTS rather than data ensures execute bit gets set on Cygwin -nvc_SCRIPTS = $(nvc_so) - -$(nvc_SCRIPTS) : $(nvc_DATA) -else - -nvc_DATA += $(nvc_so) - -endif # IMPLIB_REQUIRED - EXTRA_DIST += \ lib/nvc/sim_pkg.vhd \ lib/nvc/polyfill.vhd \ diff --git a/lib/std.08/Makemodule.am b/lib/std.08/Makemodule.am index e36f2c32..6335a15b 100644 --- a/lib/std.08/Makemodule.am +++ b/lib/std.08/Makemodule.am @@ -8,23 +8,6 @@ std_08_DATA = \ lib/std.08/STD.ENV \ lib/std.08/STD.ENV-body -std_08_so = \ - lib/std.08/_STD.STANDARD.$(DLL_EXT) \ - lib/std.08/_STD.TEXTIO.$(DLL_EXT) \ - lib/std.08/_STD.ENV.$(DLL_EXT) - -if IMPLIB_REQUIRED - -# Using SCRIPTS rather than data ensures execute bit gets set on Cygwin -std_08_SCRIPTS = $(std_08_so) - -$(std_08_SCRIPTS) : $(std_08_DATA) -else - -std_08_DATA += $(std_08_so) - -endif # IMPLIB_REQUIRED - EXTRA_DIST += \ lib/std.08/standard.vhd \ lib/std.08/env.vhd \ diff --git a/lib/std/Makemodule.am b/lib/std/Makemodule.am index 21c2ffeb..23778f7d 100644 --- a/lib/std/Makemodule.am +++ b/lib/std/Makemodule.am @@ -6,22 +6,6 @@ std_DATA = \ lib/std/STD.TEXTIO \ lib/std/STD.TEXTIO-body -std_so = \ - lib/std/_STD.STANDARD.$(DLL_EXT) \ - lib/std/_STD.TEXTIO.$(DLL_EXT) - -if IMPLIB_REQUIRED - -# Using SCRIPTS rather than data ensures execute bit gets set on Cygwin -std_SCRIPTS = $(std_so) - -$(std_SCRIPTS) : $(std_DATA) -else - -std_DATA += $(std_so) - -endif # IMPLIB_REQUIRED - EXTRA_DIST += lib/std/standard.vhd lib/std/textio.vhd lib/std/textio-body.vhd BOOTSTRAPLIBS += $(std_DATA) diff --git a/lib/synopsys/Makemodule.am b/lib/synopsys/Makemodule.am index 6c3da22e..29edd515 100644 --- a/lib/synopsys/Makemodule.am +++ b/lib/synopsys/Makemodule.am @@ -26,30 +26,6 @@ synopsys_DATA = \ lib/synopsys/_index \ lib/synopsys/SYNOPSYS.ATTRIBUTES -synopsys_ieee_so = \ - lib/ieee/_IEEE.STD_LOGIC_ARITH.$(DLL_EXT) \ - lib/ieee/_IEEE.STD_LOGIC_SIGNED.$(DLL_EXT) \ - lib/ieee/_IEEE.STD_LOGIC_UNSIGNED.$(DLL_EXT) \ - lib/ieee/_IEEE.STD_LOGIC_TEXTIO.$(DLL_EXT) \ - lib/ieee/_IEEE.STD_LOGIC_MISC.$(DLL_EXT) - -synopsys_ieee_08_so = \ - lib/ieee.08/_IEEE.STD_LOGIC_ARITH.$(DLL_EXT) \ - lib/ieee.08/_IEEE.STD_LOGIC_SIGNED.$(DLL_EXT) \ - lib/ieee.08/_IEEE.STD_LOGIC_UNSIGNED.$(DLL_EXT) - -if IMPLIB_REQUIRED - -# Using SCRIPTS rather than data ensures execute bit gets set on Cygwin -synopsys_ieee_SCRIPTS = $(synopsys_ieee_so) $(synopsys_ieee_08_so) - -$(synopsys_ieee_SCRIPTS) : $(synopsys_ieee_DATA) $(synopsys_ieee_08_DATA) -else - -synopsys_ieee_DATA += $(synopsys_ieee_so) #$(synopsys_ieee_08_so) - -endif # IMPLIB_REQUIRED - EXTRA_DIST += lib/synopsys/std_logic_arith.vhd lib/synopsys/std_logic_misc.vhd \ lib/synopsys/std_logic_misc.vhd lib/synopsys/std_logic_signed.vhd \ lib/synopsys/std_logic_unsigned.vhd lib/synopsys/std_logic_textio.vhd \ diff --git a/lib/vital/Makemodule.am b/lib/vital/Makemodule.am index e2011161..b464cbc9 100644 --- a/lib/vital/Makemodule.am +++ b/lib/vital/Makemodule.am @@ -10,23 +10,6 @@ vital_DATA = \ lib/ieee/IEEE.VITAL_PRIMITIVES-body \ lib/ieee/IEEE.VITAL_MEMORY \ lib/ieee/IEEE.VITAL_MEMORY-body - -vital_so = \ - lib/ieee/_IEEE.VITAL_TIMING.$(DLL_EXT) \ - lib/ieee/_IEEE.VITAL_PRIMITIVES.$(DLL_EXT) \ - lib/ieee/_IEEE.VITAL_MEMORY.$(DLL_EXT) - -if IMPLIB_REQUIRED - -# Using SCRIPTS rather than data ensures execute bit gets set on Cygwin -vital_SCRIPTS = $(vital_so) - -$(vital_SCRIPTS) : $(vital_DATA) -else - -vital_DATA += $(vital_so) - -endif # IMPLIB_REQUIRED endif # ENABLE_VITAL EXTRA_DIST += \ diff --git a/src/cgen.c b/src/cgen.c index 0b611f54..a38d8674 100644 --- a/src/cgen.c +++ b/src/cgen.c @@ -617,6 +617,8 @@ static void cgen_debug_push_func(cgen_ctx_t *ctx) LOCAL_TEXT_BUF symbol = safe_symbol(vcode_unit_name()); const loc_t *loc = vcode_unit_loc(); + assert(!loc_invalid_p(loc)); + LLVMMetadataRef file_ref = cgen_debug_file(loc, true); LLVMMetadataRef dtype = LLVMDIBuilderCreateSubroutineType( debuginfo, file_ref, NULL, 0, 0); @@ -2844,9 +2846,6 @@ static void cgen_op_link_var(int op, cgen_ctx_t *ctx) offset = LLVMAddGlobal(module, llvm_int32_type(), offset_name); LLVMSetLinkage(offset, LLVMExternalLinkage); LLVMSetGlobalConstant(offset, true); -#ifdef IMPLIB_REQUIRED - LLVMSetDLLStorageClass(global, LLVMDLLImportStorageClass); -#endif } LLVMValueRef base_ptr = llvm_void_cast(LLVMBuildLoad(builder, global, "")); @@ -3399,7 +3398,13 @@ static void cgen_global_offsets(LLVMTypeRef state_type) if (vcode_var_flags(i) & VAR_GLOBAL) { LOCAL_TEXT_BUF symbol = safe_symbol(vcode_var_name(i)); char *name LOCAL = xasprintf("__offset_%s", tb_get(symbol)); - LLVMValueRef global = LLVMAddGlobal(module, llvm_int32_type(), name); + + LLVMValueRef global = LLVMGetNamedGlobal(module, name); + if (global == NULL) + global = LLVMAddGlobal(module, llvm_int32_type(), name); + else + assert(LLVMGetInitializer(global) == NULL); + #ifdef IMPLIB_REQUIRED LLVMSetDLLStorageClass(global, LLVMDLLExportStorageClass); #endif @@ -3725,9 +3730,14 @@ static void cgen_reset_function(void) LOCAL_TEXT_BUF name = tb_new(); ident_str(vcode_unit_name(), name); - LLVMValueRef global = LLVMAddGlobal(module, - LLVMPointerType(state_type, 0), - tb_get(name)); + LLVMValueRef global = LLVMGetNamedGlobal(module, tb_get(name)); + if (global == NULL) + global = LLVMAddGlobal(module, + LLVMPointerType(state_type, 0), + tb_get(name)); + else + assert(LLVMGetInitializer(global) == NULL); + LLVMSetInitializer(global, LLVMGetUndef(LLVMPointerType(state_type, 0))); #ifdef IMPLIB_REQUIRED LLVMSetDLLStorageClass(global, LLVMDLLExportStorageClass); @@ -3771,7 +3781,7 @@ static void cgen_coverage_state(tree_t t, cover_tagging_t *tagging, } } -static void cgen_module_debug_info(tree_t top) +static void cgen_add_dwarf_flags(void) { llvm_add_module_flag("Debug Info Version", DEBUG_METADATA_VERSION); #ifdef __APPLE__ @@ -3779,7 +3789,10 @@ static void cgen_module_debug_info(tree_t top) #else llvm_add_module_flag("Dwarf Version", 4); #endif +} +static void cgen_module_debug_info(void) +{ const loc_t *loc = vcode_unit_loc(); assert(!loc_invalid_p(loc)); @@ -3798,8 +3811,19 @@ static void cgen_module_debug_info(tree_t top) cgen_push_debug_scope(cu); + vcode_state_t state; + vcode_state_save(&state); + + while (vcode_unit_context() != NULL) + vcode_select_unit(vcode_unit_context()); + LOCAL_TEXT_BUF tb = tb_new(); - ident_str(tree_ident(top), tb); + ident_str(vcode_unit_name(), tb); + + if (vcode_unit_kind() == VCODE_UNIT_INSTANCE) + tb_cat(tb, ".elab"); + + vcode_state_restore(&state); LLVMMetadataRef mod = LLVMDIBuilderCreateModule( debuginfo, cu, tb_get(tb), tb_len(tb), "", 0, "", 0, "", 0); @@ -3807,19 +3831,82 @@ static void cgen_module_debug_info(tree_t top) cgen_push_debug_scope(mod); } -static void cgen_find_units(vcode_unit_t root, unit_list_t *units) +static void cgen_find_children(vcode_unit_t root, unit_list_t *units) { vcode_select_unit(root); + const vunit_kind_t kind = vcode_unit_kind(); + if (kind != VCODE_UNIT_INSTANCE && kind != VCODE_UNIT_PROCESS) + return; + for (vcode_unit_t it = vcode_unit_child(root); it != NULL; it = vcode_unit_next(it)) { - cgen_find_units(it, units); + cgen_find_children(it, units); } APUSH(*units, root); } +static void cgen_add_dependency(ident_t name, unit_list_t *list) +{ + vcode_state_t state; + vcode_state_save(&state); + + vcode_unit_t vu = vcode_find_unit(name); + assert(vu); + + unsigned pos = 0; + for (; pos < list->count; pos++) { + if (list->items[pos] == vu) + break; + } + + if (pos == list->count) + APUSH(*list, vu); + + vcode_state_restore(&state); +} + +static void cgen_find_dependencies(vcode_unit_t unit, unit_list_t *list) +{ + vcode_select_unit(unit); + + const int nblocks = vcode_count_blocks(); + for (int i = 0; i < nblocks; i++) { + vcode_select_block(i); + + const int nops = vcode_count_ops(); + for (int op = 0; op < nops; op++) { + switch (vcode_get_op(op)) { + case VCODE_OP_LINK_PACKAGE: + cgen_add_dependency(vcode_get_ident(op), list); + break; + case VCODE_OP_LINK_VAR: + cgen_add_dependency(ident_runtil(vcode_get_ident(op), '.'), list); + break; + case VCODE_OP_FCALL: + case VCODE_OP_PCALL: + case VCODE_OP_CLOSURE: + case VCODE_OP_PROTECTED_INIT: + if (vcode_get_subkind(op) != VCODE_CC_FOREIGN) + cgen_add_dependency(vcode_get_func(op), list); + break; + default: + break; + } + } + } +} + +static void cgen_find_units(vcode_unit_t root, unit_list_t *units) +{ + cgen_find_children(root, units); + + for (unsigned i = 0; i < units->count; i++) + cgen_find_dependencies(units->items[i], units); +} + static void cgen_partition_jobs(unit_list_t *units, job_list_t *jobs, const char *base_name, int units_per_job) { @@ -4335,45 +4422,6 @@ static void cgen_link_arg(const char *fmt, ...) APUSH(link_args, buf); } -#ifdef IMPLIB_REQUIRED -static void cgen_find_dll_deps(ident_t unit_name, void *__ctx) -{ - ident_list_t **deps = __ctx; - - tree_t unit = lib_get_qualified(unit_name); - if (unit == NULL) - return; - - unit_name = tree_ident(unit); - - if (ident_list_find(*deps, unit_name)) - return; - - ident_list_push(deps, unit_name); - - switch (tree_kind(unit)) { - case T_PACKAGE: - { - ident_t body_name = ident_prefix(unit_name, ident_new("body"), '-'); - cgen_find_dll_deps(body_name, deps); - } - break; - - case T_PACK_BODY: - { - ident_t pack_name = ident_until(unit_name, '-'); - cgen_find_dll_deps(pack_name, deps); - } - break; - - default: - break; - } - - tree_walk_deps(unit, cgen_find_dll_deps, deps); -} -#endif // IMPLIB_REQUIRED - static void cgen_native(LLVMTargetMachineRef tm_ref, char *obj_path) { char *error; @@ -4442,33 +4490,6 @@ static void cgen_link(const char *module_name, char **objs, int nobjs) cgen_link_arg("/usr/lib/crtendS.o"); #endif -#if IMPLIB_REQUIRED - // Windows needs all symbols to be resolved when linking a DLL - - cgen_link_arg("-L%s", lib_path(lib_work())); - - ident_t name = ident_new(module_name); - LOCAL_IDENT_LIST deps = NULL; - cgen_find_dll_deps(name, &deps); - - for (const ident_list_t *it = deps; it != NULL; it = it->next) { - if (it->ident == name) - continue; - - lib_t lib = lib_require(ident_until(it->ident, '.')); - - char *dll_name LOCAL = xasprintf("_%s." DLL_EXT, istr(it->ident)); - char dll_path[PATH_MAX]; - lib_realpath(lib, dll_name, dll_path, PATH_MAX); - - if (access(dll_path, F_OK) == 0) { - if (lib != lib_work()) - cgen_link_arg("-L%s", lib_path(lib)); - cgen_link_arg("-l_%s", istr(it->ident)); - } - } -#endif - const char *obj = getenv("NVC_FOREIGN_OBJ"); if (obj != NULL) cgen_link_arg(obj); @@ -4533,7 +4554,7 @@ static void cgen_units(unit_list_t *units, tree_t top, cover_tagging_t *cover, vcode_select_unit(units->items[0]); cgen_tmp_stack(); - cgen_module_debug_info(top); + cgen_add_dwarf_flags(); if (primary) { cgen_abi_version(); @@ -4545,6 +4566,8 @@ static void cgen_units(unit_list_t *units, tree_t top, cover_tagging_t *cover, for (unsigned i = 0; i < units->count; i++) { vcode_select_unit(units->items[i]); + cgen_module_debug_info(); + switch (vcode_unit_kind()) { case VCODE_UNIT_PROCEDURE: cgen_procedure(); @@ -4566,10 +4589,10 @@ static void cgen_units(unit_list_t *units, tree_t top, cover_tagging_t *cover, default: break; } - } - cgen_pop_debug_scope(); - cgen_pop_debug_scope(); + cgen_pop_debug_scope(); + cgen_pop_debug_scope(); + } cgen_global_ctors(); diff --git a/src/debug.c b/src/debug.c index f2dac97c..b7e26ed7 100644 --- a/src/debug.c +++ b/src/debug.c @@ -140,6 +140,52 @@ static bool di_lru_get(uintptr_t pc, debug_frame_t **pframe) } } +#if !defined HAVE_LIBDW && !defined HAVE_LIBDWARF +static void guess_vhdl_symbol(debug_frame_t *frame) +{ + // Use some dodgy heuristics to determine if this a VHDL symbol when + // DWARF information is not available + + const char *slash = strrchr(frame->module, DIR_SEP[0]); + char *file LOCAL = xstrdup(slash ? slash + 1 : frame->module); + if (file[0] != '_') + return; + +#if !defined __MINGW32__ && !defined __CYGWIN__ + char *last_dot = strrchr(file, '.'); + if (last_dot == NULL || strcmp(last_dot + 1, DLL_EXT) != 0) + return; + + *last_dot = '\0'; +#endif + + if (frame->symbol == NULL) + return; + + char *dup LOCAL = xstrdup(frame->symbol); + + char *dot1 = strchr(dup, '.'); + if (dot1 == NULL) + return; + + char *dot2 = strchr(dot1 + 1, '.'); + if (dot2 == NULL) + return; + + *dot2 = '\0'; + + const size_t duplen = strlen(dup); + if (strncmp(file + 1, dup, duplen) == 0 && file[duplen + 1] == '.') { + frame->kind = FRAME_VHDL; + frame->vhdl_unit = ident_new(file + 1); + } + else { + frame->kind = FRAME_VHDL; + frame->vhdl_unit = ident_new(dup); + } +} +#endif // !HAVE_LIBDW && !HAVE_LIBDWARF + //////////////////////////////////////////////////////////////////////////////// // Libdw backend @@ -739,11 +785,8 @@ static void debug_walk_frames(debug_info_t *di) if (SymGetModuleInfo(hProcess, stk.AddrPC.Offset, &module)) { frame->module = xstrdup(module.ModuleName); - lib_t lib = lib_at(module.ImageName); - if (lib != NULL && module.ModuleName[0] == '_') { - frame->kind = FRAME_VHDL; - frame->vhdl_unit = ident_new(module.ModuleName + 1); - } + if (lib_at(module.ImageName) != NULL) + guess_vhdl_symbol(frame); } } @@ -757,27 +800,6 @@ static void debug_walk_frames(debug_info_t *di) #else -static void unwind_parse_vhdl_symbol(debug_frame_t *frame) -{ - lib_t lib = lib_at(frame->module); - if (lib == NULL) - return; - - const char *slash = strrchr(frame->module, DIR_SEP[0]); - char *file LOCAL = xstrdup(slash ? slash + 1 : frame->module); - if (file[0] != '_') - return; - - char *last_dot = strrchr(file, '.'); - if (last_dot == NULL || strcmp(last_dot + 1, DLL_EXT) != 0) - return; - - *last_dot = '\0'; - - frame->kind = FRAME_VHDL; - frame->vhdl_unit = ident_new(file + 1); -} - static void unwind_fill_frame(uintptr_t ip, debug_frame_t *frame) { Dl_info dli; @@ -798,7 +820,9 @@ static void unwind_fill_frame(uintptr_t ip, debug_frame_t *frame) if (dli.dli_sname) { frame->symbol = xstrdup(dli.dli_sname); - unwind_parse_vhdl_symbol(frame); + + if (lib_at(frame->module) != NULL) + guess_vhdl_symbol(frame); } } diff --git a/src/lower.c b/src/lower.c index 4170aa28..68e0b354 100644 --- a/src/lower.c +++ b/src/lower.c @@ -1470,10 +1470,9 @@ static vcode_reg_t lower_builtin(tree_t fcall, subprogram_kind_t builtin, static vcode_type_t lower_func_result_type(type_t result) { - if (type_is_array(result) && lower_const_bounds(result)) { + if (type_is_array(result) && lower_const_bounds(result)) return vtype_pointer(lower_type(lower_elem_recur(result))); - } - if (type_is_record(result)) + else if (type_is_record(result)) return vtype_pointer(lower_type(result)); else return lower_type(result); @@ -4878,7 +4877,7 @@ static vcode_reg_t lower_resolution_func(type_t type) const bool is_carray = vtype_kind(vtype) == VCODE_TYPE_CARRAY; vcode_type_t elem = is_carray ? vtype_elem(vtype) : vtype; - vcode_type_t rtype = vtype_is_composite(vtype) ? vtype_pointer(elem) : vtype; + vcode_type_t rtype = lower_func_result_type(type); vcode_type_t atype = vtype_uarray(1, elem, vtype_int(0, INT32_MAX)); vcode_reg_t context_reg = lower_context_for_call(rfunc); @@ -7107,7 +7106,7 @@ static ident_t lower_converter(tree_t expr, type_t atype, type_t rtype, if (!p0_uarray && !r_uarray) { *vatype = lower_type(atype); - *vrtype = lower_type(rtype); + *vrtype = lower_func_result_type(rtype); return tree_ident2(fdecl); } } @@ -7154,7 +7153,7 @@ static ident_t lower_converter(tree_t expr, type_t atype, type_t rtype, vrbounds = lower_bounds(elem); } else { - *vrtype = lower_type(rtype); + *vrtype = lower_func_result_type(rtype); vrbounds = lower_bounds(rtype); } } diff --git a/src/nvc.c b/src/nvc.c index 68fa56bb..1df45921 100644 --- a/src/nvc.c +++ b/src/nvc.c @@ -169,7 +169,6 @@ static int analyse(int argc, char **argv) } SCOPED_A(tree_t) units = AINIT; - SCOPED_A(tree_t) cgen_units = AINIT; lib_t work = lib_work(); @@ -187,7 +186,6 @@ static int analyse(int argc, char **argv) if (error_count() == 0 && unit_needs_cgen(unit)) { vcode_unit_t vu = lower_unit(unit, NULL); lib_put_vcode(work, unit, vu); - APUSH(cgen_units, unit); } } } @@ -201,15 +199,6 @@ static int analyse(int argc, char **argv) lib_save(work); - for (unsigned i = 0; i < cgen_units.count; i++) { - // The unit could have been obsoleted by a later design unit in - // the same file so check it is still present in the library - if (lib_contains(work, cgen_units.items[i])) { - vcode_unit_t vu = lib_get_vcode(work, cgen_units.items[i]); - cgen(cgen_units.items[i], vu, NULL); - } - } - argc -= next_cmd - 1; argv += next_cmd - 1; diff --git a/src/rt/jit.c b/src/rt/jit.c index f8aa067b..3e8bf2bd 100644 --- a/src/rt/jit.c +++ b/src/rt/jit.c @@ -141,7 +141,7 @@ static void jit_load_module(ident_t name) #else void *handle = dlopen(so_path, RTLD_LAZY | RTLD_GLOBAL); if (handle == NULL) - fatal("%s: %s", so_path, dlerror()); + fatal("%s", dlerror()); uint32_t *p = dlsym(handle, "__nvc_abi_version"); if (p == NULL) @@ -163,10 +163,6 @@ void jit_init(tree_t top, e_node_t e) APUSH(search_modules, GetModuleHandle("MSVCRT.DLL")); #endif - const int ndeps = e_deps(e); - for (int i = 0; i < ndeps; i++) - jit_load_module(e_dep(e, i)); - jit_load_module(tree_ident(top)); } diff --git a/src/rt/rtkern.c b/src/rt/rtkern.c index 9c5729c1..b2b8d099 100644 --- a/src/rt/rtkern.c +++ b/src/rt/rtkern.c @@ -63,7 +63,6 @@ typedef struct waveform waveform_t; typedef struct sens_list sens_list_t; typedef struct value value_t; typedef struct callback callback_t; -typedef struct image_map image_map_t; typedef struct rt_nexus_s rt_nexus_t; typedef struct rt_scope_s rt_scope_t; typedef struct rt_source_s rt_source_t; @@ -274,14 +273,6 @@ struct callback { callback_t *next; }; -struct image_map { - int32_t kind; - int32_t stride; - const char *elems; - const int64_t *values; - int32_t count; -}; - typedef struct { uint32_t n_signals; uint32_t n_contig; @@ -2274,8 +2265,6 @@ static void *rt_call_module_reset(ident_t name, void *arg) void *(*reset_fn)(void *) = jit_find_symbol(buf, false); if (reset_fn != NULL) result = (*reset_fn)(arg); - else - warnf("symbol %s not found", buf); global_tmp_alloc = _tmp_alloc; return result; diff --git a/test/regress/testlist.txt b/test/regress/testlist.txt index 59c4bf82..631ae381 100644 --- a/test/regress/testlist.txt +++ b/test/regress/testlist.txt @@ -383,7 +383,7 @@ issue423 normal driver6 normal driver7 fail,gold issue428 normal -protected5 normal,2000,!windows +protected5 normal,2000 issue429 normal record18 normal issue98 normal -- 2.39.2