Em qui., 9 de jan. de 2020 às 00:26, Paul Cercueil
<address@hidden> escreveu:
>
> Hi Paulo,
Hi Paul,
Sorry for the delay. Just found this message I previously missed.
> I am facing a problem related to register liveliness. I could only
> reproduce it on MinGW, I never faced it on Linux x86_64 or MIPS.
>
> Here is an example code to reproduce the issue (sorry for the
length).
> It is not important to understand what the code does; what is
important
> to see, is that my JIT_V0 (== rbx), which is set at the very
beginning
> of the code and read back at the last opcode (provided that the
node2
> beqi branch is taken), is overwritten by the call to jit_ltr_u.
>
> I know that Lightning assumes that the caller-saved registers are
dead
> after a function call, but there's no function call here.
>
> Could you give me some light in why Lightning uses my registers?
Do I
> have to use jit_live() somewhere here?
I understand what is happening. It is a bug in the logic of live
registers,
that does not mark JIT_V0 live, and then it is used in the ltr_u
translation,
when it needs a special kind of register. Due to the way it handles
the live
state, it thinks it is dead in 'jit_movi(JIT_V0, 0x80065ff8);' and
does not
properly follow the previous branch in 'node2 = jit_beqi(JIT_V1,
0);'.
I will work on a patch, and let you know about it when it is
ready.
An ugly hack, for a temporary solution would be to add a jit_live
as below:
jit_subi(CYCLE_REG, CYCLE_REG, 0x14);
+ jit_live(JIT_V0);
node2 = jit_beqi(JIT_V1, 0);