Skip to content

8381872: C2: assert before block local scheduling failed with UseCompactObjectHeaders#30762

Open
rkennke wants to merge 2 commits intoopenjdk:masterfrom
rkennke:JDK-8381872
Open

8381872: C2: assert before block local scheduling failed with UseCompactObjectHeaders#30762
rkennke wants to merge 2 commits intoopenjdk:masterfrom
rkennke:JDK-8381872

Conversation

@rkennke
Copy link
Copy Markdown
Contributor

@rkennke rkennke commented Apr 16, 2026

This fixes a bug in Peephole::lea_remove_redundant() in peephole_x86_64.cpp, which can lead to miscompilations caused by two distinct values getting assigned to the same register.

Testing:

  • tier1 -UCOH
  • tier1 +UCOH


Progress

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

Issue

  • JDK-8381872: C2: assert before block local scheduling failed with UseCompactObjectHeaders (Bug - P3)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 30762

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link
Copy Markdown

bridgekeeper Bot commented Apr 16, 2026

👋 Welcome back rkennke! 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
Copy Markdown

openjdk Bot commented Apr 16, 2026

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk Bot added the hotspot-compiler hotspot-compiler-dev@openjdk.org label Apr 16, 2026
@openjdk
Copy link
Copy Markdown

openjdk Bot commented Apr 16, 2026

@rkennke 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.

@rkennke rkennke marked this pull request as ready for review April 16, 2026 11:53
@openjdk openjdk Bot added the rfr Pull request is ready for review label Apr 16, 2026
@mlbridge
Copy link
Copy Markdown

mlbridge Bot commented Apr 16, 2026

Webrevs

Copy link
Copy Markdown
Contributor

@mhaessig mhaessig left a comment

Choose a reason for hiding this comment

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

Thank you for fixing this, @rkennke. The fix looks good to me.

I'm giving this a spin on our CI on higher tiers and will report back with the results.

@openjdk
Copy link
Copy Markdown

openjdk Bot commented Apr 16, 2026

The total number of required reviews for this PR has been set to 2 based on the presence of this label: hotspot-compiler. This can be overridden with the /reviewers command.

Copy link
Copy Markdown
Contributor

@mhaessig mhaessig left a comment

Choose a reason for hiding this comment

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

I tested up to tier4 for for -UCOH and up to tier6 for +UCOH and everything passed.

@merykitty
Copy link
Copy Markdown
Member

Is it necessary that the base input of a leaP... is non-null? Given that the leaP... does not appear in an oop map, can we make the base input nullptr, so we don't need to worry about register conflict anymore?

}
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I experimented with this so I could understand it better, and something seems to be off. The above code disables the optimization even if the only dependant_lea is the lone lea_derived_oop, in which case it would seem to be OK because we aren't replacing the base with a "new base".
Also, I tried disabling the above change, and the test below still passes.

Node* dependant_lea = decode->fast_out(i);
if (dependant_lea->is_Mach() && dependant_lea->as_Mach()->ideal_Opcode() == Op_AddP) {
dependant_lea->set_req(AddPNode::Base, lea_derived_oop->in(AddPNode::Address));
dependant_lea->set_req(AddPNode::Base, new_base);
Copy link
Copy Markdown
Contributor

@mhaessig mhaessig Apr 24, 2026

Choose a reason for hiding this comment

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

Is it necessary that the base input of a leaP... is non-null? Given that the leaP... does not appear in an oop map, can we make the base input nullptr, so we don't need to worry about register conflict anymore?

You are absolutely right, @merykitty. The AddPNode::Base is only for the oop map and does not even get matched. This peephole is for cleaning up decodes that nevver get used in an oop map so rewiring is not even necessary. I wish I had thought of this a year ago...

The following does the trick (inspired by AddPNode::make_off_heap since using nullptr does not work):

Suggested change
dependant_lea->set_req(AddPNode::Base, new_base);
dependant_lea->set_req(AddPNode::Base, Compile::current()->top());

By not introducing a dependency, there will also not be a conflict.

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 rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

4 participants