-
Notifications
You must be signed in to change notification settings - Fork 137
8369045: [lworld] valhalla/valuetypes/WeakReferenceTest.java has an unschedulable graph #1768
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
base: lworld
Are you sure you want to change the base?
Conversation
…an unschedulable graph
|
👋 Welcome back dfenacci! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
Webrevs
|
src/hotspot/share/opto/graphKit.cpp
Outdated
| store_to_buf_call->init_req(i, top()); | ||
| continue; | ||
| // Don't add store to buffer call if we are strength reducing | ||
| if (!C->strength_reduction()) { |
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.
Can we use _gvn.is_IterGVN() && !C->inlining_incrementally() here instead? Assuming that whenever we call this after parsing and when not incrementally inlining, we are doing post-parse devirtualization of a call.
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.
That's a possibility. I've also considered checking for !C->inlining_incrementally() && C->late_inline_count() > 0 but I'm a bit torn between being 100% sure we are doing strength reduction but using a compile "flags" (a bit 🫤) and checking for other, already available, conditions (like the one you suggest), which make me a bit unsure and could potentially change in the future...
But I guess introducing a new field to Compile just for this should be avoided. So, let's go for _gvn.is_IterGVN() && !C->inlining_incrementally() 🙂
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.
Fixed.
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.
I spoke too soon: _gvn is actually set when the GraphKit is created (when generating the call) and is not using the context of the call being strength-reduced. So, unfortunately it seems that the least-invasive way to figure out if we are strength-reducing is to have a compile flag. I reverted the change.
src/hotspot/share/opto/graphKit.cpp
Outdated
| if (domain->field_at(i) == Type::HALF) { | ||
| store_to_buf_call->init_req(i, top()); | ||
| continue; | ||
| // Don't add store to buffer call if we are strength reducing |
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.
Why do we need to add the above runtime check of the result again when doing strength reduction?
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.
We actually don't 🙂
I moved it inside the not-strength-reducing block.
|
You also need to remove the tests from the problem list again (see #1793). |
Co-authored-by: Tobias Hartmann <tobias.hartmann@oracle.com>
This reverts commit ccf5812.
…to JDK-8369045
|
|
|
@dafedafe this pull request can not be integrated into git checkout JDK-8369045
git fetch https://git.openjdk.org/valhalla.git lworld
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge lworld"
git push |
Removed. |
TobiHartmann
left a comment
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 to me!
Issue
A few test failed intermittently with -Xcomp on Mac due to an unschedulable graph in C2:
Causes
The origin of the issue seems to be coming from strength reduction (
process_late_inline_calls_no_inline) where we replace virtual and MH calls with direct calls.https://github.com/dafedafe/valhalla/blob/75e2dd95df5d847d7d6e35a23016d22705681cf4/src/hotspot/share/opto/compile.cpp#L3072
If the return type of the methods are not loaded, we add a call to runtime's
store_inline_type_fields_to_bufright after the actual method call, to save the scalarized return into a oop. This happens first for the caller at parse time and then for the callee when strength-reducing the virtual call to a direct one. The return projections of the inline fields of the call are added tostore_inline_type_fields_to_bufand its oop projection is then added as input to the otherstore_inline_type_fields_to_bufwhich fundamentally leaves the graph around it in an awkward state.If this happens in combination with loop unswitching it can lead to a graph not being schedulable, which is what happens in the failure of this issue, where we have:
store_inline_type_fields_to_buf(1) in a loop.store_inline_type_fields_to_buf.store_inline_type_fields_to_buf(2) right after the direct call. All the inline type return values of the call being inlined are removed, so the phis now only have one input and are removed by a later GVN pass.store_inline_type_fields_to_buf(1) call is logically not dominated by any of the 2 sides of the unswitched loop and lands in a separate dominance path of the arguments whose phis have been removed (which are still dominated by the original virtual call).Solution
The issue happens only when strength-reducing to a direct call and the return type is not loaded. So, there seems to be 2 conceivable fixes: either we avoid strength-reduction if the type is not loaded or we avoid creating the second
store_inline_type_fields_to_bufand rewire the output projections of the strength-reduced call to the output of the projections of the original virtual call.By choosing the first solution we potentially skip a useful optimization (in particular if the return value is always null, which won't trigger the deoptimization). So, the rewiring solution seems to be the best option in this case.
Testing
Unfortunately creating a regression test that would consistently trigger the specific issue with unloaded return type and strength-reduction to direct call has proven to be unviable.
Progress
Error
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/valhalla.git pull/1768/head:pull/1768$ git checkout pull/1768Update a local copy of the PR:
$ git checkout pull/1768$ git pull https://git.openjdk.org/valhalla.git pull/1768/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 1768View PR using the GUI difftool:
$ git pr show -t 1768Using diff file
Download this PR as a diff file:
https://git.openjdk.org/valhalla/pull/1768.diff
Using Webrev
Link to Webrev Comment