JIT: don't inline methods with small stackallocs if the call site is … (#43516)
authorAndy Ayers <andya@microsoft.com>
Mon, 19 Oct 2020 19:48:16 +0000 (12:48 -0700)
committerGitHub <noreply@github.com>
Mon, 19 Oct 2020 19:48:16 +0000 (12:48 -0700)
commitf8fb84ca9ab13e1f81ad7ed5366c164bcf5bb1e2
tree2c11fa8c37f3d387936f58aff7c6f7dd351631a5
parent466e4b78e4a06a73ea6cbe24324c6256fc546f58
JIT: don't inline methods with small stackallocs if the call site is … (#43516)

The logic in `fgInlinePrependStatements` that zero-initializes locals doesn't
kick in for jit temps introduced when small stackallocs are optimized. So if we
inline a method with a small stackalloc into a loop, the memory for the
stackalloc doesn't get properly re-zeroed on each iteration.

Fix by disallowing such inlines by adding an extra check: the call site must
not be in a loop.

Closes #43391.
src/coreclr/src/jit/compiler.h
src/coreclr/src/jit/importer.cpp
src/tests/JIT/Regression/JitBlue/Runtime_43391/Runtime_43391.cs [new file with mode: 0644]
src/tests/JIT/Regression/JitBlue/Runtime_43391/Runtime_43391.csproj [new file with mode: 0644]