Skip to content

JIT: Avoid changing def registers that may assume an implicit kill#127184

Merged
jakobbotsch merged 1 commit intodotnet:mainfrom
jakobbotsch:fix-127131
Apr 23, 2026
Merged

JIT: Avoid changing def registers that may assume an implicit kill#127184
jakobbotsch merged 1 commit intodotnet:mainfrom
jakobbotsch:fix-127131

Conversation

@jakobbotsch
Copy link
Copy Markdown
Member

LSRA build has places where it assumes that BuildDef(tree, SRBM_REG) means that SRBM_REG is going to be spilled if something is in it, without constructing any explicit kill. This assumption is incompatible with the logic in resolveConflictingDefAndUse that changes the def register on fixed reg definitions -- the required spilling will happen only if there ends up being a def into that register.

We could fix all the places that assume this and add explicit kills, but instead this change just avoids changing the def assignment away from the register when it detects there is an active interval assigned to the fixed def register.

Fix #127130
Fix #127131

LSRA build has places where it assumes that `BuildDef(tree, SRBM_REG)`
means that `SRBM_REG` is going to be spilled if something is in it,
without constructing any explicit kill. This assumption is incompatible
with the logic in `resolveConflictingDefAndUse` that changes the def
register on fixed reg definitions -- the required spilling will happen
only if there ends up being a def into that register.

We could fix all the places that assume this and add explicit kills, but
instead this change just avoids changing the def assignment away from
the register when it detects there is an active interval assigned to the
fixed def register.
Copilot AI review requested due to automatic review settings April 20, 2026 21:17
@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Apr 20, 2026
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts LSRA’s conflicting def/use resolution to avoid changing the assigned register of fixed-reg defs when doing so would prevent an implicit spill of a currently-occupied fixed register. This targets stress-induced miscompilations/test failures reported in #127130 and #127131.

Changes:

  • Introduce a canChangeDef gate to prevent def-reg reassignment for multireg nodes.
  • Further restrict def-reg reassignment for fixed-reg defs when the fixed register currently holds an active interval (ensuring the expected spill occurs).

Comment thread src/coreclr/jit/lsrabuild.cpp
@jakobbotsch
Copy link
Copy Markdown
Member Author

jakobbotsch commented Apr 21, 2026

cc @dotnet/jit-contrib PTAL @AndyAyersMS

No diffs. Verified this fixes the two failures locally.

Slowly learning LSRA intricacies one stress failure at a time...

@jakobbotsch
Copy link
Copy Markdown
Member Author

@dhartglassMSFT Maybe you can take a look at this?

Copy link
Copy Markdown
Member

@tannergooding tannergooding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good/correct to me with what I understand of LSRA

@jakobbotsch jakobbotsch merged commit a32ff81 into dotnet:main Apr 23, 2026
147 of 150 checks passed
@jakobbotsch jakobbotsch deleted the fix-127131 branch April 23, 2026 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

4 participants