Skip to content

Conversation

@jakobbotsch
Copy link
Member

rax was used before, but rax is used as an argument for the indirection cell for R2R tailcalls. r10 has a use for some pinvokes, but we do not tailcall for these.

Fix #120780

rax was used before, but rax is used as an argument for the indirection
cell for R2R tailcalls. r10 has a use for some pinvokes, but we do not
tailcall for these.
@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 Oct 21, 2025
@jakobbotsch jakobbotsch marked this pull request as ready for review October 22, 2025 21:02
@Copilot Copilot AI review requested due to automatic review settings October 22, 2025 21:02
Copy link
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

This PR fixes a register conflict issue in JIT compilation where the GS cookie check was using the rax register for tailcalls, but rax is also needed for R2R (Ready-to-Run) indirection cells during tailcalls. The fix changes the temporary register used for GS cookie checks in tailcall scenarios from rax to r10 on x64 platforms.

Key changes:

  • Modified genGetGSCookieTempRegs to return r10 instead of rax for x64 tailcalls
  • Added an assertion in AddFinalArgsAndDetermineABIInfo to verify that PInvoke functions with non-standard args are not tail-called

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/coreclr/jit/codegencommon.cpp Changes GS cookie temp register from rax to r10 for x64 tailcalls and refactors conditional compilation directives
src/coreclr/jit/morph.cpp Adds assertion and comment documenting that PInvoke functions are not tail-called, preventing conflict with r11

@jakobbotsch
Copy link
Member Author

PTAL @dotnet/jit-contrib, another one of these, this time around the change that enabled tailcalls for functions with GS cookie checks on x64.

@jakobbotsch jakobbotsch merged commit e9be069 into dotnet:main Oct 22, 2025
112 checks passed
@jakobbotsch jakobbotsch deleted the fix-120780 branch October 22, 2025 22:42
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

Development

Successfully merging this pull request may close these issues.

Test failure: JIT/Directed/perffix/primitivevt/mixed1_cs_do/mixed1_cs_do.dll

2 participants