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

8263303: C2 compilation fails with assert(found_sfpt) failed: no node in loop that's not input to safepoint #4278

Closed
wants to merge 3 commits into from

Conversation

rwestrel
Copy link
Contributor

@rwestrel rwestrel commented Jun 1, 2021

The loop strip mining verification code catches a node which is pinned
in the outer strip mined loop but not referenced from the safepoint
node.

The test case is an example of how this could happen. The array[i]
load is referenced from the safepoint initially through:

(j - 10) * array[i]

It is sunk out of the inner loop and pinned in the outer loop. A
following loop opts round causes j - 10 to constant fold to 0 and as a
consequence the array load is no longer referenced from the safepoint
but pinned in the outer strip mined loop.

I tried to find a way to preserve the invariant that all nodes in the
outer strip mined loop are referenced from the safepoint but found no
robust way for that. So the fix removes that part of the verification
code.

This requires loop cloning code to be adjusted for nodes pinned in the
outer strip mined loop but not referenced from the safepoint.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8263303: C2 compilation fails with assert(found_sfpt) failed: no node in loop that's not input to safepoint

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/4278/head:pull/4278
$ git checkout pull/4278

Update a local copy of the PR:
$ git checkout pull/4278
$ git pull https://git.openjdk.java.net/jdk pull/4278/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 4278

View PR using the GUI difftool:
$ git pr show -t 4278

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/4278.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 1, 2021

👋 Welcome back roland! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Jun 1, 2021
@openjdk
Copy link

openjdk bot commented Jun 1, 2021

@rwestrel The following label will be automatically applied to this pull request:

  • hotspot-compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the hotspot-compiler hotspot-compiler-dev@openjdk.org label Jun 1, 2021
@mlbridge
Copy link

mlbridge bot commented Jun 1, 2021

Webrevs

Copy link
Member

@chhagedorn chhagedorn left a comment

That's reasonable. Looks good to me!

// rr record ~/jdk-jdk/build/linux-x86_64-server-fastdebug/images/jdk/bin/java -XX:-TieredCompilation -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:+PrintCompilation -XX:CompileOnly=TestPinnedUseInOuterLSM::test -XX:CompileCommand=quiet -XX:PrintIdealGraphFile=graph.xml -XX:PrintIdealGraphLevel=2 -XX:+UseG1GC -XX:+TraceLoopOpts -XX:LoopUnrollLimit=0 TestPinnedUseInOuterLSM

Copy link
Member

@chhagedorn chhagedorn Jun 9, 2021

Choose a reason for hiding this comment

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

Probably a leftover, can be removed

Copy link
Contributor Author

@rwestrel rwestrel Jun 9, 2021

Choose a reason for hiding this comment

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

fixed

@openjdk
Copy link

openjdk bot commented Jun 9, 2021

@rwestrel This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8263303: C2 compilation fails with assert(found_sfpt) failed: no node in loop that's not input to safepoint

Reviewed-by: chagedorn, kvn

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 175 new commits pushed to the master branch:

  • bb3d226: 8238213: Method resolution should stop on static error
  • 81fdeb5: 8268417: Add test from JDK-8268360
  • caf7f49: 8268122: Add specific gc cause for G1 full collections
  • 43e38a1: 8268377: Windows 32bit build fails after JDK-8268174
  • 5fbb62c: 8268163: Change the order of fallback full GCs in G1
  • 7b1e402: 8266598: Exception values for AnnotationTypeMismatchException are not always informative
  • 13d6180: 8264859: Implement Context-Specific Deserialization Filters
  • dd34a4c: 8268372: ZGC: dynamically select the number of concurrent GC threads used
  • 4388959: 8268056: Update java.net and java.nio to use switch expressions
  • 9cfd560: 8267663: [vector] Add unsigned comparison operators on AArch64
  • ... and 165 more: https://git.openjdk.java.net/jdk/compare/ae2f37f868bfdcb3d46098e91ed537fb199d7dbe...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jun 9, 2021
@rwestrel
Copy link
Contributor Author

rwestrel commented Jun 9, 2021

@chhagedorn thanks for the review.

@vnkozlov
Copy link
Contributor

vnkozlov commented Jun 9, 2021

Yes, we can't assume that all node in outer loop are referenced by Safepoint node. SP nodes reference only live values in current BC. In the test case it is value 'v'. After constant fold `v' become 0 and that is what SF should see (MulNode::Value() optimizes multiplication by 0). array[i] load should be dead at this point since nothing should be referencing it (except GC barriers, may be).

And I don't get how array[i] is moved from inner loop - it depends on i - loop's index.

@rwestrel
Copy link
Contributor Author

rwestrel commented Jun 9, 2021

Thanks for looking at this @vnkozlov

Yes, we can't assume that all node in outer loop are referenced by Safepoint node. SP nodes reference only live values in current BC. In the test case it is value 'v'. After constant fold `v' become 0 and that is what SF should see (MulNode::Value() optimizes multiplication by 0). array[i] load should be dead at this point since nothing should be referencing it (except GC barriers, may be).

The test case has: return v + array[i-1] + f;
array[i-1] is after i is incremented so commons with array[i] in the loop body. That keeps the array[i] load alive.

And I don't get how array[i] is moved from inner loop - it depends on i - loop's index.

It's sunk out of loop because it only has uses out of loop. One of the uses is still indirectly the safepoint at the time sinking happens so it's pinned in the outer loop.

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Let me run tests before you push.

@vnkozlov
Copy link
Contributor

vnkozlov commented Jun 9, 2021

Thanks for looking at this @vnkozlov

Yes, we can't assume that all node in outer loop are referenced by Safepoint node. SP nodes reference only live values in current BC. In the test case it is value 'v'. After constant fold `v' become 0 and that is what SF should see (MulNode::Value() optimizes multiplication by 0). array[i] load should be dead at this point since nothing should be referencing it (except GC barriers, may be).

The test case has: return v + array[i-1] + f;
array[i-1] is after i is incremented so commons with array[i] in the loop body. That keeps the array[i] load alive.

Got it. I assume it happens after constant folding j - 10 to 0.

And I don't get how array[i] is moved from inner loop - it depends on i - loop's index.

It's sunk out of loop because it only has uses out of loop. One of the uses is still indirectly the safepoint at the time sinking happens so it's pinned in the outer loop.

Okay.

@vnkozlov
Copy link
Contributor

vnkozlov commented Jun 9, 2021

Testing results are good.

@rwestrel
Copy link
Contributor Author

rwestrel commented Jun 10, 2021

@vnkozlov thanks for the review & testing

@rwestrel
Copy link
Contributor Author

rwestrel commented Jun 10, 2021

/integrate

@openjdk openjdk bot closed this Jun 10, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jun 10, 2021
@openjdk
Copy link

openjdk bot commented Jun 10, 2021

@rwestrel Since your change was applied there have been 189 commits pushed to the master branch:

  • dd1cbad: 8268285: vmTestbase/nsk/jvmti/GetThreadState/thrstat002 failed with "Wrong thread "thr1" (...) state after SuspendThread"
  • ece3ae3: 8268388: Update large pages information in Java manpage
  • 2623b0b: 8268475: execute runtime/InvocationTests w/ -UseVtableBasedCHA
  • f839308: 8268407: ProblemList sun/tools/jstat/jstatLineCountsX.sh on linux-aarch64 due to JDK-8268211
  • 58ba48b: 8268192: LambdaMetafactory with invokespecial causes VerificationError
  • b41f3f8: 8268478: JVMCI tests failing after JDK-8268052
  • 7ff6e7b: 8267954: Shared classes that failed to load should not be loaded again
  • 991ca14: 8267430: GraphicsDevice.setDisplayMode(REFRESH_RATE_UNKNOWN) throws IAE: Unable to set display mode!
  • bf29a01: 8228343: JCMD and attach fail to work across Linux Container boundary
  • 408e0a9: 8255148: Confusing log output: SSLSocket duplex close failed
  • ... and 179 more: https://git.openjdk.java.net/jdk/compare/ae2f37f868bfdcb3d46098e91ed537fb199d7dbe...master

Your commit was automatically rebased without conflicts.

Pushed as commit d4377af.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-compiler hotspot-compiler-dev@openjdk.org integrated Pull request has been integrated
3 participants