Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 4 additions & 24 deletions src/coreclr/jit/inline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ void InlineResult::Report()
// Was the result NEVER? If so we might want to propagate this to
// the runtime.

if (IsNever() && m_Policy->PropagateNeverToRuntime())
if (IsNever() && m_Policy->PropagateNeverToRuntime() && (m_Callee != nullptr))
{
// If we know the callee, and if the observation that got us
// to this Never inline state is something *other* than
Expand All @@ -795,36 +795,16 @@ void InlineResult::Report()
// so that future inline attempts for this callee fail faster.
//
InlineObservation obs = m_Policy->GetObservation();

bool report = (m_Callee != nullptr);
bool suppress = (obs == InlineObservation::CALLEE_IS_NOINLINE);
bool dynamicPgo = m_RootCompiler->fgPgoDynamic;

// If dynamic pgo is active, only propagate noinline back to metadata
// when there is a CALLEE FATAL observation. We want to make sure
// not to block future inlines based on performance or throughput considerations.
//
// Note fgPgoDynamic (and hence dynamicPgo) is true iff TieredPGO is enabled globally.
// In particular this value does not depend on the root method having PGO data.
//
if (dynamicPgo)
{
InlineTarget target = InlGetTarget(obs);
InlineImpact impact = InlGetImpact(obs);
suppress = (target != InlineTarget::CALLEE) || (impact != InlineImpact::FATAL);
}

if (report && !suppress)
if (obs != InlineObservation::CALLEE_IS_NOINLINE)
{
JITDUMP("\nINLINER: Marking %s as NOINLINE (observation %s)\n", callee, InlGetObservationString(obs));

COMP_HANDLE comp = m_RootCompiler->info.compCompHnd;
comp->setMethodAttribs(m_Callee, CORINFO_FLG_BAD_INLINEE);
}
else if (suppress)
else
{
JITDUMP("\nINLINER: Not marking %s NOINLINE; %s (observation %s)\n", callee,
dynamicPgo ? "pgo active" : "already known", InlGetObservationString(obs));
JITDUMP("\nINLINER: Not marking %s NOINLINE because it's already marked as such\n", callee);
}
}

Expand Down
50 changes: 40 additions & 10 deletions src/coreclr/jit/inlinepolicy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1036,18 +1036,48 @@ void DefaultPolicy::OnDumpXml(FILE* file, unsigned indent) const

bool DefaultPolicy::PropagateNeverToRuntime() const
{
//
// Do not propagate the "no return" observation. If we do this then future inlining
// attempts will fail immediately without marking the call node as "no return".
// This can have an adverse impact on caller's code quality as it may have to preserve
// registers across the call.
// TODO-Throughput: We should persist the "no return" information in the runtime
// so we don't need to re-analyze the inlinee all the time.
//
if (m_Observation == InlineObservation::CALLEE_DOES_NOT_RETURN)
{
// Do not propagate the "no return" observation. If we do this then future inlining
// attempts will fail immediately without marking the call node as "no return".
// This can have an adverse impact on caller's code quality as it may have to preserve
// registers across the call.
// TODO-Throughput: We should persist the "no return" information in the runtime
// so we don't need to re-analyze the inlinee all the time.
//
return false;
}

InlineTarget target = InlGetTarget(GetObservation());
InlineImpact impact = InlGetImpact(GetObservation());

if ((target == InlineTarget::CALLEE) && (impact == InlineImpact::FATAL))
{
// This callee will never inline.
//
return true;
}

bool propagate = (m_Observation != InlineObservation::CALLEE_DOES_NOT_RETURN);
if (m_InsideThrowBlock)
{
// We inline only trivial methods inside BBJ_THROW call-sites - no need to record that.
//
return false;
}

if (m_RootCompiler->fgPgoDynamic)
{
// If dynamic pgo is active, only propagate noinline back to metadata
// when there is a CALLEE FATAL observation. We want to make sure
// not to block future inlines based on performance or throughput considerations.
//
// Note fgPgoDynamic (and hence dynamicPgo) is true iff TieredPGO is enabled globally.
// In particular this value does not depend on the root method having PGO data.
//
return false;
}

return propagate;
return true;
}

#if defined(DEBUG)
Expand Down
Loading