JIT: Type implicit byref args as TYP_I_IMPL - #134644
Conversation
Implicit byref arguments are never on the GC heap (dotnet#133304), so type them as TYP_I_IMPL rather than TYP_BYREF to avoid GC reporting them. Also treat return buffers as non-null in fgAddrCouldBeNull. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5bb92e6b-deb1-4963-9107-87559f446347
|
Azure Pipelines: Successfully started running 6 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 |
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
One or more issues must be addressed before approval.
Review effort: Lite
Findings: None
What changed in this PR
Updates JIT handling of implicit byref parameters to use TYP_I_IMPL, avoiding GC reporting and unnecessary write barriers. It also recognizes return-buffer locals as non-null.
Changes:
- Retypes implicit byref locals and related IR.
- Updates diagnostics, async analysis, and scope handling.
- Documents the non-GC semantics of implicit byrefs.
| File | Description |
|---|---|
| src/coreclr/jit/scopeinfo.cpp | Updated as part of this pull request. |
| src/coreclr/jit/morph.cpp | Updated as part of this pull request. |
| src/coreclr/jit/lclvars.cpp | Updated as part of this pull request. |
| src/coreclr/jit/importer.cpp | Updated as part of this pull request. |
| src/coreclr/jit/gentree.cpp | Updated as part of this pull request. |
| src/coreclr/jit/flowgraph.cpp | Updated as part of this pull request. |
| src/coreclr/jit/fgdiagnostic.cpp | Updated as part of this pull request. |
| src/coreclr/jit/compiler.h | Updated as part of this pull request. |
| src/coreclr/jit/asyncanalysis.cpp | Updated as part of this pull request. |
| docs/design/coreclr/botr/clr-abi.md | Updated as part of this pull request. |
* Keep implicit byrefs TYP_BYREF in async methods: their storage changes on resumption, so derived addresses must not be kept live (e.g. CSE'd) across suspension points. * Use fgAddrCouldBeHeap for write barrier selection and teach it about implicit byrefs, removing checked barriers for stores to ret bufs and implicit byrefs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5bb92e6b-deb1-4963-9107-87559f446347
|
PTAL @jakobbotsch @dotnet/jit-contrib Diffs mostly from teaching |
|
@EgorBo I wonder if this will have beneficial impacts for Wasm CQ; Specifically, we are trying to reduce conservative spilling of refs to the shadow stack, so if these were marked as possibly GC references before and they aren't now, this could maybe remove the need for some spills. |
|
Update: looking at the diffs, I see some removals of both spills and explicit null checks, and it looks like the biggest overall code size reduction was actually on the Wasm CoreLib collection! |
Yep, it seems wasm uses implicit byrefs more (Non-unwrappable structures) |
Implicit byref args are never on the GC heap (#133304), so type them as
TYP_I_IMPLinstead ofTYP_BYREF(no GC reporting); async methods keepTYP_BYREFsince their storage changes on resumption.Treat return buffers as non-null in
fgAddrCouldBeNull, and usefgAddrCouldBeHeap(now aware of implicit byrefs) for write barrier selection.Contributes to #82166