Skip to content

Commit 3291c8c

Browse files
committed
JIT: avoid creating unnecessary temp for indirect virtual stub calls
We don't need to spill the stub address if it's already a local. Peeled off from dotnet#116771.
1 parent 0d628da commit 3291c8c

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/coreclr/jit/importercalls.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -310,14 +310,17 @@ var_types Compiler::impImportCall(OPCODE opcode,
310310
// complex expression. As it is evaluated after the args,
311311
// it may cause registered args to be spilled. Simply spill it.
312312
//
313-
unsigned const lclNum = lvaGrabTemp(true DEBUGARG("VirtualCall with runtime lookup"));
314-
if (compDonotInline())
313+
if (!stubAddr->OperIs(GT_LCL_VAR))
315314
{
316-
return TYP_UNDEF;
317-
}
315+
unsigned const lclNum = lvaGrabTemp(true DEBUGARG("VirtualCall with runtime lookup"));
316+
if (compDonotInline())
317+
{
318+
return TYP_UNDEF;
319+
}
318320

319-
impStoreToTemp(lclNum, stubAddr, CHECK_SPILL_NONE);
320-
stubAddr = gtNewLclvNode(lclNum, TYP_I_IMPL);
321+
impStoreToTemp(lclNum, stubAddr, CHECK_SPILL_NONE);
322+
stubAddr = gtNewLclvNode(lclNum, TYP_I_IMPL);
323+
}
321324

322325
// Create the actual call node
323326

0 commit comments

Comments
 (0)