Skip to content

SPMI: Record and replay notifyInstructionSetUsage properly #112764

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 4 commits into from
Feb 22, 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
12 changes: 6 additions & 6 deletions src/coreclr/inc/jiteeversionguid.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ typedef const GUID *LPCGUID;
#define GUID_DEFINED
#endif // !GUID_DEFINED

constexpr GUID JITEEVersionIdentifier = { /* a116647a-3f80-4fd6-9c80-95156c7e9923 */
0xa116647a,
0x3f80,
0x4fd6,
{0x9c, 0x80, 0x95, 0x15, 0x6c, 0x7e, 0x99, 0x23}
};
constexpr GUID JITEEVersionIdentifier = { /* 4463d6ac-dfcb-4ab0-a941-c53b56089b7c */
0x4463d6ac,
0xdfcb,
0x4ab0,
{0xa9, 0x41, 0xc5, 0x3b, 0x56, 0x08, 0x9b, 0x7c}
};

//////////////////////////////////////////////////////////////////////////////////////////////////////////
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ public void ExpandInstructionSetByImplication(TargetArchitecture architecture)

public static InstructionSet ConvertToImpliedInstructionSetForVectorInstructionSets(TargetArchitecture architecture, InstructionSet input)
{
switch(architecture)
switch (architecture)
Copy link
Member Author

Choose a reason for hiding this comment

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

#112302 enabled a new warning without updating the generator (the generated file was changed manually)

{
");
foreach (string architecture in _architectures)
Expand All @@ -554,7 +554,7 @@ public static InstructionSet ConvertToImpliedInstructionSetForVectorInstructionS
continue;

tr.Write($@" case TargetArchitecture.{architecture}:
switch(input)
switch (input)
{{
");
foreach (var vectorInstructionSet in _architectureVectorInstructionSetJitNames[architecture])
Expand Down Expand Up @@ -635,7 +635,7 @@ private static InstructionSetFlags ExpandInstructionSetByReverseImplicationHelpe
do
{
oldflags = resultflags;
switch(architecture)
switch (architecture)
{
");
foreach (string architecture in _architectures)
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ LWM(GetLazyStringLiteralHelper, DWORDLONG, DWORD)
LWM(GetLocationOfThisType, DWORDLONG, Agnostic_CORINFO_LOOKUP_KIND)
LWM(IsIntrinsic, DWORDLONG, DWORD)
LWM(NotifyMethodInfoUsage, DWORDLONG, DWORD)
LWM(NotifyInstructionSetUsage, DD, DWORD)
LWM(GetMethodAttribs, DWORDLONG, DWORD)
LWM(GetClassAssemblyName, DWORDLONG, DWORD)
LWM(GetMethodClass, DWORDLONG, DWORDLONG)
Expand Down
25 changes: 25 additions & 0 deletions src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,31 @@ bool MethodContext::repNotifyMethodInfoUsage(CORINFO_METHOD_HANDLE ftn)
return value != 0;
}

void MethodContext::recNotifyInstructionSetUsage(CORINFO_InstructionSet isa, bool supported, bool result)
{
if (NotifyInstructionSetUsage == nullptr)
NotifyInstructionSetUsage = new LightWeightMap<DD, DWORD>();

DD key{};
key.A = (DWORD)isa;
key.B = supported ? 1 : 0;
NotifyInstructionSetUsage->Add(key, result ? 1 : 0);
DEBUG_REC(dmpNotifyInstructionSetUsage(key, result ? 1 : 0));
}
void MethodContext::dmpNotifyInstructionSetUsage(DD key, DWORD value)
{
printf("NotifyInstructionSetUsage key isa-%u, supported-%u, res-%u", key.A, key.B, value);
}
bool MethodContext::repNotifyInstructionSetUsage(CORINFO_InstructionSet isa, bool supported)
{
DD key{};
key.A = (DWORD)isa;
key.B = supported ? 1 : 0;
DWORD value = LookupByKeyOrMiss(NotifyInstructionSetUsage, key, ": key %u-%u", key.A, key.B);
DEBUG_REP(dmpNotifyInstructionSetUsage(key, value));
return value != 0;
}

void MethodContext::recGetMethodAttribs(CORINFO_METHOD_HANDLE methodHandle, DWORD attribs)
{
if (GetMethodAttribs == nullptr)
Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ class MethodContext
void dmpNotifyMethodInfoUsage(DWORDLONG key, DWORD value);
bool repNotifyMethodInfoUsage(CORINFO_METHOD_HANDLE ftn);

void recNotifyInstructionSetUsage(CORINFO_InstructionSet instructionSet, bool supported, bool result);
void dmpNotifyInstructionSetUsage(DD key, DWORD supported);
bool repNotifyInstructionSetUsage(CORINFO_InstructionSet instructionSet, bool supported);

void recGetMethodAttribs(CORINFO_METHOD_HANDLE methodHandle, DWORD attribs);
void dmpGetMethodAttribs(DWORDLONG key, DWORD value);
DWORD repGetMethodAttribs(CORINFO_METHOD_HANDLE methodHandle);
Expand Down Expand Up @@ -1203,6 +1207,7 @@ enum mcPackets
Packet_GetSZArrayHelperEnumeratorClass = 226,
Packet_GetMethodInstantiationArgument = 227,
Packet_GetInstantiatedEntry = 228,
Packet_NotifyInstructionSetUsage = 229,
};

void SetDebugDumpVariables();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ bool interceptor_ICJI::notifyMethodInfoUsage(CORINFO_METHOD_HANDLE ftn)
return temp;
}

bool interceptor_ICJI::notifyInstructionSetUsage(CORINFO_InstructionSet instructionSet, bool supported)
{
mc->cr->AddCall("notifyInstructionSetUsage");
bool result = original_ICorJitInfo->notifyInstructionSetUsage(instructionSet, supported);
mc->recNotifyInstructionSetUsage(instructionSet, supported, result);
return result;
}

// return flags (defined above, CORINFO_FLG_PUBLIC ...)
uint32_t interceptor_ICJI::getMethodAttribs(CORINFO_METHOD_HANDLE ftn /* IN */)
{
Expand Down Expand Up @@ -2024,11 +2032,6 @@ uint32_t interceptor_ICJI::getExpectedTargetArchitecture()
return result;
}

bool interceptor_ICJI::notifyInstructionSetUsage(CORINFO_InstructionSet instructionSet, bool supported)
{
return original_ICorJitInfo->notifyInstructionSetUsage(instructionSet, supported);
}

CORINFO_METHOD_HANDLE interceptor_ICJI::getSpecialCopyHelper(CORINFO_CLASS_HANDLE type)
{
mc->cr->AddCall("getSpecialCopyHelper");
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1529,7 +1529,7 @@ bool MyICJI::convertPInvokeCalliToCall(CORINFO_RESOLVED_TOKEN* pResolvedToken, b
bool MyICJI::notifyInstructionSetUsage(CORINFO_InstructionSet instructionSet, bool supported)
{
jitInstance->mc->cr->AddCall("notifyInstructionSetUsage");
return supported;
return jitInstance->mc->repNotifyInstructionSetUsage(instructionSet, supported);
}

void MyICJI::updateEntryPointForTailCall(CORINFO_CONST_LOOKUP* entryPoint)
Expand Down
Loading