JIT: remove MorphAddrContext#127684
Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
There was a problem hiding this comment.
Pull request overview
This PR refactors CoreCLR JIT morphing for instance field-address null-check handling by removing the threaded MorphAddrContext state and replacing it with a pre-walk over unmorphed indirection address trees. The goal is to preserve/null-check-elide FIELD_ADDR behavior in a more explicit way during morph.
Changes:
- Adds
fgMarkAddrModeForFieldAddrto pre-scan indirection address trees and markFIELD_ADDRnodes whose explicit null check can be elided. - Replaces the old
MorphAddrContextplumbing fromfgMorphTree/fgMorphSmpOp/fgMorphFieldAddr/fgMorphExpandInstanceField. - Introduces a new
GTF_FLD_TGT_NONFAULTINGflag to carry the pre-walk decision into field-address expansion.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/coreclr/jit/morph.cpp |
Adds the new address pre-walk and updates morphing to consume a per-FIELD_ADDR flag instead of threaded context. |
src/coreclr/jit/gentree.h |
Defines the new GT_FIELD_ADDR flag used by the morph pre-walk. |
src/coreclr/jit/compiler.h |
Removes MorphAddrContext declarations and updates morph helper signatures. |
Replace the threaded MorphAddrContext with fgMarkAddrModeForFieldAddr, a pre-walk over an indirection's address tree that peels constant offsets and chained instance FIELD_ADDRs to decide null-check elision. The new GTF_FLD_TGT_NONFAULTING flag on FIELD_ADDR communicates that the consuming indirection will fault on null, so the explicit null check inserted by morph can be elided. SPMI asmdiffs: no diffs across all 11 collections. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2b35da4 to
9cbbc60
Compare
| mac = nullptr; | ||
| // Examine the unmorphed address tree to identify any FIELD_ADDR whose null check | ||
| // can be elided because this indirection will fault on null instead. | ||
| fgMarkAddrModeForFieldAddr(tree->AsIndir()); |
There was a problem hiding this comment.
It might be handled by PGO, but I think you want an early guard here to avoid the TP hit:
basically do the initial check that tree->Addr()->OperIs(GT_FIELD_ADDR) || !tree->Addr()->AsFieldAddr()->IsInstance(), to avoid hitting the call + loop for all the other indirection types
Removes the
MorphAddrContextthread-through hack fromfgMorphTree/fgMorphSmpOp/fgMorphFieldAddr/fgMorphExpandInstanceFieldand replaces it with a smallfgMarkAddrModeForFieldAddrpre-walk that peels constant offsets and chained instanceFIELD_ADDRs off an indirection's unmorphed address tree to decide null-check elision (a newGTF_FLD_TGT_NONFAULTINGflag is set on each elidableFIELD_ADDR).No SPMI asmdiffs.