Skip to content

Conversation

@BruceForstall
Copy link
Contributor

When traversing the IDom tree from the single loop exit, you must reach the single loop entry.

When traversing the IDom tree from the single loop exit, you must
reach the single loop entry.
@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Apr 1, 2023
@ghost ghost assigned BruceForstall Apr 1, 2023
@ghost
Copy link

ghost commented Apr 1, 2023

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch, @kunalspathak
See info in area-owners.md if you want to be subscribed.

Issue Details

When traversing the IDom tree from the single loop exit, you must reach the single loop entry.

Author: BruceForstall
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@BruceForstall
Copy link
Contributor Author

/azp run runtime-coreclr outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@BruceForstall
Copy link
Contributor Author

There are a few asserts on spmi replay on win-x86 on libraries_tests.pmi:

[19:54:07] ISSUE: <ASSERT> #291793 D:\a\_work\1\s\src\coreclr\jit\optimizer.cpp (6937) - Assertion failed 'pLoopDsc->lpContains(cur)' in 'System.IO.Ports.Tests.DiscardNull_Property:Read_byte_int_int(System.IO.Ports.SerialPort):ushort[]:this' during 'Hoist loop code' (IL size 89; hash 0x9bf77ea5; FullOpts)

[19:54:07] ISSUE: <ASSERT> #292001 D:\a\_work\1\s\src\coreclr\jit\optimizer.cpp (6937) - Assertion failed 'pLoopDsc->lpContains(cur)' in 'System.IO.Ports.Tests.ReadByte_Generic:ParityErrorOnLastByte():this' during 'Hoist loop code' (IL size 423; hash 0x3a597446; FullOpts)

[19:54:07] ISSUE: <ASSERT> #292741 D:\a\_work\1\s\src\coreclr\jit\optimizer.cpp (6937) - Assertion failed 'pLoopDsc->lpContains(cur)' in 'System.IO.Ports.Tests.SerialStream_Flush:VerifyFlush(System.IO.Ports.SerialPort):this' during 'Hoist loop code' (IL size 214; hash 0xa01046a4; FullOpts)

[19:54:07] ISSUE: <ASSERT> #291794 D:\a\_work\1\s\src\coreclr\jit\optimizer.cpp (6937) - Assertion failed 'pLoopDsc->lpContains(cur)' in 'System.IO.Ports.Tests.DiscardNull_Property:Read_char_int_int(System.IO.Ports.SerialPort):ushort[]:this' during 'Hoist loop code' (IL size 78; hash 0x5d81d7b7; FullOpts)

[19:54:07] ISSUE: <ASSERT> #292763 D:\a\_work\1\s\src\coreclr\jit\optimizer.cpp (6937) - Assertion failed 'pLoopDsc->lpContains(cur)' in 'System.IO.Ports.Tests.SerialStream_ReadByte_Generic:ParityErrorOnLastByte():this' during 'Hoist loop code' (IL size 468; hash 0xc3659885; FullOpts)

[19:54:07] ISSUE: <ASSERT> #292040 D:\a\_work\1\s\src\coreclr\jit\optimizer.cpp (6937) - Assertion failed 'pLoopDsc->lpContains(cur)' in 'System.IO.Ports.Tests.ReadChar_Generic:ParityErrorOnLastByte():this' during 'Hoist loop code' (IL size 368; hash 0x1cdc0714; FullOpts)

@BruceForstall
Copy link
Contributor Author

One case (291793) looks like the following:

***************  Natural loop table
L00, from BB02 to BB04 (Head=BB01, Entry=BB02, Exit=BB03) call

--- blocks:

BB02 [0002]  2  0    BB01,BB04            1472. 5888  0 [00F..01E)-> BB04 (always) T0      try { }     keep i try Loop hascall gcsafe idxlen bwd IBC
BB03 [0003]  1     0                       0       0  0 [01E..021)-> BB05 (always)    H0   catch { }   keep i rare hascall bwd IBC
BB04 [0004]  1       BB02                  0       0  0 [021..02F)-> BB02 (always)                     i rare hascall gcsafe bwd bwd-src IBC

So, we've got an infinite loop where the "loop exit" is a branch from the "catch". Note that on x86 the handlers haven't been moved to funclets. BB03, the handler, has no predecessors in our graph, so is a dominator "root". The IDom parent is empty. Walking up from this exit will obviously not reach the loop entry.

This seems very strange. Perhaps we should disallow handler branches to be considered as a loop exit? Perhaps we should verify and assert that a loop entry dominates all its exits?

@ghost ghost locked as resolved and limited conversation to collaborators May 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant