teapotd commented on Issue #1162:
It looks like the bug is in x86
legalize_signature
:Function that returns only
i128
is single-return before legalization, so struct-return parameter is never introduced, even thoughlegalize_args
doesn't assign registers properly. After changing it to always backup arguments it generates correct code:function %test_i128(i64 sret [%rcx], i64 fp [%rbp]) -> i64 sret [%rax], i64 fp [%rbp] windows_fastcall { ss0 = incoming_arg 16, offset -48 block0(v3: i64 [%rcx], v6: i64 [%rbp]): [RexOp1pushq#50] x86_push v6 [RexOp1copysp#8089] copy_special %rsp -> %rbp [RexOp1adjustsp_ib#d083] adjust_sp_down_imm 32 [RexOp1pu_iq#80b8,%rax] v0 = iconst.i64 0x4242_3535_1234_5678 v4 -> v0 [RexOp1pu_iq#80b8,%rdx] v1 = iconst.i64 0xabcd_ef01_beef_b411 v5 -> v1 [-,-] v2 = iconcat v0, v1 [RexOp1st#8089] store notrap aligned v0, v3 [RexOp1stDisp8#8089] store notrap aligned v1, v3+8 [RexOp1rmov#8089] regmove v3, %rcx -> %rax [RexOp1adjustsp_ib#8083] adjust_sp_up_imm 32 [RexOp1popq#58,%rbp] v7 = x86_pop.i64 [Op1ret#c3] return v3, v7 } Disassembly of 46 bytes: 0: 40 55 push rbp 2: 48 89 e5 mov rbp, rsp 5: 48 83 ec 20 sub rsp, 0x20 9: 48 b8 78 56 34 12 35 35 42 42 movabs rax, 0x4242353512345678 13: 48 ba 11 b4 ef be 01 ef cd ab movabs rdx, 0xabcdef01beefb411 1d: 48 89 01 mov qword ptr [rcx], rax 20: 48 89 51 08 mov qword ptr [rcx + 8], rdx 24: 48 89 c8 mov rax, rcx 27: 48 83 c4 20 add rsp, 0x20 2b: 40 5d pop rbp 2d: c3 retI'll make a PR.
fitzgen closed Issue #1162:
- Run the following test with bytecodealliance/cranelift#1231 applied.
- Test fails with
Verifier errors
on Windows 10 x86-64, for details see https://github.com/bytecodealliance/cranelift/pull/1231#issuecomment-561820442- Test does not fail on ubuntu.
function %test_i128() -> i128 { ebb0: v0 = iconst.i64 0x4242_3535_1234_5678 v1 = iconst.i64 0xabcd_ef01_beef_b411 v2 = iconcat v0, v1 return v2 } ; run: %fn() == 0x4242_3535_1234_5678_abcd_ef01_beef_b411
Last updated: Nov 22 2024 at 17:03 UTC