Skip to content

JIT: Spill value before byref address in stsfld #115772

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

Merged
merged 1 commit into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12975,6 +12975,11 @@ void Compiler::gtDispTree(GenTree* tree,
disp();
}

if (call->IsAsync())
{
printf(" (async)");
}

if ((call->gtFlags & GTF_CALL_UNMANAGED) && (call->gtCallMoreFlags & GTF_CALL_M_FRAME_VAR_DEATH))
{
printf(" (FramesRoot last use)");
Expand Down
10 changes: 8 additions & 2 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9592,8 +9592,8 @@ void Compiler::impImportBlockCode(BasicBlock* block)
{
bool isHoistable =
info.compCompHnd->getClassAttribs(resolvedToken.hClass) & CORINFO_FLG_BEFOREFIELDINIT;
unsigned check_spill = isHoistable ? CHECK_SPILL_NONE : CHECK_SPILL_ALL;
impAppendTree(helperNode, check_spill, impCurStmtDI);
unsigned checkSpill = isHoistable ? CHECK_SPILL_NONE : CHECK_SPILL_ALL;
impAppendTree(helperNode, checkSpill, impCurStmtDI);
}
}

Expand Down Expand Up @@ -9627,6 +9627,12 @@ void Compiler::impImportBlockCode(BasicBlock* block)
{
impSpillSideEffects(true, CHECK_SPILL_ALL DEBUGARG("value for stsfld with typeinit"));
}
else if (compIsAsync() && op1->TypeIs(TYP_BYREF))
Copy link
Preview

Copilot AI May 20, 2025

Choose a reason for hiding this comment

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

The new condition for spilling byref addresses in async methods always triggers the spill even though the inline comment suggests it may only be necessary if op2 possibly performs an async call. Consider refining this condition in the future to more precisely match the intended necessity for spilling.

Copilot uses AI. Check for mistakes.

{
// TODO-Async: We really only need to spill if
// there is a possibility of an async call in op2.
impSpillSideEffects(true, CHECK_SPILL_ALL DEBUGARG("byref address in async method"));
}
break;

default:
Expand Down
Loading