Skip to content
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

Merged
merged 1 commit into from
Nov 20, 2023

Conversation

RalfJung
Copy link
Member

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.

@rustbot
Copy link
Collaborator

rustbot commented Nov 12, 2023

r? @cjgillot

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 12, 2023
@rustbot
Copy link
Collaborator

rustbot commented Nov 12, 2023

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.
Copy link
Member Author

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.

Copy link
Member

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.

@rust-log-analyzer

This comment has been minimized.

…signed and unsigned shift amounts in the same branch
@cjgillot
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Nov 19, 2023

📌 Commit 31493c7 has been approved by cjgillot

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 19, 2023
compiler-errors added a commit to compiler-errors/rust that referenced this pull request Nov 20, 2023
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.
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 20, 2023
…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
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 20, 2023
…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
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 20, 2023
…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
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 20, 2023
…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
@bors bors merged commit 94d9b7e into rust-lang:master Nov 20, 2023
11 checks passed
@rustbot rustbot added this to the 1.76.0 milestone Nov 20, 2023
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Nov 20, 2023
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.
@bors
Copy link
Contributor

bors commented Nov 20, 2023

⌛ Testing commit 31493c7 with merge 46ecc10...

@Noratrieb
Copy link
Member

https://bors.rust-lang.org/queue/rust according to the queue, this is currently being bored...
@bors r- wtf are you doing

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 20, 2023
@Noratrieb
Copy link
Member

Screenshot_20231120-182602

@RalfJung RalfJung deleted the interpret-shift branch November 20, 2023 17:30
@RalfJung
Copy link
Member Author

@bors force

@dtolnay
Copy link
Member

dtolnay commented Nov 20, 2023

5 hours later, still running in queue and blocking other PRs from being tested.

I believe this interrupts a currently running build:

@bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 20, 2023
@dtolnay
Copy link
Member

dtolnay commented Nov 20, 2023

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.

@dtolnay
Copy link
Member

dtolnay commented Nov 20, 2023

Okay it just took 6 minutes after "bors retry", but #118093 (comment) is testing now. Everything looks back to normal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants