Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix JitOptRepeat #94250

Merged
merged 1 commit into from
Apr 1, 2024
Merged

Fix JitOptRepeat #94250

merged 1 commit into from
Apr 1, 2024

Conversation

BruceForstall
Copy link
Member

@BruceForstall BruceForstall commented Nov 1, 2023

Many individual fixes have already been merged. This change adds two more fixes, updates the disabling of OptRepeat for one test, and enables OptRepeat in JitStress.

@ghost ghost assigned BruceForstall Nov 1, 2023
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Nov 1, 2023
@ghost
Copy link

ghost commented Nov 1, 2023

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

Issue Details

null

Author: BruceForstall
Assignees: BruceForstall
Labels:

area-CodeGen-coreclr

Milestone: -

@ghost
Copy link

ghost commented Dec 18, 2023

Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it.

@ghost ghost closed this Dec 18, 2023
@BruceForstall BruceForstall reopened this Dec 19, 2023
@BruceForstall BruceForstall force-pushed the FixOptRepeat branch 2 times, most recently from 9a0d871 to 7127941 Compare January 23, 2024 07:45
@BruceForstall BruceForstall force-pushed the FixOptRepeat branch 2 times, most recently from aeda642 to e28e362 Compare February 16, 2024 00:01
@BruceForstall
Copy link
Member Author

/azp run runtime-coreclr outerloop, runtime-coreclr jitstress, runtime-coreclr libraries-jitstress

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

BruceForstall added a commit to BruceForstall/runtime that referenced this pull request Mar 29, 2024
@BruceForstall
Copy link
Member Author

/azp run runtime-coreclr outerloop, runtime-coreclr jitstress, runtime-coreclr libraries-jitstress

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

1. Remove an assertion checking assert that can be invalid under JitOptRepeat, where we might
lose information that a constant was ever a handle.
2. Disable JIT/Directed/debugging/debuginfo/tester.csproj under OptRepeat: optimizations
mess with its debug info expectations.
3. Enable JitOptRepeat under stress
@BruceForstall
Copy link
Member Author

/azp run runtime-coreclr outerloop, runtime-coreclr jitstress, runtime-coreclr libraries-jitstress

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@BruceForstall BruceForstall marked this pull request as ready for review March 29, 2024 22:42
@BruceForstall
Copy link
Member Author

@AndyAyersMS @dotnet/jit-contrib PTAL

@BruceForstall
Copy link
Member Author

There may be additional JitOptRepeat failures exposed by enabling 4 iterations and enabling it for all functions (instead of just for stress): see #100447. These will be investigated as part of continuing work.

@@ -1876,7 +1883,6 @@ void Compiler::optDebugCheckAssertion(AssertionDsc* assertion)
{
case O1K_EXACT_TYPE:
case O1K_SUBTYPE:
assert(assertion->op2.HasIconFlag());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we shouldn't create such assertions in the first places rather than relaxing this requirement.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you be ok taking this and addressing that in a follow-up?

Copy link
Member

@EgorBo EgorBo Mar 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok to me to merge if it's blocking, my concern that we're effectively allowing arbitary constants for these assertions - from a quick look, users of O1K_EXACT_TYPE/O1K_SUBTYPE assume it's always a valid handle we can pass to VM, etc. (I guess they need to use HasIconFlag too then)

Another concern that we try to avoid generating not-useful assertions since we run out of assertion limit farily often

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can generate an assertion for:

N010 ( 18, 25) [000186] -A---O-----                         *  JTRUE     void   $VN.Void
N009 ( 16, 23) [000031] JA---O-N---                         \--*  EQ        int    $282
N002 (  3,  2) [000030] #----O-----                            +--*  IND       long   $103
N001 (  1,  1) [000029] -----------                            |  \--*  LCL_VAR   ref    V02 arg2         u:1 $82
N008 ( 12, 20) [000202] -A---------                            \--*  COMMA     long   $1c5
N004 (  7, 15) [000198] DA---------                               +--*  STORE_LCL_VAR long   V14 tmp10        d:1 $VN.Void
N003 (  3, 12) [000197] -----------                               |  \--*  CNS_INT   long   0x1237f0098 $1c3
N007 (  5,  5) [000201] -------N---                               \--*  ADD       long   $1c5
N005 (  3,  2) [000199] -----------                                  +--*  LCL_VAR   long   V14 tmp10        u:1 $1c3
N006 (  1,  2) [000200] -----------                                  \--*  CNS_INT   long   0x768 $1c4

namely,

GenTreeNode creates assertion:
N010 ( 18, 25) [000186] -A---O-----                         *  JTRUE     void   $VN.Void
In BB04 New Global Type     Assertion: ($82,$1c5) V02.01 is Exact Type MT(0x0x1237f0800 <unknown class>)

The actual number is correct, but there is no handle data (it's been lost with shared constant CSE).

Where in the code could this be wrong? I.e., where would we look at this value, pass it the VM, etc.?

I guess in optPrintAssertion we cast the constant to CORINFO_CLASS_HANDLE (for non-R2R/NAOT) and pass it to eeGetClassName. But it would be the same number as when we knew it was a handle.

(The previous iteration, the tree looked like:

N005 (  9, 17) [000186] -----O-----                         *  JTRUE     void
N004 (  7, 15) [000031] J----O-N---                         \--*  EQ        int
N002 (  3,  2) [000030] #----O-----                            +--*  IND       long
N001 (  1,  1) [000029] -----------                            |  \--*  LCL_VAR   ref    V02 arg2         u:1
N003 (  3, 12) [000028] H----------                            \--*  CNS_INT(h) long   0x1237f0800 class <unknown class>

)

Copy link
Member

@AndyAyersMS AndyAyersMS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for keeping at this...

@@ -1876,7 +1883,6 @@ void Compiler::optDebugCheckAssertion(AssertionDsc* assertion)
{
case O1K_EXACT_TYPE:
case O1K_SUBTYPE:
assert(assertion->op2.HasIconFlag());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you be ok taking this and addressing that in a follow-up?

@BruceForstall BruceForstall merged commit dc01e99 into dotnet:main Apr 1, 2024
195 checks passed
@BruceForstall BruceForstall deleted the FixOptRepeat branch April 1, 2024 22:19
BruceForstall added a commit to BruceForstall/runtime that referenced this pull request Apr 6, 2024
This test enables JitOptRepeat, which is fixed as of
dotnet#94250
BruceForstall added a commit that referenced this pull request Apr 6, 2024
This test enables JitOptRepeat, which is fixed as of
#94250
matouskozak pushed a commit to matouskozak/runtime that referenced this pull request Apr 30, 2024
1. Remove an assertion checking assert that can be invalid under JitOptRepeat, where we might
lose information that a constant was ever a handle.
2. Disable JIT/Directed/debugging/debuginfo/tester.csproj under OptRepeat: optimizations
mess with its debug info expectations.
3. Enable JitOptRepeat under stress
matouskozak pushed a commit to matouskozak/runtime that referenced this pull request Apr 30, 2024
This test enables JitOptRepeat, which is fixed as of
dotnet#94250
@github-actions github-actions bot locked and limited conversation to collaborators May 2, 2024
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.

3 participants