Repository navigation
Fix tree type in impStoreNullableFields and impLoadNullableFields for simds - #124432
Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
There was a problem hiding this comment.
Pull request overview
This PR fixes a critical bug (issue #124425) where nullable SIMD types (e.g., Vector2?, Vector3?, Vector4?) caused an InvalidProgramException in debug builds (with JIT MinOpts enabled). The root cause was that impStoreNullableFields and impLoadNullableFields were using JITtype2varType, which always maps CORINFO_TYPE_VALUECLASS to the generic TYP_STRUCT type. For SIMD types, the specific normalized type (e.g., TYP_SIMD8 for Vector2) must be used instead.
Changes:
- Modified
impStoreNullableFieldsandimpLoadNullableFieldsto useTypeHandleToVarTypewith both theCorInfoTypeand class handle, which properly resolves SIMD types to their normalized type through the layout system - Added a comprehensive regression test that verifies nullable SIMD types throw the expected
NullReferenceExceptionwhen cast from null values
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/coreclr/jit/importer.cpp | Fixed type resolution for nullable SIMD fields in impStoreNullableFields (lines 2996-2998) and impLoadNullableFields (lines 3034-3036) to use TypeHandleToVarType instead of JITtype2varType |
| src/tests/JIT/Regression/JitBlue/Runtime_124425/Runtime_124425.csproj | Test project configuration with DOTNET_JITMinOpts=1 to trigger the unoptimized code path where the bug occurred |
| src/tests/JIT/Regression/JitBlue/Runtime_124425/Runtime_124425.cs | Regression test covering nullable Vector2, Vector3, and Vector4 types |
|
PTAL @jakobbotsch @dotnet/jit-contrib |
… simds (dotnet#124432) Fixes dotnet#124425 - the actual issue is TYP_SIMD* was typed as TYP_STRUCT. We use TypeHandleToVarType for similar places - it correctly maps CORINFO_CLASS_HANDLE into SIMD.
|
/backport to release/10.0 |
|
Started backporting to |
Fixes #124425 - the actual issue is TYP_SIMD* was typed as TYP_STRUCT.
We use TypeHandleToVarType for similar places - it correctly maps CORINFO_CLASS_HANDLE into SIMD.