qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] tcg/tcg: Avoid TS_DEAD for basic block ending


From: Richard Henderson
Subject: Re: [PATCH] tcg/tcg: Avoid TS_DEAD for basic block ending
Date: Tue, 21 Mar 2023 08:39:23 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0

On 3/20/23 23:44, LIU Zhiwei wrote:

On 2023/3/21 14:06, Richard Henderson wrote:
On 3/20/23 21:53, LIU Zhiwei wrote:
TS_DEAD means we will release the register allocated for this temporary. But
at basic block ending, we can still use the allocted register.

Signed-off-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>

Test case?

I have run an Ubuntu image after this patch. It can boot.

That's surprising. I would have expected an assert with --enable-debug-tcg, but this appears to be an oversight in tcg_reg_alloc_bb_end. We only validate the liveness data for TEMP_EBB and TEMP_CONST, but not TEMP_TB or TEMP_GLOBAL.

But I can't find a direct test case.  Because the IRs supported with flags TCG_OPF_BB_END do not have  input or output parameter, such as the set_label or br.

That's exactly why we want all GLOBAL and TB to be DEAD | MEM, so that they're saved back to their home slots and released from their registers.

The register allocator for TCG does not work across extended basic blocks. Importantly, if you have a forward branch like so:


        g1 = func(a)
        brcond ..., L1

        stuff
        g2 = func(b)    
        g1 = g2
        discard g2

L1:

What value should g1->reg have at L1? The allocator does not do the global control flow and allocation required to ensure that g1->reg is the same at the brcond and at the label.

Nominally, I would have expected one value for g1->reg at the branch, a different value for g2->reg in the second BB, and for the assignment to steal g2->reg and move it to g1->reg (per tcg_reg_alloc_mov of an IS_DEAD_ARG temp). Which would result in an incorrect allocation at L1.

What are you attempting to do?  Is this just guesswork?


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]