Repository navigation
Closed
Closed
Copy link
Labels
JitStressCLR JIT issues involving JIT internal stress modesPriority:2Work that is important, but not critical for the releasearea-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIblocking-clean-ci-optionalBlocking optional rolling runs
Milestone
Description
With DOTNET_JitStress=2 and DOTNET_JitStressRegs=8 we hit this assert in some of the Swift tests.
ISSUE: <ASSERT> #16 C:\dev\dotnet\runtime\src\coreclr\jit\lsra.cpp (7418) - Assertion failed 'parent->OperGet() == oper' in 'SwiftRetAbiStress:TestSwiftRetFunc0()' during 'LSRA allocate' (IL size 95; hash 0xbcced63c; Tier0)When we hit the assert, the LIR looks like the following:
N070 ( 14, 5) [000038] --CXG-----Z t38 = ▌ CALL unman struct SwiftRetAbiStress:SwiftRetFunc0():SwiftRetAbiStress+S0 REG rax,rdx,rcx
┌──▌ t38 struct
[000129] --CXG------ t129 = ▌ COPY struct REG rbx,r15,NA
N072 ( 3, 2) [000094] ----------- t94 = LCL_VAR long V03 FramesRoot NA REG NA
┌──▌ t94 long
N074 ( 4, 3) [000096] -c--------- t96 = ▌ LEA(b+12) long REG NA
N076 ( 1, 1) [000095] -c--------- t95 = CNS_INT byte 1 REG NA
┌──▌ t96 long
├──▌ t95 byte
N078 ( 10, 8) [000097] ----------- ▌ STOREIND byte REG NA
N080 ( 3, 10) [000098] Hc--------- t98 = CNS_INT(h) long 0x10e8b4e70 ftn REG NA
┌──▌ t98 long
N082 ( 5, 12) [000099] nc--G------ t99 = ▌ IND int REG NA
┌──▌ t99 int
N084 ( 6, 13) [000100] ----G------ ▌ RETURNTRAP int REG NA
N086 ( 3, 2) [000101] ----------- t101 = LCL_VAR long V03 FramesRoot NA REG NA
┌──▌ t101 long
N088 ( 4, 3) [000102] -c--------- t102 = ▌ LEA(b+16) long REG NA
N090 ( 3, 4) [000103] ----------- t103 = LCL_FLD byref (AX) V04 PInvokeFrame [+16] NA REG NA
┌──▌ t102 long
├──▌ t103 byref
N092 ( 11, 10) [000104] ----------- ▌ STOREIND long REG NA
┌──▌ t129 struct
N094 ( 24, 12) [000037] DACXG------ ▌ STORE_LCL_VAR struct<SwiftRetAbiStress+S0, 18> V02 tmp1 NA REG NAThe refPosition has refPosition->reload == 1, but the parent node (of [000038]) is a GT_COPY.
I've attached an SPMI collection that repros the assertion on commit 0ea9b8f with clrjit_unix_x64_x64.dll -- pass -c 16.
cc @kunalspathak -- any idea?
Metadata
Metadata
Assignees
Labels
JitStressCLR JIT issues involving JIT internal stress modesPriority:2Work that is important, but not critical for the releasearea-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIblocking-clean-ci-optionalBlocking optional rolling runs
Activity
dotnet-policy-service commentedon Mar 15, 2024
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.
kunalspathak commentedon Mar 15, 2024
Thanks for the spmi collection. Will take a look.
BruceForstall commentedon Mar 18, 2024
Here's a pipeline run with the failure:
https://dev.azure.com/dnceng-public/public/_build/results?buildId=607040&view=ms.vss-test-web.build-test-results-tab
BruceForstall commentedon Mar 18, 2024
Looks like it doesn't require JitStress, just JitStressRegs=8:
https://dev.azure.com/dnceng-public/public/_build/results?buildId=607046&view=ms.vss-test-web.build-test-results-tab
v-wenyuxu commentedon Mar 25, 2024
Failed in: runtime-coreclr jitstressregs 20240324.1
Failed tests:
Error message:
Stack trace:
v-wenyuxu commentedon Apr 1, 2024
Failed in: runtime-coreclr jitstressregs 20240331.1
Failed tests:
Error message:
Stack trace:
v-wenyuxu commentedon Apr 7, 2024
Failed in: runtime-coreclr jitstressregs 20240406.1
Failed tests:
Error message:
Stack trace:
v-wenyuxu commentedon Apr 15, 2024
Failed in: runtime-coreclr jitstressregs 20240414.1
Failed tests:
Error message:
Stack trace:
v-wenyuxu commentedon Apr 22, 2024
Failed in: runtime-coreclr jitstressregs 20240421.1
Failed tests:
Error message:
Stack trace:
kunalspathak commentedon May 2, 2024
We define 3 multi-reg for
SwiftRetAbiStress:SwiftRetFunc0():SwiftRetAbiStress+S0. At the use, we do not get same registers for all 3 of them and so we need to insertGT_COPY. 2 of the registers are not spilled and hence COPY suffice, but for 3rd, we spilled it and hence have to RELOAD it (to a different register) at the use.At the use, we create this single tree node
GenTreeCopyOrReloadand setmultiRegIdxfor the 3 registers. However, for the 3rd register (which is RELOAD), we cannot use the logic ofGT_COPYand emit themov, but need to reload it from the stack. If we ignore the fact thatGT_COPYis required for the 3rd register and letGT_RELOADcontinue, I wanted to see where it goes wrong, but unfortunately the superpmi collection I have seems outdated and it failed withMISSING: Method context 16 failed to replay: SuperPMI assertion failed (missing key "key" in map GetHelperFtn): key 82. Probably I will need to try reproing on osx/x64 directly and test out few theories.I am also wondering why we did not see similar situation in the past or perhaps the jitstressregs were restricting it from limiting the available regs under stress, making this situation less common or undiscovered.
kunalspathak commentedon May 2, 2024
It turns out, we do mark the entire tree spilled when one or more allocated registers are spilled
runtime/src/coreclr/jit/lsra.cpp
Lines 8176 to 8185 in 28c39bc
and during unspill, already take care of that.
runtime/src/coreclr/jit/codegenlinear.cpp
Lines 2117 to 2129 in 28c39bc
As such the assert in the issue is not needed. I verified that the registers marked as
COPYvs.RELOADare retrieved accurately at the use: