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

8319372: C2 compilation fails with "Bad immediate dominator info" #16844

Closed
wants to merge 4 commits into from

Conversation

rwestrel
Copy link
Contributor

@rwestrel rwestrel commented Nov 28, 2023

I included the test case from 8318690 because the cause of the failure
is similar, the fix I propose applies to both. If this fix goes in
then 8318690 can be closed as duplicate of this one.

In both cases, a CastII's type is narrowed because it is control
dependent on a condition that tests the input of the CastII (code in
CastIINode::Value()). In both cases, that CastII is input to a
range check CastII. Predication leaves that second CastII in the
loop body but the range check that guards it is replaced by
predicates. The difference in the 2 test cases is where the first
CastII comes from: PhiNode::Ideal() in one case,
PhaseIdealLoop::try_sink_out_of_loop() in the other. The narrowed
type of the first CastII conflicts with the type of the range check
CastII and that causes that one to become top. The path where that
CastII is is unreachable but c2 can't prove it. The inconsistency
causes the asserts.

To fix this we would need to prove that the path where the CastII
nodes are is dead and for that we would need to prove that the
condition that guards that path and at least one of the predicates
can't be true at the same time. While it may be feasible, that seems
like a lot of extra complexity.

Instead I propose removing the logic in CastIINode::Value()
entirely. I went back to the change that introduced it and, as I
understand, it was added as an attempt to detect and remove useless
CastII nodes. There was no correctness issue involved AFAICT.


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-8319372: C2 compilation fails with "Bad immediate dominator info" (Bug - P2)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 16844

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 28, 2023

👋 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
Copy link

openjdk bot commented Nov 28, 2023

@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 Nov 28, 2023
@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 28, 2023
@mlbridge
Copy link

mlbridge bot commented Nov 28, 2023

Webrevs

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.

Agree.

@openjdk
Copy link

openjdk bot commented Nov 28, 2023

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

8319372: C2 compilation fails with "Bad immediate dominator info"

Reviewed-by: kvn, chagedorn, thartmann

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

  • 940f67c: 8318854: [macos14] Running any AWT app prints Secure coding warning
  • c864317: 8320888: Shenandoah: Enable ShenandoahVerifyOptoBarriers in debug builds
  • d1e73b1: 8318626: GetClassFields does not filter out ConstantPool.constantPoolOop field
  • ea6e92e: 8320945: problemlist tests failing on latest Windows 11 update
  • 2584bf8: 8210410: Refactor java.util.Currency:i18n shell tests to plain java tests
  • 454b116: 8320942: Only set openjdk-target when cross compiling linux-aarch64
  • eb44baf: 8320937: support latest VS2022 MSC_VER in abstract_vm_version.cpp
  • 62418c6: 8319444: Unhelpful failure output in TestLegalNotices
  • cdd1a6e: 8313816: Accessing jmethodID might lead to spurious crashes
  • b65ccff: 8320877: Shenandoah: Remove ShenandoahUnloadClassesFrequency support
  • ... and 63 more: https://git.openjdk.org/jdk/compare/0c9a61c18545c7bd48e54e6b4e523b9ad8d0507d...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 Nov 28, 2023
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.

I found myself before at that point to just get rid of this code to fix JDK-8272562 back there (also see #5199 (review)). It's a trade-off between better type information and avoiding these kind of issues. However, we could fix some cases by restricting try_sink_out_of_loop(). However, there was still this test

$ java -Xcomp -XX:CompileOnly=Reduced*::* -XX:-TieredCompilation Reduced2.java

which fails with mainline today but would work with your fix. You might want to add this test case as well.

Maybe we need to step through all the reported test cases which we closed as duplicates of JDK-8275202 at some point and see if this patch can fix them as well. I have the feeling that it can.

Additionally, we might want to investigate separately at some point if this patch allows us to relax some of the constraints of try_sink_out_of_loop() which we added fix these kind of issues with CastII nodes. I'm not sure though how much benefit it will bring.

Anyway, the fix looks good to me!

Comment on lines +28 to +31
* @run main/othervm -Xcomp -XX:CompileOnly=TestTopCastIIOnUndetectedDeadPath::test -XX:CompileCommand=quiet -XX:-TieredCompilation
* -XX:+UnlockDiagnosticVMOptions -XX:StressSeed=426264791 -XX:+StressIGVN TestTopCastIIOnUndetectedDeadPath
* @run main/othervm -Xcomp -XX:CompileOnly=TestTopCastIIOnUndetectedDeadPath::test -XX:CompileCommand=quiet -XX:-TieredCompilation
* -XX:+UnlockDiagnosticVMOptions -XX:+StressIGVN TestTopCastIIOnUndetectedDeadPath
Copy link
Member

Choose a reason for hiding this comment

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

Since StressIGVN is a C2 flag, you should also add a @requires vm.compiler2.enabled. Same for the other test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in new commit.

@rwestrel
Copy link
Contributor Author

However, there was still this test

$ java -Xcomp -XX:CompileOnly=Reduced*::* -XX:-TieredCompilation Reduced2.java

which fails with mainline today but would work with your fix. You might want to add this test case as well.

I looked at this one and it indeed looks like some variation of the same problem (range checks are eliminated by range check elimination and not predication). I added it.

Maybe we need to step through all the reported test cases which we closed as duplicates of JDK-8275202 at some point and see if this patch can fix them as well. I have the feeling that it can.

Yes, that would make sense.

Additionally, we might want to investigate separately at some point if this patch allows us to relax some of the constraints of try_sink_out_of_loop() which we added fix these kind of issues with CastII nodes. I'm not sure though how much benefit it will bring.

This too makes sense to me.

Anyway, the fix looks good to me!

Thanks for the review!

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.

Update is good.

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.

Looks good to me too.

@chhagedorn
Copy link
Member

chhagedorn commented Nov 30, 2023

However, there was still this test

$ java -Xcomp -XX:CompileOnly=Reduced*::* -XX:-TieredCompilation Reduced2.java

which fails with mainline today but would work with your fix. You might want to add this test case as well.

I looked at this one and it indeed looks like some variation of the same problem (range checks are eliminated by range check elimination and not predication). I added it.

Nice, thanks!

Maybe we need to step through all the reported test cases which we closed as duplicates of JDK-8275202 at some point and see if this patch can fix them as well. I have the feeling that it can.

Yes, that would make sense.

Sounds good. I think I will do that and also file a new bug to re-link all of the duplicates of JDK-8275202 to it. Then we could revert it back to an RFE which I think it should be if you agree (it was just a nice side effect that it also fixed the linked bugs).

Additionally, we might want to investigate separately at some point if this patch allows us to relax some of the constraints of try_sink_out_of_loop() which we added fix these kind of issues with CastII nodes. I'm not sure though how much benefit it will bring.

This too makes sense to me.

I will file an additional RFE while at it.

Anyway, the fix looks good to me!

Thanks for the review!

The update looks good!

@rwestrel
Copy link
Contributor Author

Sounds good. I think I will do that and also file a new bug to re-link all of the duplicates of JDK-8275202 to it. Then we could revert it back to an RFE which I think it should be if you agree (it was just a nice side effect that it also fixed the linked bugs).

Sounds good to me. Thanks.

Roland.

@rwestrel
Copy link
Contributor Author

@vnkozlov @chhagedorn @TobiHartmann thanks for the reviews.

@rwestrel
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Nov 30, 2023

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

  • 940f67c: 8318854: [macos14] Running any AWT app prints Secure coding warning
  • c864317: 8320888: Shenandoah: Enable ShenandoahVerifyOptoBarriers in debug builds
  • d1e73b1: 8318626: GetClassFields does not filter out ConstantPool.constantPoolOop field
  • ea6e92e: 8320945: problemlist tests failing on latest Windows 11 update
  • 2584bf8: 8210410: Refactor java.util.Currency:i18n shell tests to plain java tests
  • 454b116: 8320942: Only set openjdk-target when cross compiling linux-aarch64
  • eb44baf: 8320937: support latest VS2022 MSC_VER in abstract_vm_version.cpp
  • 62418c6: 8319444: Unhelpful failure output in TestLegalNotices
  • cdd1a6e: 8313816: Accessing jmethodID might lead to spurious crashes
  • b65ccff: 8320877: Shenandoah: Remove ShenandoahUnloadClassesFrequency support
  • ... and 63 more: https://git.openjdk.org/jdk/compare/0c9a61c18545c7bd48e54e6b4e523b9ad8d0507d...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Nov 30, 2023
@openjdk openjdk bot closed this Nov 30, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Nov 30, 2023
@openjdk
Copy link

openjdk bot commented Nov 30, 2023

@rwestrel Pushed as commit 7766785.

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

@chhagedorn
Copy link
Member

Sounds good. I think I will do that and also file a new bug to re-link all of the duplicates of JDK-8275202 to it. Then we could revert it back to an RFE which I think it should be if you agree (it was just a nice side effect that it also fixed the linked bugs).

Sounds good to me. Thanks.

I filed JDK-8321097 as an umbrella bug and re-linked all the bugs from JDK-8275202 and turned it back into an RFE. I've walked through all the linked bugs and as suspected, the patch of this PR fixes the remaining (known) failing cases. I therefore closed JDK-8321097 again as "Not an Issue" (anymore). I found three additional test cases that were still failing but are now fixed with this patch. I'm planning to add them as separate test cases with JDK-8321107.

Additionally, we might want to investigate separately at some point if this patch allows us to relax some of the constraints of try_sink_out_of_loop() which we added fix these kind of issues with CastII nodes. I'm not sure though how much benefit it will bring.

This too makes sense to me.

I will file an additional RFE while at it.

Filed JDK-8321109 to keep track of that.

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
4 participants