JIT: Expand simple stfld addresses early#125141
JIT: Expand simple stfld addresses early#125141jakobbotsch wants to merge 6 commits intodotnet:mainfrom
Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
There was a problem hiding this comment.
Pull request overview
This PR updates CoreCLR JIT import/morph logic to preserve IL evaluation order for stfld when the field address involves a large offset (which may require an explicit null check), and adds a regression test to cover the scenario.
Changes:
- Add a new JIT regression test (
Runtime_125124) validating that RHS evaluation is not reordered past a null check for large-offsetstfld. - Teach the importer to expand “simple” instance field store addresses early (when the offset is not “big”), avoiding the need for an explicit null check in those cases.
- Add
impCanReorderWithNullCheckhelper and adjustString.get_Lengthintrinsic import by removing a redundantGTF_EXCEPTannotation.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tests/JIT/Regression/Regression_ro_1.csproj | Adds the new regression test source file to the test project. |
| src/tests/JIT/Regression/JitBlue/Runtime_125124/Runtime_125124.cs | New regression test covering stfld RHS vs null-check ordering for large offsets. |
| src/coreclr/jit/lclmorph.cpp | Updates local address recognition to account for GT_LCL_ADDR offsets during struct field promotion/address morphing. |
| src/coreclr/jit/importercalls.cpp | Removes redundant manual GTF_EXCEPT marking for String.get_Length (array-length node already annotates exceptions). |
| src/coreclr/jit/importer.cpp | Adds reorderability helper and implements early expansion of small-offset stfld addresses with updated spilling logic. |
| src/coreclr/jit/compiler.h | Declares the new impCanReorderWithNullCheck helper. |
|
|
||
| [Fact] | ||
| public static void TestEntryPoint() | ||
| { |
There was a problem hiding this comment.
The test relies on the initial value of the static flag s_barCalled. To make the test self-contained (and resilient to potential re-runs within the same process), consider explicitly resetting s_barCalled to false at the start of TestEntryPoint before executing the scenario.
| { | |
| { | |
| s_barCalled = false; |
Alternative to #125126