From e9ea14546380205e5595ca3d84e48e8e4e2a51e0 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Tue, 25 Feb 2025 22:48:34 +0100 Subject: [PATCH] SPMI: Add fallback for `notifyInstructionSetUsage` I noticed that `notifyInstructionSetUsage` misses are pretty common, particularly because we query for instruction sets for some very basic instructions (e.g. `GT_RSZ/`GT_RSH`). So changes that introduce new kinds of nodes now seem to be much more likely to miss. The best solution would probably be to add another set of ISAs that is passed to the JIT so that `notifyInstructionSetUsage` can be purely a "result" type of JIT-EE call, but this change at least gets us back to what we had before with an improvement to when we actually know the answer. --- .../superpmi/superpmi-shared/methodcontext.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp index 17de2d83eec18d..0621f2bcd1eb23 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp @@ -811,9 +811,21 @@ bool MethodContext::repNotifyInstructionSetUsage(CORINFO_InstructionSet isa, boo 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; + + if (NotifyInstructionSetUsage != nullptr) + { + int index = NotifyInstructionSetUsage->GetIndex(key); + if (index != -1) + { + DWORD value = NotifyInstructionSetUsage->GetItem(index); + DEBUG_REP(dmpNotifyInstructionSetUsage(key, value)); + return value != 0; + } + } + + // Fall back to most likely implementation instead of missing, since ISA + // usage changes are quite common on normal JIT changes. + return supported; } void MethodContext::recGetMethodAttribs(CORINFO_METHOD_HANDLE methodHandle, DWORD attribs)