-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
interpret: simplify handling of shifts by no longer trying to handle signed and unsigned shift amounts in the same branch #117832
Conversation
r? @cjgillot (rustbot has picked a reviewer for you, use r? to override) |
This PR changes MIR cc @oli-obk, @RalfJung, @JakobDegen, @davidtwco, @celinval, @vakaras The Miri subtree was changed cc @rust-lang/miri Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri |
@@ -600,10 +600,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { | |||
BinOp::Shl | BinOp::Shr if self.check_overflow && ty.is_integral() => { | |||
// For an unsigned RHS, the shift is in-range for `rhs < bits`. | |||
// For a signed RHS, `IntToInt` cast to the equivalent unsigned | |||
// type and do that same comparison. Because the type is the | |||
// same size, there's no negative shift amount that ends up | |||
// overlapping with valid ones, thus it catches negatives too. |
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.
@scottmcm you wrote in b537e6b "because the type is the same size, there's no negative shift amount that ends up overlapping with valid ones". I don't understand that argument. What does "we're casting from signed to unsigned with the same size" have to do with the second half of the sentence?
I have replaced this comment with an argument that I do understand.
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 remember what I meant by "same size", since mixed-width shifts are allowed for MIR.
What you have now -- that iN::MIN as uN
will never conflict with a legal shift -- is really what I was trying to express, I think.
5bc4a16
to
efa6ebf
Compare
efa6ebf
to
1ee7f36
Compare
This comment has been minimized.
This comment has been minimized.
…signed and unsigned shift amounts in the same branch
1ee7f36
to
31493c7
Compare
@bors r+ |
interpret: simplify handling of shifts by no longer trying to handle signed and unsigned shift amounts in the same branch While we're at it, also update comments in codegen and MIR building related to shifts, and fix the overflow error printed by Miri on negative shift amounts.
…mpiler-errors Rollup of 8 pull requests Successful merges: - rust-lang#115526 (Add arm64e-apple-ios & arm64e-apple-darwin targets) - rust-lang#115691 (Add `$message_type` field to distinguish json diagnostic outputs) - rust-lang#117828 (Avoid iterating over hashmaps in astconv) - rust-lang#117832 (interpret: simplify handling of shifts by no longer trying to handle signed and unsigned shift amounts in the same branch) - rust-lang#117891 (Recover `dyn` and `impl` after `for<...>`) - rust-lang#117957 (if available use a Child's pidfd for kill/wait) - rust-lang#117994 (Ignore but do not assume region obligations from unifying headers in negative coherence) - rust-lang#118068 (subtree update cg_gcc 2023/11/17) r? `@ghost` `@rustbot` modify labels: rollup
…mpiler-errors Rollup of 8 pull requests Successful merges: - rust-lang#115526 (Add arm64e-apple-ios & arm64e-apple-darwin targets) - rust-lang#115691 (Add `$message_type` field to distinguish json diagnostic outputs) - rust-lang#117828 (Avoid iterating over hashmaps in astconv) - rust-lang#117832 (interpret: simplify handling of shifts by no longer trying to handle signed and unsigned shift amounts in the same branch) - rust-lang#117891 (Recover `dyn` and `impl` after `for<...>`) - rust-lang#117957 (if available use a Child's pidfd for kill/wait) - rust-lang#117994 (Ignore but do not assume region obligations from unifying headers in negative coherence) - rust-lang#118068 (subtree update cg_gcc 2023/11/17) r? `@ghost` `@rustbot` modify labels: rollup
…mpiler-errors Rollup of 8 pull requests Successful merges: - rust-lang#117828 (Avoid iterating over hashmaps in astconv) - rust-lang#117832 (interpret: simplify handling of shifts by no longer trying to handle signed and unsigned shift amounts in the same branch) - rust-lang#117891 (Recover `dyn` and `impl` after `for<...>`) - rust-lang#117957 (if available use a Child's pidfd for kill/wait) - rust-lang#117988 (Handle attempts to have multiple `cfg`d tail expressions) - rust-lang#117994 (Ignore but do not assume region obligations from unifying headers in negative coherence) - rust-lang#118000 (Make regionck care about placeholders in outlives components) - rust-lang#118068 (subtree update cg_gcc 2023/11/17) r? `@ghost` `@rustbot` modify labels: rollup
…tthiaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#117828 (Avoid iterating over hashmaps in astconv) - rust-lang#117832 (interpret: simplify handling of shifts by no longer trying to handle signed and unsigned shift amounts in the same branch) - rust-lang#117891 (Recover `dyn` and `impl` after `for<...>`) - rust-lang#117957 (if available use a Child's pidfd for kill/wait) - rust-lang#117988 (Handle attempts to have multiple `cfg`d tail expressions) - rust-lang#117994 (Ignore but do not assume region obligations from unifying headers in negative coherence) - rust-lang#118000 (Make regionck care about placeholders in outlives components) - rust-lang#118068 (subtree update cg_gcc 2023/11/17) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#117832 - RalfJung:interpret-shift, r=cjgillot interpret: simplify handling of shifts by no longer trying to handle signed and unsigned shift amounts in the same branch While we're at it, also update comments in codegen and MIR building related to shifts, and fix the overflow error printed by Miri on negative shift amounts.
https://bors.rust-lang.org/queue/rust according to the queue, this is currently being bored... |
@bors force |
5 hours later, still running in queue and blocking other PRs from being tested. I believe this interrupts a currently running build: @bors retry |
That worked — this PR is no longer "pending" at the top of the queue. But no other PR has immediately started being tested, as far as I can tell, which is a bad sign. |
Okay it just took 6 minutes after "bors retry", but #118093 (comment) is testing now. Everything looks back to normal. |
While we're at it, also update comments in codegen and MIR building related to shifts, and fix the overflow error printed by Miri on negative shift amounts.