Skip to content
Closed
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
20 changes: 12 additions & 8 deletions src/coreclr/jit/importercalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7887,6 +7887,14 @@ void Compiler::impMarkInlineCandidateHelper(GenTreeCall* call,
return;
}

if (call->IsUnmanaged())
{
// We must have IL to inline.
//
inlineResult->NoteFatal(InlineObservation::CALLEE_IS_UNMANAGED);
return;
}

// Inlining candidate determination needs to honor only IL tail prefix.
// Inlining takes precedence over implicit tail call optimization (if the call is not directly recursive).
if (call->IsTailPrefixedCall())
Expand Down Expand Up @@ -8068,6 +8076,10 @@ void Compiler::impMarkInlineCandidateHelper(GenTreeCall* call,

if (methAttr & CORINFO_FLG_PINVOKE)
{
// We should have already ruled out cases where we can directly call the unamanged method.
Copy link

Copilot AI Jul 28, 2025

Choose a reason for hiding this comment

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

There is a spelling error in the comment: 'unamanged' should be 'unmanaged'.

Suggested change
// We should have already ruled out cases where we can directly call the unamanged method.
// We should have already ruled out cases where we can directly call the unmanaged method.

Copilot uses AI. Check for mistakes.

//
assert(!call->IsUnmanaged());

if (!impCanPInvokeInlineCallSite(compCurBB))
{
inlineResult->NoteFatal(InlineObservation::CALLSITE_PINVOKE_EH);
Expand All @@ -8093,14 +8105,6 @@ void Compiler::impMarkInlineCandidateHelper(GenTreeCall* call,
inlineResult->NoteFatal(InlineObservation::CALLSITE_IS_WITHIN_FILTER);
return;
}

// Do not inline pinvoke stubs with EH.
//
if ((methAttr & CORINFO_FLG_PINVOKE) != 0)
{
inlineResult->NoteFatal(InlineObservation::CALLEE_HAS_EH);
return;
}
}

// The old value should be null OR this call should be a guarded devirtualization candidate.
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/inline.def
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ INLINE_OBSERVATION(IS_ARRAY_METHOD, bool, "is array method",
INLINE_OBSERVATION(IS_JIT_NOINLINE, bool, "noinline per JitNoinline", FATAL, CALLEE)
INLINE_OBSERVATION(IS_NOINLINE, bool, "noinline per IL/cached result", FATAL, CALLEE)
INLINE_OBSERVATION(IS_SYNCHRONIZED, bool, "is synchronized", FATAL, CALLEE)
INLINE_OBSERVATION(IS_UNMANAGED, bool, "is unmanaged code", FATAL, CALLEE)
INLINE_OBSERVATION(IS_VM_NOINLINE, bool, "noinline per VM", FATAL, CALLEE)
INLINE_OBSERVATION(LACKS_RETURN, bool, "no return opcode", FATAL, CALLEE)
INLINE_OBSERVATION(LDFLD_NEEDS_HELPER, bool, "ldfld needs helper", FATAL, CALLEE)
Expand Down
Loading