8358889: C2 hits assert in backend due to malformed uncommon trap - #32507
8358889: C2 hits assert in backend due to malformed uncommon trap#32507TobiHartmann wants to merge 1 commit into
Conversation
|
👋 Welcome back thartmann! A progress list of the required criteria for merging this PR into |
|
@TobiHartmann 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 /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 19 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. ➡️ To integrate this PR with the above commit message to the |
|
@TobiHartmann 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. |
|
The total number of required reviews for this PR has been set to 2 based on the presence of this label: |
|
Thanks for working on this, Tobias. Why does C2 prefer to spill the trap request input instead of rematerializing it? |
|
Thanks for looking at this, Roberto!
Short answer: It is rematerialized initially, but Gory details: There are three
So the RA spills the value shared by A and C. The trap request B is then rematerialized initially, but post-allocation copy removal eliminates that rematerialization and reuses the existing reload. |
merykitty
left a comment
There was a problem hiding this comment.
Thanks for the explanation. That makes sense.
|
Thanks for the review Quan-Anh! |
robcasloz
left a comment
There was a problem hiding this comment.
Thanks for the details, Tobias. Spilling -10 across dontInline() seems suboptimal, no? A better option would have been to not spill in the first place and instead rematerialize it after the dontInline() call (and then reuse it among the different users). Would it make sense to file a RFE to investigate why this is not done?
In any case, I agree with the fix, it is good to handle the general case for robustness.
|
Thanks for the review, Roberto!
Yes, agreed. I'm not familiar enough with the internals of the register allocator to tell if there's any particular reason for this though or if it's just a missing optimization. Given that, I'd lean towards not filing it for now. |
|
I don't think we ever return from UncommonTrapBlob. Instead, the next instruction is an abort/stop/ShouldNotReachHere. Instead of materializing constant arguments for UncommonTrapBlob, we could instead store the values as data, and have the blob or C++ code retrieve it: |
|
Thanks Dean, that's an interesting idea but I'm not sure there's enough benefit to justify the additional complexity (it would require quite some significant changes to the trap blobs, call-site layout and post-call metadata). Currently, rematerialization for the uncommon trap should only occur on the trap slow path and in this case it is eliminated altogether by post-allocation copy removal. Also, it would not fix the issue that Roberto pointed out about spilling Definitely out of scope of this PR, so I'm integrating the fix for now 🙂 |
|
/integrate |
|
Going to push as commit 22933b7.
Your commit was automatically rebased without conflicts. |
|
@TobiHartmann Pushed as commit 22933b7. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
On AArch64, when
Compile::current()->max_vector_size() > 0, C2's backend callsuncommon_trap_request()to distinguish an uncommon trap from an ordinary call:jdk/src/hotspot/cpu/aarch64/aarch64.ad
Lines 3662 to 3664 in f587450
jdk/src/hotspot/share/opto/machnode.cpp
Lines 837 to 839 in f587450
This calls
CallStaticJavaNode::extract_uncommon_trap_requestwhich asserts that thetrap_requestinput is always aConI:jdk/src/hotspot/share/opto/callnode.cpp
Lines 1264 to 1271 in f587450
This is not guaranteed because the register allocator might spill the value on the stack and thus replace the input with a
MachSpillCopyNode. Sincein_dump()is not set, we assert. The fix is to check the type of the node instead which is in line with the code just below:jdk/src/hotspot/share/opto/callnode.cpp
Line 1275 in f587450
Thanks,
Tobias
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/32507/head:pull/32507$ git checkout pull/32507Update a local copy of the PR:
$ git checkout pull/32507$ git pull https://git.openjdk.org/jdk.git pull/32507/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 32507View PR using the GUI difftool:
$ git pr show -t 32507Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/32507.diff
Using Webrev
Link to Webrev Comment