-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
JDK-8322854: Incorrect rematerialization of scalar replaced objects in C2 #17562
Conversation
👋 Welcome back cslucas! A progress list of the required criteria for merging this PR into |
@JohnTortugo The following label will be automatically applied to this pull request:
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. |
Webrevs
|
@JohnTortugo do I understand correctly that we have a loop and the Phi node we are processing is memory input to Allocation? If I recall correctly, the only way we get to Why your case see What other I am concern if you use projection memory edge of the Allocate you may miss/skip it during search and start searching unrelated path. |
I executed some quick testing and I see failures with
With |
@vnkozlov - Thank you for letting me know about those edge cases. I'll investigate what happens in those situations. @TobiHartmann - I'll try and reproduce these failures locally. |
@JohnTortugo - Thank you for demonstration. Now I understand the issue. Yes, your suggestion is reasonable but you need to watch out for missing allocation's memory projection - you should not use |
@JohnTortugo are you still working on it? Please, let me know when you are ready for re-review and testing. |
@vnkozlov - yes, I'm still working on it. Unfortunately, I had to push some changes in order to run tests on one of our internal systems.. |
Hi @vnkozlov , @TobiHartmann - can you please take a look at the changes and run your internal tests on it? TIA! @vnkozlov - I added an assert to check that there is a (non_io) memory projection in the Allocate. I ran |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Few comments for test.
Tobias testing is still running. So far no new failure.
test/hotspot/jtreg/compiler/c2/TestReduceAllocationAndMemoryLoop.java
Outdated
Show resolved
Hide resolved
We may need to backport this. See my comments in JDK-8324739. |
@JohnTortugo can you look on the attached |
Thanks for testing Vladimir. I'll take a look into this tomorrow morning PST. |
@JohnTortugo, thank you for investigating JDK-8324739. Let finish this fix then. Please, address my comments about test. |
@TobiHartmann - did any test fail in your latest run? |
All tests passed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix looks reasonable to me.
@JohnTortugo 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:
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 281 new commits pushed to the
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 (@vnkozlov, @TobiHartmann) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
@vnkozlov - all looking good to you? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All look good.
/integrate |
@JohnTortugo |
/sponsor |
Going to push as commit 7cd25ed.
Your commit was automatically rebased without conflicts. |
@TobiHartmann @JohnTortugo Pushed as commit 7cd25ed. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Current implementation of
PhaseMacroExpand::value_from_mem
returnsreturn _igvn.zerocon(ft);
when it hits a sentinel while searching for a memory operation on a given slice. One of the sentinels is the memory input of the allocate node origin of the memory slice. Therefore,value_from_mem
may returnzeroconf(ft)
ifsfpt_mem
is the same memory edge used by the Allocate node origin of the memory slice being traversed.The scalar replacement implementation uses
value_from_mem
during creation of metadata describing object scalar replaced (seePhaseMacroExpand::create_scalarized_object_description
). Thecreate_scalarized_object_description
method is also used as part of RAM optimization implementation. The RAM optimization targets Phi nodes and therefore a memory graph loop created by a memory phi node is possible to seen as part of the transformation. See image below:This pattern doesn't show up when scalarizing objects that don't participate in allocation merges.
To fix the issue I changed the code in
value_from_mem
to instead of using the input memory edge of the Allocate as a stop condition, it will now use the projection memory edge of the Allocate.Tested locally on windows, mac and linux x86_64 with JTREG tier1-3 and didn't observe any regression.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/17562/head:pull/17562
$ git checkout pull/17562
Update a local copy of the PR:
$ git checkout pull/17562
$ git pull https://git.openjdk.org/jdk.git pull/17562/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 17562
View PR using the GUI difftool:
$ git pr show -t 17562
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/17562.diff
Webrev
Link to Webrev Comment