diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index cc83afe48a430..8bb778f9d326e 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -25862,7 +25862,7 @@ bool GenTreeLclFld::IsOffsetMisaligned() const bool GenTree::IsInvariant() const { - return OperIsConst() || OperIs(GT_LCL_ADDR); + return OperIsConst() || OperIs(GT_LCL_ADDR) || OperIs(GT_FTN_ADDR); } //------------------------------------------------------------------------ diff --git a/src/coreclr/jit/importer.cpp b/src/coreclr/jit/importer.cpp index e7d03fbc9c236..b8e9bfde05453 100644 --- a/src/coreclr/jit/importer.cpp +++ b/src/coreclr/jit/importer.cpp @@ -12758,7 +12758,7 @@ void Compiler::impFixPredLists() // bool Compiler::impIsInvariant(const GenTree* tree) { - return tree->OperIsConst() || impIsAddressInLocal(tree); + return tree->OperIsConst() || impIsAddressInLocal(tree) || tree->OperIs(GT_FTN_ADDR); } //------------------------------------------------------------------------ diff --git a/src/coreclr/jit/importercalls.cpp b/src/coreclr/jit/importercalls.cpp index 0d6cd2aa8fb80..1cd5cc5dd18ff 100644 --- a/src/coreclr/jit/importercalls.cpp +++ b/src/coreclr/jit/importercalls.cpp @@ -1631,8 +1631,9 @@ GenTreeCall* Compiler::impImportIndirectCall(CORINFO_SIG_INFO* sig, const DebugI * it may cause registered args to be spilled. Simply spill it. */ - // Ignore this trivial case. - if (impStackTop().val->gtOper != GT_LCL_VAR) + // Ignore no args or trivial cases. + if ((sig->callConv != CORINFO_CALLCONV_DEFAULT || sig->totalILArgs() > 0) && + !impStackTop().val->OperIs(GT_LCL_VAR, GT_FTN_ADDR, GT_CNS_INT)) { impSpillStackEntry(verCurrentState.esStackDepth - 1, BAD_VAR_NUM DEBUGARG(false) DEBUGARG("impImportIndirectCall"));