Skip to content

8344251: C2: remove blackholes with dead control input #24663

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

Conversation

marc-chevalier
Copy link
Member

@marc-chevalier marc-chevalier commented Apr 15, 2025

When a BlackholeNode's control input becomes dead, the node is not removed causing the crash

 assert(!in->is_CFG()) failed: CFG Node with no controlling input?

In the case reported in the issue, after a round of peeling, a condition becomes constant, and the branch containing the blackhole becomes dead:

I simply use Node::remove_dead_region(PhaseGVN*, bool) to remove the blackhole, as many other node types do.


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-8344251: C2: remove blackholes with dead control input (Bug - P3)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 24663

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 15, 2025

👋 Welcome back mchevalier! 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 Apr 15, 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:

8344251: C2: remove blackholes with dead control input

Reviewed-by: shade, thartmann, 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 46 new commits pushed to the master branch:

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 (@shipilev, @vnkozlov, @TobiHartmann) 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 Apr 15, 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.

@marc-chevalier marc-chevalier marked this pull request as ready for review April 15, 2025 14:36
@openjdk openjdk bot added the rfr Pull request is ready for review label Apr 15, 2025
@mlbridge
Copy link

mlbridge bot commented Apr 15, 2025

Webrevs

Copy link
Member

@shipilev shipilev left a comment

Choose a reason for hiding this comment

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

Right. I should have done the similar thing from the day 1 :)

public class DeadBhElimination {
public static void main(String[] args) {
TestFramework.runWithFlags(
"-Xcomp",
Copy link
Member

Choose a reason for hiding this comment

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

-Xcomp is likely too heavy-weight here. Other tests use -XX:CompileThreshold=100. I think that is enough for IR tests to compile the method.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or you can di separate runs with different flags, including default.

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 added the -Xcomp flag because the dead if branch was compiled into an uncommon trap (reason = unstable_if), and I had no BlackholeNode. Looking at the code emitting the trap, it seems to come from some profiling information, but that the generation of this uncommon trap is explicitly disabled if -Xcomp is given. I am not entirely sure why, but -XX:CompileThreshold=100 does the job to make the compilation of the dead if branch happen as well. But if I give no such flag, the test fails for lack of a BlackholeNode after parsing (also meaning that the test doesn't exercise the deletion of the BlackholeNode).

I'm currently testing further with -XX:CompileThreshold=100 as suggested (it works on my laptop so far), but if you have a more canonical trick to inhibit the uncommon trap in the dead branch, I'd take happily!

Copy link
Member

@shipilev shipilev Apr 15, 2025

Choose a reason for hiding this comment

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

Last time I had this problem, I did this:

// Use PerMethodTrapLimit=0 to compile all branches in the intrinsics.
args.add("-XX:PerMethodTrapLimit=0");

// CTW does not have good execution profile info, which would uncommon-trap
// a lot of branches/calls that are presumed to be never executed.
// Expand the optimization scope by disallowing most traps.
"-XX:PerMethodTrapLimit=0",
"-XX:PerMethodSpecTrapLimit=0",

Copy link
Member Author

Choose a reason for hiding this comment

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

That looks exactly like what I'm trying to achieve. I'll re-test with that. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

-Xcomp is likely too heavy-weight here.

FTR another alternative is to keep -Xcomp, but limit compilation to test methods (-XX:CompileCommand=compileonly,<Test::test>).

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

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

C2 fix code is good.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Apr 15, 2025
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Apr 16, 2025
@openjdk openjdk bot added the ready Pull request is ready to be integrated label Apr 16, 2025
Copy link
Member

@TobiHartmann TobiHartmann left a comment

Choose a reason for hiding this comment

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

Great work extracting a standalone reproducer for this and narrowing it down! The fix looks good to me.

@marc-chevalier
Copy link
Member Author

/integrate

Thanks @shipilev, @vnkozlov and @TobiHartmann for reviews!

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

openjdk bot commented Apr 16, 2025

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

@openjdk openjdk bot removed sponsor Pull request is ready to be sponsored ready Pull request is ready to be integrated labels Apr 16, 2025
Copy link
Member

@shipilev shipilev left a comment

Choose a reason for hiding this comment

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

Still good.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Apr 16, 2025
@vnkozlov
Copy link
Contributor

/sponsor

@openjdk
Copy link

openjdk bot commented Apr 16, 2025

@vnkozlov The PR has been updated since the change author (@marc-chevalier) issued the integrate command - the author must perform this command again.

@marc-chevalier
Copy link
Member Author

/integrate

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

openjdk bot commented Apr 17, 2025

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

@TobiHartmann
Copy link
Member

/sponsor

@openjdk
Copy link

openjdk bot commented Apr 17, 2025

Going to push as commit 1138a18.
Since your change was applied there have been 47 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Apr 17, 2025

@TobiHartmann @marc-chevalier Pushed as commit 1138a18.

💡 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 [email protected] integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

6 participants