Repository navigation
JIT: Separate map select caches by VN kind - #137855
Conversation
Map select cache keys omit VN kind, so a liberal result can be reused during conservative phi evaluation. This can make the JIT treat separate field reads as equal and remove a necessary array bounds check. Keep separate caches for each VN kind. Fixes dotnet#134489. Co-authored-by: Copilot <[email protected]>
|
Azure Pipelines: Successfully started running 5 pipeline(s). 10 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
@jakobbotsch ptal |
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the JIT value-numbering cache fix.
No open issues 🎉
What changed in this PR
This PR fixes JIT value numbering so liberal map-select results cannot be reused during conservative evaluation, preventing incorrect bounds-check removal described in #134489.
Changes:
- Separates map-select work caches by value-number kind.
- Updates cache lookups and writes to use the requested kind.
- Adds a regression test that exercises bounds checks while another thread changes the source field.
| File | Description |
|---|---|
src/tests/JIT/Regression_ro_2/Runtime_134489.cs |
Adds the concurrent field-read regression test. |
src/coreclr/jit/valuenum.h |
Defines separate liberal and conservative caches and a kind-aware accessor. |
src/coreclr/jit/valuenum.cpp |
Passes the value-number kind to every map-select work-cache access. |
Review effort: Balanced
|
/azp run runtime-coreclr superpmi-diffs |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
/ba-g infrastructure issue, agent did not connect within 45 minutes |
| Thread writer = new Thread(() => | ||
| { | ||
| while (Volatile.Read(ref stop) == 0) | ||
| { | ||
| Volatile.Write(ref holder.F.A, 0); | ||
| Volatile.Write(ref holder.F.A, 100_000_000); | ||
| } | ||
| }) | ||
| { | ||
| IsBackground = true | ||
| }; | ||
| writer.Start(); |
There was a problem hiding this comment.
This test is failing on wasm it looks like ("Operation not supported")
There was a problem hiding this comment.
We apparently don't run this under Wasm in CI. I'll add an exclusion.
Summary
Map-select results were cached without including the value-number kind. A liberal result could be reused during conservative phi evaluation, causing the JIT to treat separate field reads as equal and remove a necessary array bounds check. This change keeps separate caches for each kind and adds a regression test.
Validation
src\tests\build.cmd -Test JIT\Regression_ro_2\Regression_ro_2.csproj x64 checked -Priority 1- passed..\build.cmd clr.jit -c Checked- passed.src\tests\build.cmd -GenerateLayoutOnly x64 checked- passed.Runtime_134489.TestEntryPointwith the checked Core_Root: failed with an access violation before the fix; passed after it (exit code 100).Resolves #134489
Note
This PR description was generated with GitHub Copilot.