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

8335708: C2: Compile::verify_graph_edges must start at root and safepoints, just like CCP traversal #23977

Conversation

marc-chevalier
Copy link
Member

@marc-chevalier marc-chevalier commented Mar 11, 2025

In CCP, we transform the nodes going up (toward inputs) starting from root and safepoints because infinite loops can be reachable from the root, but not co-reachable from the root, that is one can follow def-use from root to the loop, but not the use-def from root to loop. For more details, see:

// Initialize the traversal.
// This CCP pass may prove that no exit test for a loop ever succeeds (i.e. the loop is infinite). In that case,
// the logic below doesn't follow any path from Root to the loop body: there's at least one such path but it's proven
// never taken (its type is TOP). As a consequence the node on the exit path that's input to Root (let's call it n) is
// replaced by the top node and the inputs of that node n are not enqueued for further processing. If CCP only works
// through the graph from Root, this causes the loop body to never be processed here even when it's not dead (that
// is reachable from Root following its uses). To prevent that issue, transform() starts walking the graph from Root
// and all safepoints.

Since we are specifically marking nodes as useful if they are above a safepoint, the check that no dead nodes must be there anymore must also consider nodes above a safepoint as alive: the same criterion must apply. We should nevertheless not start from a safepoint killed by CCP.

About the test, I use this trick found in TestInfiniteLoopCCP because I indeed need a really infinite loop, but I want a terminating test. The crash is not deterministic, as it needs StressIGVN, so I did a bit of stats. Using a little helper script, on 100 runs, 69 runs fail as in the JBS ticket and 31 are successful (so 0 fail in another way). After the fix, I find 100 successes.

And thanks to @eme64 who extracted such a concise reproducer.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8335708: C2: Compile::verify_graph_edges must start at root and safepoints, just like CCP traversal (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/23977/head:pull/23977
$ git checkout pull/23977

Update a local copy of the PR:
$ git checkout pull/23977
$ git pull https://git.openjdk.org/jdk.git pull/23977/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 23977

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/23977.diff

Using Webrev

Link to Webrev Comment

Sorry, something went wrong.

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 11, 2025

👋 Welcome back marc-chevalier! 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
Copy link

openjdk bot commented Mar 11, 2025

@marc-chevalier 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:

8335708: C2: Compile::verify_graph_edges must start at root and safepoints, just like CCP traversal

Reviewed-by: chagedorn, epeter

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 182 new commits pushed to the master branch:

  • 2560a63: 8352131: [REDO] C2: Print compilation bailouts with PrintCompilation compile command
  • 73177d9: 8347734: Turning off PerfData logging doesn't work
  • 96305e0: 4466930: JTable.selectAll boundary handling
  • fb210e3: 8351952: [IR Framework]: allow ignoring methods that are not compilable
  • 3ed010a: 8352020: [CompileFramework] enable compilation for VectorAPI
  • a5d06a1: 8352249: Remove incidental whitespace in traditional doc comments
  • 74df384: 8352428: GenShen: Old-gen cycles are still looping
  • fcc2a24: 8350813: Rendering of bulky sound bank from MIDI sequence can cause OutOfMemoryError
  • ac3ad03: 8350589: Investigate cleaner implementation of AArch64 ML-DSA intrinsic introduced in JDK-8348561
  • 8a1c85e: 8350898: Shenandoah: Eliminate final roots safepoint
  • ... and 172 more: https://git.openjdk.org/jdk/compare/75f028b46b245bdcbde8391af69020befda66b7d...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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@eme64, @chhagedorn) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk
Copy link

openjdk bot commented Mar 11, 2025

@marc-chevalier 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 Mar 11, 2025
@marc-chevalier marc-chevalier marked this pull request as ready for review March 14, 2025 15:06
@openjdk openjdk bot added the rfr Pull request is ready for review label Mar 14, 2025
@mlbridge
Copy link

mlbridge bot commented Mar 14, 2025

Webrevs

Copy link
Contributor

@eme64 eme64 left a comment

Choose a reason for hiding this comment

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

Nice work, and thanks again for the offline discussion :)

I left a few comments / suggestions below.
Ah, and you could also consider changing the PR name. Maybe something like graph verification must start at root and safepoints, just like CCP traversal. Maybe you have an even better idea ;)

Comment on lines 31 to 35
* @run main/othervm
* -XX:-TieredCompilation -XX:+VerifyGraphEdges
* -XX:+StressIGVN -Xcomp
* -XX:CompileCommand=compileonly,compiler.loopopts.Test8335708::mainTest
* compiler.loopopts.Test8335708
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please add a run without any flags? Sometimes that allows other bugs to trigger, because it can then be used without any flags, or other flag combinations.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. I hope it's the right way.

@@ -0,0 +1,69 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you rename the test file? I think the new common practice is to give it a descriptive name, rather than just the bug number which is already tracked under @bug 8335708 anyway ;)

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. I think it's more explicit.

Node_List nstack(MAX2(stack_size, (uint)OptoNodeListSize));
nstack.push(_root);
Node_List nstack(MAX2(stack_size, (uint) OptoNodeListSize));
if (root_and_safepoints != nullptr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you say in which cases we don't have root_and_safepoints? Why is it ok not to also start at SafePoint in those cases?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you should also say that we start the traversal from Root and Safepoints, just like during CCP.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've improved the comment on the declaration of verify_graph_edges: it is the only caller of verify_bidirectional_edges, which acts more like a helper, and verify_graph_edges is the one called a bit everywhere. Also, I think it's not an implementation detail, but a signature/contract thing: when writing a call to verify_graph_edges, I must know what I need to provide in root_and_safepoints, or when I can omit it. So now, I hope it's documented.

@marc-chevalier
Copy link
Member Author

you could also consider changing the PR name. Maybe something like graph verification must start at root and safepoints, just like CCP traversal. Maybe you have an even better idea ;)

I don't understand what you mean. the title of the PR must match the JBS ticket. I have very little creative freedom there. No?

@eme64
Copy link
Contributor

eme64 commented Mar 18, 2025

you could also consider changing the PR name. Maybe something like graph verification must start at root and safepoints, just like CCP traversal. Maybe you have an even better idea ;)

I don't understand what you mean. the title of the PR must match the JBS ticket. I have very little creative freedom there. No?

You can always change both, so that they match ;)

@marc-chevalier marc-chevalier changed the title 8335708: C2: assert(!dead_nodes) failed: using nodes must be reachable from root 8335708: C2: Compile::verify_graph_edges must start at root and safepoints, just like CCP traversal Mar 18, 2025
Copy link
Contributor

@eme64 eme64 left a comment

Choose a reason for hiding this comment

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

@marc-chevalier Looks good to me, except for missing punctuation ;)

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Mar 20, 2025
Copy link
Member

@chhagedorn chhagedorn left a comment

Choose a reason for hiding this comment

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

Some minor comments. Otherwise, looks good to me, too!

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Mar 20, 2025
@marc-chevalier
Copy link
Member Author

marc-chevalier commented Mar 20, 2025

I applied your fixes. I don't think I need proper review again, but I need re-approval.

EDIT: nevermind, @chhagedorn was faster than me.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Mar 20, 2025
@marc-chevalier
Copy link
Member Author

/integrate

Thanks for the reviews!

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Mar 20, 2025
@openjdk
Copy link

openjdk bot commented Mar 20, 2025

@marc-chevalier
Your change (at version 6a149e2) is now ready to be sponsored by a Committer.

@TobiHartmann
Copy link
Member

/sponsor

@openjdk
Copy link

openjdk bot commented Mar 20, 2025

Going to push as commit 2bc4f64.
Since your change was applied there have been 184 commits pushed to the master branch:

  • 9a17a6f: 8350749: Upgrade JLine to 3.29.0
  • 91836e1: 8352276: Skip jtreg tests using native executable with libjvm.so/libjli.so dependencies on static JDK
  • 2560a63: 8352131: [REDO] C2: Print compilation bailouts with PrintCompilation compile command
  • 73177d9: 8347734: Turning off PerfData logging doesn't work
  • 96305e0: 4466930: JTable.selectAll boundary handling
  • fb210e3: 8351952: [IR Framework]: allow ignoring methods that are not compilable
  • 3ed010a: 8352020: [CompileFramework] enable compilation for VectorAPI
  • a5d06a1: 8352249: Remove incidental whitespace in traditional doc comments
  • 74df384: 8352428: GenShen: Old-gen cycles are still looping
  • fcc2a24: 8350813: Rendering of bulky sound bank from MIDI sequence can cause OutOfMemoryError
  • ... and 174 more: https://git.openjdk.org/jdk/compare/75f028b46b245bdcbde8391af69020befda66b7d...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Mar 20, 2025
@openjdk openjdk bot closed this Mar 20, 2025
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Mar 20, 2025
@openjdk openjdk bot removed rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Mar 20, 2025
@openjdk
Copy link

openjdk bot commented Mar 20, 2025

@TobiHartmann @marc-chevalier Pushed as commit 2bc4f64.

💡 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
Development

Successfully merging this pull request may close these issues.

None yet

4 participants