Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x86jit: Fix spill on sc in longer block #18140

Merged
merged 1 commit into from
Sep 12, 2023

Conversation

unknownbrackets
Copy link
Collaborator

I only added sc this year for the debugger - it was a mistake to not make sure any spill happens outside the conditional. That said, this should most of the time be in a tight loop, so usually won't be an issue. Still, there may be some game, especially on 32-bit, that triggers a spill inside the conditional and that'd be bad.

Just to make sure it's clear, this is the scenario (simplified, since actually li would not map a reg):

li a0, 0
li a1, 1
li a2, 2
li a3, 3
li t0, 4

sc t1, 42(t2)

In this case, i386 only has 5 mappable regs, so mapping t1 will necessarily spill one of those first 5. However, if the spill happens inside the if (skipStore = J_CC(CC_NE); - i.e. if (llBit == 1) {) then that other register will silently not be updated if llBit was 0. In that case, i.e. a0 would stay 0xDEADBEEF and not be set to 0.

I don't have Beats to make sure this works there.

-[Unknown]

@unknownbrackets unknownbrackets added the x86jit x86/x64 JIT bugs label Sep 12, 2023
@hrydgard hrydgard added this to the v1.16.1 milestone Sep 12, 2023
@hrydgard hrydgard merged commit 87a4344 into hrydgard:master Sep 12, 2023
18 checks passed
@hrydgard
Copy link
Owner

Tested, it works, not very surprisingly.

Yeah, it's a bit hard to reason about these things in conditionals...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
x86jit x86/x64 JIT bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants