JIT: stop treating ManagedThreadId helper as constant/pure#130006
JIT: stop treating ManagedThreadId helper as constant/pure#130006Copilot wants to merge 4 commits into
Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT, @VSadov |
Co-authored-by: VSadov <8218165+VSadov@users.noreply.github.com>
Co-authored-by: VSadov <8218165+VSadov@users.noreply.github.com>
|
@copilot we should also not mark the helper as "pure" in general, so that it cannot be moved and cross async suspend points. It is still valid to treat it as no-throw. |
Co-authored-by: VSadov <8218165+VSadov@users.noreply.github.com>
Updated in da58ef9: |
There was a problem hiding this comment.
Pull request overview
This change updates CoreCLR JIT value numbering and helper metadata so CORINFO_HELP_GETCURRENTMANAGEDTHREADID is no longer modeled as a pure / method-constant operation, preventing VN from treating repeated uses as equivalent across the method.
Changes:
- Removed the VN function (
VNF_ManagedThreadId) plumbing forCORINFO_HELP_GETCURRENTMANAGEDTHREADID. - Updated helper call properties so
CORINFO_HELP_GETCURRENTMANAGEDTHREADIDis no longer marked pure (while remaining no-throw). - Added a VN-path guard to ensure the helper is treated as non-pure during helper-call VN handling.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/coreclr/jit/valuenumfuncs.h | Removes the VNFunc definition previously used for ManagedThreadId. |
| src/coreclr/jit/valuenum.cpp | Stops mapping the helper to a VNFunc and adjusts helper-call VN handling accordingly. |
| src/coreclr/jit/utils.cpp | Updates helper metadata so GETCURRENTMANAGEDTHREADID is no longer classified as pure. |
| if (helpFunc == CORINFO_HELP_GETCURRENTMANAGEDTHREADID) | ||
| { | ||
| pure = false; | ||
| } |
This PR removes JIT assumptions that can treat
CORINFO_HELP_GETCURRENTMANAGEDTHREADIDas stable across async suspension, where execution may resume on a different thread.Description
CORINFO_HELP_GETCURRENTMANAGEDTHREADID -> VNF_ManagedThreadIdfromfgValueNumberJitHelperMethodVNFuncinsrc/coreclr/jit/valuenum.cpp.ValueNumFuncDef(ManagedThreadId, 0, false, false)fromsrc/coreclr/jit/valuenumfuncs.h.fgValueNumberHelperCallto treatCORINFO_HELP_GETCURRENTMANAGEDTHREADIDas non-pure for VN purposes if it survives as a helper call, so it goes through opaque VN handling instead of function-mapped VN.HelperCallProperties::init()insrc/coreclr/jit/utils.cppsoCORINFO_HELP_GETCURRENTMANAGEDTHREADIDis no longer marked pure, while still marked no-throw.What stays unchanged
CORINFO_HELP_GETCURRENTMANAGEDTHREADIDremains).impConvertToUserCallAndMarkForInlining) is unchanged.