Skip to content

Commit 75e7800

Browse files
authored
JIT: Mark certain intrinsics as non-escaping (#113093)
1 parent 1b1e94d commit 75e7800

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/coreclr/jit/objectalloc.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,25 @@ bool ObjectAllocator::CanLclVarEscapeViaParentStack(ArrayStack<GenTree*>* parent
11391139
canLclVarEscapeViaParentStack =
11401140
!Compiler::s_helperCallProperties.IsNoEscape(comp->eeGetHelperNum(asCall->gtCallMethHnd));
11411141
}
1142+
else if (asCall->IsSpecialIntrinsic())
1143+
{
1144+
// Some known special intrinsics don't escape. At this moment, only the ones accepting byrefs
1145+
// are supported. In order to support more intrinsics accepting objects, we need extra work
1146+
// on the VM side which is not ready for that yet.
1147+
//
1148+
switch (comp->lookupNamedIntrinsic(asCall->gtCallMethHnd))
1149+
{
1150+
case NI_System_SpanHelpers_ClearWithoutReferences:
1151+
case NI_System_SpanHelpers_Fill:
1152+
case NI_System_SpanHelpers_Memmove:
1153+
case NI_System_SpanHelpers_SequenceEqual:
1154+
canLclVarEscapeViaParentStack = false;
1155+
break;
1156+
1157+
default:
1158+
break;
1159+
}
1160+
}
11421161

11431162
// Note there is nothing special here about the parent being a call. We could move all this processing
11441163
// up to the caller and handle any sort of tree that could lead to escapes this way.

src/coreclr/jit/utils.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -1669,6 +1669,13 @@ void HelperCallProperties::init()
16691669
isPure = true;
16701670
break;
16711671

1672+
case CORINFO_HELP_MEMCPY:
1673+
case CORINFO_HELP_MEMZERO:
1674+
case CORINFO_HELP_MEMSET:
1675+
case CORINFO_HELP_NATIVE_MEMSET:
1676+
isNoEscape = true;
1677+
break;
1678+
16721679
case CORINFO_HELP_LDELEMA_REF:
16731680
isPure = true;
16741681
break;

0 commit comments

Comments
 (0)