Skip to content

SPU LLVM: avoid mirrored local-store aliases - #151

Open
makolg wants to merge 1 commit into
aenu1:main4from
makolg:agent/fix-spu-ls-alias
Open

SPU LLVM: avoid mirrored local-store aliases#151
makolg wants to merge 1 commit into
aenu1:main4from
makolg:agent/fix-spu-ls-alias

Conversation

@makolg

@makolg makolg commented Jul 24, 2026

Copy link
Copy Markdown

Summary

  • Sign-extend constant SPU Local Store offsets that fall outside the 256 KiB LS range instead of wrapping them to a mirrored address.
  • Apply the same canonical addressing to optimized STQX, LQX, STQD, and LQD paths.
  • Fall back to the generic path for misaligned constant STQX/LQX accesses.

This is an aPS3e main4 backport/adaptation of RPCS3 commits 9bf67f0 and 0fcb15a.

Root cause and impact

The previous optimized paths could refer to the same SPU Local Store block through different mirrored host addresses. LLVM alias analysis may then treat accesses to the same guest memory as independent and optimize them incorrectly.

On Devil May Cry 4 (BLUS30092), the failure presented as a corrupted SPU link register restored from the SPU stack. The corrupted return value resolved to zero-filled LS at PC 0x34d3c, ending in:

Unknown STOP code: 0x0 (op=0x0, Out_MBox=empty)

A mailbox-only test build still failed at the same PC after 7.18 seconds and again after clearing the generated SPU cache at 8.47 seconds. A later build containing this LS-address correction progressed past that fatal, loaded the intro/title and m00_100s/m01_100s resources, and ran for four minutes until manually stopped, with no Unknown STOP, zero-op fatal, signal, or Android crash.

This PR intentionally excludes unrelated mailbox synchronization, diagnostic logging, Android manifest, versioning, and game-profile changes.

Validation

  • git diff --check passes.
  • The modified LS section matches the source compiled into the tested Android build after newline normalization.
  • SPULLVMRecompiler.cpp compiles successfully for aarch64-none-linux-android28 using Android NDK 27 / Clang; only existing project warnings are emitted.

Disclosure

Patch preparation and log analysis were AI-assisted. The implementation is a focused adaptation of the two linked upstream RPCS3 commits; validation used native aPS3e/RPCS3 logs from a user-owned REDMAGIC device and a local Android ARM64 compiler pass.

@makolg
makolg marked this pull request as ready for review July 25, 2026 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant