From: "Alex Bennée" <alex.bennee@linaro.org>
To: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
Cc: Richard Henderson <richard.henderson@linaro.org>,
"open list:RISC-V" <qemu-riscv@nongnu.org>,
Alistair Francis <Alistair.Francis@wdc.com>,
qemu-devel@nongnu.org
Subject: Re: Question about TCG backend correctness
Date: Wed, 19 Oct 2022 14:46:01 +0100 [thread overview]
Message-ID: <87k04wapsw.fsf@linaro.org> (raw)
In-Reply-To: <020dc51f-793b-bf20-41e8-5b1447711864@linux.alibaba.com>
LIU Zhiwei <zhiwei_liu@linux.alibaba.com> writes:
> On 2022/10/18 13:22, Richard Henderson wrote:
>
> On 10/18/22 01:27, LIU Zhiwei wrote:
>
> Maybe I can run RISU on qemu-aarch64(x86) and qemu-aarch64(risc-v) to check the RISC-V backend.
>
> This is a good start for debugging a tcg backend.
>
> After fixing some bugs, RISU can run some instructions now. Thanks.
>
> IMHO, the next 2 requests should be satisfied for TCG test.
>
> 1. Add a unit test case for any lower level and small function is easy.
>
> For example, the function in risc-v backend,
>
> static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg)
> {
> if (ret == arg) {
> return true;
> }
> switch (type) {
> case TCG_TYPE_I32:
> case TCG_TYPE_I64:
> tcg_out_opc_imm(s, OPC_ADDI, ret, arg, 0);
> break;
> default:
> g_assert_not_reached();
> }
> return true;
> }
>
> Write a unit test case for it is not easy currently. I don't know how to fill the TCGContext struct and other
> parameters.
> And there is no test framework where I can reuse.
>
> The others may say that we can run a lot of benchmark to ensure we have a good coverage and don't
> need such a low level test case. Some reasonable. But it will lead to a very high test burden and it is very hard to
> get
> a good coverage only through high level test.
You can at the very least use the gcov build to identify which bits of
the backend are not exercised by "check-tcg" and maybe write a few more
tests to fill it in. It's not a direct exercising of the code but it at
least ensures it has run and worked at least once.
>
> 2. Add a unit test case for any high level function is easy, such as tcg_gen_code.
>
> The check-tcg test belongs to the high level testing.
>
> Best Regards,
> Zhiwei
>
> It's not comprehensive, because RISU executes one instruction at a time then raises an exception to check the
> results. This means that the tcg optimizer doesn't have much to work with, which means that the tcg backend is not
> as stressed as it could be.
>
> I've long wanted to have the ability to have TCG unit tests where a
> virtual processor could be defined for the purpose of directly
> exercising TCG.
>
> We already have many ISAs as the front end of TCG. Will the virtual processor here be some
> different?
>
> It wouldn't. This is my argument against creating a new virtual processor.
>
> I do think we should be better about creating regression tests for bugs fixed, in the form of small focused assembly
> test cases which get run via check-tcg.
>
> r~
--
Alex Bennée
prev parent reply other threads:[~2022-10-19 13:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-17 9:47 Question about TCG backend correctness LIU Zhiwei
2022-10-17 10:30 ` Alex Bennée
2022-10-17 15:27 ` LIU Zhiwei
2022-10-18 5:22 ` Richard Henderson
2022-10-18 9:22 ` Alex Bennée
2022-10-18 23:03 ` Richard Henderson
2022-10-19 11:59 ` LIU Zhiwei
2022-10-19 13:46 ` Alex Bennée [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k04wapsw.fsf@linaro.org \
--to=alex.bennee@linaro.org \
--cc=Alistair.Francis@wdc.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=zhiwei_liu@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).