schorrm / arm2riscv

Arm AArch64 to RISC-V Transpiler
MIT License
30 stars 3 forks source link

Barrel shifted operands sometimes crash the transpiler #2

Closed Shai-Aviv closed 4 years ago

Shai-Aviv commented 4 years ago

Consider the following input:

    .arch armv8-a
    .file   "bug.c"
    .text
    .align  2
    .global main
    .type   main, %function
main:
    add w0, w0, w0, lsl 1
    ret
    .size   main, .-main
    .ident  "GCC: (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04) 7.5.0"
    .section    .note.GNU-stack,"",@progbits

On my machine (Ubuntu 18.04 LTS running in Docker on RHEL 7.5), the output of arm2riscv.py for this input is distributed as follows:

I suspect that the bug has something to do with the random ordering of keys in Python's dict or set types, but I'm only guessing.

schorrm commented 4 years ago

In Python 3.6+ dict keys aren't randomly ordered, and I didn't use sets at all, so I'm really not sure what happened here. Trying to figure out.

schorrm commented 4 years ago

Tracked it down, it occurs at the grammar phase. Now to fix this.

Shai-Aviv commented 4 years ago

What a swift response! Thank you

schorrm commented 4 years ago

Fixed some issues with rules priorities, I think it should be addressed now (I just ran this about 30 times without a crash).