From 6b60431f2920fb2c0ac01fcb4900c69c0bf3afb7 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Sun, 23 Oct 2022 15:54:53 +0100 Subject: [PATCH] Enable regression testing with interpreter only --- .github/workflows/build-test.yml | 24 +++++++++++++++--------- src/jit/jit-dump.c | 5 +++++ src/jit/jit-interp.c | 8 +++++++- src/jit/jit-irgen.c | 19 ++++++++++++++++--- src/lower.c | 2 +- src/vcode.c | 2 ++ test/regress/access8.vhd | 5 ++++- test/regress/gold/access8.txt | 2 +- test/regress/testlist.txt | 6 +++--- test/run_regr.c | 7 +++++++ 10 files changed, 61 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 731bfe30..ef343bb9 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -33,13 +33,26 @@ jobs: make -C build bin/jitperf ./build/bin/jitperf -L build/lib/ test/perf/simple.vhd - name: Coverage report - run: make -C build cov-generate + run: | + make -C build cov-generate + mv build/coverage/nvc.info orig.info + - name: Configure for interpreter only + run: | + cd build + ../configure --enable-gcov --disable-llvm --enable-debug + - name: Interpreter only tests + run: make -C build clean check + - name: Merge coverage report + run: | + make -C build cov-generate + mv build/coverage/nvc.info interp.info + lcov -o merged.info -a interp.info -a orig.info - name: Coveralls continue-on-error: true uses: coverallsapp/github-action@master with: github-token: ${{ secrets.GITHUB_TOKEN }} - path-to-lcov: ./build/coverage/nvc.info + path-to-lcov: ./merged.info - name: Dist clean run: make -C build distclean - name: Configure for release @@ -51,15 +64,12 @@ jobs: - name: Build release run: make -C build - name: Install release - if: github.event_name != 'pull_request' run: sudo make -C build install - name: Archive - if: github.event_name != 'pull_request' run: >- tar -czf nvc-${{ env.VERSION }}.tar.gz \ /opt/nvc-${{ env.VERSION }} - name: 'Upload artifact' - if: github.event_name != 'pull_request' uses: actions/upload-artifact@v3 with: name: 'Ubuntu binaries' @@ -145,7 +155,6 @@ jobs: - name: Install UVVM run: nvc --install uvvm - name: 'Upload artifact' - if: github.event_name != 'pull_request' uses: actions/upload-artifact@v3 with: name: 'MSYS2 package' @@ -153,7 +162,6 @@ jobs: vests: name: VESTs - if: github.event_name != 'pull_request' needs: [ build-ubuntu ] runs-on: ubuntu-20.04 steps: @@ -184,7 +192,6 @@ jobs: projects: name: External Projects - if: github.event_name != 'pull_request' needs: [ build-ubuntu ] runs-on: ubuntu-20.04 timeout-minutes: 15 @@ -243,7 +250,6 @@ jobs: vunit: name: VUnit - if: github.event_name != 'pull_request' needs: [ build-ubuntu ] runs-on: ubuntu-20.04 steps: diff --git a/src/jit/jit-dump.c b/src/jit/jit-dump.c index 07be899e..3532ac7f 100644 --- a/src/jit/jit-dump.c +++ b/src/jit/jit-dump.c @@ -315,6 +315,11 @@ void jit_dump_interleaved(jit_func_t *f) jit_interleaved_cb(VCODE_DUMP_OP, -1, &d); ihash_free(d.labels); + + if (f->cpoolsz > 0) { + jit_hexdump(f->cpool, f->cpoolsz, 16, NULL, "\t"); + printf("\n"); + } } __attribute__((no_sanitize_address)) diff --git a/src/jit/jit-interp.c b/src/jit/jit-interp.c index ee4edf80..4475ce61 100644 --- a/src/jit/jit-interp.c +++ b/src/jit/jit-interp.c @@ -690,7 +690,13 @@ static void interp_galloc(jit_interp_t *state, jit_ir_t *ir) jit_thread_local_t *thread = jit_thread_local(); thread->anchor = state->anchor; - const size_t bytes = interp_get_value(state, ir->arg1).integer; + const uint64_t bytes = interp_get_value(state, ir->arg1).integer; + + if (bytes > UINT32_MAX) + jit_msg(NULL, DIAG_FATAL, "attempting to allocate %"PRIu64" byte object " + "which is larger than the maximum supported %u bytes", + bytes, UINT32_MAX); + state->regs[ir->result].pointer = mspace_alloc(state->mspace, bytes); if (state->regs[ir->result].pointer == NULL && bytes > 0) diff --git a/src/jit/jit-irgen.c b/src/jit/jit-irgen.c index 70f1f2cf..efe5adcd 100644 --- a/src/jit/jit-irgen.c +++ b/src/jit/jit-irgen.c @@ -98,6 +98,12 @@ static inline jit_value_t jit_value_from_loc(const loc_t *loc) return value; } +static inline jit_value_t jit_value_from_tree(tree_t t) +{ + jit_value_t value = { .kind = JIT_VALUE_INT64, .int64 = (intptr_t)t }; + return value; +} + static inline jit_value_t jit_null_ptr(void) { jit_value_t value = { .kind = JIT_VALUE_INT64, .int64 = 0 }; @@ -1591,8 +1597,7 @@ static void irgen_op_debug_locus(jit_irgen_t *g, int op) const ptrdiff_t offset = vcode_get_value(op); tree_t tree = tree_from_locus(unit, offset, lib_get_qualified); - - g->map[vcode_get_result(op)] = jit_value_from_int64((intptr_t)tree); + g->map[vcode_get_result(op)] = jit_value_from_tree(tree); } static void irgen_op_wrap(jit_irgen_t *g, int op) @@ -1961,7 +1966,15 @@ static void irgen_op_select(jit_irgen_t *g, int op) j_cmp(g, JIT_CC_NE, test, jit_value_from_int64(0)); } - g->map[vcode_get_result(op)] = j_csel(g, iftrue, iffalse); + vcode_reg_t result = vcode_get_result(op); + g->map[result] = j_csel(g, iftrue, iffalse); + + const int slots = irgen_slots_for_type(vcode_reg_type(result)); + for (int i = 1; i < slots; i++) { + jit_value_t iftrue_i = jit_value_from_reg(jit_value_as_reg(iftrue) + i); + jit_value_t iffalse_i = jit_value_from_reg(jit_value_as_reg(iffalse) + i); + j_csel(g, iftrue_i, iffalse_i); + } } static void irgen_op_jump(jit_irgen_t *g, int op) diff --git a/src/lower.c b/src/lower.c index af2b99a5..33bfbeb8 100644 --- a/src/lower.c +++ b/src/lower.c @@ -7185,7 +7185,7 @@ static vcode_reg_t lower_physical_value_helper(type_t type, vcode_reg_t preg) char_regs[(i * stride) + pos] = emit_const(vchar, 0); } - vcode_type_t char_array_type = vtype_carray(nunits, vchar, vchar); + vcode_type_t char_array_type = vtype_carray(nchars, vchar, vchar); vcode_reg_t char_array_reg = emit_const_array(char_array_type, char_regs, nchars); vcode_reg_t char_array_ptr = emit_address_of(char_array_reg); diff --git a/src/vcode.c b/src/vcode.c index b5e31696..4663d8cf 100644 --- a/src/vcode.c +++ b/src/vcode.c @@ -3344,6 +3344,8 @@ vcode_reg_t emit_const_array(vcode_type_t type, vcode_reg_t *values, int num) VCODE_ASSERT(kind == VCODE_TYPE_CARRAY, "constant array must have constrained array type"); + VCODE_ASSERT(vtype_size(type) == num, "expected %d elements but have %d", + vtype_size(type), num); #ifndef NDEBUG vcode_type_t elem = vtype_elem(type); diff --git a/test/regress/access8.vhd b/test/regress/access8.vhd index dad4c642..4a435ec4 100644 --- a/test/regress/access8.vhd +++ b/test/regress/access8.vhd @@ -4,7 +4,10 @@ end entity; architecture test of access8 is type int_vector is array (natural range <>) of integer; - type big_array is array (natural range <>) of int_vector(1 to 1000); + type rec is record + f : int_vector(1 to 1000); + end record; + type big_array is array (natural range <>) of rec; type p_big_array is access big_array; signal n : integer := 10000000; diff --git a/test/regress/gold/access8.txt b/test/regress/gold/access8.txt index 81fd2888..46c4e43d 100644 --- a/test/regress/gold/access8.txt +++ b/test/regress/gold/access8.txt @@ -1 +1 @@ -attempting to allocate 5640261632 byte object which is larger than the maximum supported 4294967295 bytes +attempting to allocate 40000000000 byte object which is larger than the maximum supported 4294967295 bytes diff --git a/test/regress/testlist.txt b/test/regress/testlist.txt index f9a1b283..3dbc8a4c 100644 --- a/test/regress/testlist.txt +++ b/test/regress/testlist.txt @@ -355,7 +355,7 @@ wait14 normal block2 normal issue407 normal issue412 normal -issue414 normal +issue414 normal,slow issue415 normal predef1 normal,2008 signal15 normal,2008 @@ -425,7 +425,7 @@ file4 normal vests17 normal vests18 normal vests19 normal -protected6 normal,2000 +protected6 normal,2000,slow vests20 normal vests21 normal guard1 normal @@ -658,7 +658,7 @@ libdir3 shell elab35 normal issue524 shell issue527 normal,stop=1us -ieee10 normal +ieee10 normal,slow driver15 normal,gold issue520 normal,2008 wave7 shell diff --git a/test/run_regr.c b/test/run_regr.c index f5b58837..ec0bc620 100644 --- a/test/run_regr.c +++ b/test/run_regr.c @@ -65,6 +65,7 @@ #define F_WORKLIB (1 << 11) #define F_SHELL (1 << 12) #define F_2002 (1 << 13) +#define F_SLOW (1 << 14) typedef struct test test_t; typedef struct param param_t; @@ -329,6 +330,8 @@ static bool parse_test_list(int argc, char **argv) test->flags |= F_VHPI; else if (strcmp(opt, "shell") == 0) test->flags |= F_SHELL | F_NOTWIN; + else if (strcmp(opt, "slow") == 0) + test->flags |= F_SLOW; else if (strcmp(opt, "!windows") == 0) test->flags |= F_NOTWIN; else if (strncmp(opt, "O", 1) == 0) { @@ -607,6 +610,10 @@ static bool run_test(test_t *test) #if defined __MINGW32__ || defined __CYGWIN__ skip |= (test->flags & F_NOTWIN); #endif +#ifndef HAVE_LLVM + skip |= (test->flags & F_SLOW); + skip |= (test->flags & F_COVER); // Only supported with LLVM for now +#endif if (skip) { set_attr(ANSI_FG_CYAN); -- 2.39.2