Enable must-throw for unsupported intrinsics under optimizations#129007
Enable must-throw for unsupported intrinsics under optimizations#129007tannergooding wants to merge 9 commits into
Conversation
Co-authored-by: tannergooding <10487869+tannergooding@users.noreply.github.com>
…4/128/256/512 ISAs in lookupId Co-authored-by: tannergooding <10487869+tannergooding@users.noreply.github.com>
Co-authored-by: tannergooding <10487869+tannergooding@users.noreply.github.com>
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
There was a problem hiding this comment.
Pull request overview
This PR adjusts CoreCLR JIT intrinsic recognition so that unsupported intrinsics are handled more consistently under optimizations: cross-platform intrinsic APIs (with managed fallbacks) no longer hard-throw PlatformNotSupportedException when the ISA isn’t available, while platform-specific intrinsic APIs (and platform-mismatched sub-namespaces) are forced to throw. It also changes unsupported-intrinsic expansion to prefer emitting a MustThrowException in optimized codegen, avoiding a redundant managed call that would only throw anyway.
Changes:
- Extend
HWIntrinsicInfo::lookupIdwith anisXplatIntrinsicflag to distinguish cross-platform intrinsics (managed fallback) from platform-specific intrinsics (must throw PNSE when unsupported). - In
lookupNamedIntrinsic, correctly classify intrinsics underSystem.Runtime.Intrinsicsincluding platform-mismatched sub-namespaces (e.g.,.X86on ARM64) as must-throw PNSE. - In
impUnsupportedNamedIntrinsic, return aMustThrowExceptionnode not only formustExpand, but also when optimizations are enabled.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/coreclr/jit/importercalls.cpp | Classifies cross-platform vs platform-specific intrinsics and forces PNSE for platform-mismatched intrinsic namespaces; enables must-throw emission under optimizations for unsupported intrinsics. |
| src/coreclr/jit/hwintrinsic.h | Updates HWIntrinsicInfo::lookupId declaration to accept the new isXplatIntrinsic parameter. |
| src/coreclr/jit/hwintrinsic.cpp | Implements the new isXplatIntrinsic behavior: cross-platform intrinsics with unsupported ISA return NI_Illegal (allowing managed fallback), platform-specific intrinsics return PNSE. |
2e60a4b to
ad543ec
Compare
This should put less pressure on the doing repetitive work and should allow merging of the various must throw blocks. The general issue was noticed in #128513 (comment), where we had some size regressions due to cold blocks for throwing intrinsics not being merged as they callee was unique for each; even though we don't really care about it being in the stack trace (its optimized code, inlining and loss of that stack trace entry was already possible).