Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1ed1f17

Browse files
committedMar 25, 2025
Fix AltJit and VectorT ISA specification
When running as an AltJit when the generated code will not be used (either because of a mismatched VM, or because RunAltJitCode=0), the JIT overwrites the passed in ISAs. When it does so, it zeros out the VectorT* ISA flags. Instead of this, carry over the existing ISA flags. This should work for same-architecture SPMI replays. I'm not sure if additional logic for specifically setting the VectorT* ISA is required for other scenarios, or if incorporating similar logic to `EEJitManager::SetCpuInfo()` into `Compiler::compCompile()` is required. Adds new JIT debugging helpers `dIsa()` and `dIsaFlags()` to dump out string representations of `CORINFO_InstructionSet` and `CORINFO_InstructionSetFlags`. Fixes dotnet#113869
1 parent de72cb8 commit 1ed1f17

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
 

‎src/coreclr/jit/compiler.cpp

+60
Original file line numberDiff line numberDiff line change
@@ -5998,6 +5998,7 @@ int Compiler::compCompile(CORINFO_MODULE_HANDLE classPtr,
59985998

59995999
if (enableAvailableIsas)
60006000
{
6001+
CORINFO_InstructionSetFlags currentInstructionSetFlags = compileFlags->GetInstructionSetFlags();
60016002
CORINFO_InstructionSetFlags instructionSetFlags;
60026003

60036004
// We need to assume, by default, that all flags coming from the VM are invalid.
@@ -6011,6 +6012,12 @@ int Compiler::compCompile(CORINFO_MODULE_HANDLE classPtr,
60116012
// needing to have the hardware in question.
60126013

60136014
#if defined(TARGET_ARM64)
6015+
// Keep the existing VectorT* ISAs.
6016+
if (currentInstructionSetFlags.HasInstructionSet(InstructionSet_VectorT128))
6017+
{
6018+
instructionSetFlags.AddInstructionSet(InstructionSet_VectorT128);
6019+
}
6020+
60146021
if (JitConfig.EnableHWIntrinsic() != 0)
60156022
{
60166023
instructionSetFlags.AddInstructionSet(InstructionSet_ArmBase);
@@ -6066,6 +6073,20 @@ int Compiler::compCompile(CORINFO_MODULE_HANDLE classPtr,
60666073
instructionSetFlags.AddInstructionSet(InstructionSet_Sve);
60676074
}
60686075
#elif defined(TARGET_XARCH)
6076+
// Keep the existing VectorT* ISAs.
6077+
if (currentInstructionSetFlags.HasInstructionSet(InstructionSet_VectorT128))
6078+
{
6079+
instructionSetFlags.AddInstructionSet(InstructionSet_VectorT128);
6080+
}
6081+
if (currentInstructionSetFlags.HasInstructionSet(InstructionSet_VectorT256))
6082+
{
6083+
instructionSetFlags.AddInstructionSet(InstructionSet_VectorT256);
6084+
}
6085+
if (currentInstructionSetFlags.HasInstructionSet(InstructionSet_VectorT512))
6086+
{
6087+
instructionSetFlags.AddInstructionSet(InstructionSet_VectorT512);
6088+
}
6089+
60696090
if (JitConfig.EnableHWIntrinsic() != 0)
60706091
{
60716092
instructionSetFlags.AddInstructionSet(InstructionSet_X86Base);
@@ -9355,6 +9376,8 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
93559376
* The following don't require a Compiler* to work:
93569377
* dRegMask : Display a regMaskTP (call dspRegMask(mask)).
93579378
* dBlockList : Display a BasicBlockList*.
9379+
* dIsa : Display a CORINFO_InstructionSet
9380+
* dIsaFlags : Display a CORINFO_InstructionSetFlags
93589381
*
93599382
* The following find an object in the IR and return it, as well as setting a global variable with the value that can
93609383
* be used in the debugger (e.g., in the watch window, or as a way to get an address for data breakpoints).
@@ -9438,6 +9461,8 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
94389461
// Functions which don't require a Compiler*
94399462
#pragma comment(linker, "/include:dRegMask")
94409463
#pragma comment(linker, "/include:dBlockList")
9464+
#pragma comment(linker, "/include:dIsa")
9465+
#pragma comment(linker, "/include:dIsaFlags")
94419466

94429467
// Functions which search for objects in the IR
94439468
#pragma comment(linker, "/include:dFindTreeInTree")
@@ -10322,6 +10347,41 @@ JITDBGAPI void __cdecl dBlockList(BasicBlockList* list)
1032210347
printf("\n");
1032310348
}
1032410349

10350+
JITDBGAPI void __cdecl dIsa(const CORINFO_InstructionSet isa)
10351+
{
10352+
static unsigned sequenceNumber = 0; // separate calls with a number to indicate this function has been called
10353+
printf("===================================================================== dIsa %u\n", sequenceNumber++);
10354+
printf("%s\n", InstructionSetToString(isa));
10355+
}
10356+
10357+
JITDBGAPI void __cdecl dIsaFlags(const CORINFO_InstructionSetFlags& isaFlags)
10358+
{
10359+
static unsigned sequenceNumber = 0; // separate calls with a number to indicate this function has been called
10360+
printf("===================================================================== dIsaFlags %u\n", sequenceNumber++);
10361+
if (isaFlags.IsEmpty())
10362+
{
10363+
printf("<empty>\n");
10364+
}
10365+
else
10366+
{
10367+
bool first = true;
10368+
// The flags start at '1'. We don't know the last flag, so compute the maximum.
10369+
// It would be better if CORINFO_InstructionSet defined InstructionSet_FIRST and InstructionSet_LAST,
10370+
// or even better, if CORINFO_InstructionSetFlags defined an iterator over the instruction sets in the flags.
10371+
CORINFO_InstructionSet isaFirst = (CORINFO_InstructionSet)1;
10372+
CORINFO_InstructionSet isaLast = (CORINFO_InstructionSet)(sizeof(CORINFO_InstructionSetFlags) * 8 - 1);
10373+
for (CORINFO_InstructionSet isa = isaFirst; isa <= isaLast; isa = (CORINFO_InstructionSet)((int)isa + 1))
10374+
{
10375+
if (isaFlags.HasInstructionSet(isa))
10376+
{
10377+
printf("%s%s", first ? "" : " ", InstructionSetToString(isa));
10378+
first = false;
10379+
}
10380+
}
10381+
}
10382+
printf("\n");
10383+
}
10384+
1032510385
// Global variables available in debug mode. That are set by debug APIs for finding
1032610386
// Trees, Stmts, and/or Blocks using id or bbNum.
1032710387
// That can be used in watch window or as a way to get address of fields for data breakpoints.

0 commit comments

Comments
 (0)
Please sign in to comment.