@@ -1440,6 +1440,32 @@ var_types Compiler::impImportCall(OPCODE opcode,
1440
1440
{
1441
1441
impSpillSideEffects (true , CHECK_SPILL_ALL DEBUGARG (" non-inline candidate call" ));
1442
1442
}
1443
+
1444
+ if (JitConfig.JitProfileValues () && call->IsCall () &&
1445
+ call->AsCall ()->IsSpecialIntrinsic (this , NI_System_SpanHelpers_SequenceEqual))
1446
+ {
1447
+ if (opts.IsOptimizedWithProfile ())
1448
+ {
1449
+ call = impDuplicateWithProfiledArg (call->AsCall (), rawILOffset);
1450
+ if (call->OperIs (GT_QMARK))
1451
+ {
1452
+ // QMARK has to be a root node
1453
+ unsigned tmp = lvaGrabTemp (true DEBUGARG (" Grabbing temp for Qmark" ));
1454
+ impStoreTemp (tmp, call, CHECK_SPILL_ALL);
1455
+ call = gtNewLclvNode (tmp, call->TypeGet ());
1456
+ }
1457
+ }
1458
+ else if (opts.IsInstrumented ())
1459
+ {
1460
+ // We might want to instrument it for optimized versions too, but we don't currently.
1461
+ HandleHistogramProfileCandidateInfo* pInfo =
1462
+ new (this , CMK_Inlining) HandleHistogramProfileCandidateInfo;
1463
+ pInfo->ilOffset = rawILOffset;
1464
+ pInfo->probeIndex = 0 ;
1465
+ call->AsCall ()->gtHandleHistogramProfileCandidateInfo = pInfo;
1466
+ compCurBB->SetFlags (BBF_HAS_VALUE_PROFILE);
1467
+ }
1468
+ }
1443
1469
}
1444
1470
1445
1471
// -------------------------------------------------------------------------
@@ -1536,7 +1562,15 @@ GenTree* Compiler::impDuplicateWithProfiledArg(GenTreeCall* call, IL_OFFSET ilOf
1536
1562
argNum = 2 ;
1537
1563
1538
1564
minValue = 1 ; // TODO: enable for 0 as well.
1539
- maxValue = (ssize_t )getUnrollThreshold (Memmove);
1565
+ maxValue = (ssize_t )getUnrollThreshold (ProfiledMemmove);
1566
+ }
1567
+ else if (call->IsSpecialIntrinsic (this , NI_System_SpanHelpers_SequenceEqual))
1568
+ {
1569
+ // dst(0), src(1), len(2)
1570
+ argNum = 2 ;
1571
+
1572
+ minValue = 1 ; // TODO: enable for 0 as well.
1573
+ maxValue = (ssize_t )getUnrollThreshold (ProfiledMemcmp);
1540
1574
}
1541
1575
else
1542
1576
{
@@ -2729,7 +2763,8 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis,
2729
2763
break ;
2730
2764
2731
2765
case NI_System_Buffer_Memmove:
2732
- // We're going to instrument this one
2766
+ case NI_System_SpanHelpers_SequenceEqual:
2767
+ // We're going to instrument these
2733
2768
betterToExpand = opts.IsInstrumented ();
2734
2769
break ;
2735
2770
0 commit comments