Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all 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
51 changes: 47 additions & 4 deletions src/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4282,7 +4282,6 @@ int Compiler::compCompile(CORINFO_METHOD_HANDLE methodHnd,
{
if (compIsForInlining())
{
JITLOG((LL_INFO1000000, INLINER_FAILED "Inlinee marked as skipped.\n"));
compInlineResult->setNever("Inlinee marked as skipped");
}
return CORJIT_SKIPPED;
Expand Down Expand Up @@ -4891,7 +4890,7 @@ int Compiler::compCompileHelper (CORINFO_MODULE_HANDLE clas
if (opts.eeFlags & CORJIT_FLG_PREJIT)
{
// Cache inlining hint during NGen to avoid touching bodies of non-inlineable methods at runtime
JitInlineResult trialResult(info.compCompHnd, nullptr, methodHnd);
JitInlineResult trialResult(this, nullptr, methodHnd, "prejit1");
impCanInlineIL(methodHnd, methodInfo, forceInline, &trialResult);
if (trialResult.isFailure())
{
Expand Down Expand Up @@ -4937,7 +4936,7 @@ int Compiler::compCompileHelper (CORINFO_MODULE_HANDLE clas
assert(compNativeSizeEstimate != NATIVE_SIZE_INVALID);

int callsiteNativeSizeEstimate = impEstimateCallsiteNativeSize(methodInfo);
JitInlineResult trialResult(info.compCompHnd, nullptr, methodHnd);
JitInlineResult trialResult(this, nullptr, methodHnd, "prejit2");

impCanInlineNative(callsiteNativeSizeEstimate,
compNativeSizeEstimate,
Expand Down Expand Up @@ -5000,7 +4999,6 @@ int Compiler::compCompileHelper (CORINFO_MODULE_HANDLE clas
(fgBBcount > 5) &&
!forceInline)
{
JITLOG((LL_INFO1000000, INLINER_FAILED "Too many basic blocks in the inlinee.\n"));
compInlineResult->setNever("Too many basic blocks in the inlinee");
goto _Next;
}
Expand Down Expand Up @@ -9750,3 +9748,48 @@ HelperCallProperties Compiler::s_helperCallProperties;

/*****************************************************************************/
/*****************************************************************************/

//------------------------------------------------------------------------
// report: Dump, log, and report information about an inline decision.
//
// Notes:
//
// Called (automatically via the JitInlineResult dtor) when the inliner
// is done evaluating a candidate.
//
// Dumps state of the inline candidate, and if a decision was reached
// sends it to the log and reports the decision back to the EE.
//
// All this can be suppressed if desired by calling setReported() before
// the JitInlineResult goes out of scope.

void JitInlineResult::report()
{
// User may have suppressed reporting via setReported(). If so, do nothing.
if (inlReported)
{
return;
}

inlReported = true;

#ifdef DEBUG

const char* format = "INLINER: during '%s' result '%s' reason '%s' for '%s' calling '%s'\n";
const char* caller = (inlInliner == nullptr) ? "n/a" : inlCompiler->eeGetMethodFullName(inlInliner);
const char* callee = (inlInlinee == nullptr) ? "n/a" : inlCompiler->eeGetMethodFullName(inlInlinee);

JITDUMP(format, inlContext, resultString(), inlReason, caller, callee);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like you might as well put this within the #if DEBUG, above


#endif // DEBUG

if (isDecided())
{
JITLOG_THIS(inlCompiler, (LL_INFO100000, format, inlContext, resultString(), inlReason, caller, callee));
COMP_HANDLE comp = inlCompiler->info.compCompHnd;
comp->reportInliningDecision(inlInliner, inlInlinee, result(), inlReason);
}
}



48 changes: 32 additions & 16 deletions src/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -878,14 +878,16 @@ class JitInlineResult
public:

// Construct a new JitInlineResult.
JitInlineResult(COMP_HANDLE compiler,
JitInlineResult(Compiler* compiler,
CORINFO_METHOD_HANDLE inliner,
CORINFO_METHOD_HANDLE inlinee)
: inlComp(compiler)
CORINFO_METHOD_HANDLE inlinee,
const char* context)
: inlCompiler(compiler)
, inlDecision(InlineDecision::UNDECIDED)
, inlInliner(inliner)
, inlInlinee(inlinee)
, inlReason(nullptr)
, inlContext(context)
, inlReported(false)
{
// empty
Expand All @@ -910,6 +912,26 @@ class JitInlineResult
}
}

// Translate into string for dumping
const char* resultString() const
{
switch (inlDecision) {
case InlineDecision::SUCCESS:
return "success";
case InlineDecision::FAILURE:
return "failed this call site";
case InlineDecision::NEVER:
return "failed this callee";
case InlineDecision::CANDIDATE:
return "candidate";
case InlineDecision::UNDECIDED:
return "undecided";
default:
assert(!"Unexpected: interim inline result");
unreached();
}
}

// True if this definitely a failed inline candidate
bool isFailure() const
{
Expand Down Expand Up @@ -1012,7 +1034,7 @@ class JitInlineResult
setCommon(InlineDecision::NEVER, reason);
}

// Report decision, if necessary.
// Report/log/dump decision as appropriate
~JitInlineResult()
{
report();
Expand All @@ -1021,7 +1043,7 @@ class JitInlineResult
const char * reason() const { return inlReason; }

// setReported indicates that this particular result doesn't need
// to be reported back to the runtime, either becaus the runtime
// to be reported back to the runtime, either because the runtime
// already knows, or we weren't actually inlining yet.
void setReported() { inlReported = true; }

Expand All @@ -1038,21 +1060,15 @@ class JitInlineResult
inlDecision = decision;
inlReason = reason;
}

void report()
{
if (!inlReported && isDecided())
{
inlComp->reportInliningDecision(inlInliner, inlInlinee, result(), inlReason);
}
inlReported = true;
}

COMP_HANDLE inlComp;

void report();

Compiler* inlCompiler;
InlineDecision inlDecision;
CORINFO_METHOD_HANDLE inlInliner;
CORINFO_METHOD_HANDLE inlInlinee;
const char* inlReason;
const char* inlContext;
bool inlReported;
};

Expand Down
3 changes: 0 additions & 3 deletions src/jit/flowgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22053,9 +22053,6 @@ void Compiler::fgInvokeInlineeCompiler(GenTreeCall* call,
if (!(info.compCompHnd->initClass(NULL /* field */, fncHandle /* method */,
inlineCandidateInfo->exactContextHnd /* context */) & CORINFO_INITCLASS_INITIALIZED))
{
JITLOG((LL_INFO100000, INLINER_FAILED "Could not complete class init side effect: "
"%s called by %s\n",
eeGetMethodFullName(fncHandle), info.compFullName));
inlineResult->setNever("Failed class init side-effect");
return;
}
Expand Down
Loading