Inliner: fix assert for multiple failure reasons when inlining
authorAndy Ayers <andya@microsoft.com>
Wed, 2 Mar 2016 07:24:43 +0000 (23:24 -0800)
committerAndy Ayers <andya@microsoft.com>
Wed, 2 Mar 2016 07:30:14 +0000 (23:30 -0800)
commit48d47cafab3622ec1fca1ac22d924d2397162140
treeca5c42a20d6c9b55ae927a71ad10bf98ae4e6a33
parent51d2bf16ecb4843226922e750979e95cf1f78a1e
Inliner: fix assert for multiple failure reasons when inlining

Change dotnet/coreclr#3436 added asserts that checked that the LegacyPolicy would not
see multiple failing observations when inlining because we expect the
inliner to fail fast when it hits the first bad observation.

This change adds a test case that shows one example where we could get
two failing observations, along with code changes to fix the issue.

When an inlinee has invalid IL, an exception is raised and caught in
`jitNativeCode`. The catch there sets the inline result to the never
state. A failure code is propagated back to `fgInvokeInlineeCompiler`
which redundantly sets the inline result to a failing state with a
generic "something bad happened" observation. This second observation
triggers an assert since the jit is inlining and the result is already
known to be a failure.

The fix is to check in `fgInvokeInlineeCompiler` if the inline result
is already known to be in a failing state, and if so, forgo the new
observation.

Commit migrated from https://github.com/dotnet/coreclr/commit/eec9185b2257e8810d8e2af1a4bc41a05cdf51b6
src/coreclr/src/jit/flowgraph.cpp
src/coreclr/tests/src/JIT/opt/Inline/regression/badcallee/app.config [new file with mode: 0644]
src/coreclr/tests/src/JIT/opt/Inline/regression/badcallee/badcallee.il [new file with mode: 0644]
src/coreclr/tests/src/JIT/opt/Inline/regression/badcallee/badcallee.ilproj [new file with mode: 0644]