-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8344304: [s390x] ubsan: negation of -2147483648 cannot be represented in type 'int' #22456
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
Conversation
👋 Welcome back amitkumar! A progress list of the required criteria for merging this PR into |
@offamitkumar 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 53 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 |
@offamitkumar 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
|
} else { | ||
__ z_slfi(lreg, c); | ||
} | ||
break; |
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.
Would it be simpler to use java_negate(c)
(from globalDefinitions.hpp)?
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.
Not sure of that actually. I didn't even know that there exists such helper method. Thanks for making me aware.
I updated current solution in accordance with GCC compiler. So Z don't have a shi
instruction which can handle 16-bit numbers, so GCC negates the number and adds it with ahi
instruction. Then for number upto 32bits, slfi
instruction is emitted for subtraction.
@RealLucy do you have other thoughts on this ?
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 agree,
__ z_afi(lreg, java_negate(c));
reads better.
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.
Couldn't you use add2reg_32() for the subtraction as well?
if (Immediate::is_simm16(c)) { | ||
__ z_ahi(lreg, c); | ||
} else { | ||
__ z_afi(lreg, c); | ||
} |
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.
It seems like it would be better to have code like this in a helper function, instead of making every call site repeat the pattern. Can you use add2reg() here?
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.
add2reg will emit z_aghi
instruction which is for 64 bit (register) <- 16 bit (immediate). z_ahi
and z_afi
are both
32 bit (register) < - 16 bit (immediate), 32 bit (register) <- 32 bit (immediate). So I guess these are better here. Though we can move the logic to new method add2reg_32() method which will do the check and emit correct instruction.
} else { | ||
__ z_slfi(lreg, c); | ||
} | ||
break; |
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.
Couldn't you use add2reg_32() for the subtraction as well?
@@ -681,6 +681,17 @@ void MacroAssembler::add2reg(Register r1, int64_t imm, Register r2) { | |||
z_agfi(r1, imm); | |||
} | |||
|
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 would prefer this method to have the same interface as add2reg(). Of course, that implies a more complex method body. Your choice.
@@ -156,7 +156,9 @@ class MacroAssembler: public Assembler { | |||
unsigned int mul_reg64_const16(Register rval, Register work, int cval); | |||
|
|||
// Generic operation r1 := r2 + imm. | |||
void add2reg(Register r1, int64_t imm, Register r2 = noreg); | |||
void add2reg (Register r1, int64_t imm, Register r2 = noreg); | |||
void add2reg_32(Register r1, int64_t imm, Register r2 = noreg); |
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 don't understand the difference between these two. For both, imm must be a simm_32. I don't think we need add2reg_32.
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.
for add2reg_32
the sum and the first operand, register in this case, are treated as 32 bits signed integers. But for add2reg
, sum and operands will be treated as 64 bits
signed integers. Immediate value in both case will be 32 bits only.
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.
LGTM.
Thanks for reviews & suggestions Lutz, Dean. |
Going to push as commit 43b337e.
Your commit was automatically rebased without conflicts. |
@offamitkumar Pushed as commit 43b337e. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
fixes the issue reported by ubsan.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/22456/head:pull/22456
$ git checkout pull/22456
Update a local copy of the PR:
$ git checkout pull/22456
$ git pull https://git.openjdk.org/jdk.git pull/22456/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 22456
View PR using the GUI difftool:
$ git pr show -t 22456
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/22456.diff
Using Webrev
Link to Webrev Comment