Repository navigation
JIT: check guard types during CEA cloning - #137092
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: c987451d-dcb7-4398-a2d6-8c2ab3f3a8ca
|
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. |
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
|
Note this bug is currently NAOT specific, it only happens when we allow multiple GDV checks (NAOT enables 3 by default) and have a polymorphic profile. If we have this setup then we need to ensure that in the CEA clone we specialize the right checks (since there is more than one to choose from at each site). Also note we are not anti-specializing the known to be wrong checks, which means the cloned code is slightly inefficient coming out of CEA, but these get cleaned up later on by RBO/AP. If we just have a single GDV check and a polymorphic profile (which is what we normally see during jitting) then a diverging GDV will cause CEA to fail. We apparently don't enable multi-guess GDV in PGO stress modes. Seems like we should. |
|
@jakobbotsch PTAL Will probably want to backport this. |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the change restricting guard specialization to matching allocation types.
No open issues 🎉
What changed in this PR
This PR fixes incorrect guarded devirtualization during conditional escape analysis (CEA) cloning in the JIT by requiring guards to match the allocation’s type.
Changes:
- Restricts guard specialization to matching allocation types.
- Adds a regression with opposing factory-call and iteration profiles.
- Configures the regression for tiered compilation, dynamic profile-guided optimization, and multiple type checks.
| File | Description |
|---|---|
src/tests/JIT/opt/ObjectStackAllocation/Runtime_137063.csproj |
Configures isolated execution and optimization settings for the regression. |
src/tests/JIT/opt/ObjectStackAllocation/Runtime_137063.cs |
Tests enumeration counts with conflicting type profiles. |
src/coreclr/jit/objectalloc.cpp |
Checks guard type equality before specializing during cloning. |
Review effort: Balanced
JulieLeeMSFT
left a comment
There was a problem hiding this comment.
LGTM. The fix adds a type-match check so CEA uses the guard for the correct type when a call site has multiple GDV checks.
The author said that backport would work for them. We can skip backports. |
Did you mean to write "will not"? I think we should consider fixing this... |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: c987451d-dcb7-4398-a2d6-8c2ab3f3a8ca
|
Formatter failure looks like a .NET 10 servicing timing glitch, fails looking for 10.0.15. Will retry in an hour or so. |
I mean workaround works for them -- #137063 (comment). |
<!-- --> Add `fullpgo_multiguess_gdv`, based on `fullpgo` with `JitGuardedDevirtualizationMaxTypeChecks=3`. Keep the existing modes unchanged. Run it in the runtime and libraries PGO stress groups. Leave the reduced Windows arm64 scenario lists unchanged because of their existing timeout constraints. Local validation: generated and checked 16 Windows/Unix environment scripts and parsed both changed pipeline YAML files. The new mode emits two guesses at both iterator call sites in the positive control; it fails with the baseline JIT and passes with the fix. Ordinary `fullpgo` still passes on the baseline. Complements #137092. > [!NOTE] > This PR description was generated by GitHub Copilot. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: c987451d-dcb7-4398-a2d6-8c2ab3f3a8ca
|
/azp run runtime |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Only specialize GDV guards that match the allocation's type during CEA cloning. Previously, a cloned boxed List enumerator could take an array-enumerator fast path.
Add a regression with opposing factory and iteration profiles and multiple GDV type checks.
Validation: Checked JIT build passed; the regression fails before the fix and passes afterward. Six neighboring test wrappers passed. The original NativeAOT repro improves from 2/5 to 5/5 correct results.
SPMI: 2,081,803 cached contexts, no assembly diffs or failing compiles; one context lacks data in both JITs. The 3,328-context NativeAOT repro collection changes only
Dfa.DfaBuilder.Closure: 1,032 -> 1,130 bytes (+98 bytes, +9.50%). Stack allocation is retained.Resolves #137063
Note
This PR description was generated by GitHub Copilot.