diff --git a/src/coreclr/jit/importercalls.cpp b/src/coreclr/jit/importercalls.cpp index a7ccd9ebdf0850..13dec2ec193387 100644 --- a/src/coreclr/jit/importercalls.cpp +++ b/src/coreclr/jit/importercalls.cpp @@ -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()) @@ -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. + // + assert(!call->IsUnmanaged()); + if (!impCanPInvokeInlineCallSite(compCurBB)) { inlineResult->NoteFatal(InlineObservation::CALLSITE_PINVOKE_EH); @@ -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. diff --git a/src/coreclr/jit/inline.def b/src/coreclr/jit/inline.def index 47a226e07d4116..2dfbccd20dc182 100644 --- a/src/coreclr/jit/inline.def +++ b/src/coreclr/jit/inline.def @@ -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)