mirror of
https://github.com/FEX-Emu/FEX.git
synced 2025-02-03 13:03:22 +00:00
636f8aa4a7
Arm64 store with writeback when source register is the same register as the address is undefined behaviour. Depending on hardware details this can do a whole bunch of things. This situation happens when the x86 code does `push rsp` which is quite common for applications to do. We would then convert this to a `str x8, [x8, #-8]!` Which results in undefined behaviour. Now that redundant loads are optimized this showed up as an issue. Adds a unit test to ensure we don't hit this again.
23 lines
535 B
NASM
23 lines
535 B
NASM
%ifdef CONFIG
|
|
{
|
|
"RegData": {
|
|
"RAX": "0xe0000010",
|
|
"RSP": "0xe0000008"
|
|
}
|
|
}
|
|
%endif
|
|
|
|
; FEX had a bug where a `push rsp` would generate an Arm64 instruction with undefined behaviour.
|
|
; `push rsp` -> `str x8, [x8, #-8]!`
|
|
; This instruction has constrained undefined behaviour.
|
|
; On Cortex it stores the original value.
|
|
; On Apple Silicon it raises a SIGILL.
|
|
; It can also store undefined data or have undefined behaviour.
|
|
; Test to ensure we don't generate undefined behaviour.
|
|
mov rsp, 0xe0000010
|
|
push rsp
|
|
|
|
mov rax, [rsp]
|
|
|
|
hlt
|