On 2023-07-08 01:25, grischka wrote:
Hi,

well, problem is simply that with 32-bit longs your data
   0x1234567890abcd
would be truncated to
   0x7890abcd
and the output from %lx would not match the .expect file.

Thanks for explanation. But replacing 0x1234567890abcd with
0x12345678 (32-bit length) may be better?

Btw is your fix incorrect.  The code that you "fixed" is about
alignment but there was no alignment problem in your case.

The real problem is below at "vtop->c.i += regsize;" which can
advance the location to load the 2nd register only for local or
global/static memory.

If the struct is not aligned, it will be copied to an aligned
address on stack. With this fix, returned structs without
VT_LVAL | VT_LLOCAL will also be copied onto stack as the same way
in which unaligned ones are copied, thus code below could handle it.

For pointers it would need to emit an 'add r, regsize' instruction
You can see such code in gv():

    gaddrof();
    vpushs(PTR_SIZE);
    gen_op('+');
    vtop->r |= VT_LVAL;

-- gr


_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

--
Ziyao

_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to