diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index 56a9a1eb543c70..214fcd438ae2e5 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -7091,9 +7091,11 @@ class Compiler bool fgHasLoops = false; protected: - unsigned optCallCount = 0; // number of calls made in the method - unsigned optIndirectCallCount = 0; // number of virtual, interface and indirect calls made in the method - unsigned optNativeCallCount = 0; // number of Pinvoke/Native calls made in the method + unsigned optCallCount = 0; // number of calls made in the method + unsigned optIndirectCallCount = 0; // number of virtual, interface and indirect calls made in the method + unsigned optNativeCallCount = 0; // number of Pinvoke/Native calls made in the method + unsigned optFastTailCallCount = 0; // number of fast tail calls made in the method + unsigned optIndirectFastTailCallCount = 0; // number of indirect (see above) fast tail calls made in the method #ifdef DEBUG void optCheckPreds(); diff --git a/src/coreclr/jit/morph.cpp b/src/coreclr/jit/morph.cpp index a0425a44b6ea3c..65f339748c0c22 100644 --- a/src/coreclr/jit/morph.cpp +++ b/src/coreclr/jit/morph.cpp @@ -6374,6 +6374,11 @@ GenTree* Compiler::fgMorphCall(GenTreeCall* call) { optCallCount++; optIndirectCallCount++; + if (call->IsFastTailCall()) + { + optFastTailCallCount++; + optIndirectFastTailCallCount++; + } } else if (call->gtCallType == CT_USER_FUNC) { @@ -6382,6 +6387,14 @@ GenTree* Compiler::fgMorphCall(GenTreeCall* call) { optIndirectCallCount++; } + if (call->IsFastTailCall()) + { + optFastTailCallCount++; + if (call->IsVirtual()) + { + optIndirectFastTailCallCount++; + } + } } } diff --git a/src/coreclr/jit/regalloc.cpp b/src/coreclr/jit/regalloc.cpp index a2e3c28005aedb..de010e01c60875 100644 --- a/src/coreclr/jit/regalloc.cpp +++ b/src/coreclr/jit/regalloc.cpp @@ -136,12 +136,12 @@ bool Compiler::rpMustCreateEBPFrame(INDEBUG(const char** wbReason)) INDEBUG(reason = "Method has Loops"); result = true; } - if (!result && (optCallCount >= 2)) + if (!result && (optCallCount >= optFastTailCallCount + 2)) { INDEBUG(reason = "Call Count"); result = true; } - if (!result && (optIndirectCallCount >= 1)) + if (!result && (optIndirectCallCount >= optIndirectFastTailCallCount + 1)) { INDEBUG(reason = "Indirect Call"); result = true;