llvm / llvm/llvm-project

[Orc] Encodes instructions with wrong endianess on aarch64_be

Open
#188,855 3 comments 0 reactions 0 assignees View on GitHub
jitlink orcjit
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Hi there, it seems that Orc is completely broken on aarch64_be:

Take the following file, `test.ll`:

```ll
define i32 @main(i32 %argc, i8** %argv) {
entry:
ret i32 0
}
```

`lli --force-interpreter test.ll` exits just fine with exit code 0, so does `lli --jit-kind=mcjit test.ll`. But `lli test.ll` results in

```
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: lli test.ll
Illegal instruction
```

I believe this is because it emits instructions encoded in big-endian byte ordering rather than little-endian (since aarch64_be uses little endian instruction encoding).

If I run it in gdb with `gdb --args lli test.ll` and run
```
(gdb) x/20i $pc
=> 0xffffedac6054: .inst 0x00021fd6 ; undefined
```

which if we flip the endianess, is `d61f0200`, aka `br x16`.

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure with `lli test.ll`, then compare it with `lli --force-interpreter test.ll` and `lli --jit-kind=mcjit test.ll` on aarch64_be. Start by tracing the Orc JIT path and inspect the emitted instruction bytes in gdb; done means the plain `lli test.ll` run executes successfully with exit code 0 and preserves correct instruction encoding.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.