From 1e421670a6456d9c5b924b7ffea14cab8559a2e9 Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Tue, 23 May 2023 09:21:59 +0200 Subject: [PATCH] Allow overbudget for small methods (#86473) Co-authored-by: Andy Ayers --- src/coreclr/jit/inlinepolicy.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/coreclr/jit/inlinepolicy.cpp b/src/coreclr/jit/inlinepolicy.cpp index c9f0d50..75088eb 100644 --- a/src/coreclr/jit/inlinepolicy.cpp +++ b/src/coreclr/jit/inlinepolicy.cpp @@ -502,11 +502,26 @@ bool DefaultPolicy::BudgetCheck() const // assert(m_IsForceInlineKnown); assert(m_CallsiteDepth > 0); - const bool allowOverBudget = m_IsForceInline && (m_CallsiteDepth <= strategy->GetMaxForceInlineDepth()); + bool allowOverBudget = m_IsForceInline && (m_CallsiteDepth <= strategy->GetMaxForceInlineDepth()); + + const unsigned skipBudgetChecksSize = 12; + if (!allowOverBudget && (m_CodeSize <= skipBudgetChecksSize)) + { + // We don't want to give up on various getters/setters if we're running out of budget + JITDUMP("Allowing over-budget for small methods\n") + allowOverBudget = true; + } + + if (!allowOverBudget && m_IsNoReturnKnown && m_IsNoReturn) + { + // We're not going to inline no-return calls anyway + JITDUMP("Allowing over-budget for known no-returns\n") + allowOverBudget = true; + } if (allowOverBudget) { - JITDUMP("Allowing over-budget top-level forceinline\n"); + JITDUMP("Allowing over-budget: top-level forceinline, no return call, or small inlinee\n"); } else { -- 2.7.4