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

JIT: Mark certain intrinsics as non-escaping #113093

Merged
merged 2 commits into from
Mar 4, 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
19 changes: 19 additions & 0 deletions src/coreclr/jit/objectalloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,25 @@ bool ObjectAllocator::CanLclVarEscapeViaParentStack(ArrayStack<GenTree*>* parent
canLclVarEscapeViaParentStack =
!Compiler::s_helperCallProperties.IsNoEscape(comp->eeGetHelperNum(asCall->gtCallMethHnd));
}
else if (asCall->IsSpecialIntrinsic())
{
// Some known special intrinsics don't escape. At this moment, only the ones accepting byrefs
Copy link
Member

Choose a reason for hiding this comment

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

byrefs for non-GC types....

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll add that to the comment as part of a different PR to avoid re-running CI 🙂

// are supported. In order to support more intrinsics accepting objects, we need extra work
// on the VM side which is not ready for that yet.
//
switch (comp->lookupNamedIntrinsic(asCall->gtCallMethHnd))
{
case NI_System_SpanHelpers_ClearWithoutReferences:
case NI_System_SpanHelpers_Fill:
case NI_System_SpanHelpers_Memmove:
case NI_System_SpanHelpers_SequenceEqual:
canLclVarEscapeViaParentStack = false;
break;

default:
break;
}
}

// Note there is nothing special here about the parent being a call. We could move all this processing
// up to the caller and handle any sort of tree that could lead to escapes this way.
Expand Down
7 changes: 7 additions & 0 deletions src/coreclr/jit/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1669,6 +1669,13 @@ void HelperCallProperties::init()
isPure = true;
break;

case CORINFO_HELP_MEMCPY:
case CORINFO_HELP_MEMZERO:
case CORINFO_HELP_MEMSET:
case CORINFO_HELP_NATIVE_MEMSET:
isNoEscape = true;
break;

case CORINFO_HELP_LDELEMA_REF:
isPure = true;
break;
Expand Down
Loading